@splinetool/runtime 0.9.517 → 0.9.518

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.cjs CHANGED
@@ -3149,10 +3149,10 @@ void main() {
3149
3149
  squared_mean = squared_mean / samples;
3150
3150
  float std_dev = sqrt( squared_mean - mean * mean );
3151
3151
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3152
- }`;function fz(i,t,e){let r=new Bf,n=new N,s=new N,o=new Xe,a=new Ff({depthPacking:Jb}),l=new Cb,u={},c=e.maxTextureSize,h={[Pi]:Qr,[Qr]:Pi,[Ln]:Ln},d=new at({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new N},radius:{value:4}},vertexShader:hz,fragmentShader:dz}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ae;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new _r(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ng,this.render=function(w,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let E=i.getRenderTarget(),b=i.getActiveCubeFace(),M=i.getActiveMipmapLevel(),T=i.state;T.setBlending(Vt),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let C=0,P=w.length;C<P;C++){let D=w[C],I=D.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",D,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;n.copy(I.mapSize);let R=I.getFrameExtents();if(n.multiply(R),s.copy(I.mapSize),(n.x>c||n.y>c)&&(n.x>c&&(s.x=Math.floor(c/R.x),n.x=s.x*R.x,I.mapSize.x=s.x),n.y>c&&(s.y=Math.floor(c/R.y),n.y=s.y*R.y,I.mapSize.y=s.y)),I.map===null){let F=this.type!==Mf?{minFilter:kt,magFilter:kt}:{};I.map=new ht(n.x,n.y,F),I.map.texture.name=D.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let U=I.getViewportCount();for(let F=0;F<U;F++){let V=I.getViewport(F);o.set(s.x*V.x,s.y*V.y,s.x*V.z,s.y*V.w),T.viewport(o),I.updateMatrices(D,F),r=I.getFrustum(),x(S,A,I.camera,D,this.type)}I.isPointLightShadow!==!0&&this.type===Mf&&y(I,A),I.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(E,b,M)};function y(w,S){let A=t.update(m);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ht(n.x,n.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(S,null,A,d,m,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(S,null,A,f,m,null)}function v(w,S,A,E,b,M){let T=null,C=A.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0)T=C;else if(T=A.isPointLight===!0?l:a,i.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let P=T.uuid,D=S.uuid,I=u[P];I===void 0&&(I={},u[P]=I);let R=I[D];R===void 0&&(R=T.clone(),I[D]=R),T=R}return T.visible=S.visible,T.wireframe=S.wireframe,M===Mf?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:h[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,A.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(A.matrixWorld),T.nearDistance=E,T.farDistance=b),T}function x(w,S,A,E,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===Mf)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,w.matrixWorld);let C=t.update(w),P=w.material;if(Array.isArray(P)){let D=C.groups;for(let I=0,R=D.length;I<R;I++){let U=D[I],F=P[U.materialIndex];if(F&&F.visible){let V=v(w,F,E,A.near,A.far,b);i.renderBufferDirect(A,null,C,V,w,U)}}}else if(P.visible){let D=v(w,P,E,A.near,A.far,b);i.renderBufferDirect(A,null,C,D,w,null)}}let T=w.children;for(let C=0,P=T.length;C<P;C++)x(T[C],S,A,E,b)}}function pz(i,t,e){let r=e.isWebGL2;function n(){let Q=!1,ce=new Xe,ve=null,Ve=new Xe(0,0,0,0);return{setMask:function(Fe){ve!==Fe&&!Q&&(i.colorMask(Fe,Fe,Fe,Fe),ve=Fe)},setLocked:function(Fe){Q=Fe},setClear:function(Fe,Et,Hr,Pr,Dl){Dl===!0&&(Fe*=Pr,Et*=Pr,Hr*=Pr),ce.set(Fe,Et,Hr,Pr),Ve.equals(ce)===!1&&(i.clearColor(Fe,Et,Hr,Pr),Ve.copy(ce))},reset:function(){Q=!1,ve=null,Ve.set(-1,0,0,0)}}}function s(){let Q=!1,ce=null,ve=null,Ve=null;return{setTest:function(Fe){Fe?J(2929):Z(2929)},setMask:function(Fe){ce!==Fe&&!Q&&(i.depthMask(Fe),ce=Fe)},setFunc:function(Fe){if(ve!==Fe){switch(Fe){case W3:i.depthFunc(512);break;case q3:i.depthFunc(519);break;case Y3:i.depthFunc(513);break;case fb:i.depthFunc(515);break;case X3:i.depthFunc(514);break;case Q3:i.depthFunc(518);break;case K3:i.depthFunc(516);break;case Z3:i.depthFunc(517);break;default:i.depthFunc(515)}ve=Fe}},setLocked:function(Fe){Q=Fe},setClear:function(Fe){Ve!==Fe&&(i.clearDepth(Fe),Ve=Fe)},reset:function(){Q=!1,ce=null,ve=null,Ve=null}}}function o(){let Q=!1,ce=null,ve=null,Ve=null,Fe=null,Et=null,Hr=null,Pr=null,Dl=null;return{setTest:function(hr){Q||(hr?J(2960):Z(2960))},setMask:function(hr){ce!==hr&&!Q&&(i.stencilMask(hr),ce=hr)},setFunc:function(hr,Io,Vi){(ve!==hr||Ve!==Io||Fe!==Vi)&&(i.stencilFunc(hr,Io,Vi),ve=hr,Ve=Io,Fe=Vi)},setOp:function(hr,Io,Vi){(Et!==hr||Hr!==Io||Pr!==Vi)&&(i.stencilOp(hr,Io,Vi),Et=hr,Hr=Io,Pr=Vi)},setLocked:function(hr){Q=hr},setClear:function(hr){Dl!==hr&&(i.clearStencil(hr),Dl=hr)},reset:function(){Q=!1,ce=null,ve=null,Ve=null,Fe=null,Et=null,Hr=null,Pr=null,Dl=null}}}let a=new n,l=new s,u=new o,c=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,w=null,S=null,A=null,E=null,b=null,M=!1,T=null,C=null,P=null,D=null,I=null,R=i.getParameter(35661),U=!1,F=0,V=i.getParameter(7938);V.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(V)[1]),U=F>=1):V.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),U=F>=2);let G=null,H={},Y=i.getParameter(3088),k=i.getParameter(2978),j=new Xe().fromArray(Y),X=new Xe().fromArray(k);function q(Q,ce,ve){let Ve=new Uint8Array(4),Fe=i.createTexture();i.bindTexture(Q,Fe),i.texParameteri(Q,10241,9728),i.texParameteri(Q,10240,9728);for(let Et=0;Et<ve;Et++)i.texImage2D(ce+Et,0,6408,1,1,0,6408,5121,Ve);return Fe}let z={};z[3553]=q(3553,3553,1),z[34067]=q(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),J(2929),l.setFunc(fb),Oe(!1),Ie(S_),J(2884),_e(Vt);function J(Q){d[Q]!==!0&&(i.enable(Q),d[Q]=!0)}function Z(Q){d[Q]!==!1&&(i.disable(Q),d[Q]=!1)}function K(Q,ce){return f[Q]!==ce?(i.bindFramebuffer(Q,ce),f[Q]=ce,r&&(Q===36009&&(f[36160]=ce),Q===36160&&(f[36009]=ce)),!0):!1}function W(Q,ce){let ve=m,Ve=!1;if(Q)if(ve=p.get(ce),ve===void 0&&(ve=[],p.set(ce,ve)),Q.isWebGLMultipleRenderTargets){let Fe=Q.texture;if(ve.length!==Fe.length||ve[0]!==36064){for(let Et=0,Hr=Fe.length;Et<Hr;Et++)ve[Et]=36064+Et;ve.length=Fe.length,Ve=!0}}else ve[0]!==36064&&(ve[0]=36064,Ve=!0);else ve[0]!==1029&&(ve[0]=1029,Ve=!0);Ve&&(e.isWebGL2?i.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ye(Q){return g!==Q?(i.useProgram(Q),g=Q,!0):!1}let fe={[eu]:32774,[L3]:32778,[N3]:32779};if(r)fe[M_]=32775,fe[T_]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(fe[M_]=Q.MIN_EXT,fe[T_]=Q.MAX_EXT)}let se={[B3]:0,[F3]:1,[k3]:768,[$E]:770,[j3]:776,[G3]:774,[z3]:772,[V3]:769,[eM]:771,[H3]:775,[U3]:773};function _e(Q,ce,ve,Ve,Fe,Et,Hr,Pr){if(Q===Vt){y===!0&&(Z(3042),y=!1);return}if(y===!1&&(J(3042),y=!0),Q!==R3){if(Q!==v||Pr!==M){if((x!==eu||A!==eu)&&(i.blendEquation(32774),x=eu,A=eu),Pr)switch(Q){case _a:i.blendFuncSeparate(1,771,1,771);break;case A_:i.blendFunc(1,1);break;case __:i.blendFuncSeparate(0,769,0,1);break;case E_:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case _a:i.blendFuncSeparate(770,771,1,771);break;case A_:i.blendFunc(770,1);break;case __:i.blendFuncSeparate(0,769,0,1);break;case E_:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}w=null,S=null,E=null,b=null,v=Q,M=Pr}return}Fe=Fe||ce,Et=Et||ve,Hr=Hr||Ve,(ce!==x||Fe!==A)&&(i.blendEquationSeparate(fe[ce],fe[Fe]),x=ce,A=Fe),(ve!==w||Ve!==S||Et!==E||Hr!==b)&&(i.blendFuncSeparate(se[ve],se[Ve],se[Et],se[Hr]),w=ve,S=Ve,E=Et,b=Hr),v=Q,M=!1}function xe(Q,ce){Q.side===Ln?Z(2884):J(2884);let ve=Q.side===Qr;ce&&(ve=!ve),Oe(ve),Q.blending===_a&&Q.transparent===!1?_e(Vt):_e(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let Ve=Q.stencilWrite;u.setTest(Ve),Ve&&(u.setMask(Q.stencilWriteMask),u.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),u.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),Me(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?J(32926):Z(32926)}function Oe(Q){T!==Q&&(Q?i.frontFace(2304):i.frontFace(2305),T=Q)}function Ie(Q){Q!==D3?(J(2884),Q!==C&&(Q===S_?i.cullFace(1029):Q===I3?i.cullFace(1028):i.cullFace(1032))):Z(2884),C=Q}function Pe(Q){Q!==P&&(U&&i.lineWidth(Q),P=Q)}function Me(Q,ce,ve){Q?(J(32823),(D!==ce||I!==ve)&&(i.polygonOffset(ce,ve),D=ce,I=ve)):Z(32823)}function ze(Q){Q?J(3089):Z(3089)}function Ue(Q){Q===void 0&&(Q=33984+R-1),G!==Q&&(i.activeTexture(Q),G=Q)}function L(Q,ce,ve){ve===void 0&&(G===null?ve=33984+R-1:ve=G);let Ve=H[ve];Ve===void 0&&(Ve={type:void 0,texture:void 0},H[ve]=Ve),(Ve.type!==Q||Ve.texture!==ce)&&(G!==ve&&(i.activeTexture(ve),G=ve),i.bindTexture(Q,ce||z[Q]),Ve.type=Q,Ve.texture=ce)}function O(){let Q=H[G];Q!==void 0&&Q.type!==void 0&&(i.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function re(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ue(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function me(){try{i.texSubImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function De(){try{i.texSubImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Te(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ee(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function le(){try{i.texStorage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ke(){try{i.texStorage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ke(){try{i.texImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ne(){try{i.texImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function We(Q){j.equals(Q)===!1&&(i.scissor(Q.x,Q.y,Q.z,Q.w),j.copy(Q))}function $e(Q){X.equals(Q)===!1&&(i.viewport(Q.x,Q.y,Q.z,Q.w),X.copy(Q))}function _t(Q,ce){let ve=h.get(ce);ve===void 0&&(ve=new WeakMap,h.set(ce,ve));let Ve=ve.get(Q);Ve===void 0&&(Ve=i.getUniformBlockIndex(ce,Q.name),ve.set(Q,Ve))}function ir(Q,ce){let Ve=h.get(ce).get(Q);c.get(ce)!==Ve&&(i.uniformBlockBinding(ce,Ve,Q.__bindingPointIndex),c.set(ce,Ve))}function Gr(){i.disable(3042),i.disable(2884),i.disable(2929),i.disable(32823),i.disable(3089),i.disable(2960),i.disable(32926),i.blendEquation(32774),i.blendFunc(1,0),i.blendFuncSeparate(1,0,1,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(513),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(519,0,4294967295),i.stencilOp(7680,7680,7680),i.clearStencil(0),i.cullFace(1029),i.frontFace(2305),i.polygonOffset(0,0),i.activeTexture(33984),i.bindFramebuffer(36160,null),r===!0&&(i.bindFramebuffer(36009,null),i.bindFramebuffer(36008,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),d={},G=null,H={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,w=null,S=null,A=null,E=null,b=null,M=!1,T=null,C=null,P=null,D=null,I=null,j.set(0,0,i.canvas.width,i.canvas.height),X.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:J,disable:Z,bindFramebuffer:K,drawBuffers:W,useProgram:ye,setBlending:_e,setMaterial:xe,setFlipSided:Oe,setCullFace:Ie,setLineWidth:Pe,setPolygonOffset:Me,setScissorTest:ze,activeTexture:Ue,bindTexture:L,unbindTexture:O,compressedTexImage2D:re,compressedTexImage3D:ue,texImage2D:ke,texImage3D:Ne,updateUBOMapping:_t,uniformBlockBinding:ir,texStorage2D:le,texStorage3D:Ke,texSubImage2D:me,texSubImage3D:De,compressedTexSubImage2D:Te,compressedTexSubImage3D:Ee,scissor:We,viewport:$e,reset:Gr}}function mz(i,t,e,r,n,s,o){let a=n.isWebGL2,l=n.maxTextures,u=n.maxCubemapSize,c=n.maxTextureSize,h=n.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(L,O){return y?new OffscreenCanvas(L,O):fg("canvas")}function x(L,O,re,ue){let me=1;if((L.width>ue||L.height>ue)&&(me=ue/Math.max(L.width,L.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let De=O?dg:Math.floor,Te=De(me*L.width),Ee=De(me*L.height);m===void 0&&(m=v(Te,Ee));let le=re?v(Te,Ee):m;return le.width=Te,le.height=Ee,le.getContext("2d").drawImage(L,0,0,Te,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+Te+"x"+Ee+")."),le}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function w(L){return xb(L.width)&&xb(L.height)}function S(L){return a?!1:L.wrapS!==sr||L.wrapT!==sr||L.minFilter!==kt&&L.minFilter!==Je}function A(L,O){return L.generateMipmaps&&O&&L.minFilter!==kt&&L.minFilter!==Je}function E(L){i.generateMipmap(L)}function b(L,O,re,ue,me=!1){if(a===!1)return O;if(L!==null){if(i[L]!==void 0)return i[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let De=O;return O===6403&&(re===5126&&(De=33326),re===5131&&(De=33325),re===5121&&(De=33321)),O===33319&&(re===5126&&(De=33328),re===5131&&(De=33327),re===5121&&(De=33323)),O===6408&&(re===5126&&(De=34836),re===5131&&(De=34842),re===5121&&(De=ue===et&&me===!1?35907:32856),re===32819&&(De=32854),re===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function M(L,O,re){return A(L,re)===!0||L.isFramebufferTexture&&L.minFilter!==kt&&L.minFilter!==Je?Math.log2(Math.max(O.width,O.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?O.mipmaps.length:1}function T(L){return L===kt||L===C_||L===Dx?9728:9729}function C(L){let O=L.target;O.removeEventListener("dispose",C),D(O),O.isVideoTexture&&p.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),R(O)}function D(L){let O=r.get(L);if(O.__webglInit===void 0)return;let re=L.source,ue=g.get(re);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(L),Object.keys(ue).length===0&&g.delete(re)}r.remove(L)}function I(L){let O=r.get(L);i.deleteTexture(O.__webglTexture);let re=L.source,ue=g.get(re);delete ue[O.__cacheKey],o.memory.textures--}function R(L){let O=L.texture,re=r.get(L),ue=r.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(re.__webglFramebuffer[me]),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(re.__webglFramebuffer),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer),re.__webglMultisampledFramebuffer&&i.deleteFramebuffer(re.__webglMultisampledFramebuffer),re.__webglColorRenderbuffer)for(let me=0;me<re.__webglColorRenderbuffer.length;me++)re.__webglColorRenderbuffer[me]&&i.deleteRenderbuffer(re.__webglColorRenderbuffer[me]);re.__webglDepthRenderbuffer&&i.deleteRenderbuffer(re.__webglDepthRenderbuffer)}if(L.isWebGLMultipleRenderTargets)for(let me=0,De=O.length;me<De;me++){let Te=r.get(O[me]);Te.__webglTexture&&(i.deleteTexture(Te.__webglTexture),o.memory.textures--),r.remove(O[me])}r.remove(O),r.remove(L)}let U=0;function F(){U=0}function V(){let L=U;return L>=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),U+=1,L}function G(L){let O=[];return O.push(L.wrapS),O.push(L.wrapT),O.push(L.wrapR||0),O.push(L.magFilter),O.push(L.minFilter),O.push(L.anisotropy),O.push(L.internalFormat),O.push(L.format),O.push(L.type),O.push(L.generateMipmaps),O.push(L.premultiplyAlpha),O.push(L.flipY),O.push(L.unpackAlignment),O.push(L.encoding),O.join()}function H(L,O){let re=r.get(L);if(L.isVideoTexture&&ze(L),L.isRenderTargetTexture===!1&&L.version>0&&re.__version!==L.version){let ue=L.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(re,L,O);return}}e.bindTexture(3553,re.__webglTexture,33984+O)}function Y(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(35866,re.__webglTexture,33984+O)}function k(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(32879,re.__webglTexture,33984+O)}function j(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){K(re,L,O);return}e.bindTexture(34067,re.__webglTexture,33984+O)}let X={[ms]:10497,[sr]:33071,[gb]:33648},q={[kt]:9728,[C_]:9984,[Dx]:9986,[Je]:9729,[sN]:9985,[Ul]:9987};function z(L,O,re){if(re?(i.texParameteri(L,10242,X[O.wrapS]),i.texParameteri(L,10243,X[O.wrapT]),(L===32879||L===35866)&&i.texParameteri(L,32882,X[O.wrapR]),i.texParameteri(L,10240,q[O.magFilter]),i.texParameteri(L,10241,q[O.minFilter])):(i.texParameteri(L,10242,33071),i.texParameteri(L,10243,33071),(L===32879||L===35866)&&i.texParameteri(L,32882,33071),(O.wrapS!==sr||O.wrapT!==sr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(L,10240,T(O.magFilter)),i.texParameteri(L,10241,T(O.minFilter)),O.minFilter!==kt&&O.minFilter!==Je&&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 ue=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===kt||O.minFilter!==Dx&&O.minFilter!==Ul||O.type===Xr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===Go&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(i.texParameterf(L,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,n.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function J(L,O){let re=!1;L.__webglInit===void 0&&(L.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=G(O);if(De!==L.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,re=!0),me[De].usedTimes++;let Te=me[L.__cacheKey];Te!==void 0&&(me[L.__cacheKey].usedTimes--,Te.usedTimes===0&&I(O)),L.__cacheKey=De,L.__webglTexture=me[De].texture}return re}function Z(L,O,re){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=J(L,O),De=O.source;e.bindTexture(ue,L.__webglTexture,33984+re);let Te=r.get(De);if(De.version!==Te.__version||me===!0){e.activeTexture(33984+re),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Ee=S(O)&&w(O.image)===!1,le=x(O.image,Ee,!1,c);le=Ue(O,le);let Ke=w(le)||a,ke=s.convert(O.format,O.encoding),Ne=s.convert(O.type),We=b(O.internalFormat,ke,Ne,O.encoding,O.isVideoTexture);z(ue,O,Ke);let $e,_t=O.mipmaps,ir=a&&O.isVideoTexture!==!0,Gr=Te.__version===void 0||me===!0,Q=M(O,le,Ke);if(O.isDepthTexture)We=6402,a?O.type===Xr?We=36012:O.type===ps?We=33190:O.type===Ea?We=35056:We=33189:O.type===Xr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Vl&&We===6402&&O.type!==nM&&O.type!==ps&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=ps,Ne=s.convert(O.type)),O.format===Ca&&We===6402&&(We=34041,O.type!==Ea&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Ea,Ne=s.convert(O.type))),Gr&&(ir?e.texStorage2D(3553,1,We,le.width,le.height):e.texImage2D(3553,0,We,le.width,le.height,0,ke,Ne,null));else if(O.isDataTexture)if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],ir?e.texSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,Ne,$e.data):e.texImage2D(3553,ce,We,$e.width,$e.height,0,ke,Ne,$e.data);O.generateMipmaps=!1}else ir?(Gr&&e.texStorage2D(3553,Q,We,le.width,le.height),e.texSubImage2D(3553,0,0,0,le.width,le.height,ke,Ne,le.data)):e.texImage2D(3553,0,We,le.width,le.height,0,ke,Ne,le.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){ir&&Gr&&e.texStorage3D(35866,Q,We,_t[0].width,_t[0].height,le.depth);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],O.format!==$n?ke!==null?ir?e.compressedTexSubImage3D(35866,ce,0,0,0,$e.width,$e.height,le.depth,ke,$e.data,0,0):e.compressedTexImage3D(35866,ce,We,$e.width,$e.height,le.depth,0,$e.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ir?e.texSubImage3D(35866,ce,0,0,0,$e.width,$e.height,le.depth,ke,Ne,$e.data):e.texImage3D(35866,ce,We,$e.width,$e.height,le.depth,0,ke,Ne,$e.data)}else{ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],O.format!==$n?ke!==null?ir?e.compressedTexSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,$e.data):e.compressedTexImage2D(3553,ce,We,$e.width,$e.height,0,$e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ir?e.texSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,Ne,$e.data):e.texImage2D(3553,ce,We,$e.width,$e.height,0,ke,Ne,$e.data)}else if(O.isDataArrayTexture)ir?(Gr&&e.texStorage3D(35866,Q,We,le.width,le.height,le.depth),e.texSubImage3D(35866,0,0,0,0,le.width,le.height,le.depth,ke,Ne,le.data)):e.texImage3D(35866,0,We,le.width,le.height,le.depth,0,ke,Ne,le.data);else if(O.isData3DTexture)ir?(Gr&&e.texStorage3D(32879,Q,We,le.width,le.height,le.depth),e.texSubImage3D(32879,0,0,0,0,le.width,le.height,le.depth,ke,Ne,le.data)):e.texImage3D(32879,0,We,le.width,le.height,le.depth,0,ke,Ne,le.data);else if(O.isFramebufferTexture){if(Gr)if(ir)e.texStorage2D(3553,Q,We,le.width,le.height);else{let ce=le.width,ve=le.height;for(let Ve=0;Ve<Q;Ve++)e.texImage2D(3553,Ve,We,ce,ve,0,ke,Ne,null),ce>>=1,ve>>=1}}else if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],ir?e.texSubImage2D(3553,ce,0,0,ke,Ne,$e):e.texImage2D(3553,ce,We,ke,Ne,$e);O.generateMipmaps=!1}else ir?(Gr&&e.texStorage2D(3553,Q,We,le.width,le.height),e.texSubImage2D(3553,0,0,0,ke,Ne,le)):e.texImage2D(3553,0,We,ke,Ne,le);A(O,Ke)&&E(ue),Te.__version=De.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function K(L,O,re){if(O.image.length!==6)return;let ue=J(L,O),me=O.source;e.bindTexture(34067,L.__webglTexture,33984+re);let De=r.get(me);if(me.version!==De.__version||ue===!0){e.activeTexture(33984+re),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Te=O.isCompressedTexture||O.image[0].isCompressedTexture,Ee=O.image[0]&&O.image[0].isDataTexture,le=[];for(let ce=0;ce<6;ce++)!Te&&!Ee?le[ce]=x(O.image[ce],!1,!0,u):le[ce]=Ee?O.image[ce].image:O.image[ce],le[ce]=Ue(O,le[ce]);let Ke=le[0],ke=w(Ke)||a,Ne=s.convert(O.format,O.encoding),We=s.convert(O.type),$e=b(O.internalFormat,Ne,We,O.encoding),_t=a&&O.isVideoTexture!==!0,ir=De.__version===void 0||ue===!0,Gr=M(O,Ke,ke);z(34067,O,ke);let Q;if(Te){_t&&ir&&e.texStorage2D(34067,Gr,$e,Ke.width,Ke.height);for(let ce=0;ce<6;ce++){Q=le[ce].mipmaps;for(let ve=0;ve<Q.length;ve++){let Ve=Q[ve];O.format!==$n?Ne!==null?_t?e.compressedTexSubImage2D(34069+ce,ve,0,0,Ve.width,Ve.height,Ne,Ve.data):e.compressedTexImage2D(34069+ce,ve,$e,Ve.width,Ve.height,0,Ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_t?e.texSubImage2D(34069+ce,ve,0,0,Ve.width,Ve.height,Ne,We,Ve.data):e.texImage2D(34069+ce,ve,$e,Ve.width,Ve.height,0,Ne,We,Ve.data)}}}else{Q=O.mipmaps,_t&&ir&&(Q.length>0&&Gr++,e.texStorage2D(34067,Gr,$e,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(Ee){_t?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Ne,We,le[ce].data):e.texImage2D(34069+ce,0,$e,le[ce].width,le[ce].height,0,Ne,We,le[ce].data);for(let ve=0;ve<Q.length;ve++){let Fe=Q[ve].image[ce].image;_t?e.texSubImage2D(34069+ce,ve+1,0,0,Fe.width,Fe.height,Ne,We,Fe.data):e.texImage2D(34069+ce,ve+1,$e,Fe.width,Fe.height,0,Ne,We,Fe.data)}}else{_t?e.texSubImage2D(34069+ce,0,0,0,Ne,We,le[ce]):e.texImage2D(34069+ce,0,$e,Ne,We,le[ce]);for(let ve=0;ve<Q.length;ve++){let Ve=Q[ve];_t?e.texSubImage2D(34069+ce,ve+1,0,0,Ne,We,Ve.image[ce]):e.texImage2D(34069+ce,ve+1,$e,Ne,We,Ve.image[ce])}}}A(O,ke)&&E(34067),De.__version=me.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function W(L,O,re,ue,me){let De=s.convert(re.format,re.encoding),Te=s.convert(re.type),Ee=b(re.internalFormat,De,Te,re.encoding);r.get(O).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Ee,O.width,O.height,O.depth,0,De,Te,null):e.texImage2D(me,0,Ee,O.width,O.height,0,De,Te,null)),e.bindFramebuffer(36160,L),Me(O)?d.framebufferTexture2DMultisampleEXT(36160,ue,me,r.get(re).__webglTexture,0,Pe(O)):(me===3553||me>=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,r.get(re).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(L,O,re){if(i.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(re||Me(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===Xr?ue=36012:me.type===ps&&(ue=33190));let De=Pe(O);Me(O)?d.renderbufferStorageMultisampleEXT(36161,De,ue,O.width,O.height):i.renderbufferStorageMultisample(36161,De,ue,O.width,O.height)}else i.renderbufferStorage(36161,ue,O.width,O.height);i.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);re&&Me(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):Me(O)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,L)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<ue.length;me++){let De=ue[me],Te=s.convert(De.format,De.encoding),Ee=s.convert(De.type),le=b(De.internalFormat,Te,Ee,De.encoding),Ke=Pe(O);re&&Me(O)===!1?i.renderbufferStorageMultisample(36161,Ke,le,O.width,O.height):Me(O)?d.renderbufferStorageMultisampleEXT(36161,Ke,le,O.width,O.height):i.renderbufferStorage(36161,le,O.width,O.height)}}i.bindRenderbuffer(36161,null)}function fe(L,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,L),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),H(O.depthTexture,0);let ue=r.get(O.depthTexture).__webglTexture,me=Pe(O);if(O.depthTexture.format===Vl)Me(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,me):i.framebufferTexture2D(36160,36096,3553,ue,0);else if(O.depthTexture.format===Ca)Me(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,me):i.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function se(L){let O=r.get(L),re=L.isWebGLCubeRenderTarget===!0;if(L.depthTexture&&!O.__autoAllocateDepthBuffer){if(re)throw new Error("target.depthTexture not supported in Cube render targets");fe(O.__webglFramebuffer,L)}else if(re){O.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)e.bindFramebuffer(36160,O.__webglFramebuffer[ue]),O.__webglDepthbuffer[ue]=i.createRenderbuffer(),ye(O.__webglDepthbuffer[ue],L,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=i.createRenderbuffer(),ye(O.__webglDepthbuffer,L,!1);e.bindFramebuffer(36160,null)}function _e(L,O,re){let ue=r.get(L);O!==void 0&&W(ue.__webglFramebuffer,L,L.texture,36064,3553),re!==void 0&&se(L)}function xe(L){let O=L.texture,re=r.get(L),ue=r.get(O);L.addEventListener("dispose",P),L.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=O.version,o.memory.textures++);let me=L.isWebGLCubeRenderTarget===!0,De=L.isWebGLMultipleRenderTargets===!0,Te=w(L)||a;if(me){re.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)re.__webglFramebuffer[Ee]=i.createFramebuffer()}else{if(re.__webglFramebuffer=i.createFramebuffer(),De)if(n.drawBuffers){let Ee=L.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=r.get(Ee[le]);ke.__webglTexture===void 0&&(ke.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&L.samples>0&&Me(L)===!1){let Ee=De?O:[O];re.__webglMultisampledFramebuffer=i.createFramebuffer(),re.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,re.__webglMultisampledFramebuffer);for(let le=0;le<Ee.length;le++){let Ke=Ee[le];re.__webglColorRenderbuffer[le]=i.createRenderbuffer(),i.bindRenderbuffer(36161,re.__webglColorRenderbuffer[le]);let ke=s.convert(Ke.format,Ke.encoding),Ne=s.convert(Ke.type),We=b(Ke.internalFormat,ke,Ne,Ke.encoding,L.isXRRenderTarget===!0),$e=Pe(L);i.renderbufferStorageMultisample(36161,$e,We,L.width,L.height),i.framebufferRenderbuffer(36160,36064+le,36161,re.__webglColorRenderbuffer[le])}i.bindRenderbuffer(36161,null),L.depthBuffer&&(re.__webglDepthRenderbuffer=i.createRenderbuffer(),ye(re.__webglDepthRenderbuffer,L,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ue.__webglTexture),z(34067,O,Te);for(let Ee=0;Ee<6;Ee++)W(re.__webglFramebuffer[Ee],L,O,36064,34069+Ee);A(O,Te)&&E(34067),e.unbindTexture()}else if(De){let Ee=L.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=Ee[le],Ne=r.get(ke);e.bindTexture(3553,Ne.__webglTexture),z(3553,ke,Te),W(re.__webglFramebuffer,L,ke,36064+le,3553),A(ke,Te)&&E(3553)}e.unbindTexture()}else{let Ee=3553;(L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(a?Ee=L.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Ee,ue.__webglTexture),z(Ee,O,Te),W(re.__webglFramebuffer,L,O,36064,Ee),A(O,Te)&&E(Ee),e.unbindTexture()}L.depthBuffer&&se(L)}function Oe(L){let O=w(L)||a,re=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ue=0,me=re.length;ue<me;ue++){let De=re[ue];if(A(De,O)){let Te=L.isWebGLCubeRenderTarget?34067:3553,Ee=r.get(De).__webglTexture;e.bindTexture(Te,Ee),E(Te),e.unbindTexture()}}}function Ie(L){if(a&&L.samples>0&&Me(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],re=L.width,ue=L.height,me=16384,De=[],Te=L.stencilBuffer?33306:36096,Ee=r.get(L),le=L.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke<O.length;Ke++)e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,null),e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,null,0);e.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let Ke=0;Ke<O.length;Ke++){De.push(36064+Ke),L.depthBuffer&&De.push(Te);let ke=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(ke===!1&&(L.depthBuffer&&(me|=256),L.stencilBuffer&&(me|=1024)),le&&i.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[Ke]),ke===!0&&(i.invalidateFramebuffer(36008,[Te]),i.invalidateFramebuffer(36009,[Te])),le){let Ne=r.get(O[Ke]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Ne,0)}i.blitFramebuffer(0,0,re,ue,0,0,re,ue,me,9728),f&&i.invalidateFramebuffer(36008,De)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),le)for(let Ke=0;Ke<O.length;Ke++){e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,Ee.__webglColorRenderbuffer[Ke]);let ke=r.get(O[Ke]).__webglTexture;e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,ke,0)}e.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function Pe(L){return Math.min(h,L.samples)}function Me(L){let O=r.get(L);return a&&L.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ze(L){let O=o.render.frame;p.get(L)!==O&&(p.set(L,O),L.update())}function Ue(L,O){let re=L.encoding,ue=L.format,me=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===vb||re!==Di&&(re===et?a===!1?t.has("EXT_sRGB")===!0&&ue===$n?(L.format=vb,L.minFilter=Je,L.generateMipmaps=!1):O=pg.sRGBToLinear(O):(ue!==$n||me!==lr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",re)),O}this.allocateTextureUnit=V,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=Y,this.setTexture3D=k,this.setTextureCube=j,this.rebindTextures=_e,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=W,this.useMultisampledRTT=Me}function gz(i,t,e){let r=e.isWebGL2;function n(s,o=null){let a;if(s===lr)return 5121;if(s===cN)return 32819;if(s===uN)return 32820;if(s===oN)return 5120;if(s===aN)return 5122;if(s===nM)return 5123;if(s===lN)return 5124;if(s===ps)return 5125;if(s===Xr)return 5126;if(s===Go)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===hN)return 6406;if(s===$n)return 6408;if(s===dN)return 6409;if(s===fN)return 6410;if(s===Vl)return 6402;if(s===Ca)return 34041;if(s===vb)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===pN)return 6403;if(s===mN)return 36244;if(s===Pu)return 33319;if(s===gN)return 33320;if(s===Xb)return 36249;if(s===Ix||s===Ox||s===Rx||s===Lx)if(o===et)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ix)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ix)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===P_||s===D_||s===I_||s===O_)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===P_)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===D_)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===I_)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===O_)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===yN)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===R_||s===L_)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===R_)return o===et?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===L_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===N_||s===B_||s===F_||s===k_||s===V_||s===z_||s===U_||s===G_||s===H_||s===j_||s===W_||s===q_||s===Y_||s===X_)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===N_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===B_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===F_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===k_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===V_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===z_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===U_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===G_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===H_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===j_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===W_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===q_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Y_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===X_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Nx)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Nx)return o===et?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===vN||s===Q_||s===K_||s===Z_)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Nx)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Q_)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===K_)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Z_)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ea?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:n}}var Pb=class extends Ir{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},js=class extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}},yz={type:"move"},Df=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new js,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 js,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new _,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new _),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new js,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new _,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new _),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let r of t.hand.values())this._getHandJoint(e,r)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,r){let n=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(u,m);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,p=.005;u.inputState.pinching&&d>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&d<=f-p&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(n=e.getPose(t.targetRaySpace,r),n===null&&s!==null&&(n=s),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(yz)))}return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new js;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},Gi=class extends or{constructor(t,e,r,n,s,o,a,l,u,c){if(c=c!==void 0?c:Vl,c!==Vl&&c!==Ca)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&c===Vl&&(r=ps),r===void 0&&c===Ca&&(r=Ea),super(null,n,s,o,a,l,c,r,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:kt,this.minFilter=l!==void 0?l:kt,this.flipY=!1,this.generateMipmaps=!1}},Db=class extends Yt{constructor(t,e){super();let r=this,n=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,A=new Ir;A.layers.enable(1),A.viewport=new Xe;let E=new Ir;E.layers.enable(2),E.viewport=new Xe;let b=[A,E],M=new Pb;M.layers.enable(1),M.layers.enable(2);let T=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(k){let j=v[k];return j===void 0&&(j=new Df,v[k]=j),j.getTargetRaySpace()},this.getControllerGrip=function(k){let j=v[k];return j===void 0&&(j=new Df,v[k]=j),j.getGripSpace()},this.getHand=function(k){let j=v[k];return j===void 0&&(j=new Df,v[k]=j),j.getHandSpace()};function P(k){let j=x.indexOf(k.inputSource);if(j===-1)return;let X=v[j];X!==void 0&&X.dispatchEvent({type:k.type,data:k.inputSource})}function D(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",D),n.removeEventListener("inputsourceschange",I);for(let k=0;k<v.length;k++){let j=x[k];j!==null&&(x[k]=null,v[k].disconnect(j))}T=null,C=null,t.setRenderTarget(g),f=null,d=null,h=null,n=null,y=null,Y.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(k){s=k,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(k){a=k,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(k){u=k},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(k){if(n=k,n!==null){if(g=t.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",D),n.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),n.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let j={antialias:n.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,j),n.updateRenderState({baseLayer:f}),y=new ht(f.framebufferWidth,f.framebufferHeight,{format:$n,type:lr,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let j=null,X=null,q=null;m.depth&&(q=m.stencil?35056:33190,j=m.stencil?Ca:Vl,X=m.stencil?Ea:ps);let z={colorFormat:32856,depthFormat:q,scaleFactor:s};h=new XRWebGLBinding(n,e),d=h.createProjectionLayer(z),n.updateRenderState({layers:[d]}),y=new ht(d.textureWidth,d.textureHeight,{format:$n,type:lr,depthTexture:new Gi(d.textureWidth,d.textureHeight,X,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.antialias?4:0});let J=t.properties.get(y);J.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await n.requestReferenceSpace(a),Y.setContext(n),Y.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function I(k){for(let j=0;j<k.removed.length;j++){let X=k.removed[j],q=x.indexOf(X);q>=0&&(x[q]=null,v[q].disconnect(X))}for(let j=0;j<k.added.length;j++){let X=k.added[j],q=x.indexOf(X);if(q===-1){for(let J=0;J<v.length;J++)if(J>=x.length){x.push(X),q=J;break}else if(x[J]===null){x[J]=X,q=J;break}if(q===-1)break}let z=v[q];z&&z.connect(X)}}let R=new _,U=new _;function F(k,j,X){R.setFromMatrixPosition(j.matrixWorld),U.setFromMatrixPosition(X.matrixWorld);let q=R.distanceTo(U),z=j.projectionMatrix.elements,J=X.projectionMatrix.elements,Z=z[14]/(z[10]-1),K=z[14]/(z[10]+1),W=(z[9]+1)/z[5],ye=(z[9]-1)/z[5],fe=(z[8]-1)/z[0],se=(J[8]+1)/J[0],_e=Z*fe,xe=Z*se,Oe=q/(-fe+se),Ie=Oe*-fe;j.matrixWorld.decompose(k.position,k.quaternion,k.scale),k.translateX(Ie),k.translateZ(Oe),k.matrixWorld.compose(k.position,k.quaternion,k.scale),k.matrixWorldInverse.copy(k.matrixWorld).invert();let Pe=Z+Oe,Me=K+Oe,ze=_e-Ie,Ue=xe+(q-Ie),L=W*K/Me*Pe,O=ye*K/Me*Pe;k.projectionMatrix.makePerspective(ze,Ue,L,O,Pe,Me)}function V(k,j){j===null?k.matrixWorld.copy(k.matrix):k.matrixWorld.multiplyMatrices(j.matrixWorld,k.matrix),k.matrixWorldInverse.copy(k.matrixWorld).invert()}this.updateCamera=function(k){if(n===null)return;M.near=E.near=A.near=k.near,M.far=E.far=A.far=k.far,(T!==M.near||C!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,C=M.far);let j=k.parent,X=M.cameras;V(M,j);for(let z=0;z<X.length;z++)V(X[z],j);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),k.matrix.copy(M.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale);let q=k.children;for(let z=0,J=q.length;z<J;z++)q[z].updateMatrixWorld(!0);X.length===2?F(M,A,E):M.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(k){l=k,d!==null&&(d.fixedFoveation=k),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=k)},this.getPlanes=function(){return w};let G=null;function H(k,j){if(c=j.getViewerPose(u||o),p=j,c!==null){let X=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let q=!1;X.length!==M.cameras.length&&(M.cameras.length=0,q=!0);for(let z=0;z<X.length;z++){let J=X[z],Z=null;if(f!==null)Z=f.getViewport(J);else{let W=h.getViewSubImage(d,J);Z=W.viewport,z===0&&(t.setRenderTargetTextures(y,W.colorTexture,d.ignoreDepthValues?void 0:W.depthStencilTexture),t.setRenderTarget(y))}let K=b[z];K===void 0&&(K=new Ir,K.layers.enable(z),K.viewport=new Xe,b[z]=K),K.matrix.fromArray(J.transform.matrix),K.projectionMatrix.fromArray(J.projectionMatrix),K.viewport.set(Z.x,Z.y,Z.width,Z.height),z===0&&M.matrix.copy(K.matrix),q===!0&&M.cameras.push(K)}}for(let X=0;X<v.length;X++){let q=x[X],z=v[X];q!==null&&z!==void 0&&z.update(q,j,u||o)}if(G&&G(k,j),j.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:j.detectedPlanes});let X=null;for(let q of w)j.detectedPlanes.has(q)||(X===null&&(X=[]),X.push(q));if(X!==null)for(let q of X)w.delete(q),S.delete(q),r.dispatchEvent({type:"planeremoved",data:q});for(let q of j.detectedPlanes)if(!w.has(q))w.add(q),S.set(q,j.lastChangedTime),r.dispatchEvent({type:"planeadded",data:q});else{let z=S.get(q);q.lastChangedTime>z&&(S.set(q,q.lastChangedTime),r.dispatchEvent({type:"planechanged",data:q}))}}p=null}let Y=new cM;Y.setAnimationLoop(H),this.setAnimationLoop=function(k){G=k},this.dispose=function(){}}};function vz(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,lM(i)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?n(m,g):g.isMeshToonMaterial?(n(m,g),c(m,g)):g.isMeshPhongMaterial?(n(m,g),u(m,g)):g.isMeshStandardMaterial?(n(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(n(m,g),f(m,g)):g.isMeshDepthMaterial?n(m,g):g.isMeshDistanceMaterial?(n(m,g),p(m,g)):g.isMeshNormalMaterial?n(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function n(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===Qr&&(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===Qr&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.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 w=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.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 s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.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 y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(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 d(m,g,y){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===Qr&&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=y.texture,m.transmissionSamplerSize.value.set(y.width,y.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 f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function xz(i,t,e,r){let n={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let w=x.program;r.uniformBlockBinding(v,w)}function u(v,x){let w=n[v.id];w===void 0&&(p(v),w=c(v),n[v.id]=w,v.addEventListener("dispose",g));let S=x.program;r.updateUBOMapping(v,S);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function c(v){let x=h();v.__bindingPointIndex=x;let w=i.createBuffer(),S=v.__size,A=v.usage;return i.bindBuffer(35345,w),i.bufferData(35345,S,A),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,w),w}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=n[v.id],w=v.uniforms,S=v.__cache;i.bindBuffer(35345,x);for(let A=0,E=w.length;A<E;A++){let b=w[A];if(f(b,A,S)===!0){let M=b.__offset,T=Array.isArray(b.value)?b.value:[b.value],C=0;for(let P=0;P<T.length;P++){let D=T[P],I=m(D);typeof D=="number"?(b.__data[0]=D,i.bufferSubData(35345,M+C,b.__data)):D.isMatrix3?(b.__data[0]=D.elements[0],b.__data[1]=D.elements[1],b.__data[2]=D.elements[2],b.__data[3]=D.elements[0],b.__data[4]=D.elements[3],b.__data[5]=D.elements[4],b.__data[6]=D.elements[5],b.__data[7]=D.elements[0],b.__data[8]=D.elements[6],b.__data[9]=D.elements[7],b.__data[10]=D.elements[8],b.__data[11]=D.elements[0]):(D.toArray(b.__data,C),C+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,M,b.__data)}}i.bindBuffer(35345,null)}function f(v,x,w){let S=v.value;if(w[x]===void 0){if(typeof S=="number")w[x]=S;else{let A=Array.isArray(S)?S:[S],E=[];for(let b=0;b<A.length;b++)E.push(A[b].clone());w[x]=E}return!0}else if(typeof S=="number"){if(w[x]!==S)return w[x]=S,!0}else{let A=Array.isArray(w[x])?w[x]:[w[x]],E=Array.isArray(S)?S:[S];for(let b=0;b<A.length;b++){let M=A[b];if(M.equals(E[b])===!1)return M.copy(E[b]),!0}}return!1}function p(v){let x=v.uniforms,w=0,S=16,A=0;for(let E=0,b=x.length;E<b;E++){let M=x[E],T={boundary:0,storage:0},C=Array.isArray(M.value)?M.value:[M.value];for(let P=0,D=C.length;P<D;P++){let I=C[P],R=m(I);T.boundary+=R.boundary,T.storage+=R.storage}if(M.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=w,E>0){A=w%S;let P=S-A;A!==0&&P-T.boundary<0&&(w+=S-A,M.__offset=w)}w+=T.storage}return A=w%S,A>0&&(w+=S-A),v.__size=w,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),i.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function y(){for(let v in n)i.deleteBuffer(n[v]);o=[],n={},s={}}return{bind:l,update:u,dispose:y}}function bz(){let i=fg("canvas");return i.style.display="block",i}function tw(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:bz(),e=i.context!==void 0?i.context:null,r=i.depth!==void 0?i.depth:!0,n=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.alpha:!1;let h=null,d=null,f=[],p=[];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=Di,this.physicallyCorrectLights=!1,this.toneMapping=Uo,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,w=-1,S=null,A=new Xe,E=new Xe,b=null,M=t.width,T=t.height,C=1,P=null,D=null,I=new Xe(0,0,M,T),R=new Xe(0,0,M,T),U=!1,F=new Bf,V=!1,G=!1,H=null,Y=new ie,k=new N,j=new _,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let z=e;function J(B,te){for(let he=0;he<B.length;he++){let ee=B[he],pe=t.getContext(ee,te);if(pe!==null)return pe}return null}try{let B={alpha:!0,depth:r,stencil:n,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${qo}`),t.addEventListener("webglcontextlost",We,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",_t,!1),z===null){let te=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&te.shift(),z=J(te,B),z===null)throw J(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let Z,K,W,ye,fe,se,_e,xe,Oe,Ie,Pe,Me,ze,Ue,L,O,re,ue,me,De,Te,Ee,le,Ke;function ke(){Z=new Uk(z),K=new Nk(z,Z,i),Z.init(K),Ee=new gz(z,Z,K),W=new pz(z,Z,K),ye=new jk,fe=new rz,se=new mz(z,Z,W,fe,K,Ee,ye),_e=new Fk(m),xe=new zk(m),Oe=new $N(z,K),le=new Rk(z,Z,Oe,K),Ie=new Gk(z,Oe,ye,le),Pe=new Xk(z,Ie,Oe,ye),me=new Yk(z,K,se),O=new Bk(fe),Me=new tz(m,_e,xe,Z,K,le,O),ze=new vz(m,fe),Ue=new iz,L=new uz(Z,K),ue=new Ok(m,_e,xe,W,Pe,c,o),re=new fz(m,Pe,K),Ke=new xz(z,ye,K,W),De=new Lk(z,Z,ye,K),Te=new Hk(z,Z,ye,K),ye.programs=Me.programs,m.capabilities=K,m.extensions=Z,m.properties=fe,m.renderLists=Ue,m.shadowMap=re,m.state=W,m.info=ye}ke();let Ne=new Db(m,z);this.xr=Ne,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let B=Z.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=Z.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(B){B!==void 0&&(C=B,this.setSize(M,T,!1))},this.getSize=function(B){return B.set(M,T)},this.setSize=function(B,te,he){if(Ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=B,T=te,t.width=Math.floor(B*C),t.height=Math.floor(te*C),he!==!1&&(t.style.width=B+"px",t.style.height=te+"px"),this.setViewport(0,0,B,te)},this.getDrawingBufferSize=function(B){return B.set(M*C,T*C).floor()},this.setDrawingBufferSize=function(B,te,he){M=B,T=te,C=he,t.width=Math.floor(B*he),t.height=Math.floor(te*he),this.setViewport(0,0,B,te)},this.getCurrentViewport=function(B){return B.copy(A)},this.getViewport=function(B){return B.copy(I)},this.setViewport=function(B,te,he,ee){B.isVector4?I.set(B.x,B.y,B.z,B.w):I.set(B,te,he,ee),W.viewport(A.copy(I).multiplyScalar(C).floor())},this.getScissor=function(B){return B.copy(R)},this.setScissor=function(B,te,he,ee){B.isVector4?R.set(B.x,B.y,B.z,B.w):R.set(B,te,he,ee),W.scissor(E.copy(R).multiplyScalar(C).floor())},this.getScissorTest=function(){return U},this.setScissorTest=function(B){W.setScissorTest(U=B)},this.setOpaqueSort=function(B){P=B},this.setTransparentSort=function(B){D=B},this.getClearColor=function(B){return B.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(B=!0,te=!0,he=!0){let ee=0;B&&(ee|=16384),te&&(ee|=256),he&&(ee|=1024),z.clear(ee)},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",We,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",_t,!1),Ue.dispose(),L.dispose(),fe.dispose(),_e.dispose(),xe.dispose(),Pe.dispose(),le.dispose(),Ke.dispose(),Me.dispose(),Ne.dispose(),Ne.removeEventListener("sessionstart",Ve),Ne.removeEventListener("sessionend",Fe),H&&(H.dispose(),H=null),Et.stop()};function We(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function $e(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let B=ye.autoReset,te=re.enabled,he=re.autoUpdate,ee=re.needsUpdate,pe=re.type;ke(),ye.autoReset=B,re.enabled=te,re.autoUpdate=he,re.needsUpdate=ee,re.type=pe}function _t(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function ir(B){let te=B.target;te.removeEventListener("dispose",ir),Gr(te)}function Gr(B){Q(B),fe.remove(B)}function Q(B){let te=fe.get(B).programs;te!==void 0&&(te.forEach(function(he){Me.releaseProgram(he)}),B.isShaderMaterial&&Me.releaseShaderCache(B))}this.renderBufferDirect=function(B,te,he,ee,pe,st){te===null&&(te=X);let dt=pe.isMesh&&pe.matrixWorld.determinant()<0,mt=x3(B,te,he,ee,pe);W.setMaterial(ee,dt);let xt=he.index,Lt=1;ee.wireframe===!0&&(xt=Ie.getWireframeAttribute(he),Lt=2);let Mt=he.drawRange,Tt=he.attributes.position,jr=Mt.start*Lt,Ei=(Mt.start+Mt.count)*Lt;st!==null&&(jr=Math.max(jr,st.start*Lt),Ei=Math.min(Ei,(st.start+st.count)*Lt)),xt!==null?(jr=Math.max(jr,0),Ei=Math.min(Ei,xt.count)):Tt!=null&&(jr=Math.max(jr,0),Ei=Math.min(Ei,Tt.count));let Oo=Ei-jr;if(Oo<0||Oo===1/0)return;le.setup(pe,ee,mt,he,xt);let Il,Wr=De;if(xt!==null&&(Il=Oe.get(xt),Wr=Te,Wr.setIndex(Il)),pe.isMesh)ee.wireframe===!0?(W.setLineWidth(ee.wireframeLinewidth*q()),Wr.setMode(1)):Wr.setMode(4);else if(pe.isLine){let Ct=ee.linewidth;Ct===void 0&&(Ct=1),W.setLineWidth(Ct*q()),pe.isLineSegments?Wr.setMode(1):pe.isLineLoop?Wr.setMode(2):Wr.setMode(3)}else pe.isPoints?Wr.setMode(0):pe.isSprite&&Wr.setMode(4);if(pe.isInstancedMesh)Wr.renderInstances(jr,Oo,pe.count);else if(he.isInstancedBufferGeometry){let Ct=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,Mx=Math.min(he.instanceCount,Ct);Wr.renderInstances(jr,Oo,Mx)}else Wr.render(jr,Oo)},this.compile=function(B,te){function he(ee,pe,st){ee.transparent===!0&&ee.side===Ln&&ee.forceSinglePass===!1?(ee.side=Qr,ee.needsUpdate=!0,Vi(ee,pe,st),ee.side=Pi,ee.needsUpdate=!0,Vi(ee,pe,st),ee.side=Ln):Vi(ee,pe,st)}d=L.get(B),d.init(),p.push(d),B.traverseVisible(function(ee){ee.isLight&&ee.layers.test(te.layers)&&(d.pushLight(ee),ee.castShadow&&d.pushShadow(ee))}),d.setupLights(m.physicallyCorrectLights),B.traverse(function(ee){let pe=ee.material;if(pe)if(Array.isArray(pe))for(let st=0;st<pe.length;st++){let dt=pe[st];he(dt,B,ee)}else he(pe,B,ee)}),p.pop(),d=null};let ce=null;function ve(B){ce&&ce(B)}function Ve(){Et.stop()}function Fe(){Et.start()}let Et=new cM;Et.setAnimationLoop(ve),typeof self<"u"&&Et.setContext(self),this.setAnimationLoop=function(B){ce=B,Ne.setAnimationLoop(B),B===null?Et.stop():Et.start()},Ne.addEventListener("sessionstart",Ve),Ne.addEventListener("sessionend",Fe),this.render=function(B,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(te),te=Ne.getCamera()),B.isScene===!0&&B.onBeforeRender(m,B,te,x),d=L.get(B,p.length),d.init(),p.push(d),Y.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),F.setFromProjectionMatrix(Y),G=this.localClippingEnabled,V=O.init(this.clippingPlanes,G),h=Ue.get(B,f.length),h.init(),f.push(h),Hr(B,te,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(P,D),V===!0&&O.beginShadows();let he=d.state.shadowsArray;if(re.render(he,B,te),V===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(h,B),d.setupLights(m.physicallyCorrectLights),te.isArrayCamera){let ee=te.cameras;for(let pe=0,st=ee.length;pe<st;pe++){let dt=ee[pe];Pr(h,B,dt,dt.viewport)}}else Pr(h,B,te);x!==null&&(se.updateMultisampleRenderTarget(x),se.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(m,B,te),le.resetDefaultState(),w=-1,S=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Hr(B,te,he,ee){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)he=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)d.pushLight(B),B.castShadow&&d.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||F.intersectsSprite(B)){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Y);let dt=Pe.update(B),mt=B.material;mt.visible&&h.push(B,dt,mt,he,j.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==ye.render.frame&&(B.skeleton.update(),B.skeleton.frame=ye.render.frame),!B.frustumCulled||F.intersectsObject(B))){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Y);let dt=Pe.update(B),mt=B.material;if(Array.isArray(mt)){let xt=dt.groups;for(let Lt=0,Mt=xt.length;Lt<Mt;Lt++){let Tt=xt[Lt],jr=mt[Tt.materialIndex];jr&&jr.visible&&h.push(B,dt,jr,he,j.z,Tt)}}else mt.visible&&h.push(B,dt,mt,he,j.z,null)}}let st=B.children;for(let dt=0,mt=st.length;dt<mt;dt++)Hr(st[dt],te,he,ee)}function Pr(B,te,he,ee){let pe=B.opaque,st=B.transmissive,dt=B.transparent;d.setupLightsView(he),V===!0&&O.setGlobalState(m.clippingPlanes,he),st.length>0&&Dl(pe,te,he),ee&&W.viewport(A.copy(ee)),pe.length>0&&hr(pe,te,he),st.length>0&&hr(st,te,he),dt.length>0&&hr(dt,te,he),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Dl(B,te,he){let ee=K.isWebGL2;H===null&&(H=new ht(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?Go:lr,minFilter:Ul,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(k),ee?H.setSize(k.x,k.y):H.setSize(dg(k.x),dg(k.y));let pe=m.getRenderTarget();m.setRenderTarget(H),m.clear();let st=m.toneMapping;m.toneMapping=Uo,hr(B,te,he),m.toneMapping=st,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),m.setRenderTarget(pe)}function hr(B,te,he){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,st=B.length;pe<st;pe++){let dt=B[pe],mt=dt.object,xt=dt.geometry,Lt=ee===null?dt.material:ee,Mt=dt.group;mt.layers.test(he.layers)&&Io(mt,te,he,xt,Lt,Mt)}}function Io(B,te,he,ee,pe,st){B.onBeforeRender(m,te,he,ee,pe,st),B.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),pe.onBeforeRender(m,te,he,ee,B,st),pe.transparent===!0&&pe.side===Ln&&pe.forceSinglePass===!1?(pe.side=Qr,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,B,st),pe.side=Pi,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,B,st),pe.side=Ln):m.renderBufferDirect(he,te,ee,pe,B,st),B.onAfterRender(m,te,he,ee,pe,st)}function Vi(B,te,he){te.isScene!==!0&&(te=X);let ee=fe.get(B),pe=d.state.lights,st=d.state.shadowsArray,dt=pe.state.version,mt=Me.getParameters(B,pe.state,st,te,he),xt=Me.getProgramCacheKey(mt),Lt=ee.programs;ee.environment=B.isMeshStandardMaterial?te.environment:null,ee.fog=te.fog,ee.envMap=(B.isMeshStandardMaterial?xe:_e).get(B.envMap||ee.environment),Lt===void 0&&(B.addEventListener("dispose",ir),Lt=new Map,ee.programs=Lt);let Mt=Lt.get(xt);if(Mt!==void 0){if(ee.currentProgram===Mt&&ee.lightsStateVersion===dt)return y_(B,mt),Mt}else mt.uniforms=Me.getUniforms(B),B.onBuild(he,mt,m),B.onBeforeCompile(mt,m),Mt=Me.acquireProgram(mt,xt),Lt.set(xt,Mt),ee.uniforms=mt.uniforms;let Tt=ee.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(Tt.clippingPlanes=O.uniform),y_(B,mt),ee.needsLights=w3(B),ee.lightsStateVersion=dt,ee.needsLights&&(Tt.ambientLightColor.value=pe.state.ambient,Tt.lightProbe.value=pe.state.probe,Tt.directionalLights.value=pe.state.directional,Tt.directionalLightShadows.value=pe.state.directionalShadow,Tt.spotLights.value=pe.state.spot,Tt.spotLightShadows.value=pe.state.spotShadow,Tt.rectAreaLights.value=pe.state.rectArea,Tt.ltc_1.value=pe.state.rectAreaLTC1,Tt.ltc_2.value=pe.state.rectAreaLTC2,Tt.pointLights.value=pe.state.point,Tt.pointLightShadows.value=pe.state.pointShadow,Tt.hemisphereLights.value=pe.state.hemi,Tt.directionalShadowMap.value=pe.state.directionalShadowMap,Tt.directionalShadowMatrix.value=pe.state.directionalShadowMatrix,Tt.spotShadowMap.value=pe.state.spotShadowMap,Tt.spotLightMatrix.value=pe.state.spotLightMatrix,Tt.spotLightMap.value=pe.state.spotLightMap,Tt.pointShadowMap.value=pe.state.pointShadowMap,Tt.pointShadowMatrix.value=pe.state.pointShadowMatrix);let jr=Mt.getUniforms(),Ei=su.seqWithValue(jr.seq,Tt);return ee.currentProgram=Mt,ee.uniformsList=Ei,Mt}function y_(B,te){let he=fe.get(B);he.outputEncoding=te.outputEncoding,he.instancing=te.instancing,he.skinning=te.skinning,he.morphTargets=te.morphTargets,he.morphNormals=te.morphNormals,he.morphColors=te.morphColors,he.morphTargetsCount=te.morphTargetsCount,he.numClippingPlanes=te.numClippingPlanes,he.numIntersection=te.numClipIntersection,he.vertexAlphas=te.vertexAlphas,he.vertexTangents=te.vertexTangents,he.toneMapping=te.toneMapping}function x3(B,te,he,ee,pe){te.isScene!==!0&&(te=X),se.resetTextureUnits();let st=te.fog,dt=ee.isMeshStandardMaterial?te.environment:null,mt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Di,xt=(ee.isMeshStandardMaterial?xe:_e).get(ee.envMap||dt),Lt=ee.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,Mt=!!ee.normalMap&&!!he.attributes.tangent,Tt=!!he.morphAttributes.position,jr=!!he.morphAttributes.normal,Ei=!!he.morphAttributes.color,Oo=ee.toneMapped?m.toneMapping:Uo,Il=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,Wr=Il!==void 0?Il.length:0,Ct=fe.get(ee),Mx=d.state.lights;if(V===!0&&(G===!0||B!==S)){let Mi=B===S&&ee.id===w;O.setState(ee,B,Mi)}let fn=!1;ee.version===Ct.__version?(Ct.needsLights&&Ct.lightsStateVersion!==Mx.state.version||Ct.outputEncoding!==mt||pe.isInstancedMesh&&Ct.instancing===!1||!pe.isInstancedMesh&&Ct.instancing===!0||pe.isSkinnedMesh&&Ct.skinning===!1||!pe.isSkinnedMesh&&Ct.skinning===!0||Ct.envMap!==xt||ee.fog===!0&&Ct.fog!==st||Ct.numClippingPlanes!==void 0&&(Ct.numClippingPlanes!==O.numPlanes||Ct.numIntersection!==O.numIntersection)||Ct.vertexAlphas!==Lt||Ct.vertexTangents!==Mt||Ct.morphTargets!==Tt||Ct.morphNormals!==jr||Ct.morphColors!==Ei||Ct.toneMapping!==Oo||K.isWebGL2===!0&&Ct.morphTargetsCount!==Wr)&&(fn=!0):(fn=!0,Ct.__version=ee.version);let Ol=Ct.currentProgram;fn===!0&&(Ol=Vi(ee,te,pe));let v_=!1,gf=!1,Tx=!1,Rn=Ol.getUniforms(),Rl=Ct.uniforms;if(W.useProgram(Ol.program)&&(v_=!0,gf=!0,Tx=!0),ee.id!==w&&(w=ee.id,gf=!0),v_||S!==B){if(Rn.setValue(z,"projectionMatrix",B.projectionMatrix),K.logarithmicDepthBuffer&&Rn.setValue(z,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),S!==B&&(S=B,gf=!0,Tx=!0),ee.isShaderMaterial||ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshStandardMaterial||ee.envMap){let Mi=Rn.map.cameraPosition;Mi!==void 0&&Mi.setValue(z,j.setFromMatrixPosition(B.matrixWorld))}(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&Rn.setValue(z,"isOrthographic",B.isOrthographicCamera===!0),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial||ee.isShadowMaterial||pe.isSkinnedMesh)&&Rn.setValue(z,"viewMatrix",B.matrixWorldInverse)}if(pe.isSkinnedMesh){Rn.setOptional(z,pe,"bindMatrix"),Rn.setOptional(z,pe,"bindMatrixInverse");let Mi=pe.skeleton;Mi&&(K.floatVertexTextures?(Mi.boneTexture===null&&Mi.computeBoneTexture(),Rn.setValue(z,"boneTexture",Mi.boneTexture,se),Rn.setValue(z,"boneTextureSize",Mi.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 Cx=he.morphAttributes;if((Cx.position!==void 0||Cx.normal!==void 0||Cx.color!==void 0&&K.isWebGL2===!0)&&me.update(pe,he,ee,Ol),(gf||Ct.receiveShadow!==pe.receiveShadow)&&(Ct.receiveShadow=pe.receiveShadow,Rn.setValue(z,"receiveShadow",pe.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(Rl.envMap.value=xt,Rl.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),gf&&(Rn.setValue(z,"toneMappingExposure",m.toneMappingExposure),Ct.needsLights&&b3(Rl,Tx),st&&ee.fog===!0&&ze.refreshFogUniforms(Rl,st),ze.refreshMaterialUniforms(Rl,ee,C,T,H),su.upload(z,Ct.uniformsList,Rl,se)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(su.upload(z,Ct.uniformsList,Rl,se),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&Rn.setValue(z,"center",pe.center),Rn.setValue(z,"modelViewMatrix",pe.modelViewMatrix),Rn.setValue(z,"normalMatrix",pe.normalMatrix),Rn.setValue(z,"modelMatrix",pe.matrixWorld),pe.previousModelViewMatrix&&Rn.setValue(z,"previousModelViewMatrix",pe.previousModelViewMatrix),B.previousProjectionMatrix&&Rn.setValue(z,"previousProjectionMatrix",B.previousProjectionMatrix),ee.isShaderMaterial||ee.isRawShaderMaterial){let Mi=ee.uniformsGroups;for(let Px=0,S3=Mi.length;Px<S3;Px++)if(K.isWebGL2){let x_=Mi[Px];Ke.update(x_,Ol),Ke.bind(x_,Ol)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ol}function b3(B,te){B.ambientLightColor.needsUpdate=te,B.lightProbe.needsUpdate=te,B.directionalLights.needsUpdate=te,B.directionalLightShadows.needsUpdate=te,B.pointLights.needsUpdate=te,B.pointLightShadows.needsUpdate=te,B.spotLights.needsUpdate=te,B.spotLightShadows.needsUpdate=te,B.rectAreaLights.needsUpdate=te,B.hemisphereLights.needsUpdate=te}function w3(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,te,he){fe.get(B.texture).__webglTexture=te,fe.get(B.depthTexture).__webglTexture=he;let ee=fe.get(B);ee.__hasExternalTextures=!0,ee.__hasExternalTextures&&(ee.__autoAllocateDepthBuffer=he===void 0,ee.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ee.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(B,te){let he=fe.get(B);he.__webglFramebuffer=te,he.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(B,te=0,he=0){x=B,y=te,v=he;let ee=!0,pe=null,st=!1,dt=!1;if(B){let xt=fe.get(B);xt.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(36160,null),ee=!1):xt.__webglFramebuffer===void 0?se.setupRenderTarget(B):xt.__hasExternalTextures&&se.rebindTextures(B,fe.get(B.texture).__webglTexture,fe.get(B.depthTexture).__webglTexture);let Lt=B.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(dt=!0);let Mt=fe.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(pe=Mt[te],st=!0):K.isWebGL2&&B.samples>0&&se.useMultisampledRTT(B)===!1?pe=fe.get(B).__webglMultisampledFramebuffer:pe=Mt,A.copy(B.viewport),E.copy(B.scissor),b=B.scissorTest}else A.copy(I).multiplyScalar(C).floor(),E.copy(R).multiplyScalar(C).floor(),b=U;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(B,pe),W.viewport(A),W.scissor(E),W.setScissorTest(b),st){let xt=fe.get(B.texture);z.framebufferTexture2D(36160,36064,34069+te,xt.__webglTexture,he)}else if(dt){let xt=fe.get(B.texture),Lt=te||0;z.framebufferTextureLayer(36160,36064,xt.__webglTexture,he||0,Lt)}w=-1},this.readRenderTargetPixels=function(B,te,he,ee,pe,st,dt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let mt=fe.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&dt!==void 0&&(mt=mt[dt]),mt){W.bindFramebuffer(36160,mt);try{let xt=B.texture,Lt=xt.format,Mt=xt.type;if(Lt!==$n&&Ee.convert(Lt)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Tt=Mt===Go&&(Z.has("EXT_color_buffer_half_float")||K.isWebGL2&&Z.has("EXT_color_buffer_float"));if(Mt!==lr&&Ee.convert(Mt)!==z.getParameter(35738)&&!(Mt===Xr&&(K.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!Tt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=B.width-ee&&he>=0&&he<=B.height-pe&&z.readPixels(te,he,ee,pe,Ee.convert(Lt),Ee.convert(Mt),st)}finally{let xt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,xt)}}},this.copyFramebufferToTexture=function(B,te,he=0){let ee=Math.pow(2,-he),pe=Math.floor(te.image.width*ee),st=Math.floor(te.image.height*ee);se.setTexture2D(te,0),z.copyTexSubImage2D(3553,he,0,0,B.x,B.y,pe,st),W.unbindTexture()},this.copyTextureToTexture=function(B,te,he,ee=0){let pe=te.image.width,st=te.image.height,dt=Ee.convert(he.format),mt=Ee.convert(he.type);se.setTexture2D(he,0),z.pixelStorei(37440,he.flipY),z.pixelStorei(37441,he.premultiplyAlpha),z.pixelStorei(3317,he.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,ee,B.x,B.y,pe,st,dt,mt,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,ee,B.x,B.y,te.mipmaps[0].width,te.mipmaps[0].height,dt,te.mipmaps[0].data):z.texSubImage2D(3553,ee,B.x,B.y,dt,mt,te.image),ee===0&&he.generateMipmaps&&z.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(B,te,he,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let st=B.max.x-B.min.x+1,dt=B.max.y-B.min.y+1,mt=B.max.z-B.min.z+1,xt=Ee.convert(ee.format),Lt=Ee.convert(ee.type),Mt;if(ee.isData3DTexture)se.setTexture3D(ee,0),Mt=32879;else if(ee.isDataArrayTexture)se.setTexture2DArray(ee,0),Mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,ee.flipY),z.pixelStorei(37441,ee.premultiplyAlpha),z.pixelStorei(3317,ee.unpackAlignment);let Tt=z.getParameter(3314),jr=z.getParameter(32878),Ei=z.getParameter(3316),Oo=z.getParameter(3315),Il=z.getParameter(32877),Wr=he.isCompressedTexture?he.mipmaps[0]:he.image;z.pixelStorei(3314,Wr.width),z.pixelStorei(32878,Wr.height),z.pixelStorei(3316,B.min.x),z.pixelStorei(3315,B.min.y),z.pixelStorei(32877,B.min.z),he.isDataTexture||he.isData3DTexture?z.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Wr.data)):z.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr),z.pixelStorei(3314,Tt),z.pixelStorei(32878,jr),z.pixelStorei(3316,Ei),z.pixelStorei(3315,Oo),z.pixelStorei(32877,Il),pe===0&&ee.generateMipmaps&&z.generateMipmap(Mt),W.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?se.setTextureCube(B,0):B.isData3DTexture?se.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?se.setTexture2DArray(B,0):se.setTexture2D(B,0),W.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,W.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Ib=class extends tw{};Ib.prototype.isWebGL1Renderer=!0;var cu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new Re(t),this.near=e,this.far=r}clone(){return new cu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Nn=class extends gt{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(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},wg=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=yb,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ui()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[r+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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}}},Zn=new _,Hl=class{constructor(t,e,r,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.applyMatrix4(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.applyNormalMatrix(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.transformDirection(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}setX(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=zo(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=zo(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=zo(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=zo(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this}setXYZW(t,e,r,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array),s=Kt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new Ge(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Hl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var kf=class extends gt{constructor(){super(),this.isBone=!0,this.type="Bone"}},li=class extends or{constructor(t=null,e=1,r=1,n,s,o,a,l,u=kt,c=kt,h,d){super(null,o,a,l,u,c,n,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},IE=new ie,wz=new ie,Pa=class{constructor(t=[],e=[]){this.uuid=Ui(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,n=this.bones.length;r<n;r++)this.boneInverses.push(new ie)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ie;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,n=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:wz;IE.multiplyMatrices(a,e[s]),IE.toArray(r,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Pa(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=sM(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new li(e,t,t,$n,Xr);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,n=t.bones.length;r<n;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new kf),this.bones.push(o),this.boneInverses.push(new ie().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let n=0,s=e.length;n<s;n++){let o=e[n];t.bones.push(o.uuid);let a=r[n];t.boneInverses.push(a.toArray())}return t}},uu=class extends Ge{constructor(t,e,r,n=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var Hi=class extends Gl{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Re(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},OE=new _,RE=new _,LE=new ie,ab=new gs,eg=new fr,jl=class extends gt{constructor(t=new Ae,e=new Hi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let n=1,s=e.count;n<s;n++)OE.fromBufferAttribute(e,n-1),RE.fromBufferAttribute(e,n),r[n]=r[n-1],r[n]+=OE.distanceTo(RE);t.setAttribute("lineDistance",new be(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),eg.copy(r.boundingSphere),eg.applyMatrix4(n),eg.radius+=s,t.ray.intersectsSphere(eg)===!1)return;LE.copy(n).invert(),ab.copy(t.ray).applyMatrix4(LE);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new _,c=new _,h=new _,d=new _,f=this.isLineSegments?2:1,p=r.index,g=r.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){let S=p.getX(x),A=p.getX(x+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,A),ab.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),ab.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},NE=new _,BE=new _,Da=class extends jl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let n=0,s=e.count;n<s;n+=2)NE.fromBufferAttribute(e,n),BE.fromBufferAttribute(e,n+1),r[n]=n===0?0:r[n-1],r[n+1]=r[n]+NE.distanceTo(BE);t.setAttribute("lineDistance",new be(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Sg=class extends or{constructor(t,e,r,n,s,o,a,l,u){super(t,e,r,n,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Je,this.magFilter=s!==void 0?s:Je,this.generateMipmaps=!1;let c=this;function h(){c.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var ji=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,n=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(n),e.push(s),n=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),n=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,u;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),u=r[n]-o,u<0)a=n+1;else if(u>0)l=n-1;else{l=n;break}if(n=l,r[n]===o)return n/(s-1);let c=r[n],d=r[n+1]-c,f=(o-c)/d;return(n+f)/(s-1)}getTangent(t,e){let n=t-1e-4,s=t+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=e||(o.isVector2?new N:new _);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new _,n=[],s=[],o=[],a=new _,l=new ie;for(let f=0;f<=t;f++){let p=f/t;n[f]=this.getTangentAt(p,new _)}s[0]=new _,o[0]=new _;let u=Number.MAX_VALUE,c=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);c<=u&&(u=c,r.set(1,0,0)),h<=u&&(u=h,r.set(0,1,0)),d<=u&&r.set(0,0,1),a.crossVectors(n[0],r).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(n[f-1],n[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Yr(n[f-1].dot(n[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(n[f],s[f])}if(e===!0){let f=Math.acos(Yr(s[0].dot(s[t]),-1,1));f/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(n[p],f*p)),o[p].crossVectors(n[p],s[p])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Wl=class extends ji{constructor(t=0,e=0,r=1,n=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new N,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(o?s=0:s=n),this.aClockwise===!0&&!o&&(s===n?s=-n:s=s-n);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+f*c+this.aY}return r.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},Ob=class extends Wl{constructor(t,e,r,n,s,o){super(t,e,r,r,n,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function rw(){let i=0,t=0,e=0,r=0;function n(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){n(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,n(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+r*a}}}var tg=new _,lb=new rw,cb=new rw,ub=new rw,Rb=class extends ji{constructor(t=[],e=!1,r="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=n}getPoint(t,e=new _){let r=e,n=this.points,s=n.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=n[(a-1)%s]:(tg.subVectors(n[0],n[1]).add(n[0]),u=tg);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2<s?c=n[(a+2)%s]:(tg.subVectors(n[s-1],n[s-2]).add(n[s-1]),c=tg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(u.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),lb.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,p,m,g),cb.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,p,m,g),ub.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(lb.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),cb.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),ub.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return r.set(lb.calc(l),cb.calc(l),ub.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new _().fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function FE(i,t,e,r,n){let s=(r-t)*.5,o=(n-e)*.5,a=i*i,l=i*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*i+e}function Sz(i,t){let e=1-i;return e*e*t}function Az(i,t){return 2*(1-i)*i*t}function _z(i,t){return i*i*t}function If(i,t,e,r){return Sz(i,t)+Az(i,e)+_z(i,r)}function Ez(i,t){let e=1-i;return e*e*e*t}function Mz(i,t){let e=1-i;return 3*e*e*i*t}function Tz(i,t){return 3*(1-i)*i*i*t}function Cz(i,t){return i*i*i*t}function Of(i,t,e,r,n){return Ez(i,t)+Mz(i,e)+Tz(i,r)+Cz(i,n)}var jn=class extends ji{constructor(t=new N,e=new N,r=new N,n=new N){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new N){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Of(t,n.x,s.x,o.x,a.x),Of(t,n.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},ql=class extends ji{constructor(t=new _,e=new _,r=new _,n=new _){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new _){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Of(t,n.x,s.x,o.x,a.x),Of(t,n.y,s.y,o.y,a.y),Of(t,n.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Wn=class extends ji{constructor(t=new N,e=new N){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new N){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let r=e||new N;return r.copy(this.v2).sub(this.v1).normalize(),r}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Vf=class extends ji{constructor(t=new _,e=new _){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new _){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ii=class extends ji{constructor(t=new N,e=new N,r=new N){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new N){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(If(t,n.x,s.x,o.x),If(t,n.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Lb=class extends ji{constructor(t=new _,e=new _,r=new _){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new _){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(If(t,n.x,s.x,o.x),If(t,n.y,s.y,o.y),If(t,n.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},hu=class extends ji{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new N){let r=e,n=this.points,s=(n.length-1)*t,o=Math.floor(s),a=s-o,l=n[o===0?o:o-1],u=n[o],c=n[o>n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return r.set(FE(a,l.x,u.x,c.x,h.x),FE(a,l.y,u.y,c.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new N().fromArray(n))}return this}},Pz=Object.freeze({__proto__:null,ArcCurve:Ob,CatmullRomCurve3:Rb,CubicBezierCurve:jn,CubicBezierCurve3:ql,EllipseCurve:Wl,LineCurve:Wn,LineCurve3:Vf,QuadraticBezierCurve:Ii,QuadraticBezierCurve3:Lb,SplineCurve:hu}),zf=class extends ji{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Wn(e,t))}getPoint(t,e){let r=t*this.getLength(),n=this.getCurveLengths(),s=0;for(;s<n.length;){if(n[s]>=r){let o=n[s]-r,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.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 t=[],e=0;for(let r=0,n=this.curves.length;r<n;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let n=0,s=this.curves;n<s.length;n++){let o=s[n],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];r&&r.equals(c)||(e.push(c),r=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(new Pz[n.type]().fromJSON(n))}return this}},Yl=class extends zf{constructor(t){super(),this.type="Path",this.currentPoint=new N,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new Wn(this.currentPoint.clone(),new N(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,n){let s=new Ii(this.currentPoint.clone(),new N(t,e),new N(r,n));return this.curves.push(s),this.currentPoint.set(r,n),this}bezierCurveTo(t,e,r,n,s,o){let a=new jn(this.currentPoint.clone(),new N(t,e),new N(r,n),new N(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new hu(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,n,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,n,s,o),this}absarc(t,e,r,n,s,o){return this.absellipse(t,e,r,r,n,s,o),this}ellipse(t,e,r,n,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,r,n,s,o,a,l),this}absellipse(t,e,r,n,s,o,a,l){let u=new Wl(t,e,r,n,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},du=class extends Ae{constructor(t=[new N(0,-.5),new N(.5,0),new N(0,.5)],e=12,r=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:n},e=Math.floor(e),n=Yr(n,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,h=new _,d=new N,f=new _,p=new _,m=new _,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=r+v*c*n,w=Math.sin(x),S=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*w,h.y=t[A].y,h.z=t[A].x*S,o.push(h.x,h.y,h.z),d.x=v/e,d.y=A/(t.length-1),a.push(d.x,d.y);let E=l[3*A+0]*w,b=l[3*A+1],M=l[3*A+0]*S;u.push(E,b,M)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let w=x+v*t.length,S=w,A=w+t.length,E=w+t.length+1,b=w+1;s.push(S,A,b),s.push(E,b,A)}this.setIndex(s),this.setAttribute("position",new be(o,3)),this.setAttribute("uv",new be(a,2)),this.setAttribute("normal",new be(u,3))}static fromJSON(t){return new du(t.points,t.segments,t.phiStart,t.phiLength)}};var Xl=class extends Ae{constructor(t=1,e=1,r=1,n=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;n=Math.floor(n),s=Math.floor(s);let c=[],h=[],d=[],f=[],p=0,m=[],g=r/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function v(){let w=new _,S=new _,A=0,E=(e-t)/r;for(let b=0;b<=s;b++){let M=[],T=b/s,C=T*(e-t)+t;for(let P=0;P<=n;P++){let D=P/n,I=D*l+a,R=Math.sin(I),U=Math.cos(I);S.x=C*R,S.y=-T*r+g,S.z=C*U,h.push(S.x,S.y,S.z),w.set(R,E,U).normalize(),d.push(w.x,w.y,w.z),f.push(D,1-T),M.push(p++)}m.push(M)}for(let b=0;b<n;b++)for(let M=0;M<s;M++){let T=m[M][b],C=m[M+1][b],P=m[M+1][b+1],D=m[M][b+1];c.push(T,C,D),c.push(C,P,D),A+=6}u.addGroup(y,A,0),y+=A}function x(w){let S=p,A=new N,E=new _,b=0,M=w===!0?t:e,T=w===!0?1:-1;for(let P=1;P<=n;P++)h.push(0,g*T,0),d.push(0,T,0),f.push(.5,.5),p++;let C=p;for(let P=0;P<=n;P++){let I=P/n*l+a,R=Math.cos(I),U=Math.sin(I);E.x=M*U,E.y=g*T,E.z=M*R,h.push(E.x,E.y,E.z),d.push(0,T,0),A.x=R*.5+.5,A.y=U*.5*T+.5,f.push(A.x,A.y),p++}for(let P=0;P<n;P++){let D=S+P,I=C+P;w===!0?c.push(I,I+1,D):c.push(I+1,I,D),b+=3}u.addGroup(y,b,w===!0?1:2),y+=b}}static fromJSON(t){return new Xl(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},fu=class extends Xl{constructor(t=1,e=1,r=32,n=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,n,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new fu(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},pu=class extends Ae{constructor(t=[],e=[],r=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n};let s=[],o=[];a(n),u(r),c(),this.setAttribute("position",new be(s,3)),this.setAttribute("normal",new be(s.slice(),3)),this.setAttribute("uv",new be(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new _,w=new _,S=new _;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],w),f(e[A+2],S),l(x,w,S,v)}function l(v,x,w,S){let A=S+1,E=[];for(let b=0;b<=A;b++){E[b]=[];let M=v.clone().lerp(w,b/A),T=x.clone().lerp(w,b/A),C=A-b;for(let P=0;P<=C;P++)P===0&&b===A?E[b][P]=M:E[b][P]=M.clone().lerp(T,P/C)}for(let b=0;b<A;b++)for(let M=0;M<2*(A-b)-1;M++){let T=Math.floor(M/2);M%2===0?(d(E[b][T+1]),d(E[b+1][T]),d(E[b][T])):(d(E[b][T+1]),d(E[b+1][T+1]),d(E[b+1][T]))}}function u(v){let x=new _;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function c(){let v=new _;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,S=y(v)/Math.PI+.5;o.push(w,1-S)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],S=o[v+4],A=Math.max(x,w,S),E=Math.min(x,w,S);A>.9&&E<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function p(){let v=new _,x=new _,w=new _,S=new _,A=new N,E=new N,b=new N;for(let M=0,T=0;M<s.length;M+=9,T+=6){v.set(s[M+0],s[M+1],s[M+2]),x.set(s[M+3],s[M+4],s[M+5]),w.set(s[M+6],s[M+7],s[M+8]),A.set(o[T+0],o[T+1]),E.set(o[T+2],o[T+3]),b.set(o[T+4],o[T+5]),S.copy(v).add(x).add(w).divideScalar(3);let C=g(S);m(A,T+0,v,C),m(E,T+2,x,C),m(b,T+4,w,C)}}function m(v,x,w,S){S<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new pu(t.vertices,t.indices,t.radius,t.details)}},mu=class extends pu{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=1/r,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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],o=[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,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new mu(t.radius,t.detail)}};var Wo=class extends Yl{constructor(t){super(t),this.uuid=Ui(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,n=this.holes.length;r<n;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(new Yl().fromJSON(n))}return this}},Dz={triangulate:function(i,t,e=2){let r=t&&t.length,n=r?t[0]*e:i.length,s=pM(i,0,n,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(r&&(s=Nz(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let p=e;p<n;p+=e)h=i[p],d=i[p+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return Uf(s,o,e,a,l,f,0),o}};function pM(i,t,e,r,n){let s,o;if(n===qz(i,t,e,r)>0)for(s=t;s<e;s+=r)o=kE(s,i[s],i[s+1],o);else for(s=e-r;s>=t;s-=r)o=kE(s,i[s],i[s+1],o);return o&&Fg(o,o.next)&&(Hf(o),o=o.next),o}function Ql(i,t){if(!i)return i;t||(t=i);let e=i,r;do if(r=!1,!e.steiner&&(Fg(e,e.next)||vr(e.prev,e,e.next)===0)){if(Hf(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Uf(i,t,e,r,n,s,o){if(!i)return;!o&&s&&zz(i,r,n,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?Oz(i,r,n,s):Iz(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),Hf(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=Rz(Ql(i),t,e),Uf(i,t,e,r,n,s,2)):o===2&&Lz(i,t,e,r,n,s):Uf(Ql(i),t,e,r,n,s,1);break}}}function Iz(i){let t=i.prev,e=i,r=i.next;if(vr(t,e,r)>=0)return!1;let n=t.x,s=e.x,o=r.x,a=t.y,l=e.y,u=r.y,c=n<s?n<o?n:o:s<o?s:o,h=a<l?a<u?a:u:l<u?l:u,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=r.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&iu(n,a,s,l,o,u,p.x,p.y)&&vr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Oz(i,t,e,r){let n=i.prev,s=i,o=i.next;if(vr(n,s,o)>=0)return!1;let a=n.x,l=s.x,u=o.x,c=n.y,h=s.y,d=o.y,f=a<l?a<u?a:u:l<u?l:u,p=c<h?c<d?c:d:h<d?h:d,m=a>l?a>u?a:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,y=Nb(f,p,t,e,r),v=Nb(m,g,t,e,r),x=i.prevZ,w=i.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&iu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&iu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&iu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&iu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Rz(i,t,e){let r=i;do{let n=r.prev,s=r.next.next;!Fg(n,s)&&mM(n,r,r.next,s)&&Gf(n,s)&&Gf(s,n)&&(t.push(n.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),Hf(r),Hf(r.next),r=i=s),r=r.next}while(r!==i);return Ql(r)}function Lz(i,t,e,r,n,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Hz(o,a)){let l=gM(o,a);o=Ql(o,o.next),l=Ql(l,l.next),Uf(o,t,e,r,n,s,0),Uf(l,t,e,r,n,s,0);return}a=a.next}o=o.next}while(o!==i)}function Nz(i,t,e,r){let n=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:i.length,u=pM(i,a,l,r,!1),u===u.next&&(u.steiner=!0),n.push(Gz(u));for(n.sort(Bz),s=0;s<n.length;s++)e=Fz(n[s],e);return e}function Bz(i,t){return i.x-t.x}function Fz(i,t){let e=kz(i,t);if(!e)return t;let r=gM(e,i);return Ql(r,r.next),Ql(e,e.next)}function kz(i,t){let e=t,r=-1/0,n,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,n=e.x<e.next.x?e:e.next,d===s))return n}e=e.next}while(e!==t);if(!n)return null;let a=n,l=n.x,u=n.y,c=1/0,h;e=n;do s>=e.x&&e.x>=l&&s!==e.x&&iu(o<u?s:r,o,l,u,o<u?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),Gf(e,i)&&(h<c||h===c&&(e.x>n.x||e.x===n.x&&Vz(n,e)))&&(n=e,c=h)),e=e.next;while(e!==a);return n}function Vz(i,t){return vr(i.prev,i,t.prev)<0&&vr(t.next,i,i.next)<0}function zz(i,t,e,r){let n=i;do n.z===0&&(n.z=Nb(n.x,n.y,t,e,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,Uz(n)}function Uz(i){let t,e,r,n,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<u&&(a++,r=r.nextZ,!!r);t++);for(l=u;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(n=e,e=e.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:i=n,n.prevZ=s,s=n;e=r}s.nextZ=null,u*=2}while(o>1);return i}function Nb(i,t,e,r,n){return i=(i-e)*n|0,t=(t-r)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Gz(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function iu(i,t,e,r,n,s,o,a){return(n-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(r-a)}function Hz(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!jz(i,t)&&(Gf(i,t)&&Gf(t,i)&&Wz(i,t)&&(vr(i.prev,i,t.prev)||vr(i,t.prev,t))||Fg(i,t)&&vr(i.prev,i,i.next)>0&&vr(t.prev,t,t.next)>0)}function vr(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Fg(i,t){return i.x===t.x&&i.y===t.y}function mM(i,t,e,r){let n=ng(vr(i,t,e)),s=ng(vr(i,t,r)),o=ng(vr(e,r,i)),a=ng(vr(e,r,t));return!!(n!==s&&o!==a||n===0&&rg(i,e,t)||s===0&&rg(i,r,t)||o===0&&rg(e,i,r)||a===0&&rg(e,t,r))}function rg(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function ng(i){return i>0?1:i<0?-1:0}function jz(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&mM(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Gf(i,t){return vr(i.prev,i,i.next)<0?vr(i,t,i.next)>=0&&vr(i,i.prev,t)>=0:vr(i,t,i.prev)<0||vr(i,i.next,t)<0}function Wz(i,t){let e=i,r=!1,n=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function gM(i,t){let e=new Bb(i.i,i.x,i.y),r=new Bb(t.i,t.x,t.y),n=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function kE(i,t,e,r){let n=new Bb(i,t,e);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Hf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Bb(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qz(i,t,e,r){let n=0;for(let s=t,o=e-r;s<e;s+=r)n+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return n}var gu=class{static area(t){let e=t.length,r=0;for(let n=e-1,s=0;s<e;n=s++)r+=t[n].x*t[s].y-t[s].x*t[n].y;return r*.5}static isClockWise(t){return gu.area(t)<0}static triangulateShape(t,e){let r=[],n=[],s=[];VE(t),zE(r,t);let o=t.length;e.forEach(VE);for(let l=0;l<e.length;l++)n.push(o),o+=e[l].length,zE(r,e[l]);let a=Dz.triangulate(r,n);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function VE(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function zE(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var yu=class extends pu{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=[-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],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(n,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new yu(t.radius,t.detail)}};var Kl=class extends Ae{constructor(t=1,e=32,r=16,n=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new _,d=new _,f=[],p=[],m=[],g=[];for(let y=0;y<=r;y++){let v=[],x=y/r,w=0;y==0&&o==0?w=.5/e:y==r&&l==Math.PI&&(w=-.5/e);for(let S=0;S<=e;S++){let A=S/e;h.x=-t*Math.cos(n+A*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(n+A*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(A+w,1-x),v.push(u++)}c.push(v)}for(let y=0;y<r;y++)for(let v=0;v<e;v++){let x=c[y][v+1],w=c[y][v],S=c[y+1][v],A=c[y+1][v+1];(y!==0||o>0)&&f.push(x,w,A),(y!==r-1||l<Math.PI)&&f.push(w,S,A)}this.setIndex(f),this.setAttribute("position",new be(p,3)),this.setAttribute("normal",new be(m,3)),this.setAttribute("uv",new be(g,2))}static fromJSON(t){return new Kl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var vu=class extends Ae{constructor(t=1,e=.4,r=64,n=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o},r=Math.floor(r),n=Math.floor(n);let a=[],l=[],u=[],c=[],h=new _,d=new _,f=new _,p=new _,m=new _,g=new _,y=new _;for(let x=0;x<=r;++x){let w=x/r*s*Math.PI*2;v(w,s,o,t,f),v(w+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let S=0;S<=n;++S){let A=S/n*Math.PI*2,E=-e*Math.cos(A),b=e*Math.sin(A);h.x=f.x+(E*y.x+b*m.x),h.y=f.y+(E*y.y+b*m.y),h.z=f.z+(E*y.z+b*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(x/r),c.push(S/n)}}for(let x=1;x<=r;x++)for(let w=1;w<=n;w++){let S=(n+1)*(x-1)+(w-1),A=(n+1)*x+(w-1),E=(n+1)*x+w,b=(n+1)*(x-1)+w;a.push(S,A,b),a.push(A,E,b)}this.setIndex(a),this.setAttribute("position",new be(l,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(c,2));function v(x,w,S,A,E){let b=Math.cos(x),M=Math.sin(x),T=S/w*x,C=Math.cos(T);E.x=A*(2+C)*.5*b,E.y=A*(2+C)*M*.5,E.z=A*Math.sin(T)*.5}}static fromJSON(t){return new vu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Aa(i,t,e){return yM(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function ig(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function yM(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Yz(i){function t(n,s){return i[n]-i[s]}let e=i.length,r=new Array(e);for(let n=0;n!==e;++n)r[n]=n;return r.sort(t),r}function UE(i,t,e){let r=i.length,n=new i.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)n[o++]=i[a+l]}return n}function vM(i,t,e,r){let n=1,s=i[0];for(;s!==void 0&&s[r]===void 0;)s=i[n++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[n++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=i[n++];while(s!==void 0)}var xu=class{constructor(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,n=e[r],s=e[r-1];e:{t:{let o;r:{n:if(!(t<n)){for(let a=r+2;;){if(n===void 0){if(t<s)break n;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=n,n=e[++r],t<n)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(n=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(n=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,n)}return this.interpolate_(r,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=t*n;for(let o=0;o!==n;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Fb=class extends xu{constructor(t,e,r,n){super(t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:tu,endingEnd:tu}}intervalChanged_(t,e,r){let n=this.parameterPositions,s=t-2,o=t+1,a=n[s],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case ru:s=t,a=2*e-r;break;case hg:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case ru:o=t,l=2*r-e;break;case hg:o=1,l=r+n[1]-n[0];break;default:o=t-1,l=e}let u=(r-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-r),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(r-e)/(n-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,w=f*g-f*m;for(let S=0;S!==a;++S)s[S]=y*o[c+S]+v*o[u+S]+x*o[l+S]+w*o[h+S];return s}},Ag=class extends xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(r-e)/(n-e),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},kb=class extends xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t){return this.copySampleValue_(t-1)}},Wi=class{constructor(t,e,r,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ig(e,this.TimeBufferType),this.values=ig(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:ig(t.times,Array),values:ig(t.values,Array)};let n=t.getInterpolation();n!==t.DefaultInterpolation&&(r.interpolation=n)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new kb(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ag(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Fb(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case cg:e=this.InterpolantFactoryMethodDiscrete;break;case ug:e=this.InterpolantFactoryMethodLinear;break;case Bx:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return cg;case this.InterpolantFactoryMethodLinear:return ug;case this.InterpolantFactoryMethodSmooth:return Bx}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]*=t}return this}trim(t,e){let r=this.times,n=r.length,s=0,o=n-1;for(;s!==n&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Aa(r,s,o),this.values=Aa(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,n=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(n!==void 0&&yM(n))for(let a=0,l=n.length;a!==l;++a){let u=n[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Aa(this.times),e=Aa(this.values),r=this.getValueSize(),n=this.getInterpolation()===Bx,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(n)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let p=0;p!==r;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,u=0;u!==r;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Aa(t,0,o),this.values=Aa(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Aa(this.times,0),e=Aa(this.values,0),r=this.constructor,n=new r(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}};Wi.prototype.TimeBufferType=Float32Array;Wi.prototype.ValueBufferType=Float32Array;Wi.prototype.DefaultInterpolation=ug;var Ia=class extends Wi{};Ia.prototype.ValueTypeName="bool";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=cg;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;var _g=class extends Wi{};_g.prototype.ValueTypeName="color";var bu=class extends Wi{};bu.prototype.ValueTypeName="number";var Vb=class extends xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(n-e),u=t*a;for(let c=u+a;u!==c;u+=4)He.slerpFlat(s,0,o,u-a,o,u,l);return s}},Zl=class extends Wi{InterpolantFactoryMethodLinear(t){return new Vb(this.times,this.values,this.getValueSize(),t)}};Zl.prototype.ValueTypeName="quaternion";Zl.prototype.DefaultInterpolation=ug;Zl.prototype.InterpolantFactoryMethodSmooth=void 0;var Oa=class extends Wi{};Oa.prototype.ValueTypeName="string";Oa.prototype.ValueBufferType=Array;Oa.prototype.DefaultInterpolation=cg;Oa.prototype.InterpolantFactoryMethodLinear=void 0;Oa.prototype.InterpolantFactoryMethodSmooth=void 0;var wu=class extends Wi{};wu.prototype.ValueTypeName="vector";var Su=class{constructor(t,e=-1,r,n=Zb){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=Ui(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,n=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(Qz(r[o]).scale(n));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(Wi.toJSON(r[s]));return n}static CreateFromMorphTargetSequence(t,e,r,n){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],u=[];l.push((a+s-1)%s,a,(a+1)%s),u.push(0,1,0);let c=Yz(l);l=UE(l,1,c),u=UE(u,1,c),!n&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new bu(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let n=t;r=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<r.length;n++)if(r[n].name===e)return r[n];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let u=t[a],c=u.name.match(s);if(c&&c.length>1){let h=c[1],d=n[h];d||(n[h]=d=[]),d.push(u)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,p,m){if(f.length!==0){let g=[],y=[];vM(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},n=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let h=0;h<u.length;h++){let d=u[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}n.push(new bu(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(wu,f+".position",d,"pos",n),r(Zl,f+".quaternion",d,"rot",n),r(wu,f+".scale",d,"scl",n)}}return n.length===0?null:new this(s,l,n,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,n=t.length;r!==n;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function Xz(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return bu;case"vector":case"vector2":case"vector3":case"vector4":return wu;case"color":return _g;case"quaternion":return Zl;case"bool":case"boolean":return Ia;case"string":return Oa}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Qz(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Xz(i.type);if(i.times===void 0){let e=[],r=[];vM(i.keys,e,r,"value"),i.times=e,i.values=r}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var GE={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},jf=class{constructor(t,e,r){let n=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(c){a++,s===!1&&n.onStart!==void 0&&n.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,n.onProgress!==void 0&&n.onProgress(c,o,a),o===a&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(c){n.onError!==void 0&&n.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],p=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}},Kz=new jf,Au=class{constructor(t){this.manager=t!==void 0?t:Kz,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(n,s){r.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},ko={},zb=class extends Error{constructor(t,e){super(t),this.response=e}},_u=class extends Au{constructor(t){super(t)}load(t,e,r,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=GE.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(ko[t]!==void 0){ko[t].push({onLoad:e,onProgress:r,onError:n});return}ko[t]=[],ko[t].push({onLoad:e,onProgress:r,onError:n});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=ko[t],h=u.body.getReader(),d=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:w})=>{if(x)y.close();else{m+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,E=c.length;A<E;A++){let b=c[A];b.onProgress&&b.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw new zb(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{GE.add(t,u);let c=ko[t];delete ko[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=ko[t];if(c===void 0)throw this.manager.itemError(t),u;delete ko[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Ra=class extends gt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Eg=class extends Ra{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Re(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},hb=new ie,HE=new _,jE=new _,Wf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new N(512,512),this.map=null,this.mapPass=null,this.matrix=new ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Bf,this._frameExtents=new N(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;HE.setFromMatrixPosition(t.matrixWorld),e.position.copy(HE),jE.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(jE),e.updateMatrixWorld(),hb.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hb),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(hb)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},Ub=class extends Wf{constructor(){super(new Ir(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Lf*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Mg=class extends Ra{constructor(t,e,r=0,n=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=r,this.angle=n,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Ub}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},WE=new ie,Ef=new _,db=new _,Gb=class extends Wf{constructor(){super(new Ir(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new N(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new _(1,0,0),new _(-1,0,0),new _(0,0,1),new _(0,0,-1),new _(0,1,0),new _(0,-1,0)],this._cubeUps=[new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,0,1),new _(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,n=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Ef.setFromMatrixPosition(t.matrixWorld),r.position.copy(Ef),db.copy(r.position),db.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(db),r.updateMatrixWorld(),n.makeTranslation(-Ef.x,-Ef.y,-Ef.z),WE.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(WE)}},Tg=class extends Ra{constructor(t,e,r=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=n,this.shadow=new Gb}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},Hb=class extends Wf{constructor(){super(new lu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Cg=class extends Ra{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new Hb}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var qf=class extends Ae{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Eu=class extends Au{constructor(t){super(t)}load(t,e,r,n){let s=this,o=new _u(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),s.manager.itemError(t)}},r,n)}parse(t){let e={},r={};function n(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=Nm(g.type,y),x=new wg(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return r[p]=y,y}let o=t.isInstancedBufferGeometry?new qf:new Ae,a=t.data.index;if(a!==void 0){let f=Nm(a.type,a.array);o.setIndex(new Ge(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=n(t.data,p.data);m=new Hl(g,p.itemSize,p.offset,p.normalized)}else{let g=Nm(p.type,p.array),y=p.isInstancedBufferAttribute?uu:Ge;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let u=t.data.morphAttributes;if(u)for(let f in u){let p=u[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let w=n(t.data,v.data);x=new Hl(w,v.itemSize,v.offset,v.normalized)}else{let w=Nm(v.type,v.array);x=new Ge(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new _;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new fr(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Pg=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=qE(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=qE();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function qE(){return(typeof performance>"u"?Date:performance).now()}var jb=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let n,s,o;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:n=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,n=this.valueSize,s=t*n+n,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,n=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,n=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,n,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(r[l]!==r[l+e]){a.setValue(r,n);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let s=r,o=n;s!==o;++s)e[s]=e[n+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,n,s){if(n>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,n){He.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,s){let o=this._workIndex*s;He.multiplyQuaternionsFlat(t,o,t,e,t,r),He.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,r,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*n}}_lerpAdditive(t,e,r,n,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*n}}},nw="\\[\\]\\.:\\/",Zz=new RegExp("["+nw+"]","g"),iw="[^"+nw+"]",Jz="[^"+nw.replace("\\.","")+"]",$z=/((?:WC+[\/:])*)/.source.replace("WC",iw),eU=/(WCOD+)?/.source.replace("WCOD",Jz),tU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",iw),rU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",iw),nU=new RegExp("^"+$z+eU+tU+rU+"$"),iU=["material","materials","bones","map"],Wb=class{constructor(t,e,r){let n=r||Ft.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,n=this._bindings[r];n!==void 0&&n.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=r.length;n!==s;++n)r[n].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},Ft=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Ft.parseTrackName(e),this.node=Ft.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new Ft.Composite(t,e,r):new Ft(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Zz,"")}static parseTrackName(t){let e=nU.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=r.nodeName.substring(n+1);iU.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},n=r(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)t[e++]=r[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,n=e.propertyName,s=e.propertyIndex;if(t||(t=Ft.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(r){let u=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[n];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+n+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ft.Composite=Wb;Ft.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ft.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ft.prototype.GetterByBindingType=[Ft.prototype._getValue_direct,Ft.prototype._getValue_array,Ft.prototype._getValue_arrayElement,Ft.prototype._getValue_toArray];Ft.prototype.SetterByBindingTypeAndVersioning=[[Ft.prototype._setValue_direct,Ft.prototype._setValue_direct_setNeedsUpdate,Ft.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_array,Ft.prototype._setValue_array_setNeedsUpdate,Ft.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_arrayElement,Ft.prototype._setValue_arrayElement_setNeedsUpdate,Ft.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_fromArray,Ft.prototype._setValue_fromArray_setNeedsUpdate,Ft.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var qb=class{constructor(t,e,r=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=n;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:tu,endingEnd:tu};for(let u=0;u!==o;++u){let c=s[u].createInterpolant(null);a[u]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Kb,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let n=this._clip.duration,s=t._clip.duration,o=s/n,a=n/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let n=this._mixer,s=n.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+r,u[0]=t/o,u[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,n){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case xN:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case Zb:default:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulate(n,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,n=this.time+t,s=this._loopCount,o=r===Xf;if(t===0)return s===-1?n:o&&(s&1)===1?e-n:n;if(r===Qb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=e||n<0){let a=Math.floor(n/e);n-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return e-n}return n}_setEndings(t,e,r){let n=this._interpolantSettings;r?(n.endingStart=ru,n.endingEnd=ru):(t?n.endingStart=this.zeroSlopeAtStart?ru:tu:n.endingStart=hg,e?n.endingEnd=this.zeroSlopeAtEnd?ru:tu:n.endingEnd=hg)}_scheduleFading(t,e,r){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},sU=new Float32Array(1),Dg=class extends Yt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,n=t._clip.tracks,s=n.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let h=0;h!==s;++h){let d=n[h],f=d.name,p=c[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new jb(Ft.create(r,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,r)}let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let n=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=n.length,n.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],n=t._cacheIndex;r._cacheIndex=n,e[n]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,u=l[l.length-1],c=t._byClipCacheIndex;u._byClipCacheIndex=c,l[c]=u,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let n=this._bindingsByRootAndName,s=this._bindings,o=n[e];o===void 0&&(o={},n[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,n=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[n],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[n]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new Ag(new Float32Array(2),new Float32Array(2),1,sU),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let n=e||this._root,s=n.uuid,o=typeof t=="string"?Su.findByName(n,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(r===void 0&&(o!==null?r=o.blendMode:r=Zb),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new qb(this,o,e,r);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let r=e||this._root,n=r.uuid,s=typeof t=="string"?Su.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,n=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==r;++u)e[u]._update(n,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,n=this._actionsByClip,s=n[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let u=o[a];this._deactivateAction(u);let c=u._cacheIndex,h=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,h._cacheIndex=c,e[c]=h,e.pop(),this._removeInactiveBindingsForAction(u)}delete n[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},oe=class{constructor(t){this.value=t}clone(){return new oe(this.value.clone===void 0?this.value:this.value.clone())}};var Mu=class{constructor(t,e,r=0,n=1/0){this.ray=new gs(t,e),this.near=r,this.far=n,this.camera=null,this.layers=new Nf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,r=[]){return Yb(t,this,r,e),r.sort(YE),r}intersectObjects(t,e=!0,r=[]){for(let n=0,s=t.length;n<s;n++)Yb(t[n],this,r,e);return r.sort(YE),r}};function YE(i,t){return i.distance-t.distance}function Yb(i,t,e,r){if(i.layers.test(t.layers)&&i.raycast(t,e),r===!0){let n=i.children;for(let s=0,o=n.length;s<o;s++)Yb(n[s],t,e,!0)}}var Yf=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(Yr(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var XE=new N,Tu=class{constructor(t=new N(1/0,1/0),e=new N(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=XE.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return XE.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},QE=new _,sg=new _,nn=class{constructor(t=new _,e=new _){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){QE.subVectors(t,this.start),sg.subVectors(this.end,this.start);let r=sg.dot(sg),s=sg.dot(QE)/r;return e&&(s=Yr(s,0,1)),s}closestPointToPoint(t,e,r){let n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},KE=new _,Ig=class extends gt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ae,n=[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 o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;n.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}r.setAttribute("position",new be(n,3));let s=new Hi({fog:!1,toneMapped:!1});this.cone=new Da(r,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 t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),KE.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(KE),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Og=class extends _r{constructor(t,e,r){let n=new Kl(e,4,2),s=new Ho({wireframe:!0,fog:!1,toneMapped:!1});super(n,s),this.light=t,this.color=r,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)}};var ZE=new _,og=new _,JE=new _,Rg=class extends gt{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let n=new Ae;n.setAttribute("position",new be([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Hi({fog:!1,toneMapped:!1});this.lightPlane=new jl(n,s),this.add(this.lightPlane),n=new Ae,n.setAttribute("position",new be([0,0,0,0,0,1],3)),this.targetLine=new jl(n,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),ZE.setFromMatrixPosition(this.light.matrixWorld),og.setFromMatrixPosition(this.light.target.matrixWorld),JE.subVectors(og,ZE),this.lightPlane.lookAt(og),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(og),this.targetLine.scale.z=JE.length()}},ag=new _,Ar=new ys,La=class extends Da{constructor(t){let e=new Ae,r=new Hi({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,m){l(p),l(m)}function l(p){n.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(n.length/3-1)}e.setAttribute("position",new be(n,3)),e.setAttribute("color",new be(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Re(16755200),c=new Re(16711680),h=new Re(43775),d=new Re(16777215),f=new Re(3355443);this.setColors(u,c,h,d,f)}setColors(t,e,r,n,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.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 t=this.geometry,e=this.pointMap,r=1,n=1;Ar.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Dr("c",e,t,Ar,0,0,-1),Dr("t",e,t,Ar,0,0,1),Dr("n1",e,t,Ar,-r,-n,-1),Dr("n2",e,t,Ar,r,-n,-1),Dr("n3",e,t,Ar,-r,n,-1),Dr("n4",e,t,Ar,r,n,-1),Dr("f1",e,t,Ar,-r,-n,1),Dr("f2",e,t,Ar,r,-n,1),Dr("f3",e,t,Ar,-r,n,1),Dr("f4",e,t,Ar,r,n,1),Dr("u1",e,t,Ar,r*.7,n*1.1,-1),Dr("u2",e,t,Ar,-r*.7,n*1.1,-1),Dr("u3",e,t,Ar,0,n*2,-1),Dr("cf1",e,t,Ar,-r,0,1),Dr("cf2",e,t,Ar,r,0,1),Dr("cf3",e,t,Ar,0,-n,1),Dr("cf4",e,t,Ar,0,n,1),Dr("cn1",e,t,Ar,-r,0,-1),Dr("cn2",e,t,Ar,r,0,-1),Dr("cn3",e,t,Ar,0,-n,-1),Dr("cn4",e,t,Ar,0,n,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Dr(i,t,e,r,n,s,o){ag.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],ag.x,ag.y,ag.z)}}var Na=class extends Da{constructor(t,e=16776960){let r=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]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ae;s.setIndex(new Ge(r,1)),s.setAttribute("position",new be(n,3)),super(s,new Hi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var Lg=class extends Da{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new Ae;n.setAttribute("position",new be(e,3)),n.setAttribute("color",new be(r,3));let s=new Hi({vertexColors:!0,toneMapped:!1});super(n,s),this.type="AxesHelper"}setColors(t,e,r){let n=new Re,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(r),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var Vo=oU();function oU(){let i=new ArrayBuffer(4),t=new Float32Array(i),e=new Uint32Array(i),r=new Uint32Array(512),n=new Uint32Array(512);for(let l=0;l<256;++l){let u=l-127;u<-27?(r[l]=0,r[l|256]=32768,n[l]=24,n[l|256]=24):u<-14?(r[l]=1024>>-u-14,r[l|256]=1024>>-u-14|32768,n[l]=-u-1,n[l|256]=-u-1):u<=15?(r[l]=u+15<<10,r[l|256]=u+15<<10|32768,n[l]=13,n[l|256]=13):u<128?(r[l]=31744,r[l|256]=64512,n[l]=24,n[l|256]=24):(r[l]=31744,r[l|256]=64512,n[l]=13,n[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:r,shiftTable:n,mantissaTable:s,exponentTable:o,offsetTable:a}}function aU(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=Yr(i,-65504,65504),Vo.floatView[0]=i;let t=Vo.uint32View[0],e=t>>23&511;return Vo.baseTable[e]+((t&8388607)>>Vo.shiftTable[e])}function lU(i){let t=i>>10;return Vo.uint32View[0]=Vo.mantissaTable[Vo.offsetTable[t]+(i&1023)]+Vo.exponentTable[t],Vo.floatView[0]}var xM=Object.freeze({__proto__:null,fromHalfFloat:lU,toHalfFloat:aU});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qo);var Iu=".",Qf=Symbol("target"),sw=Symbol("unsubscribe");function Kf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function bM(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Ri=Array.isArray;function Jl(i){return typeof i=="symbol"}var cU={after:(i,t)=>Ri(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>Ri(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=Iu),Jl(t)?i+t.toString():i+t):i,initial:i=>{if(Ri(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(Iu);return t===-1?"":i.slice(0,t)},last:i=>{if(Ri(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(Iu);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(Ri(i))for(let e of i)t(e);else if(i!==""){let e=0,r=i.indexOf(Iu);if(r===-1)t(i);else for(;e<i.length;)r===-1&&(r=i.length),t(i.slice(e,r)),e=r+1,r=i.indexOf(Iu,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},ei=cU;function ow(i){return typeof i=="object"&&typeof i.next=="function"}function aw(i,t,e,r,n){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],t,o.value[0],r),o.value[1]=n(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[Qf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,t,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,t,o.value,r)),o};return i}function kg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Jl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Zf=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),n=r[e];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(t,e),r[e]=n),n}getProxy(t,e,r,n){if(this.isUnsubscribed)return t;let s=t[n],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,ei.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,n,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,n):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(t);n&&(delete n[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let n=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&n!==void 0&&Object.is(t.value,n.value)&&(t.writable||!1)===(n.writable||!1)&&(t.enumerable||!1)===(n.enumerable||!1)&&(t.configurable||!1)===(n.configurable||!1)&&t.get===n.get&&t.set===n.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Ou(i){return toString.call(i)==="[object Object]"}function Ru(){return!0}function Ba(i,t){return i.length!==t.length||i.some((e,r)=>t[r]!==e)}var Vg=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var uU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),lw={push:Ru,pop:Ru,shift:Ru,unshift:Ru,copyWithin:Ba,reverse:Ba,sort:Ba,splice:Ba,flat:Ba,fill:Ba},wM=new Set([...Vg,...uU,...Object.keys(lw)]);function Lu(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var cw=["keys","values","entries"],uw=new Set(["has","toString"]),hw={add:Lu,clear:Lu,delete:Lu,forEach:Lu},SM=new Set([...uw,...Object.keys(hw),...cw]);function Nu(i,t){if(i.size!==t.size)return!0;let e;for(let[r,n]of i)if(e=t.get(r),e!==n||e===void 0&&!t.has(r))return!0;return!1}var hU=new Set([...uw,"get"]),dw={set:Nu,clear:Nu,delete:Nu,forEach:Nu},AM=new Set([...hU,...Object.keys(dw),...cw]);var xn=class{constructor(t,e,r,n){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Vg.has(t)}_shallowClone(t){let e=t;if(Ou(t))e={...t};else if(Ri(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,n]of t.entries())e.set(r,this._shallowClone(n))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,n){return t?(Ri(n)?this._onIsChanged=lw[e]:n instanceof Set?this._onIsChanged=hw[e]:n instanceof Map&&(this._onIsChanged=dw[e]),n):r}update(t,e,r){let n=ei.after(t,this._path);if(e!=="length"){let s=this.clone;ei.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],ei.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Bu=class extends xn{static isHandledMethod(t){return wM.has(t)}};var Jf=class extends xn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Fu=class extends xn{static isHandledMethod(t){return SM.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var ku=class extends xn{static isHandledMethod(t){return AM.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var $f=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var ep=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var xs=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Ou(t)||Ri(t)||Kf(t)}static isHandledMethod(t,e){return Ou(t)?xn.isHandledMethod(e):Ri(t)?Bu.isHandledMethod(e):t instanceof Set?Fu.isHandledMethod(e):t instanceof Map?ku.isHandledMethod(e):Kf(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let n=xn;Ri(t)?n=Bu:t instanceof Date?n=Jf:t instanceof Set?n=Fu:t instanceof Map?n=ku:t instanceof WeakSet?n=$f:t instanceof WeakMap&&(n=ep),this._stack.push(new n(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:n}=t,s=xs.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var dU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},fw=(i,t,e={})=>{e={...dU,...e};let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=e,l=new Zf(n),u=typeof e.onValidate=="function",c=new xs(u),h=(v,x,w,S,A)=>!u||c.isCloning||e.onValidate(ei.concat(l.getPath(v),x),w,S,A)===!0,d=(v,x,w,S)=>{!kg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,A)=>{c.isCloning?c.update(v,x,S):t(ei.concat(v,x),w,S,A)},p=v=>v&&(v[r]||v),m=(v,x,w,S)=>bM(v)||w==="constructor"||s&&!xs.isHandledMethod(x,w)||kg(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,ei.concat(S,w),g,r)),g={get(v,x,w){if(Jl(x)){if(x===r||x===Qf)return v;if(x===sw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Kf(v)?Reflect.get(v,x):Reflect.get(v,x,w);return m(S,v,x)},set(v,x,w,S){w=p(w);let A=v[r]||v,E=A[x];if(n(E,w)&&x in v)return!0;let b=h(v,x,w,E);return b&&l.setProperty(A,x,w,S,E)?(d(v,x,v[x],E),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];h(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&d(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=h(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(d(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&xs.isHandledType(S)){let A=ei.initial(l.getPath(v)),E=xs.isHandledMethod(S,v.name);c.start(S,A,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),E?w.map(C=>p(C)):w),M=c.isChanged(S,n),T=c.stop();if(xs.isHandledType(b)&&E&&(x instanceof Map&&v.name==="get"&&(A=ei.concat(A,w[0])),b=l.getProxy(b,A,g)),M){let C={name:v.name,args:w,result:b},P=c.isCloning?ei.initial(A):A,D=c.isCloning?ei.last(A):"";h(ei.get(i,P),D,S,T,C)?f(P,D,S,T,C):c.undo(S)}return(x instanceof Map||x instanceof Set)&&ow(b)?aw(b,v,x,A,m):b}return Reflect.apply(v,x,w)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};fw.target=i=>i&&i[Qf]||i;fw.unsubscribe=i=>i[sw]||i;var pw=fw;var fU=typeof global=="object"&&global&&global.Object===Object&&global,zg=fU;var pU=typeof self=="object"&&self&&self.Object===Object&&self,mU=zg||pU||Function("return this")(),Er=mU;var gU=Er.Symbol,bn=gU;var _M=Object.prototype,yU=_M.hasOwnProperty,vU=_M.toString,tp=bn?bn.toStringTag:void 0;function xU(i){var t=yU.call(i,tp),e=i[tp];try{i[tp]=void 0;var r=!0}catch{}var n=vU.call(i);return r&&(t?i[tp]=e:delete i[tp]),n}var EM=xU;var bU=Object.prototype,wU=bU.toString;function SU(i){return wU.call(i)}var MM=SU;var AU="[object Null]",_U="[object Undefined]",TM=bn?bn.toStringTag:void 0;function EU(i){return i==null?i===void 0?_U:AU:TM&&TM in Object(i)?EM(i):MM(i)}var Li=EU;function MU(i){return i!=null&&typeof i=="object"}var Bn=MU;var TU="[object Symbol]";function CU(i){return typeof i=="symbol"||Bn(i)&&Li(i)==TU}var Fa=CU;function PU(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var Ug=PU;var DU=Array.isArray,sn=DU;var IU=1/0,CM=bn?bn.prototype:void 0,PM=CM?CM.toString:void 0;function DM(i){if(typeof i=="string")return i;if(sn(i))return Ug(i,DM)+"";if(Fa(i))return PM?PM.call(i):"";var t=i+"";return t=="0"&&1/i==-IU?"-0":t}var IM=DM;var OU=/\s/;function RU(i){for(var t=i.length;t--&&OU.test(i.charAt(t)););return t}var OM=RU;var LU=/^\s+/;function NU(i){return i&&i.slice(0,OM(i)+1).replace(LU,"")}var RM=NU;function BU(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Kr=BU;var LM=0/0,FU=/^[-+]0x[0-9a-f]+$/i,kU=/^0b[01]+$/i,VU=/^0o[0-7]+$/i,zU=parseInt;function UU(i){if(typeof i=="number")return i;if(Fa(i))return LM;if(Kr(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Kr(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=RM(i);var e=kU.test(i);return e||VU.test(i)?zU(i.slice(2),e?2:8):FU.test(i)?LM:+i}var mw=UU;function GU(i){return i}var NM=GU;var HU="[object AsyncFunction]",jU="[object Function]",WU="[object GeneratorFunction]",qU="[object Proxy]";function YU(i){if(!Kr(i))return!1;var t=Li(i);return t==jU||t==WU||t==HU||t==qU}var Gg=YU;var XU=Er["__core-js_shared__"],Hg=XU;var BM=function(){var i=/[^.]+$/.exec(Hg&&Hg.keys&&Hg.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function QU(i){return!!BM&&BM in i}var FM=QU;var KU=Function.prototype,ZU=KU.toString;function JU(i){if(i!=null){try{return ZU.call(i)}catch{}try{return i+""}catch{}}return""}var Yo=JU;var $U=/[\\^$.*+?()[\]{}|]/g,eG=/^\[object .+?Constructor\]$/,tG=Function.prototype,rG=Object.prototype,nG=tG.toString,iG=rG.hasOwnProperty,sG=RegExp("^"+nG.call(iG).replace($U,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function oG(i){if(!Kr(i)||FM(i))return!1;var t=Gg(i)?sG:eG;return t.test(Yo(i))}var kM=oG;function aG(i,t){return i?.[t]}var VM=aG;function lG(i,t){var e=VM(i,t);return kM(e)?e:void 0}var ci=lG;var cG=ci(Er,"WeakMap"),jg=cG;var zM=Object.create,uG=function(){function i(){}return function(t){if(!Kr(t))return{};if(zM)return zM(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),UM=uG;function hG(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var GM=hG;function dG(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var HM=dG;var fG=800,pG=16,mG=Date.now;function gG(i){var t=0,e=0;return function(){var r=mG(),n=pG-(r-e);if(e=r,n>0){if(++t>=fG)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var jM=gG;function yG(i){return function(){return i}}var WM=yG;var vG=function(){try{var i=ci(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Vu=vG;var xG=Vu?function(i,t){return Vu(i,"toString",{configurable:!0,enumerable:!1,value:WM(t),writable:!0})}:NM,qM=xG;var bG=jM(qM),YM=bG;function wG(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var XM=wG;var SG=9007199254740991,AG=/^(?:0|[1-9]\d*)$/;function _G(i,t){var e=typeof i;return t=t??SG,!!t&&(e=="number"||e!="symbol"&&AG.test(i))&&i>-1&&i%1==0&&i<t}var zu=_G;function EG(i,t,e){t=="__proto__"&&Vu?Vu(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Wg=EG;function MG(i,t){return i===t||i!==i&&t!==t}var Uu=MG;var TG=Object.prototype,CG=TG.hasOwnProperty;function PG(i,t,e){var r=i[t];(!(CG.call(i,t)&&Uu(r,e))||e===void 0&&!(t in i))&&Wg(i,t,e)}var Gu=PG;function DG(i,t,e,r){var n=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),n?Wg(e,a,l):Gu(e,a,l)}return e}var qs=DG;var QM=Math.max;function IG(i,t,e){return t=QM(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,s=QM(r.length-t,0),o=Array(s);++n<s;)o[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=e(o),GM(i,this,a)}}var KM=IG;var OG=9007199254740991;function RG(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=OG}var Hu=RG;function LG(i){return i!=null&&Hu(i.length)&&!Gg(i)}var qg=LG;var NG=Object.prototype;function BG(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||NG;return i===e}var ju=BG;function FG(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var ZM=FG;var kG="[object Arguments]";function VG(i){return Bn(i)&&Li(i)==kG}var gw=VG;var JM=Object.prototype,zG=JM.hasOwnProperty,UG=JM.propertyIsEnumerable,GG=gw(function(){return arguments}())?gw:function(i){return Bn(i)&&zG.call(i,"callee")&&!UG.call(i,"callee")},Wu=GG;function HG(){return!1}var $M=HG;var rT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,eT=rT&&typeof module=="object"&&module&&!module.nodeType&&module,jG=eT&&eT.exports===rT,tT=jG?Er.Buffer:void 0,WG=tT?tT.isBuffer:void 0,qG=WG||$M,$l=qG;var YG="[object Arguments]",XG="[object Array]",QG="[object Boolean]",KG="[object Date]",ZG="[object Error]",JG="[object Function]",$G="[object Map]",e4="[object Number]",t4="[object Object]",r4="[object RegExp]",n4="[object Set]",i4="[object String]",s4="[object WeakMap]",o4="[object ArrayBuffer]",a4="[object DataView]",l4="[object Float32Array]",c4="[object Float64Array]",u4="[object Int8Array]",h4="[object Int16Array]",d4="[object Int32Array]",f4="[object Uint8Array]",p4="[object Uint8ClampedArray]",m4="[object Uint16Array]",g4="[object Uint32Array]",cr={};cr[l4]=cr[c4]=cr[u4]=cr[h4]=cr[d4]=cr[f4]=cr[p4]=cr[m4]=cr[g4]=!0;cr[YG]=cr[XG]=cr[o4]=cr[QG]=cr[a4]=cr[KG]=cr[ZG]=cr[JG]=cr[$G]=cr[e4]=cr[t4]=cr[r4]=cr[n4]=cr[i4]=cr[s4]=!1;function y4(i){return Bn(i)&&Hu(i.length)&&!!cr[Li(i)]}var nT=y4;function v4(i){return function(t){return i(t)}}var qu=v4;var iT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rp=iT&&typeof module=="object"&&module&&!module.nodeType&&module,x4=rp&&rp.exports===iT,yw=x4&&zg.process,b4=function(){try{var i=rp&&rp.require&&rp.require("util").types;return i||yw&&yw.binding&&yw.binding("util")}catch{}}(),Xo=b4;var sT=Xo&&Xo.isTypedArray,w4=sT?qu(sT):nT,Yg=w4;var S4=Object.prototype,A4=S4.hasOwnProperty;function _4(i,t){var e=sn(i),r=!e&&Wu(i),n=!e&&!r&&$l(i),s=!e&&!r&&!n&&Yg(i),o=e||r||n||s,a=o?ZM(i.length,String):[],l=a.length;for(var u in i)(t||A4.call(i,u))&&!(o&&(u=="length"||n&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||zu(u,l)))&&a.push(u);return a}var Xg=_4;function E4(i,t){return function(e){return i(t(e))}}var Qg=E4;var M4=Qg(Object.keys,Object),oT=M4;var T4=Object.prototype,C4=T4.hasOwnProperty;function P4(i){if(!ju(i))return oT(i);var t=[];for(var e in Object(i))C4.call(i,e)&&e!="constructor"&&t.push(e);return t}var aT=P4;function D4(i){return qg(i)?Xg(i):aT(i)}var Yu=D4;function I4(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var lT=I4;var O4=Object.prototype,R4=O4.hasOwnProperty;function L4(i){if(!Kr(i))return lT(i);var t=ju(i),e=[];for(var r in i)r=="constructor"&&(t||!R4.call(i,r))||e.push(r);return e}var cT=L4;function N4(i){return qg(i)?Xg(i,!0):cT(i)}var qi=N4;var B4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,F4=/^\w*$/;function k4(i,t){if(sn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Fa(i)?!0:F4.test(i)||!B4.test(i)||t!=null&&i in Object(t)}var uT=k4;var V4=ci(Object,"create"),Qo=V4;function z4(){this.__data__=Qo?Qo(null):{},this.size=0}var hT=z4;function U4(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var dT=U4;var G4="__lodash_hash_undefined__",H4=Object.prototype,j4=H4.hasOwnProperty;function W4(i){var t=this.__data__;if(Qo){var e=t[i];return e===G4?void 0:e}return j4.call(t,i)?t[i]:void 0}var fT=W4;var q4=Object.prototype,Y4=q4.hasOwnProperty;function X4(i){var t=this.__data__;return Qo?t[i]!==void 0:Y4.call(t,i)}var pT=X4;var Q4="__lodash_hash_undefined__";function K4(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Qo&&t===void 0?Q4:t,this}var mT=K4;function Xu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Xu.prototype.clear=hT;Xu.prototype.delete=dT;Xu.prototype.get=fT;Xu.prototype.has=pT;Xu.prototype.set=mT;var vw=Xu;function Z4(){this.__data__=[],this.size=0}var gT=Z4;function J4(i,t){for(var e=i.length;e--;)if(Uu(i[e][0],t))return e;return-1}var ka=J4;var $4=Array.prototype,eH=$4.splice;function tH(i){var t=this.__data__,e=ka(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():eH.call(t,e,1),--this.size,!0}var yT=tH;function rH(i){var t=this.__data__,e=ka(t,i);return e<0?void 0:t[e][1]}var vT=rH;function nH(i){return ka(this.__data__,i)>-1}var xT=nH;function iH(i,t){var e=this.__data__,r=ka(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var bT=iH;function Qu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Qu.prototype.clear=gT;Qu.prototype.delete=yT;Qu.prototype.get=vT;Qu.prototype.has=xT;Qu.prototype.set=bT;var Va=Qu;var sH=ci(Er,"Map"),za=sH;function oH(){this.size=0,this.__data__={hash:new vw,map:new(za||Va),string:new vw}}var wT=oH;function aH(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var ST=aH;function lH(i,t){var e=i.__data__;return ST(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ua=lH;function cH(i){var t=Ua(this,i).delete(i);return this.size-=t?1:0,t}var AT=cH;function uH(i){return Ua(this,i).get(i)}var _T=uH;function hH(i){return Ua(this,i).has(i)}var ET=hH;function dH(i,t){var e=Ua(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var MT=dH;function Ku(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Ku.prototype.clear=wT;Ku.prototype.delete=AT;Ku.prototype.get=_T;Ku.prototype.has=ET;Ku.prototype.set=MT;var ec=Ku;var fH="Expected a function";function xw(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(fH);var e=function(){var r=arguments,n=t?t.apply(this,r):r[0],s=e.cache;if(s.has(n))return s.get(n);var o=i.apply(this,r);return e.cache=s.set(n,o)||s,o};return e.cache=new(xw.Cache||ec),e}xw.Cache=ec;var TT=xw;var pH=500;function mH(i){var t=TT(i,function(r){return e.size===pH&&e.clear(),r}),e=t.cache;return t}var CT=mH;var gH=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,yH=/\\(\\)?/g,vH=CT(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(gH,function(e,r,n,s){t.push(n?s.replace(yH,"$1"):r||e)}),t}),PT=vH;function xH(i){return i==null?"":IM(i)}var DT=xH;function bH(i,t){return sn(i)?i:uT(i,t)?[i]:PT(DT(i))}var Yi=bH;var wH=1/0;function SH(i){if(typeof i=="string"||Fa(i))return i;var t=i+"";return t=="0"&&1/i==-wH?"-0":t}var Ga=SH;function AH(i,t){t=Yi(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Ga(t[e++])];return e&&e==r?i:void 0}var Kg=AH;function _H(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var Zu=_H;var IT=bn?bn.isConcatSpreadable:void 0;function EH(i){return sn(i)||Wu(i)||!!(IT&&i&&i[IT])}var OT=EH;function RT(i,t,e,r,n){var s=-1,o=i.length;for(e||(e=OT),n||(n=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?RT(a,t-1,e,r,n):Zu(n,a):r||(n[n.length]=a)}return n}var LT=RT;function MH(i){var t=i==null?0:i.length;return t?LT(i,1):[]}var NT=MH;function TH(i){return YM(KM(i,void 0,NT),i+"")}var Zg=TH;var CH=Qg(Object.getPrototypeOf,Object),Ju=CH;var PH="[object Object]",DH=Function.prototype,IH=Object.prototype,BT=DH.toString,OH=IH.hasOwnProperty,RH=BT.call(Object);function LH(i){if(!Bn(i)||Li(i)!=PH)return!1;var t=Ju(i);if(t===null)return!0;var e=OH.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&BT.call(e)==RH}var FT=LH;function NH(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+t];return s}var kT=NH;function BH(){this.__data__=new Va,this.size=0}var VT=BH;function FH(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var zT=FH;function kH(i){return this.__data__.get(i)}var UT=kH;function VH(i){return this.__data__.has(i)}var GT=VH;var zH=200;function UH(i,t){var e=this.__data__;if(e instanceof Va){var r=e.__data__;if(!za||r.length<zH-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new ec(r)}return e.set(i,t),this.size=e.size,this}var HT=UH;function $u(i){var t=this.__data__=new Va(i);this.size=t.size}$u.prototype.clear=VT;$u.prototype.delete=zT;$u.prototype.get=UT;$u.prototype.has=GT;$u.prototype.set=HT;var eh=$u;function GH(i,t){return i&&qs(t,Yu(t),i)}var jT=GH;function HH(i,t){return i&&qs(t,qi(t),i)}var WT=HH;var QT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qT=QT&&typeof module=="object"&&module&&!module.nodeType&&module,jH=qT&&qT.exports===QT,YT=jH?Er.Buffer:void 0,XT=YT?YT.allocUnsafe:void 0;function WH(i,t){if(t)return i.slice();var e=i.length,r=XT?XT(e):new i.constructor(e);return i.copy(r),r}var KT=WH;function qH(i,t){for(var e=-1,r=i==null?0:i.length,n=0,s=[];++e<r;){var o=i[e];t(o,e,i)&&(s[n++]=o)}return s}var ZT=qH;function YH(){return[]}var Jg=YH;var XH=Object.prototype,QH=XH.propertyIsEnumerable,JT=Object.getOwnPropertySymbols,KH=JT?function(i){return i==null?[]:(i=Object(i),ZT(JT(i),function(t){return QH.call(i,t)}))}:Jg,th=KH;function ZH(i,t){return qs(i,th(i),t)}var $T=ZH;var JH=Object.getOwnPropertySymbols,$H=JH?function(i){for(var t=[];i;)Zu(t,th(i)),i=Ju(i);return t}:Jg,$g=$H;function e5(i,t){return qs(i,$g(i),t)}var eC=e5;function t5(i,t,e){var r=t(i);return sn(i)?r:Zu(r,e(i))}var ey=t5;function r5(i){return ey(i,Yu,th)}var np=r5;function n5(i){return ey(i,qi,$g)}var ty=n5;var i5=ci(Er,"DataView"),ry=i5;var s5=ci(Er,"Promise"),ny=s5;var o5=ci(Er,"Set"),iy=o5;var tC="[object Map]",a5="[object Object]",rC="[object Promise]",nC="[object Set]",iC="[object WeakMap]",sC="[object DataView]",l5=Yo(ry),c5=Yo(za),u5=Yo(ny),h5=Yo(iy),d5=Yo(jg),tc=Li;(ry&&tc(new ry(new ArrayBuffer(1)))!=sC||za&&tc(new za)!=tC||ny&&tc(ny.resolve())!=rC||iy&&tc(new iy)!=nC||jg&&tc(new jg)!=iC)&&(tc=function(i){var t=Li(i),e=t==a5?i.constructor:void 0,r=e?Yo(e):"";if(r)switch(r){case l5:return sC;case c5:return tC;case u5:return rC;case h5:return nC;case d5:return iC}return t});var Ko=tc;var f5=Object.prototype,p5=f5.hasOwnProperty;function m5(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&p5.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var oC=m5;var g5=Er.Uint8Array,rh=g5;function y5(i){var t=new i.constructor(i.byteLength);return new rh(t).set(new rh(i)),t}var nh=y5;function v5(i,t){var e=t?nh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var aC=v5;var x5=/\w*$/;function b5(i){var t=new i.constructor(i.source,x5.exec(i));return t.lastIndex=i.lastIndex,t}var lC=b5;var cC=bn?bn.prototype:void 0,uC=cC?cC.valueOf:void 0;function w5(i){return uC?Object(uC.call(i)):{}}var hC=w5;function S5(i,t){var e=t?nh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var dC=S5;var A5="[object Boolean]",_5="[object Date]",E5="[object Map]",M5="[object Number]",T5="[object RegExp]",C5="[object Set]",P5="[object String]",D5="[object Symbol]",I5="[object ArrayBuffer]",O5="[object DataView]",R5="[object Float32Array]",L5="[object Float64Array]",N5="[object Int8Array]",B5="[object Int16Array]",F5="[object Int32Array]",k5="[object Uint8Array]",V5="[object Uint8ClampedArray]",z5="[object Uint16Array]",U5="[object Uint32Array]";function G5(i,t,e){var r=i.constructor;switch(t){case I5:return nh(i);case A5:case _5:return new r(+i);case O5:return aC(i,e);case R5:case L5:case N5:case B5:case F5:case k5:case V5:case z5:case U5:return dC(i,e);case E5:return new r;case M5:case P5:return new r(i);case T5:return lC(i);case C5:return new r;case D5:return hC(i)}}var fC=G5;function H5(i){return typeof i.constructor=="function"&&!ju(i)?UM(Ju(i)):{}}var pC=H5;var j5="[object Map]";function W5(i){return Bn(i)&&Ko(i)==j5}var mC=W5;var gC=Xo&&Xo.isMap,q5=gC?qu(gC):mC,yC=q5;var Y5="[object Set]";function X5(i){return Bn(i)&&Ko(i)==Y5}var vC=X5;var xC=Xo&&Xo.isSet,Q5=xC?qu(xC):vC,bC=Q5;var K5=1,Z5=2,J5=4,wC="[object Arguments]",$5="[object Array]",ej="[object Boolean]",tj="[object Date]",rj="[object Error]",SC="[object Function]",nj="[object GeneratorFunction]",ij="[object Map]",sj="[object Number]",AC="[object Object]",oj="[object RegExp]",aj="[object Set]",lj="[object String]",cj="[object Symbol]",uj="[object WeakMap]",hj="[object ArrayBuffer]",dj="[object DataView]",fj="[object Float32Array]",pj="[object Float64Array]",mj="[object Int8Array]",gj="[object Int16Array]",yj="[object Int32Array]",vj="[object Uint8Array]",xj="[object Uint8ClampedArray]",bj="[object Uint16Array]",wj="[object Uint32Array]",ar={};ar[wC]=ar[$5]=ar[hj]=ar[dj]=ar[ej]=ar[tj]=ar[fj]=ar[pj]=ar[mj]=ar[gj]=ar[yj]=ar[ij]=ar[sj]=ar[AC]=ar[oj]=ar[aj]=ar[lj]=ar[cj]=ar[vj]=ar[xj]=ar[bj]=ar[wj]=!0;ar[rj]=ar[SC]=ar[uj]=!1;function sy(i,t,e,r,n,s){var o,a=t&K5,l=t&Z5,u=t&J5;if(e&&(o=n?e(i,r,n,s):e(i)),o!==void 0)return o;if(!Kr(i))return i;var c=sn(i);if(c){if(o=oC(i),!a)return HM(i,o)}else{var h=Ko(i),d=h==SC||h==nj;if($l(i))return KT(i,a);if(h==AC||h==wC||d&&!n){if(o=l||d?{}:pC(i),!a)return l?eC(i,WT(o,i)):$T(i,jT(o,i))}else{if(!ar[h])return n?i:{};o=fC(i,h,a)}}s||(s=new eh);var f=s.get(i);if(f)return f;s.set(i,o),bC(i)?i.forEach(function(g){o.add(sy(g,t,e,g,i,s))}):yC(i)&&i.forEach(function(g,y){o.set(y,sy(g,t,e,y,i,s))});var p=u?l?ty:np:l?qi:Yu,m=c?void 0:p(i);return XM(m||i,function(g,y){m&&(y=g,g=i[y]),Gu(o,y,sy(g,t,e,y,i,s))}),o}var oy=sy;var Sj=1,Aj=4;function _j(i){return oy(i,Sj|Aj)}var Zo=_j;var Ej="__lodash_hash_undefined__";function Mj(i){return this.__data__.set(i,Ej),this}var _C=Mj;function Tj(i){return this.__data__.has(i)}var EC=Tj;function ay(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new ec;++t<e;)this.add(i[t])}ay.prototype.add=ay.prototype.push=_C;ay.prototype.has=EC;var MC=ay;function Cj(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var TC=Cj;function Pj(i,t){return i.has(t)}var CC=Pj;var Dj=1,Ij=2;function Oj(i,t,e,r,n,s){var o=e&Dj,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var h=-1,d=!0,f=e&Ij?new MC:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],m=t[h];if(r)var g=o?r(m,p,h,t,i,s):r(p,m,h,i,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!TC(t,function(y,v){if(!CC(f,v)&&(p===y||n(p,y,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||n(p,m,e,r,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var ly=Oj;function Rj(i){var t=-1,e=Array(i.size);return i.forEach(function(r,n){e[++t]=[n,r]}),e}var PC=Rj;function Lj(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var DC=Lj;var Nj=1,Bj=2,Fj="[object Boolean]",kj="[object Date]",Vj="[object Error]",zj="[object Map]",Uj="[object Number]",Gj="[object RegExp]",Hj="[object Set]",jj="[object String]",Wj="[object Symbol]",qj="[object ArrayBuffer]",Yj="[object DataView]",IC=bn?bn.prototype:void 0,bw=IC?IC.valueOf:void 0;function Xj(i,t,e,r,n,s,o){switch(e){case Yj:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case qj:return!(i.byteLength!=t.byteLength||!s(new rh(i),new rh(t)));case Fj:case kj:case Uj:return Uu(+i,+t);case Vj:return i.name==t.name&&i.message==t.message;case Gj:case jj:return i==t+"";case zj:var a=PC;case Hj:var l=r&Nj;if(a||(a=DC),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;r|=Bj,o.set(i,t);var c=ly(a(i),a(t),r,n,s,o);return o.delete(i),c;case Wj:if(bw)return bw.call(i)==bw.call(t)}return!1}var OC=Xj;var Qj=1,Kj=Object.prototype,Zj=Kj.hasOwnProperty;function Jj(i,t,e,r,n,s){var o=e&Qj,a=np(i),l=a.length,u=np(t),c=u.length;if(l!=c&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:Zj.call(t,d)))return!1}var f=s.get(i),p=s.get(t);if(f&&p)return f==t&&p==i;var m=!0;s.set(i,t),s.set(t,i);for(var g=o;++h<l;){d=a[h];var y=i[d],v=t[d];if(r)var x=o?r(v,y,d,t,i,s):r(y,v,d,i,t,s);if(!(x===void 0?y===v||n(y,v,e,r,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var w=i.constructor,S=t.constructor;w!=S&&"constructor"in i&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(m=!1)}return s.delete(i),s.delete(t),m}var RC=Jj;var $j=1,LC="[object Arguments]",NC="[object Array]",cy="[object Object]",eW=Object.prototype,BC=eW.hasOwnProperty;function tW(i,t,e,r,n,s){var o=sn(i),a=sn(t),l=o?NC:Ko(i),u=a?NC:Ko(t);l=l==LC?cy:l,u=u==LC?cy:u;var c=l==cy,h=u==cy,d=l==u;if(d&&$l(i)){if(!$l(t))return!1;o=!0,c=!1}if(d&&!c)return s||(s=new eh),o||Yg(i)?ly(i,t,e,r,n,s):OC(i,t,l,e,r,n,s);if(!(e&$j)){var f=c&&BC.call(i,"__wrapped__"),p=h&&BC.call(t,"__wrapped__");if(f||p){var m=f?i.value():i,g=p?t.value():t;return s||(s=new eh),n(m,g,e,r,s)}}return d?(s||(s=new eh),RC(i,t,e,r,n,s)):!1}var FC=tW;function kC(i,t,e,r,n){return i===t?!0:i==null||t==null||!Bn(i)&&!Bn(t)?i!==i&&t!==t:FC(i,t,e,r,kC,n)}var VC=kC;function rW(i,t){return i!=null&&t in Object(i)}var zC=rW;function nW(i,t,e){t=Yi(t,i);for(var r=-1,n=t.length,s=!1;++r<n;){var o=Ga(t[r]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++r!=n?s:(n=i==null?0:i.length,!!n&&Hu(n)&&zu(o,n)&&(sn(i)||Wu(i)))}var UC=nW;function iW(i,t){return i!=null&&UC(i,t,zC)}var GC=iW;var sW=function(){return Er.Date.now()},uy=sW;var oW="Expected a function",aW=Math.max,lW=Math.min;function cW(i,t,e){var r,n,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(oW);t=mw(t)||0,Kr(e)&&(c=!!e.leading,h="maxWait"in e,s=h?aW(mw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var E=r,b=n;return r=n=void 0,u=A,o=i.apply(b,E),o}function p(A){return u=A,a=setTimeout(y,t),c?f(A):o}function m(A){var E=A-l,b=A-u,M=t-E;return h?lW(M,s-b):M}function g(A){var E=A-l,b=A-u;return l===void 0||E>=t||E<0||h&&b>=s}function y(){var A=uy();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=n=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,r=l=n=a=void 0}function w(){return a===void 0?o:v(uy())}function S(){var A=uy(),E=g(A);if(r=arguments,n=this,l=A,E){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return S.cancel=x,S.flush=w,S}var rc=cW;function uW(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var HC=uW;function hW(i,t){return t.length<2?i:Kg(i,kT(t,0,-1))}var jC=hW;function dW(i,t){return VC(i,t)}var ip=dW;function fW(i,t){return t=Yi(t,i),i=jC(i,t),i==null||delete i[Ga(HC(t))]}var WC=fW;function pW(i){return FT(i)?void 0:i}var qC=pW;var mW=1,gW=2,yW=4,vW=Zg(function(i,t){var e={};if(i==null)return e;var r=!1;t=Ug(t,function(s){return s=Yi(s,i),r||(r=s.length>1),s}),qs(i,ty(i),e),r&&(e=oy(e,mW|gW|yW,qC));for(var n=t.length;n--;)WC(e,t[n]);return e}),ih=vW;function xW(i,t,e,r){if(!Kr(i))return i;t=Yi(t,i);for(var n=-1,s=t.length,o=s-1,a=i;a!=null&&++n<s;){var l=Ga(t[n]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(n!=o){var c=a[l];u=r?r(c,l,a):void 0,u===void 0&&(u=Kr(c)?c:zu(t[n+1])?[]:{})}Gu(a,l,u),a=a[l]}return i}var YC=xW;function bW(i,t,e){for(var r=-1,n=t.length,s={};++r<n;){var o=t[r],a=Kg(i,o);e(a,o)&&YC(s,Yi(o,i),a)}return s}var XC=bW;function wW(i,t){return XC(i,t,function(e,r){return GC(i,r)})}var QC=wW;var SW=Zg(function(i,t){return i==null?{}:QC(i,t)}),Ni=SW;var AW="Expected a function";function _W(i,t,e){var r=!0,n=!0;if(typeof i!="function")throw new TypeError(AW);return Kr(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),rc(i,t,{leading:r,maxWait:t,trailing:n})}var ww=_W;function KC(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function ui(i,t){return Object.setPrototypeOf(i,t),i}var EW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),MW=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),TW=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||nc&&"ontouchend"in document,CW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,PW=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,DW=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},IW=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},OW=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},RW=EW(),Kse=RW?OW():void 0,nc=MW(),sh=TW(),ZC=CW(),on=PW(),Sw=DW(),Aw=Number(IW());function hy(i){return Array.isArray(i)?i:[i]}function JC(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function sp(i){return nc?i.metaKey:i.ctrlKey}var qe=[],fy={},op={},dy={};function $C(i){qe.includes(i)||qe.push(i)}function oh(i){delete fy[i.pointerId];for(let t=0;t<qe.length;t++)if(qe[t].pointerId===i.pointerId){qe.splice(t,1);break}}function eP(){qe.splice(0,qe.length)}function py(i){if(i.pointerType!=="touch")return;let t=fy[i.pointerId];t===void 0&&(t={x:0,y:0},fy[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function my(i){let t=i.pointerId===qe[0].pointerId?qe[1]:qe[0];return fy[t.pointerId]}function tP(i){op[i.key]=!0,dy[i.key]=dy[i.key]===void 0?1:dy[i.key]+1}function rP(i){if(nc&&op.Meta)for(let t in op)op[t]=!1;else op[i.key]=!1;dy={}}function nP(i){i.addEventListener("pointerdown",$C,!0),i.addEventListener("pointerdown",py,!0),i.addEventListener("pointermove",py,!0),i.addEventListener("pointerup",oh,!0),i.addEventListener("pointercancel",oh,!0),i.addEventListener("pointerleave",oh,!0),window.addEventListener("keydown",tP,!0),window.addEventListener("keyup",rP,!0)}function iP(i){i.removeEventListener("pointerdown",$C,!0),i.removeEventListener("pointerdown",py,!0),i.removeEventListener("pointermove",py,!0),i.removeEventListener("pointerup",oh,!0),i.removeEventListener("pointercancel",oh,!0),i.removeEventListener("pointerleave",oh,!0),window.removeEventListener("keydown",tP,!0),window.removeEventListener("keyup",rP,!0)}var sP,oP=new Promise(i=>{sP=i});var gy;function aP(){if(gy)return gy;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.517/build",n=import("./navmesh.js"),[s,o]=await Promise.all([n,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});sP(l)}return gy=i(),gy}var lP,cP=new Promise(i=>{lP=i});var yy;function uP(){if(yy)return yy;async function i(){let e=await import("./physics.js");await e.init(),lP(e)}return yy=i(),yy}var rt=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,rt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,rt.prototype),{data:a,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,rt.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:n}}}}return null}};function ap(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&ap(r)}return Object.freeze(i)}function hP(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ah=class extends Error{};function vy(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ys(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let r=[],n=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*n;r.push(o)}return r}function lh(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function dP(){return typeof process<"u"}function fP(i,t){for(let e of i)t(e.id,e.data)!==!0&&fP(e.children,t)}function pP(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)pP(e,t)}var pr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,pr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ap(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let n of e.children)this.fillCaches0(n,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,r){if(!this.has(e))return!0;for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}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,r){if(e===null)this.traverse(r);else{let n=this.get(e);n&&pP(n,r)}}traverse(e){fP(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let n=e,s=r;for(;n!==null;){let a=s,l=n;if(n=this.parent(n),n===void 0)throw new Error;s=this.childrenArray(n);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,pr.prototype);let o=s;return o.fillCaches(),o}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:r}){if(this.get(e)!==void 0)return!0;for(let n of r)if(this.checkDuplicatedIdRec(n))return!0;return!1}addOp(e){let{parent:r,fi:n,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:n,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let s=this.childrenArray(n),o=s.findIndex(u=>u.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(n,s),actual:e,reverse:{type:7,...a,parent:n}}}}moveOp(e){let{parent:r,fi:n,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new ah("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:n},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let n=null;for(let s of this.childrenArray(e)){if(s.id===r)return n;n=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)+1;if(s<n.length)return n[s].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(n[s].id):r}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push({...n,...s})}r.sort((n,s)=>hP(n.sortKey,s.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)n.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:n}}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let s=this.childrenArray(e);if(r===null){if(s.length===0)return Ys(0,n,n);{let o=s[0].fi;return Ys(o-n,o,n)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ys(l,l+n,n)}else return Ys(o.fi,a.fi,n)}}};var ch;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let n=r.props,s={},o=[...e],a=!1;if(n)for(let l of Object.keys(n)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=n[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let n=r.props,s={},o={...e},a=!1;if(n)for(let l of Object.keys(n)){s[l]=o[l];let u=n[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=i})(ch||(ch={}));var Le=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Le.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ap(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Le.prototype);let r=e;return dP()||r.fillCaches(),r}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:r,id:n,data:s}=e,o=this,a={fi:r,id:n,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,s=n.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,n=[...n];let o=n.splice(s,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:n}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===n);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return Ys(0,r,r);{let s=n[0].fi;return Ys(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=n.find(a=>a.fi>s.fi);if(o===void 0){let a=n[n.length-1].fi;return Ys(a,a+r,r)}else return Ys(s.fi,o.fi,r)}}};function uh(i){return i&&typeof i=="object"&&i instanceof Jt}var Jt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,n=0,s={};for(;n<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!uh(r))return null;n+=1}r=r?vy(r):new Jt;for(let[l,u]of Object.entries(t.props)){let c=r[l];s[l]=c,u===void 0?delete r[l]:r[l]=u}for(;n>0;){if(Object.keys(r).length===0){let l=e[n-1];l&&(r=vy(l),delete r[t.path[n-1]])}else{let l=e[n-1];if(l){let u=vy(l);u[t.path[n-1]]=r,r=u}else{let u=new Jt;u[t.path[n-1]]=r,r=u}}n-=1}let o=Object.setPrototypeOf(r,Jt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Xs;(r=>{function i(n,s){return lp(n,s)??n}r.apply=i;function t(n,s){return Ew(n,s)}r.merge=t;function e(n,s){let o=0,a=s.path,l=n;for(;o<a.length&&l!==void 0;){if(l=Rr.zoomOnce(l,a[o]),l===void 0)return s;if(!uh(l))return;o+=1}if(l===void 0)return s;if(!!uh(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=_w([s],l);return u?(console.log(u),u):s}else return s}r.filterOp=e})(Xs||(Xs={}));function _w(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=lp(n.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=n.data),n.children){let a=_w(n.children,t);return a!==void 0?e=!0:a=n.children,{...n,id:s,data:o,children:a}}else return{...n,id:s,data:o}});if(e)return r}function LW(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=lp(n.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=n.data),{...n,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function lp(i,t){if(!uh(t))return t;if(i instanceof pr){let e=_w(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Le)return LW(i,t);if(Array.isArray(i)){let e=!1,r=i.map((n,s)=>{let o=lp(n,t[s]);return e=e||o!==void 0,o===void 0&&(o=n),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof Jt)return Ew(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[n,s]of Object.entries(i)){let o=lp(s,t[n]);r=r||o!==void 0,o===void 0&&(o=s),e[n]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Ew(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!uh(t))return t;if(!uh(i))return Xs.apply(i,t);let e=new Set;for(let n of Object.keys(i))e.add(n);for(let n of Object.keys(t))e.add(n);let r=new Jt;for(let n of e){let s=Ew(i===void 0?void 0:i[n],t===void 0?void 0:t[n]);r[n]=s}return r}function mP(i,t){let e={cur:[],result:[],len:0};return i=cp(i,t,e)??i,[i,e.result]}function xy(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function by(i){i&&(i.len-=1)}function NW(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function gP(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=cp(s.data,t,xy(e,o));by(e),r=r||l!==void 0,l===void 0&&(l=s.data);let u=gP(s.children,t,e);return u!==void 0?r=!0:u=s.children,{...s,id:o,data:l,children:u}});if(r)return n}function BW(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=cp(s.data,t,xy(e,o));return by(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function cp(i,t,e){if(i instanceof pr){let r=gP(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof Le)return BW(i,t,e);if(Array.isArray(i)){let r=!1,n=i.map((s,o)=>{let a=cp(s,t,xy(e,o));return by(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(i&&typeof i=="object"&&!lh(i)){let r={},n=!1;for(let[s,o]of Object.entries(i))if(s!=="name"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");n=!0,s=a}let l=cp(o,t,xy(e,s));by(e),n=n||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&NW(e),r}else return}}var wy;(t=>{function i(e,r){let n=Rr.zoom(r,e.path);if(typeof n=="object"){let s={};for(let o of Object.keys(e.props))s[o]=n[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(wy||(wy={}));var Lr;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Jt&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===c.length&&(l instanceof pr||l instanceof Le||l instanceof rt?d=l.runOp(u):d=ch.runOp(l,u)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=c[g],v=h[g];if(v instanceof pr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Le){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof rt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Jt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Jt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],p;if(l instanceof pr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Le){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function r(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=r;function n(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=n;function s(l,u){return r(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&n(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(Lr||(Lr={}));var up;(l=>{function i(){return[]}l.empty=i;function t(u,c){let h=[];for(let d of u){let[f,...p]=d.path;f===c&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function n(u,c){return[...u.filter(d=>!c.some(f=>Lr.subsumed(d,f))),...c]}l.compress=n;function s(u,c){return u.every(h=>c.every(d=>Lr.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let p of c)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Rr.zoom(h,[...p.path,p.id]),y=Lr.apply(h,{...p,type:2})):(m=Rr.zoom(h,[...p.path,p.id,"value"]),y=Lr.apply(h,p)),y!==null){h=y.data;let[v,x]=mP(h,{[p.id]:m});h=v;for(let w=0;w<x.length;w++){let S=x[w],A=S.pop();if(typeof A=="number"){let E=[A];for(let M=w+1;M<x.length;M++){let T=x[M],C=T[T.length-1];if(typeof C=="number"&&Rr.equal(S,T.slice(0,T.length-1)))E.push(C),x.splice(M,1);else break}let b=Rr.zoom(h,S);g=b.map((M,T)=>E.includes(T)?p.id:M),m=b,A=S.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let E=m,b=Rr.zoom(h,S.slice(0,S.length-2)),M=b.layers.map(T=>T.id===S[S.length-1]?{...T,data:{...T.data,[A]:E}}:T);Object.setPrototypeOf(M,Object.getPrototypeOf(b.layers)),b.layers=M}g=p.id}d.push({type:0,path:S,props:{[A]:m}}),f.push({type:0,path:S,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Lr.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ah)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(up||(up={}));var yP=Symbol(),FW=Symbol(),Ay=Symbol(),ic=class{reportOp(t,e,r=[]){let n=this;if(e===null)return;n._current=e.data;let s=r;for(;!(n instanceof Sy);){let o=n._path,a=n._current;if(o!==""&&s.splice(0,0,o),n=n._parent,n===null)return;n.update(o,a)}n.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ay];r&&r(),delete this._children[t]}}}},Tw=class extends ic{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,ch.runOp(this._current,t),t.path)}},Cw=class extends ic{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,rt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},vP={get(i,t){if(t===Ay)return()=>{i._parent=null};if(t===yP)return i._current;if(t===FW)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e[t],o=_y(i,t,s);return o!==s?(r===void 0&&(r={},i._children=r),r[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},kW={...vP,set(i,t,e){let r={type:0,props:{[t]:xr(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},VW={...vP,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},hh=class extends ic{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ay]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=_y(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,n,s){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}moveBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},dh=class extends ic{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ay]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),n,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id;if(t(this.data(n),n))return this.get(n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=_y(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Mw(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Rr.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Sy=class extends ic{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,n){Mw(this.ts,e,t),Mw(this.actual,r,t),Mw(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _y(i,t,e){return e instanceof pr?new hh(i,t,e):e instanceof Le?new dh(i,t,e):e instanceof rt?new Proxy(new Cw(i,t,e),VW):e!==null&&typeof e=="object"?lh(e)?e:new Proxy(new Tw(i,t,e),kW):e}function Pw(i){let t=new Sy(i);return[_y(t,"",i),t]}function Ha(i,t){let[e,r]=Pw(i);return t(e),r.result()}function xr(i){return i instanceof hh||i instanceof dh?i._current:i!==null&&typeof i=="object"?i[yP]:i}var Rr;(n=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}n.equal=i;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}n.removeOverridden=t;function e(s,o){if((s instanceof pr||s instanceof hh)&&typeof o=="string")return s.data(o);if((s instanceof Le||s instanceof dh)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}n.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}n.zoom=r})(Rr||(Rr={}));function xP(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function qn(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var Ey=class{},hp=class extends Ey{constructor(e){super();this.id=e}},dp=class extends Ey{constructor(e){super();this.data=e}};var Iw;try{Iw=new TextDecoder}catch{}var Be,Wa,$=0;var TP=[],Ow=TP,Rw=0,hi={},Nt,ja,Xi=0,Qs=0,Bi,Jo,ti=[],Ht,bP={useRecords:!1,mapsAsObjects:!0},fp=class{},Nw=new fp;Nw.name="MessagePack 0xC1";var fh=!1,Ks=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Be)return OP(()=>(Ty(),this?this.unpack(t,e):Ks.prototype.unpack.call(bP,t,e)));Wa=e>-1?e:t.length,$=0,Rw=0,Qs=0,ja=null,Ow=TP,Bi=null,Be=t;try{Ht=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Be=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ks){if(hi=this,this.structures)return Nt=this.structures,My();(!Nt||Nt.length>0)&&(Nt=[])}else hi=bP,(!Nt||Nt.length>0)&&(Nt=[]);return My()}unpackMultiple(t,e){let r,n=0;try{fh=!0;let s=t.length,o=this?this.unpack(t,s):Dy.unpack(t,s);if(e){for(e(o);$<s;)if(n=$,e(My())===!1)return}else{for(r=[o];$<s;)n=$,r.push(My());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{fh=!1,Ty()}}_mergeStructures(t,e){t=t||[];for(let r=0,n=t.length;r<n;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],s=e[r];s&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function My(){try{if(!hi.trusted&&!fh){let t=Nt.sharedLength||0;t<Nt.length&&(Nt.length=t)}let i=Mr();if($==Wa)Nt.restoreStructures&&wP(),Nt=null,Be=null,Jo&&(Jo=null);else if($>Wa){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!fh)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Nt.restoreStructures&&wP(),Ty(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function wP(){for(let i in Nt.restoreStructures)Nt[i]=Nt.restoreStructures[i];Nt.restoreStructures=null}function Mr(){let i=Be[$++];if(i<160)if(i<128){if(i<64)return i;{let t=Nt[i&63]||hi.getStructures&&CP()[i&63];return t?(t.read||(t.read=Bw(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,hi.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DP()]=Mr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mr(),Mr());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mr();return t}else if(i<192){let t=i-160;if(Qs>=$)return ja.slice($-Xi,($+=t)-Xi);if(Qs==0&&Wa<140){let e=t<16?Fw(t):PP(t);if(e!=null)return e}return Lw(t)}else{let t;switch(i){case 192:return null;case 193:return Bi?(t=Mr(),t>0?Bi[1].slice(Bi.position1,Bi.position1+=t):Bi[0].slice(Bi.position0,Bi.position0-=t)):Nw;case 194:return!1;case 195:return!0;case 196:return Dw(Be[$++]);case 197:return t=Ht.getUint16($),$+=2,Dw(t);case 198:return t=Ht.getUint32($),$+=4,Dw(t);case 199:return sc(Be[$++]);case 200:return t=Ht.getUint16($),$+=2,sc(t);case 201:return t=Ht.getUint32($),$+=4,sc(t);case 202:if(t=Ht.getFloat32($),hi.useFloat32>2){let e=Py[(Be[$]&127)<<1|Be[$+1]>>7];return $+=4,(e*t+(t>0?.5:-.5)>>0)/e}return $+=4,t;case 203:return t=Ht.getFloat64($),$+=8,t;case 204:return Be[$++];case 205:return t=Ht.getUint16($),$+=2,t;case 206:return t=Ht.getUint32($),$+=4,t;case 207:return hi.int64AsNumber?(t=Ht.getUint32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigUint64($),$+=8,t;case 208:return Ht.getInt8($++);case 209:return t=Ht.getInt16($),$+=2,t;case 210:return t=Ht.getInt32($),$+=4,t;case 211:return hi.int64AsNumber?(t=Ht.getInt32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigInt64($),$+=8,t;case 212:if(t=Be[$++],t==114)return MP(Be[$++]&63);{let e=ti[t];if(e)return e.read?($++,e.read(Mr())):e.noBuffer?($++,e()):e(Be.subarray($,++$));throw new Error("Unknown extension "+t)}case 213:return t=Be[$],t==114?($++,MP(Be[$++]&63,Be[$++])):sc(2);case 214:return sc(4);case 215:return sc(8);case 216:return sc(16);case 217:return t=Be[$++],Qs>=$?ja.slice($-Xi,($+=t)-Xi):UW(t);case 218:return t=Ht.getUint16($),$+=2,Qs>=$?ja.slice($-Xi,($+=t)-Xi):GW(t);case 219:return t=Ht.getUint32($),$+=4,Qs>=$?ja.slice($-Xi,($+=t)-Xi):HW(t);case 220:return t=Ht.getUint16($),$+=2,AP(t);case 221:return t=Ht.getUint32($),$+=4,AP(t);case 222:return t=Ht.getUint16($),$+=2,_P(t);case 223:return t=Ht.getUint32($),$+=4,_P(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var zW=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Bw(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>zW.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Mr);return i.highByte===0&&(i.read=SP(t,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let o=i[n];r[o]=Mr()}return r}return e.count=0,i.highByte===0?SP(t,e):e}var SP=(i,t)=>function(){let e=Be[$++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=Nt[r]||CP()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=Bw(n,i)),n.read()};function CP(){let i=OP(()=>(Be=null,hi.getStructures()));return Nt=hi._mergeStructures(i,Nt)}var Lw=Cy,UW=Cy,GW=Cy,HW=Cy;function Cy(i){let t;if(i<16&&(t=Fw(i)))return t;if(i>64&&Iw)return Iw.decode(Be.subarray($,$+=i));let e=$+i,r=[];for(t="";$<e;){let n=Be[$++];if((n&128)===0)r.push(n);else if((n&224)===192){let s=Be[$++]&63;r.push((n&31)<<6|s)}else if((n&240)===224){let s=Be[$++]&63,o=Be[$++]&63;r.push((n&31)<<12|s<<6|o)}else if((n&248)===240){let s=Be[$++]&63,o=Be[$++]&63,a=Be[$++]&63,l=(n&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(n);r.length>=4096&&(t+=Sn.apply(String,r),r.length=0)}return r.length>0&&(t+=Sn.apply(String,r)),t}function AP(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mr();return t}function _P(i){if(hi.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DP()]=Mr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mr(),Mr());return t}}var Sn=String.fromCharCode;function PP(i){let t=$,e=new Array(i);for(let r=0;r<i;r++){let n=Be[$++];if((n&128)>0){$=t;return}e[r]=n}return Sn.apply(String,e)}function Fw(i){if(i<4)if(i<2){if(i===0)return"";{let t=Be[$++];if((t&128)>1){$-=1;return}return Sn(t)}}else{let t=Be[$++],e=Be[$++];if((t&128)>0||(e&128)>0){$-=2;return}if(i<3)return Sn(t,e);let r=Be[$++];if((r&128)>0){$-=3;return}return Sn(t,e,r)}else{let t=Be[$++],e=Be[$++],r=Be[$++],n=Be[$++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){$-=4;return}if(i<6){if(i===4)return Sn(t,e,r,n);{let s=Be[$++];if((s&128)>0){$-=5;return}return Sn(t,e,r,n,s)}}else if(i<8){let s=Be[$++],o=Be[$++];if((s&128)>0||(o&128)>0){$-=6;return}if(i<7)return Sn(t,e,r,n,s,o);let a=Be[$++];if((a&128)>0){$-=7;return}return Sn(t,e,r,n,s,o,a)}else{let s=Be[$++],o=Be[$++],a=Be[$++],l=Be[$++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){$-=8;return}if(i<10){if(i===8)return Sn(t,e,r,n,s,o,a,l);{let u=Be[$++];if((u&128)>0){$-=9;return}return Sn(t,e,r,n,s,o,a,l,u)}}else if(i<12){let u=Be[$++],c=Be[$++];if((u&128)>0||(c&128)>0){$-=10;return}if(i<11)return Sn(t,e,r,n,s,o,a,l,u,c);let h=Be[$++];if((h&128)>0){$-=11;return}return Sn(t,e,r,n,s,o,a,l,u,c,h)}else{let u=Be[$++],c=Be[$++],h=Be[$++],d=Be[$++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){$-=12;return}if(i<14){if(i===12)return Sn(t,e,r,n,s,o,a,l,u,c,h,d);{let f=Be[$++];if((f&128)>0){$-=13;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f)}}else{let f=Be[$++],p=Be[$++];if((f&128)>0||(p&128)>0){$-=14;return}if(i<15)return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p);let m=Be[$++];if((m&128)>0){$-=15;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p,m)}}}}}function Dw(i){return hi.copyBuffers?Uint8Array.prototype.slice.call(Be,$,$+=i):Be.subarray($,$+=i)}function sc(i){let t=Be[$++];if(ti[t])return ti[t](Be.subarray($,$+=i));throw new Error("Unknown extension type "+t)}var EP=new Array(4096);function DP(){let i=Be[$++];if(i>=160&&i<192){if(i=i-160,Qs>=$)return ja.slice($-Xi,($+=i)-Xi);if(!(Qs==0&&Wa<180))return Lw(i)}else return $--,Mr();let t=(i<<5^(i>1?Ht.getUint16($):i>0?Be[$]:0))&4095,e=EP[t],r=$,n=$+i-3,s,o=0;if(e&&e.bytes==i){for(;r<n;){if(s=Ht.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=Be[r++],s!=e[o++]){r=1879048192;break}if(r===n)return $=r,e.string;n-=3,r=$}for(e=[],EP[t]=e,e.bytes=i;r<n;)s=Ht.getUint32(r),e.push(s),r+=4;for(n+=3;r<n;)s=Be[r++],e.push(s);let a=i<16?Fw(i):PP(i);return a!=null?e.string=a:e.string=Lw(i)}var MP=(i,t)=>{var e=Mr();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=Nt[i];return n&&n.isShared&&((Nt.restoreStructures||(Nt.restoreStructures=[]))[i]=n),Nt[i]=e,e.read=Bw(e,r),e.read()},IP=typeof self=="object"?self:global;ti[0]=()=>{};ti[0].noBuffer=!0;ti[101]=()=>{let i=Mr();return(IP[i[0]]||Error)(i[1])};ti[105]=i=>{let t=Ht.getUint32($-4);Jo||(Jo=new Map);let e=Be[$],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};Jo.set(t,n);let s=Mr();return n.used?Object.assign(r,s):(n.target=s,s)};ti[112]=i=>{let t=Ht.getUint32($-4),e=Jo.get(t);return e.used=!0,e.target};ti[115]=()=>new Set(Mr());var kw=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");ti[116]=i=>{let t=i[0],e=kw[t];if(!e)throw new Error("Could not find typed array for code "+t);return new IP[e](Uint8Array.prototype.slice.call(i,1).buffer)};ti[120]=()=>{let i=Mr();return new RegExp(i[0],i[1])};ti[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=$;$+=t-4,Bi=[Mr(),Mr()],Bi.position0=0,Bi.position1=0;let r=$;$=e;try{return Mr()}finally{$=r}};ti[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function OP(i){let t=Wa,e=$,r=Rw,n=Xi,s=Qs,o=ja,a=Ow,l=Jo,u=Bi,c=new Uint8Array(Be.slice(0,Wa)),h=Nt,d=Nt.slice(0,Nt.length),f=hi,p=fh,m=i();return Wa=t,$=e,Rw=r,Xi=n,Qs=s,ja=o,Ow=a,Jo=l,Bi=u,Be=c,fh=p,Nt=h,Nt.splice(0,Nt.length,...d),hi=f,Ht=new DataView(Be.buffer,Be.byteOffset,Be.byteLength),m}function Ty(){Be=null,Jo=null,Nt=null}function RP(i){i.unpack?ti[i.type]=i.unpack:ti[i.type]=i}var Py=new Array(147);for(let i=0;i<256;i++)Py[i]=+("1e"+Math.floor(45.15-i*.30103));var Dy=new Ks({useRecords:!1}),jW=Dy.unpack,WW=Dy.unpackMultiple,qW=Dy.unpack,Iy={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},YW=new Float32Array(1),aae=new Uint8Array(YW.buffer,0,4);var Oy;try{Oy=new TextEncoder}catch{}var Ry,zw,Ly=typeof Buffer<"u",Vw=Ly?Buffer.allocUnsafeSlow:Uint8Array,FP=Ly?Buffer:Uint8Array,LP=Ly?4294967296:2144337920,de,Nr,ne=0,Zs,Js=null,XW=/[\u0080-\uFFFF]/,pp=Symbol("record-id"),oc=class extends Ks{constructor(t){super(t),this.offset=0;let e,r,n,s,o,a,l=0,u=FP.prototype.utf8Write?function(b,M,T){return de.utf8Write(b,M,T)}:Oy&&Oy.encodeInto?function(b,M){return Oy.encodeInto(b,de.subarray(M)).written}:!1,c=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,w=0;this.pack=this.encode=function(b,M){if(de||(de=new Vw(8192),Nr=new DataView(de.buffer,0,8192),ne=0),Zs=de.length-10,Zs-ne<2048?(de=new Vw(de.length),Nr=new DataView(de.buffer,0,de.length),Zs=de.length-10,ne=0):ne=ne+7&2147483640,r=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(Js=["",""],de[ne++]=214,de[ne++]=98,Js.position=ne-r,ne+=4):Js=null,n=c.structures,n){n.uninitialized&&(n=c._mergeStructures(c.getStructures()));let T=n.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let C=0;C<T;C++){let P=n[C];if(!P)continue;let D,I=n.transitions;for(let R=0,U=P.length;R<U;R++){let F=P[R];D=I[F],D||(D=I[F]=Object.create(null)),I=D}I[pp]=C+64}l=T}h||(n.nextId=T+64)}s&&(s=!1),o=n||[];try{if(S(b),Js){Nr.setUint32(Js.position+r,ne-Js.position-r);let T=Js;Js=null,S(T[0]),S(T[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>Zs&&E(ne),c.offset=ne;let T=KW(de.subarray(r,ne),a.idsToInsert);return a=null,T}return M&VP?(de.start=r,de.end=ne,de):de.subarray(r,ne)}finally{if(n){if(w<10&&w++,x>1e4)n.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let T=0,C=v.length;T<C;T++)v[T][pp]=0;v=[]}if(s&&c.saveStructures){let T=n.sharedLength||f;n.length>T&&(n=n.slice(0,T));let C=de.subarray(r,ne);return c.saveStructures(n,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,C)}}M&n6&&(ne=r)}};let S=b=>{ne>Zs&&(de=E(ne));var M=typeof b,T;if(M==="string"){let C=b.length;if(Js&&C>=8&&C<4096){let I=XW.test(b);Js[I?0:1]+=b,de[ne++]=193,S(I?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let D=C*3;if(ne+D>Zs&&(de=E(ne+D)),C<64||!u){let I,R,U,F=ne+P;for(I=0;I<C;I++)R=b.charCodeAt(I),R<128?de[F++]=R:R<2048?(de[F++]=R>>6|192,de[F++]=R&63|128):(R&64512)===55296&&((U=b.charCodeAt(I+1))&64512)===56320?(R=65536+((R&1023)<<10)+(U&1023),I++,de[F++]=R>>18|240,de[F++]=R>>12&63|128,de[F++]=R>>6&63|128,de[F++]=R&63|128):(de[F++]=R>>12|224,de[F++]=R>>6&63|128,de[F++]=R&63|128);T=F-ne-P}else T=u(b,ne+P,D);T<32?de[ne++]=160|T:T<256?(P<2&&de.copyWithin(ne+2,ne+1,ne+1+T),de[ne++]=217,de[ne++]=T):T<65536?(P<3&&de.copyWithin(ne+3,ne+2,ne+2+T),de[ne++]=218,de[ne++]=T>>8,de[ne++]=T&255):(P<5&&de.copyWithin(ne+5,ne+3,ne+3+T),de[ne++]=219,Nr.setUint32(ne,T),ne+=4),ne+=T}else if(M==="number")if(b>>>0===b)b<64?de[ne++]=b:b<256?(de[ne++]=204,de[ne++]=b):b<65536?(de[ne++]=205,de[ne++]=b>>8,de[ne++]=b&255):(de[ne++]=206,Nr.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?de[ne++]=256+b:b>=-128?(de[ne++]=208,de[ne++]=b+256):b>=-32768?(de[ne++]=209,Nr.setInt16(ne,b),ne+=2):(de[ne++]=210,Nr.setInt32(ne,b),ne+=4);else{let C;if((C=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){de[ne++]=202,Nr.setFloat32(ne,b);let P;if(C<4||(P=b*Py[(de[ne]&127)<<1|de[ne+1]>>7])>>0===P){ne+=4;return}else ne--}de[ne++]=203,Nr.setFloat64(ne,b),ne+=8}else if(M==="object")if(!b)de[ne++]=192;else{if(a){let P=a.get(b);if(P){if(!P.id){let D=a.idsToInsert||(a.idsToInsert=[]);P.id=D.push(P)}de[ne++]=214,de[ne++]=112,Nr.setUint32(ne,P.id),ne+=4;return}else a.set(b,{offset:ne-r})}let C=b.constructor;if(C===Object)A(b,!0);else if(C===Array){T=b.length,T<16?de[ne++]=144|T:T<65536?(de[ne++]=220,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=221,Nr.setUint32(ne,T),ne+=4);for(let P=0;P<T;P++)S(b[P])}else if(C===Map){T=b.size,T<16?de[ne++]=128|T:T<65536?(de[ne++]=222,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);for(let[P,D]of b)S(P),S(D)}else{for(let P=0,D=Ry.length;P<D;P++){let I=zw[P];if(b instanceof I){let R=Ry[P];if(R.write){R.type&&(de[ne++]=212,de[ne++]=R.type,de[ne++]=0),S(R.write.call(this,b));return}let U=de,F=Nr,V=ne;de=null;let G;try{G=R.pack.call(this,b,H=>(de=U,U=null,ne+=H,ne>Zs&&E(ne),{target:de,targetView:Nr,position:ne-H}),S)}finally{U&&(de=U,Nr=F,ne=V,Zs=de.length-10)}G&&(G.length+ne>Zs&&E(G.length+ne),ne=QW(G,de,ne,R.type));return}}A(b,!b.hasOwnProperty)}}else if(M==="boolean")de[ne++]=b?195:194;else if(M==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))de[ne++]=211,Nr.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)de[ne++]=207,Nr.setBigUint64(ne,b);else if(this.largeBigIntToFloat)de[ne++]=203,Nr.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(M==="undefined")this.encodeUndefinedAsNil?de[ne++]=192:(de[ne++]=212,de[ne++]=0,de[ne++]=0);else if(M==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?b=>{let M=Object.keys(b),T=M.length;T<16?de[ne++]=128|T:T<65536?(de[ne++]=222,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);let C;for(let P=0;P<T;P++)S(C=M[P]),S(b[C])}:(b,M)=>{de[ne++]=222;let T=ne-r;ne+=2;let C=0;for(let P in b)(M||b.hasOwnProperty(P))&&(S(P),S(b[P]),C++);de[T+++r]=C>>8,de[T+r]=C&255}:b=>{let M=Object.keys(b),T,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let I=0,R=M.length;I<R;I++){let U=M[I];T=C[U],T||(T=C[U]=Object.create(null),P++),C=T}let D=C[pp];if(D)D>=96&&m?(de[ne++]=((D-=96)&31)+96,de[ne++]=D>>5):de[ne++]=D;else{D=o.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(D=o.nextOwnId,D<y||(D=g),o.nextOwnId=D+1):(D>=y&&(D=g),o.nextId=D+1);let I=M.highByte=D>=96&&m?D-96>>5:-1;C[pp]=D,o[D-64]=M,D<g?(M.isShared=!0,o.sharedLength=D-63,s=!0,I>=0?(de[ne++]=(D&31)+96,de[ne++]=I):de[ne++]=D):(I>=0?(de[ne++]=213,de[ne++]=114,de[ne++]=(D&31)+96,de[ne++]=I):(de[ne++]=212,de[ne++]=114,de[ne++]=D),P&&(x+=w*P),v.length>=p&&(v.shift()[pp]=0),v.push(C),S(M))}for(let I=0,R=M.length;I<R;I++)S(b[M[I]])},E=b=>{let M;if(b>16777216){if(b-r>LP)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(LP,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(b-r<<2,de.length-1)>>12)+1<<12;let T=new Vw(M);return Nr=new DataView(T.buffer,0,M),de.copy?de.copy(T,0,r,b):T.set(de.slice(r,b)),ne-=r,r=0,Zs=T.length-10,de=T}}useBuffer(t){de=t,Nr=new DataView(de.buffer,de.byteOffset,de.byteLength),ne=0}};zw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,fp];Ry=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:o}=t(6);n[o++]=214,n[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:o}=t(10);n[o++]=215,n[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:n,targetView:s,position:o}=t(3);n[o++]=212,n[o++]=255,n[o++]=255}else{let{target:n,targetView:s,position:o}=t(15);n[o++]=199,n[o++]=12,n[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?NP(i,16,t):BP(Ly?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==FP&&this.structuredClone?NP(i,kw.indexOf(e.name),t):BP(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function NP(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:s,position:o}=e(4+n);s[o++]=199,s[o++]=n+1}else if(n+1<65536){var{target:s,position:o}=e(5+n);s[o++]=200,s[o++]=n+1>>8,s[o++]=n+1&255}else{var{target:s,position:o,targetView:a}=e(7+n);s[o++]=201,a.setUint32(o,n+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function BP(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:s}=t(e+5);r[n++]=198,s.setUint32(n,e),n+=4}r.set(i,n)}function QW(i,t,e,r){let n=i.length;switch(n){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function KW(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+r,s,n),r-=6;let a=s+r;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,n=s}return i}function qa(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");zw.unshift(i.Class),Ry.unshift(i)}RP(i)}var kP=new oc({useRecords:!1}),ZW=kP.pack,JW=kP.pack;var{NEVER:$W,ALWAYS:e6,DECIMAL_ROUND:t6,DECIMAL_FIT:r6}=Iy,VP=512,n6=1024;var zP=new oc({structuredClone:!0});qa({Class:rt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,rt.prototype),i}});qa({Class:Le.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Le.prototype),i}});qa({Class:pr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,pr.prototype),i}});qa({Class:hp.prototype.constructor,type:4,write(i){return i.id},read(i){return new hp(i)}});qa({Class:dp.prototype.constructor,type:5,write(i){return i.data},read(i){return new dp(i)}});qa({Class:Jt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Jt.prototype),i}});function i6(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Uw(i){if(lh(i))return i;if(Array.isArray(i))return i.map(Uw);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Uw(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var Ny;(r=>{function i(n){return zP.pack(n)}r.serialize=i;function t(n){return zP.unpack(n)}r.deserialize=t;function e(n){return i6(i(Uw(n))).toString()}r.checksum=e})(Ny||(Ny={}));var UP;(e=>{function i(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=i;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(UP||(UP={}));var di={["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","Reset","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"]},GP;(e=>{function i(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=i;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new Le}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new Le}}e.defaultData=t})(GP||(GP={}));var By;(e=>{function i(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(By||(By={}));var Gw;(r=>{function i(n){return{type:"Comparison",operator:"==",lOperand:By.propertyDefaultData(n),rOperand:{...By.valueDefaultData}}}r.comparisonDefaultData=i;function t(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}}r.distanceDefaultData=t;function e(n,s){return{type:"State",object:n??null,state:s??null}}r.stateDefaultData=e})(Gw||(Gw={}));var HP;(e=>{function i(r){return r.type==="Conditional"}e.is=i;function t(r){return{type:"Conditional",disabled:!1,inActions:new Le,outActions:new Le,condition:Gw.distanceDefaultData(r)}}e.defaultData=t})(HP||(HP={}));var jP;(t=>t.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 Le,drop:new Le}})(jP||(jP={}));var Fy;(t=>t.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 Le})(Fy||(Fy={}));var ky;(t=>t.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})(ky||(ky={}));var WP;(e=>{function i(r){return r.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Le}}e.defaultData=t})(WP||(WP={}));var qP;(e=>{function i(r){return r.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Le}}e.defaultData=t})(qP||(qP={}));var YP;(e=>{function i(r){return r.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Le}}e.defaultData=t})(YP||(YP={}));var XP;(e=>{function i(r){return r.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Le}}e.defaultData=t})(XP||(XP={}));var QP;(e=>{function i(r){return r.type==="Trigger"}e.is=i;function t(r,n){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Le,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(QP||(QP={}));var Vy;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function n(){let a={size:"mobile",operator:"<",actions:new Le},l={size:"tablet",operator:"<",actions:new Le},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Le},c=new Le;return c.push({id:Se.generateUUID(),fi:0,data:a},{id:Se.generateUUID(),fi:1,data:l},{id:Se.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=n;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Le}}o.defaultBreakpointData=s})(Vy||(Vy={}));var zy;(r=>{r.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(n){return n.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Le,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(zy||(zy={}));var Qi="personal camera",Xa="a218fcc3-276b-49b9-b485-49037fd14f5f",JP=2960946,an=5526619;var ac;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s]}e.lerp=t})(ac||(ac={}));var $s;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=r;function n(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=n;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})($s||($s={}));var mp;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}e.lerp=t})(mp||(mp={}));var Ya;(n=>{n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}n.isEqual=t;function e(s){return s??n.identity}n.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}n.applyMatrix4=r})(Ya||(Ya={}));var An;(c=>{function i(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function n(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}c.toRgb255a1=n;function s(h){return{r:h.r,g:h.g,b:h.b}}c.clone=s;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}c.fromHex=o;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}c.toHex=a;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}c.equals=l;function u(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f}}c.lerp=u})(An||(An={}));var ri;(a=>{a.white={...An.white,a:1},a.transparent={...An.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function r(l,u){return{...An.fromHex(l),a:u}}a.fromHexAndA=r;function n(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=n;function s(l,u){return An.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(ri||(ri={}));var Uy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Uy||(Uy={}));var KP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(KP||(KP={}));var ZP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(ZP||(ZP={}));var $o;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))($o||($o={}));function $P(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var bs;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(bs||(bs={}));var Qa;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}n.getZoom=r})(Qa||(Qa={}));var eo;(e=>{function i(r,n=.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]*n,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+n)),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=i;function t(r,n){let s={...r};if(Hw.forEach(o=>{Object.assign(s,{[o]:n[o]??r[o]})}),s.radial={...r.radial},n.radial){let o=r.radial,a=n.radial;jw.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},n.linear){let o=r.linear,a=n.linear;Ww.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},n.grid){let o=r.grid,a=n.grid;qw.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},n.toObject){let o=r.toObject,a=n.toObject;Yw.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},n.randomnessObject){let o=r.randomnessObject,a=n.randomnessObject;Xw.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(eo||(eo={}));var Gy;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(n,s){let o=[];n.count!==void 0&&o.push({type:0,path:s,props:{count:n.count}});for(let a of t){let l=n[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(Gy||(Gy={}));var Hw=["count"],jw=["radius","start","end","position","scale","rotation"],Ww=["position","scale","rotation"],qw=["count","size"],Yw=["count","position","scale","rotation"],Xw=["strength","scale","rotation","position","movement","seed","freqScale"];var Hy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Hy||(Hy={}));var jy;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:ri.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:ri.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:ri.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(jy||(jy={}));var Ka;(t=>t.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]})(Ka||(Ka={}));var Qw;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(Qw||(Qw={}));var Kw;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(Kw||(Kw={}));var Wy;(t=>t.defaultData={...Kw.defaultData,...Qw.defaultData})(Wy||(Wy={}));var e2;(t=>{function i(e,r){let n=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&n.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&n.push(o)}return n}t.getMaterialData=i})(e2||(e2={}));var ph;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ph||(ph={}));var t2;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(t2||(t2={}));function n2(i){return i.type!=="displace"}var r2;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(r2||(r2={}));var qy=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],i2=["wrapping","image","video","name"],_n;(n=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}n.patch=i;function t(s,o){return s==="light"&&o?e(o):r(s)}n.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,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{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ph.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:An.fromHex(an)};case"depth":return{...o,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{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,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{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...An.fromHex(6710886),a:1},colorB:{...An.fromHex(6710886),a:1},colorC:{...An.fromHex(16777215),a:1},colorD:{...An.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{...o,type:"fresnel",color:ri.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,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:ri.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:ri.fromHexAndA(0,1),contourColor:ri.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{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,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{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...An.fromHex(0),a:1},colorB:{...An.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}}}})(_n||(_n={}));var Br;(l=>{function i(u){return!u.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([d,f])=>{c+=`${d}${f}`,Array.isArray(f)?f.forEach(p=>c+=`${p}`):typeof f=="object"?Object.values(f).forEach(p=>{typeof p=="number"?c+=`${p.toFixed(4)}`:c+=`${p}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new Le}}l.defaultEmptyData=e;function r(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=r;function n(u,c){return{...u,name:c}}l.withName=n;function s(u,c="layer1",h="layer2"){let d=new Le;return d.push({fi:0,data:_n.defaultData("light",u),id:c}),d.push({fi:1,data:_n.defaultData("color"),id:h}),{layers:d}}l.defaultTwoLayerData=s;function o(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("video");Object.assign(f.texture,{video:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Br||(Br={}));var mh;(t=>{function i(){return{points:new Le,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(mh||(mh={}));var gh;(t=>{function i(){return{points:new Le,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(gh||(gh={}));var Zw={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Yy;(t=>{function i(e,r){let n={...e};return Jw.forEach(s=>{Object.assign(n,{[s]:r[s]??e[s]})}),n}t.merge=i})(Yy||(Yy={}));var Xy={shape:Zw,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},Jw=["depth","offset","angle","twist","startScale","endScale"];var gp;(e=>{function i(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=i;function t(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=t})(gp||(gp={}));var Qy;(t=>{function i(e,r){let n={...e};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...e.extrusion},Object.assign(n.extrusion,Yy.merge(n.extrusion,r.extrusion))),n}t.merge=i})(Qy||(Qy={}));var Za;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:gh.defaultData(),extrusion:Xy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:mh.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,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(e==="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")}t.defaultData=i})(Za||(Za={}));var $w=["width","height","depth"];var Ky;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:An.white,near:.1,far:2e3})(Ky||(Ky={}));var yh;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(yh||(yh={}));var eS;(t=>t.defaultData={softShadowQuality:"low"})(eS||(eS={}));var tS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(tS||(tS={}));var rS;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(rS||(rS={}));var Ja;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ja||(Ja={}));var nS;(t=>t.defaultData={playCamera:Qi,gameControlObject:null})(nS||(nS={}));var Zy;(t=>t.defaultData={backgroundColor:ri.fromHexAndA(JP,1),postprocessing:yh.defaultData,fog:Ky.defaultData,globalPhysics:Ja.defaultData,ambient:tS.defaultData,ao:rS.defaultData,shadow:eS.defaultData,publish:nS.defaultData})(Zy||(Zy={}));var s2;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(s2||(s2={}));var vh;(n=>{n.identity={...Uy.identity,hiddenMatrix:Ya.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}n.merge=e;function r(s,o){return KC({position:$s.isEqual(s.position,o.position)?void 0:o.position,rotation:$s.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:$s.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Ya.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}n.diff=r})(vh||(vh={}));var Fn;(t=>t.defaultData={states:new Le,events:new Le,visible:!0,raycastLock:!1,physics:Ka.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...vh.identity,cloner:null})(Fn||(Fn={}));var Jy;(t=>t.defaultData={type:"Empty",...Fn.defaultData})(Jy||(Jy={}));var o2;(t=>t.defaultData={type:"Component",...Fn.defaultData})(o2||(o2={}));var lc;(t=>t.defaultData={type:"Mesh",...Fn.defaultData,...Wy.defaultData})(lc||(lc={}));var cc;(t=>t.defaultData={...Fn.defaultData,...vh.identity,position:[0,0,Qa.DefaultTargetOffset],...Qa.defaultData})(cc||(cc={}));var $y;(e=>{function i(r){return{...Fn.defaultData,...jy.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($y||($y={}));var xh;(e=>{function i(r,n,s=0){for(;s<n.length;){let o=r?r[n[s]]:void 0;if(n.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(r,n,s=0){let o=i(r,n,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(xh||(xh={}));var to;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...Fn.defaultData,...a,component:o,overrides:new Jt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function n(o){let a=vh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=n})(to||(to={}));var ea;(t=>t.defaultData={type:"Page",...Fn.defaultData,physics:{...Ka.defaultData,fusedBody:!1},...Zy.defaultData,camera:cc.defaultData})(ea||(ea={}));var ev;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ya.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Ka.defaultData,states:new Le,events:new Le,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Qa.defaultData},s.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"]},s.defaultMeshObject={name:"Rectangle",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("RectangleGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("BooleanGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("TextGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")}))(ev||(ev={}));var ta;(n=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Jt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Jt})))):bs.is(s.type)&&(a.perspective={},a.orthographic={}),a}n.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Ha(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let h=l.layers.data(u);h&&_n.patch(h,c)}}).data),a.materials&&o.materials&&(a.materials=Ha(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[h,d]of Object.entries(c.layers)){let f=l[u]?.layers?.data(h);f&&_n.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...Gy.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))c(["materials",f],p);else if(u[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}n.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,vh.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),bs.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Qy.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:eo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:eo.merge(a.cloner,o.cloner)});else if(Hy.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=An.clone(l.color))}return a}n.patch=r})(ta||(ta={}));var wh;(t=>t.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})(wh||(wh={}));var ro;(t=>t.defaultData={orbitControls:wh.defaultData,playPage:Xa,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let n=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?n=30:(r===4||r===11||r===9)&&(n=-30),[120,[n,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})(ro||(ro={}));var iS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(iS||(iS={}));var sS;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(sS||(sS={}));var $a;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...iS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:sS.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))($a||($a={}));var el;(e=>{function i(r){return r.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,n,s){r.scene.objects.traverseFrom(n,(o,a)=>{if(a.type==="Instance"){let l=Sh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(el||(el={}));var tl;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=ev.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:$y.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let h=new pr;return h.push({fi:1,id:Xa,data:{...ea.defaultData,name:"Scene 1"},children:u}),h}a.defaultData={objects:t(),publish:ro.defaultData,styles:$a.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new pr,publish:ro.defaultData,styles:$a.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:ro.defaultData,styles:$a.defaultData()}};function s(l){return{...a.defaultData,objects:ui(l,pr.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(tl||(tl={}));var Ah;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ah||(Ah={}));var _h;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(_h||(_h={}));var En;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function n(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=n})(En||(En={}));var oS;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(oS||(oS={}));var a2;(t=>t.all=[...oS.all,"components"])(a2||(a2={}));var l2;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(l2||(l2={}));var rl;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(rl||(rl={}));var fi;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ui(o,rt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={..._h.emptyImage,name:"AI generated image"}),ui(a,rt.prototype)}s.defaultImages=t;function e(){return{catelogs:new rt,materials:new rt,images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,variables:new Le,lib:rl.defaultData()}}s.emptyData=e;function r(o){switch(o){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 a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,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",o)}}s.defaultVariables=r;function n(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),u=Math.floor((o-l*3600)/60),c=Math.round(o-l*3600-u*60);return{textValue:[l,u,c]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),u=Math.round(o-l*60);return{textValue:[l,u]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=n})(fi||(fi={}));var Eh;(t=>t.list=["idle","move","jump","run"])(Eh||(Eh={}));var Mh;(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 Le,move:new Le,jump:new Le,run:new Le},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:ri.fromHexAndA(3728051,1)}}))(Mh||(Mh={}));function c2(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,n=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)n.push(n[1]),s.push(1);let o={...Ni(xr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...xr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ra(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function na(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=Br.defaultData(),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&t(n.material)})})}function o6(i){Object.assign(i.scene.publish,{orbitControls:{...wh.defaultData,...xr(i.scene.publish.orbitControls)}})}function a6(i){Object.assign(i.scene.publish.settings,{video:{...ro.defaultData.settings.video,...xr(i.scene.publish.settings.video)}})}function l6(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[n,s]of Object.entries(r))if((qy.includes(n)||typeof s=="boolean")&&delete r[n],n==="texture")for(let[o,a]of Object.entries(s))(i2.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(n=>{let s=n;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function c6(i){i.scene.publish.withBackground=!0}function u6(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function h6(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(n=>n+1),r.linear.scale=r.linear.scale.map(n=>n+1))})}function d6(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function f6(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let n=xr(i.scene.objects.data(r));n&&n.type==="Mesh"&&n.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=xr(e).booleanExclude!==!0)}})}function p6(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function m6(i){function t(r){Object.setPrototypeOf(r,Jt.prototype),r.texture&&Object.setPrototypeOf(r.texture,Jt.prototype)}function e(r){Object.setPrototypeOf(r,Jt.prototype);for(let n in r)t(r[n])}i.scene.objects.traverse((r,n)=>{n.states.forEach(s=>{let o=s;if(o.material){let a=xr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=xr(l).layers;e(u),l.layers=u}})})}function u2(i){i.layers===void 0&&Object.assign(i,Br.defaultTwoLayerData("lambert"))}function aS(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...xr(t),colors:e,steps:r};Object.assign(t,n)}})}function g6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function h2(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&aS(r)}):"material"in e&&typeof e.material!="string"&&aS(e.material)}),Object.values(i.shared.materials).forEach(t=>aS(t))}function y6(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function v6(i){i.shared.audios=ui({},rt.prototype)}function x6(i){i.shared.videos=ui({},rt.prototype)}function b6(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let n={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,{[e]:n})}})}function w6(i){Object.entries(xr(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(xr(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function S6(i){i.scene.publish.settings.web.preload=!1}function d2(i){i.layers&&i.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 f2(i){i.layers&&i.layers.forEach(t=>{n2(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 A6(i){i.shared.fonts=ui({},rt.prototype)}function _6(i){return i.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function E6(i){let t=[];i.scene.objects.traverse((e,r)=>{let n=r;if(n.type==="TextFrame"){let s=Br.defaultTwoLayerData("phong"),o=typeof n.color=="string"?i.shared.colors[n.color]:n.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=n.alpha;let a=_6(n.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:n.name,...Fn.defaultData,...lc.defaultData,flatShading:!1,wireframe:!1,geometry:{...Za.defaultData("TextGeometry"),width:n.width,height:n.height,font:a,depth:0,horizontalAlign:n.horizontalAlign,verticalAlign:n.verticalAlign,fontSize:n.fontSize*1.40625,lineHeight:n.lineHeight/1.40625,letterSpacing:n.letterSpacing-1,text:n.text,textTransform:n.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:xr(n.states),events:xr(n.events),visible:n.visible,raycastLock:n.raycastLock,position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix},u=xr(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function M6(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(n=>{if(!!t[Number(n.type)])if(Object.assign(n,{type:t[Number(n.type)]}),n.type==="Audio"&&"audioEvent"in n&&(Object.assign(n,{playAudio:n.audioEvent}),delete n.audioEvent),n.type==="GameControl")Object.assign(n,{gameActions:{idle:new Le,move:new Le,jump:new Le}});else{let s=new Le;Object.assign(n,{actions:s}),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp")&&"url"in n&&s.push({fi:0,id:Se.generateUUID(),data:{type:"Link",url:n.url,delay:0}}),"targets"in n&&(n.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Ni(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Le({fi:0,id:Se.generateUUID(),data:u},{fi:1,id:Se.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete n.targets)}})})}function T6(i){i.scene.objects.traverse((t,e)=>{function r(n,s){let o=new Le,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Ni(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")&&(h={...Ni(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===n)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Se.generateUUID(),data:{type:n,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function p2(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=_n.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function m2(i){ra(i,p2),na(i,p2)}function C6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function P6(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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 D6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Br.defaultTwoLayerData("phong"))})}function I6(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function O6(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function R6(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function L6(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function N6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function B6(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function F6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Mh.defaultDataThirdPerson.navmesh)})})}function k6(i){i.scene.styles||(i.scene.styles=$a.defaultData())}function g2(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function V6(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),na(i,g2),ra(i,g2)}function z6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Le})})})}function U6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function y2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function v2(i,t){if(t<1&&(na(i,c2),ra(i,c2),i.schema=1),t<2&&(o6(i),i.schema=2),t<3&&(l6(i),i.schema=3),t<4&&(c6(i),i.schema=4),t<5&&(u6(i),i.schema=5),t<6&&(h6(i),i.schema=6),t<7&&(d6(i),i.schema=7),t<8&&(i.schema=8),t<9&&(h2(i),i.schema=9),t<10&&(g6(i),i.schema=10),t<11&&(y6(i),i.schema=11),t<12&&(h2(i),i.schema=12),t<13&&(v6(i),i.schema=13),t<14&&(b6(i),i.schema=14),t<15&&(w6(i),i.schema=15),t<16&&(S6(i),i.schema=16),t<17&&(na(i,d2),ra(i,d2),i.schema=17),t<18&&(na(i,u2),ra(i,u2),i.schema=18),t<19&&(a6(i),i.schema=19),t<20&&(A6(i),E6(i),i.schema=20),t<21&&(M6(i),T6(i),i.schema=21),t<22&&(m2(i),i.schema=22),t<23&&(C6(i),i.schema=23),t<24&&(P6(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(x6(i),t<25&&(i.schema=25)),t<26&&(f6(i),i.schema=26),t<27&&(p6(i),i.schema=27),t<28&&(m2(i),i.schema=28),t<29&&(m6(i),i.schema=29),t<30&&(D6(i),i.schema=30),t<31&&(I6(i),i.schema=31),t<33&&(O6(i),i.schema=33),t<34&&(R6(i),i.schema=34),t<35&&(L6(i),i.schema=35),t<36&&(N6(i),i.schema=36),t<37&&(B6(i),i.schema=37),t<38&&(na(i,f2),ra(i,f2),i.schema=38),t<39&&(F6(i),i.schema=39),t<40&&(k6(i),i.schema=40),t<41&&(V6(i),i.schema=41),t<42&&(z6(i),i.schema=42),t<43&&(U6(i),i.schema=43),t<99){na(i,y2),ra(i,y2),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Qi);let e=xr(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Xa,r.insertBefore(null,null,[{id:Xa,data:{...ea.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Ni(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Ni(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ja.defaultData,...Ni(i.scene.environment,"usePhysics","gravity")},camera:xr(i.scene.ownerCamera)??ea.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==tl.TRASH_CAN_ID&&r.move(Xa,o.fi,o.id);let n=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(n,2)],n+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Ka.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function x2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function G6(i){i.scene.objects.traverse((t,e)=>{let r=e.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 Th=180/Math.PI;function b2(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Th)}function w2(i){b2(i),i.type==="Page"&&b2(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Th))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Th),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Th),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Th,t.extrusion.twist*=Th),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(xr(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Once")})}function H6(i){i.shared.variables=ui({},rt.prototype)}function j6(i){let t=xr(i.shared.variables);i.shared.variables=ui(Object.entries(t??{}).map(([e,r],n)=>({fi:n,id:e,data:r})),Le.prototype)}var ia=107;function S2(i,t){t(i.data);for(let e of i.children)S2(e,t)}function W6(i){let t=i.schema??104;t!==ia&&t<105&&(S2(i.asset,w2),i.schema=105)}function tv(i){let t=i.schema??0;if(t!==ia){console.warn("updating from ",t,"to ",ia),v2(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=ro.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(na(i,x2),ra(i,x2),i.schema=101),t<102&&(G6(i),i.schema=102),t<104&&(i.shared.catelogs=new rt,i.shared.lib=rl.defaultData(),i.schema=104),t<105&&(H6(i),i.scene.objects.traverse((e,r)=>{w2(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))W6(e);t<106&&(j6(i),i.schema=106),t<107&&(i.shared.lib.variables=rl.defaultData().variables,i.schema=107)}}var Sh;(a=>{a.defaultData={schema:ia,scene:tl.defaultData,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors()}},a.emptyDataForImports=function(l){let u=tl.emptyDataWithPage(l);return{schema:ia,scene:u,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors(),images:fi.defaultImages(l)}}},a.emptyData=function(){return{schema:ia,scene:tl.emptyDataWithPage(),frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:fi.emptyData()}},a.collabHelper={...up,updateSchema(l){return(l.schema??0)<ia?Ha(l,tv):(l.schema??0)-ia}};function n(l){let u=a.collabHelper.updateSchema(l);return typeof u=="number"?u===0?l:null:u.data}a.updateSchemaDirectly=n;function s(l){return{...l,shared:{...l.shared,lib:rl.defaultData()}}}a.withoutLib=s;function o(l,u){let c=l.scene.objects.get(u);if(c&&c.data.type==="Component")return c;{let h=l.shared.lib.components[u];if(h)return h.asset}}a.getComponentData=o})(Sh||(Sh={}));function ws(i,t=!1){let e=i[0].index!==null,r=new Set(Object.keys(i[0].attributes)),n=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ae,u=0;for(let c=0;c<i.length;++c){let h=i[c],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,h=[];for(let d=0;d<i.length;++d){let f=i[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+c);c+=i[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=A2(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][d]);let p=A2(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(p)}}return l}function A2(i){let t,e,r,n=0;for(let a=0;a<i.length;++a){let l=i[a];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(e===void 0&&(e=l.itemSize),e!==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;n+=l.array.length}let s=new t(n),o=0;for(let a=0;a<i.length;++a)s.set(i[a].array,o),o+=i[a].array.length;return new Ge(s,e,r)}var _2=Math.pow(2,-24);var uc=class{constructor(){}};function Ki(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function lS(i){let t=-1,e=-1/0;for(let r=0;r<3;r++){let n=i[r+3]-i[r];n>e&&(e=n,t=r)}return t}function cS(i,t){t.set(i)}function uS(i,t,e){let r,n;for(let s=0;s<3;s++){let o=s+3;r=i[s],n=t[s],e[s]=r<n?r:n,r=i[o],n=t[o],e[o]=r>n?r:n}}function yp(i,t,e){for(let r=0;r<3;r++){let n=t[i+2*r],s=t[i+2*r+1],o=n-s,a=n+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function Ch(i){let t=i[3]-i[0],e=i[4]-i[1],r=i[5]-i[2];return 2*(t*e+e*r+r*t)}function X6(i,t){if(!i.index){let e=i.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n;e>65535?n=new Uint32Array(new r(4*e)):n=new Uint16Array(new r(2*e)),i.setIndex(new Ge(n,1));for(let s=0;s<e;s++)n[s]=s}}function Q6(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let n of i.groups)e.add(n.start),e.add(n.start+n.count);let r=Array.from(e.values()).sort((n,s)=>n-s);for(let n=0;n<r.length-1;n++){let s=r[n],o=r[n+1];t.push({offset:s/3,count:(o-s)/3})}return t}function dS(i,t,e,r,n=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=n!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let w=i[v+0],S=i[v+1],A=w-S,E=w+S;A<s&&(s=A),E>l&&(l=E),y&&w<h&&(h=w),y&&w>p&&(p=w);let b=i[v+2],M=i[v+3],T=b-M,C=b+M;T<o&&(o=T),C>u&&(u=C),y&&b<d&&(d=b),y&&b>m&&(m=b);let P=i[v+4],D=i[v+5],I=P-D,R=P+D;I<a&&(a=I),R>c&&(c=R),y&&P<f&&(f=P),y&&P>g&&(g=P)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=u,r[5]=c,y&&(n[0]=h,n[1]=d,n[2]=f,n[3]=p,n[4]=m,n[5]=g)}function K6(i,t,e,r){let n=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,h=(t+e)*6;c<h;c+=6){let d=i[c+0];d<n&&(n=d),d>a&&(a=d);let f=i[c+2];f<s&&(s=f),f>l&&(l=f);let p=i[c+4];p<o&&(o=p),p>u&&(u=p)}r[0]=n,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=u}function Z6(i,t,e,r,n){let s=e,o=e+r-1,a=n.pos,l=n.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=i[s*3+u];i[s*3+u]=i[o*3+u],i[o*3+u]=c;let h=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=h;let d=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=d}s++,o--}else return s}}var sa=32,J6=(i,t)=>i.candidate-t.candidate,nl=new Array(sa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),rv=new Float32Array(6);function $6(i,t,e,r,n,s){let o=-1,a=0;if(s===0)o=lS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=lS(i),o!==-1&&(a=e8(e,r,n,o));else if(s===2){let l=Ch(i),u=1.25*n,c=r*6,h=(r+n)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/sa;if(n<sa/4){let y=[...nl];y.length=n;let v=0;for(let w=c;w<h;w+=6,v++){let S=y[v];S.candidate=e[w+2*d],S.count=0;let{bounds:A,leftCacheBounds:E,rightCacheBounds:b}=S;for(let M=0;M<3;M++)b[M]=1/0,b[M+3]=-1/0,E[M]=1/0,E[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;yp(w,e,A)}y.sort(J6);let x=n;for(let w=0;w<x;w++){let S=y[w];for(;w+1<x&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),x--}for(let w=c;w<h;w+=6){let S=e[w+2*d];for(let A=0;A<x;A++){let E=y[A];S>=E.candidate?yp(w,e,E.rightCacheBounds):(yp(w,e,E.leftCacheBounds),E.count++)}}for(let w=0;w<x;w++){let S=y[w],A=S.count,E=n-S.count,b=S.leftCacheBounds,M=S.rightCacheBounds,T=0;A!==0&&(T=Ch(b)/l);let C=0;E!==0&&(C=Ch(M)/l);let P=1+1.25*(T*A+C*E);P<u&&(o=d,u=P,a=S.candidate)}}else{for(let x=0;x<sa;x++){let w=nl[x];w.count=0,w.candidate=f+g+x*g;let S=w.bounds;for(let A=0;A<3;A++)S[A]=1/0,S[A+3]=-1/0}for(let x=c;x<h;x+=6){let A=~~((e[x+2*d]-f)/g);A>=sa&&(A=sa-1);let E=nl[A];E.count++,yp(x,e,E.bounds)}let y=nl[sa-1];cS(y.bounds,y.rightCacheBounds);for(let x=sa-2;x>=0;x--){let w=nl[x],S=nl[x+1];uS(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;x<sa-1;x++){let w=nl[x],S=w.count,A=w.bounds,b=nl[x+1].rightCacheBounds;S!==0&&(v===0?cS(A,rv):uS(A,rv,rv)),v+=S;let M=0,T=0;v!==0&&(M=Ch(rv)/l);let C=n-v;C!==0&&(T=Ch(b)/l);let P=1+1.25*(M*v+T*C);P<u&&(o=d,u=P,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function e8(i,t,e,r){let n=0;for(let s=t,o=t+e;s<o;s++)n+=i[s*6+r*2];return n/e}function t8(i,t){let e=i.attributes.position,r=i.index.array,n=r.length/3,s=new Float32Array(n*6),o=e.normalized,a=e.array,l=e.offset||0,u=3;e.isInterleavedBufferAttribute&&(u=e.data.stride);let c=["getX","getY","getZ"];for(let h=0;h<n;h++){let d=h*3,f=h*6,p,m,g;o?(p=r[d+0],m=r[d+1],g=r[d+2]):(p=r[d+0]*u+l,m=r[d+1]*u+l,g=r[d+2]*u+l);for(let y=0;y<3;y++){let v,x,w;o?(v=e[c[y]](p),x=e[c[y]](m),w=e[c[y]](g)):(v=a[p+y],x=a[m+y],w=a[g+y]);let S=v;x<S&&(S=x),w<S&&(S=w);let A=v;x>A&&(A=x),w>A&&(A=w);let E=(A-S)/2,b=y*2;s[f+b+0]=S+E,s[f+b+1]=E+(Math.abs(S)+E)*_2,S<t[y]&&(t[y]=S),A>t[y+3]&&(t[y+3]=A)}}return s}function r8(i,t){function e(y){d&&d(y/f)}function r(y,v,x,w=null,S=0){if(!p&&S>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let A=$6(y.boundingData,w,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let E=Z6(a,o,v,x,A);if(E===v||E===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new uc,M=v,T=E-v;y.left=b,b.boundingData=new Float32Array(6),dS(o,M,T,b.boundingData,s),r(b,M,T,s,S+1);let C=new uc,P=E,D=x-T;y.right=C,C.boundingData=new Float32Array(6),dS(o,P,D,C.boundingData,s),r(C,P,D,s,S+1)}return y}X6(i,t);let n=new Float32Array(6),s=new Float32Array(6),o=t8(i,n),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,m=[],g=Q6(i);if(g.length===1){let y=g[0],v=new uc;v.boundingData=n,K6(o,y.offset,y.count,s),r(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new uc;v.boundingData=new Float32Array(6),dS(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function T2(i,t){let e=r8(i,t),r,n,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let h=e[c],d=l(h),f=new a(32*d);r=new Float32Array(f),n=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(p){let g=h.offset,y=h.count;return n[d+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=h.left,y=h.right,v=h.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=x/4,x=u(x,y),n[d+7]=v,x}}}var pi=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,n=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}setFromPoints(t,e){let r=1/0,n=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};pi.prototype.setFromBox=function(){let i=new _;return function(e,r){let n=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=n.x*l+s.x*(1-l),i.y=n.y*u+s.y*(1-u),i.z=n.z*c+s.z*(1-c);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var lhe=function(){let i=new pi;return function(e,r){let n=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,u=r.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(i.setFromPoints(d,n),h.isSeparated(i))return!1}}}();var n8=function(){let i=new _,t=new _,e=new _;return function(n,s,o){let a=n.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(n.end,n.start),t.subVectors(s.end,s.start);let h=e.dot(c),d=c.dot(l),f=c.dot(c),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),vp=function(){let i=new N,t=new _,e=new _;return function(n,s,o,a){n8(n,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){n.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),n.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?n.at(0,o):n.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=n.start:c=n.end;let h;u<0?h=s.start:h=s.end;let d=t,f=e;if(n.closestPointToPoint(h,!0,t),s.closestPointToPoint(c,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),C2=function(){let i=new _,t=new _,e=new Or,r=new nn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(r.start=u,r.end=c,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var i8=1e-15;function Ph(i){return Math.abs(i)<i8}var mi=class extends dr{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _),this.satBounds=new Array(4).fill().map(()=>new pi),this.points=[this.a,this.b,this.c],this.sphere=new fr,this.plane=new Or,this.needsUpdate=!0}intersectsSphere(t){return C2(t,this)}update(){let t=this.a,e=this.b,r=this.c,n=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,n);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,n);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,n);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};mi.prototype.closestPointToSegment=function(){let i=new _,t=new _,e=new nn;return function(n,s=null,o=null){let{start:a,end:l}=n,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(u[d]),e.end.copy(u[f]),vp(e,n,i,t),c=i.distanceToSquared(t),c<h&&(h=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(h)}}();mi.prototype.intersectsTriangle=function(){let i=new mi,t=new Array(3),e=new Array(3),r=new pi,n=new pi,s=new _,o=new _,a=new _,l=new _,u=new nn,c=new nn,h=new nn;return function(f,p=null,m=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let E=v[A],b=x[A];if(r.setFromPoints(b,e),E.isSeparated(r))return!1}let w=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let E=w[A],b=S[A];if(r.setFromPoints(b,t),E.isSeparated(r))return!1}for(let A=0;A<4;A++){let E=x[A];for(let b=0;b<4;b++){let M=S[b];if(s.crossVectors(E,M),r.setFromPoints(s,t),n.setFromPoints(s,e),r.isSeparated(n))return!1}}return p&&(m||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,x=!1,w=0;for(let I=0;I<3;I++){let R=v[I],U=v[(I+1)%3];u.start.copy(R),u.end.copy(U),u.delta(o);let F=x?c.start:c.end,V=Ph(y.distanceToPoint(R));if(Ph(y.normal.dot(o))&&V){c.copy(u),w=2;break}if((y.intersectLine(u,F)||V)&&!Ph(F.distanceTo(U))){if(w++,x)break;x=!0}}if(w===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(w!==2)return!1;let S=f.points,A=!1,E=0;for(let I=0;I<3;I++){let R=S[I],U=S[(I+1)%3];u.start.copy(R),u.end.copy(U),u.delta(a);let F=A?h.start:h.end,V=Ph(g.distanceToPoint(R));if(Ph(g.normal.dot(a))&&V){h.copy(u),E=2;break}if((g.intersectLine(u,F)||V)&&!Ph(F.distanceTo(U))){if(E++,A)break;A=!0}}if(E===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(E!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let b=c.start.dot(o),M=c.end.dot(o),T=h.start.dot(o),C=h.end.dot(o),P=M<T,D=b<C;return b!==C&&T!==M&&P===D?!1:(p&&(l.subVectors(c.start,h.start),l.dot(o)>0?p.start.copy(c.start):p.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(h.end)),!0)}}}();mi.prototype.distanceToPoint=function(){let i=new _;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();mi.prototype.distanceToTriangle=function(){let i=new _,t=new _,e=["a","b","c"],r=new nn,n=new nn;return function(o,a=null,l=null){let u=a||l?r:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),d<c&&(c=d,a&&a.copy(i),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,i),d=m.distanceToSquared(i),d<c&&(c=d,a&&a.copy(m),l&&l.copy(i))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];n.set(o[m],o[g]),vp(r,n,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var gi=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new _,this.max=new _,this.matrix=new ie,this.invMatrix=new ie,this.points=new Array(8).fill().map(()=>new _),this.satAxes=new Array(3).fill().map(()=>new _),this.satBounds=new Array(3).fill().map(()=>new pi),this.alignedSatBounds=new Array(3).fill().map(()=>new pi),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};gi.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,n=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=n[d];f.x=u?r.x:e.x,f.y=c?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=n[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<<u,f=n[d];c.subVectors(a,f),h.setFromPoints(c,n)}let l=this.alignedSatBounds;l[0].setFromPointsField(n,"x"),l[1].setFromPointsField(n,"y"),l[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();gi.prototype.intersectsBox=function(){let i=new pi;return function(e){this.needsUpdate&&this.update();let r=e.min,n=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=r.x,i.max=n.x,a[0].isSeparated(i)||(i.min=r.y,i.max=n.y,a[1].isSeparated(i))||(i.min=r.z,i.max=n.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(i.setFromBox(u,e),c.isSeparated(i))return!1}return!0}}();gi.prototype.intersectsTriangle=function(){let i=new mi,t=new Array(3),e=new pi,r=new pi,n=new _;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],p=c[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=c[p];if(n.crossVectors(f,m),e.setFromPoints(n,t),r.setFromPoints(n,h),e.isSeparated(r))return!1}}return!0}}();gi.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();gi.prototype.distanceToPoint=function(){let i=new _;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();gi.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new nn),e=new Array(12).fill().map(()=>new nn),r=new _,n=new _;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(n),this.closestPointToPoint(n,r),o.closestPointToPoint(r,n),l&&l.copy(r),u&&u.copy(n)),0;let c=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];n.copy(y).clamp(h,d);let v=y.distanceToSquared(n);if(v<p&&(p=v,l&&l.copy(y),u&&u.copy(n),v<c))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,w=(g+2)%3,S=y<<x|v<<w,A=1<<g|y<<x|v<<w,E=f[S],b=f[A];t[m].set(E,b);let T=i[g],C=i[x],P=i[w],D=e[m],I=D.start,R=D.end;I[T]=h[T],I[C]=y?h[C]:d[C],I[P]=v?h[P]:d[C],R[T]=d[T],R[C]=y?h[C]:d[C],R[P]=v?h[P]:d[C],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){n.x=g?d.x:h.x,n.y=y?d.y:h.y,n.z=v?d.z:h.z,this.closestPointToPoint(n,r);let x=n.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),u&&u.copy(n),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];vp(y,x,r,n);let w=r.distanceToSquared(n);if(w<p&&(p=w,l&&l.copy(r),u&&u.copy(n),w<c))return Math.sqrt(w)}}return Math.sqrt(p)}}();var Dh=new _,Ih=new _,Oh=new _,iv=new N,sv=new N,ov=new N,P2=new _,D2=new _,I2=new _,av=new _;function s8(i,t,e,r,n,s){let o;return s===Qr?o=i.intersectTriangle(r,e,t,!0,n):o=i.intersectTriangle(t,e,r,s!==Ln,n),o===null?null:{distance:i.origin.distanceTo(n),point:n.clone()}}function o8(i,t,e,r,n,s,o,a,l){Dh.fromBufferAttribute(t,s),Ih.fromBufferAttribute(t,o),Oh.fromBufferAttribute(t,a);let u=s8(i,Dh,Ih,Oh,av,l);if(u){r&&(iv.fromBufferAttribute(r,s),sv.fromBufferAttribute(r,o),ov.fromBufferAttribute(r,a),u.uv=dr.getInterpolation(av,Dh,Ih,Oh,iv,sv,ov,new N)),n&&(iv.fromBufferAttribute(n,s),sv.fromBufferAttribute(n,o),ov.fromBufferAttribute(n,a),u.uv1=dr.getInterpolation(av,Dh,Ih,Oh,iv,sv,ov,new N)),e&&(P2.fromBufferAttribute(e,s),D2.fromBufferAttribute(e,o),I2.fromBufferAttribute(e,a),u.normal=dr.getInterpolation(av,Dh,Ih,Oh,P2,D2,I2,new _),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new _,materialIndex:0};dr.getNormal(Dh,Ih,Oh,c.normal),u.face=c,u.faceIndex=s}return u}function pS(i,t,e,r,n){let s=r*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:h,uv1:d}=i.attributes,f=o8(e,u,c,h,d,o,a,l,t);return f?(f.faceIndex=r,n&&n.push(f),f):null}function O2(i,t,e,r,n,s){for(let o=r,a=r+n;o<a;o++)pS(i,t,e,o,s)}function R2(i,t,e,r,n){let s=1/0,o=null;for(let a=r,l=r+n;a<l;a++){let u=pS(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Zi(i,t,e,r){let n=i.a,s=i.b,o=i.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),n.x=r.getX(a),n.y=r.getY(a),n.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(u),o.y=r.getY(u),o.z=r.getZ(u)}function mS(i,t,e,r,n,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Zi(o,u*3,a,l),o.needsUpdate=!0,r(o,u,n,s))return!0;return!1}var Rh=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function oa(i,t){return t[i+15]===65535}function hc(i,t){return t[i+6]}function Lh(i,t){return t[i+14]}function Nh(i){return i+8}function Bh(i,t){return t[i+6]}function L2(i,t){return t[i+7]}var Fh=new Pt,cv=new _,l8=["x","y","z"];function uv(i,t,e,r,n){let s=i*2,o=kh,a=il,l=sl;if(oa(s,a)){let c=hc(i,l),h=Lh(s,a);O2(t,e,r,c,h,n)}else{let c=Nh(i);dv(c,o,r,cv)&&uv(c,t,e,r,n);let h=Bh(i,l);dv(h,o,r,cv)&&uv(h,t,e,r,n)}}function hv(i,t,e,r){let n=i*2,s=kh,o=il,a=sl;if(oa(n,o)){let u=hc(i,a),c=Lh(n,o);return R2(t,e,r,u,c)}else{let u=L2(i,a),c=l8[u],d=r.direction[c]>=0,f,p;d?(f=Nh(i),p=Bh(i,a)):(f=Bh(i,a),p=Nh(i));let g=dv(f,s,r,cv)?hv(f,t,e,r):null;if(g){let x=g.point[c];if(d?x<=s[p+u]:x>=s[p+u+3])return g}let v=dv(p,s,r,cv)?hv(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var N2=function(){let i,t,e=[],r=new Rh(()=>new Pt);return function(...o){i=r.getPrimitive(),t=r.getPrimitive(),e.push(i,t);let a=n(...o);r.releasePrimitive(i),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function n(s,o,a,l,u=null,c=0,h=0){function d(x){let w=x*2,S=il,A=sl;for(;!oa(w,S);)x=Nh(x),w=x*2;return hc(x,A)}function f(x){let w=x*2,S=il,A=sl;for(;!oa(w,S);)x=Bh(x,A),w=x*2;return hc(x,A)+Lh(w,S)}let p=s*2,m=kh,g=il,y=sl;if(oa(p,g)){let x=hc(s,y),w=Lh(p,g);return Ki(s,m,i),l(x,w,!1,h,c+s,i)}else{let x=Nh(s),w=Bh(s,y),S=x,A=w,E,b,M,T;if(u&&(M=i,T=t,Ki(S,m,M),Ki(A,m,T),E=u(M),b=u(T),b<E)){S=w,A=x;let F=E;E=b,b=F,M=T}M||(M=i,Ki(S,m,M));let C=oa(S*2,g),P=a(M,C,E,h+1,c+S),D;if(P===2){let F=d(S),G=f(S)-F;D=l(F,G,!0,h+1,c+S,M)}else D=P&&n(S,o,a,l,u,c,h+1);if(D)return!0;T=t,Ki(A,m,T);let I=oa(A*2,g),R=a(T,I,b,h+1,c+A),U;if(R===2){let F=d(A),G=f(A)-F;U=l(F,G,!0,h+1,c+A,T)}else U=R&&n(A,o,a,l,u,c,h+1);return!!U}}}(),B2=function(){let i=new mi,t=new mi,e=new ie,r=new gi,n=new gi;return function s(o,a,l,u,c=null){let h=o*2,d=kh,f=il,p=sl;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,u),c=r),oa(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,w=l.attributes.position,S=hc(o,p),A=Lh(h,f);if(e.copy(u).invert(),l.boundsTree)return Ki(o,d,n),n.matrix.copy(e),n.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>n.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let M=S*3,T=(A+S)*3;M<T;M+=3)if(Zi(t,M,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let E=S*3,b=A+S*3;E<b;E+=3){Zi(i,E,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let M=0,T=x.count;M<T;M+=3)if(Zi(t,M,x,w),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return Ki(g,d,Fh),!!(c.intersectsBox(Fh)&&s(g,a,l,u,c)||(Ki(y,d,Fh),c.intersectsBox(Fh)&&s(y,a,l,u,c)))}}}();function dv(i,t,e,r){return Ki(i,t,Fh),e.intersectBox(Fh,r)}var gS=[],lv,kh,il,sl;function Vh(i){lv&&gS.push(lv),lv=i,kh=new Float32Array(i),il=new Uint16Array(i),sl=new Uint32Array(i)}function xp(){lv=null,kh=null,il=null,sl=null,gS.length&&Vh(gS.pop())}var yS=Symbol("skip tree generation"),vS=new Pt,xS=new Pt,zh=new ie,dc=new gi,bp=new gi,wp=new _,fv=new _,c8=new _,u8=new _,h8=new _,F2=new Pt,no=new Rh(()=>new mi),io=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),io.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,n=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:n.map(a=>a.slice()),index:s.array.slice()}:o={roots:n,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),io.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:n,roots:s}=t,o=new io(e,{...r,[yS]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==n&&(a.array.set(n),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[yS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[yS]||(this._roots=T2(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Pt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,n=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let d=0,f=c.length;d<f;d++)s=c[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,u),u+=s.byteLength;function h(d,f,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,w=1/0,S=1/0,A=-1/0,E=-1/0,b=-1/0;for(let M=3*y,T=3*(y+v);M<T;M++){let C=r[M],P=n.getX(C),D=n.getY(C),I=n.getZ(C);P<x&&(x=P),P>A&&(A=P),D<w&&(w=D),D>E&&(E=D),I<S&&(S=I),I>b&&(b=I)}return l[d+0]!==x||l[d+1]!==w||l[d+2]!==S||l[d+3]!==A||l[d+4]!==E||l[d+5]!==b?(l[d+0]=x,l[d+1]=w,l[d+2]=S,l[d+3]=A,l[d+4]=E,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,w=v+f,S=p,A=!1,E=!1;t?S||(A=t.has(x),E=t.has(w),S=!A&&!E):(A=!0,E=!0);let b=S||A,M=S||E,T=!1;b&&(T=h(y,f,S));let C=!1;M&&(C=h(v,f,S));let P=T||C;if(P)for(let D=0;D<3;D++){let I=y+D,R=v+D,U=l[I],F=l[I+3],V=l[R],G=l[R+3];l[d+D]=U<V?U:V,l[d+D+3]=F>G?F:G}return P}}}traverse(t,e=0){let r=this._roots[e],n=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=n[a+6],d=s[u+14];t(l,c,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=n[a+6],f=n[a+7];t(l,c,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Pi){let r=this._roots,n=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=n.groups,u=o?e.side:e;for(let c=0,h=r.length;c<h;c++){let d=a?e[l[c].materialIndex].side:u,f=s.length;if(Vh(r[c]),uv(0,n,d,t,s),xp(),a){let p=l[c].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=Pi){let r=this._roots,n=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=n.groups,u=s?e.side:e;for(let c=0,h=r.length;c<h;c++){let d=o?e[l[c].materialIndex].side:u;Vh(r[c]);let f=hv(0,n,d,t);xp(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,n=!1;for(let s of this._roots)if(Vh(s),n=B2(0,r,t,e),xp(),n)break;return n}shapecast(t,e,r){let n=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,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=no.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:mS(f,p,n,u,m,g,s)}else l||(u?l=(d,f,p,m)=>mS(d,f,n,u,p,m,s):l=(d,f,p)=>p);let c=!1,h=0;for(let d of this._roots){if(Vh(d),c=N2(0,n,a,l,o,h),xp(),c)break;h+=d.byteLength}return no.releasePrimitive(s),c}bvhcast(t,e,r){let{intersectsRanges:n,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;zh.copy(e).invert();let c=no.getPrimitive(),h=no.getPrimitive();if(s){let f=function(p,m,g,y,v,x,w,S){for(let A=g,E=g+y;A<E;A++){Zi(h,A*3,l,u),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let b=p,M=p+m;b<M;b++)if(Zi(c,b*3,o,a),c.needsUpdate=!0,s(c,h,b,A,v,x,w,S))return!0}return!1};if(n){let p=n;n=function(m,g,y,v,x,w,S,A){return p(m,g,y,v,x,w,S,A)?!0:f(m,g,y,v,x,w,S,A)}}else n=f}t.getBoundingBox(xS),xS.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>xS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(vS.copy(v),vS.applyMatrix4(zh),t.shapecast({intersectsBounds:x=>vS.intersectsBox(x),intersectsRange:(x,w,S,A,E)=>n(f,p,x,w,g,y,A,E)}))});return no.releasePrimitive(c),no.releasePrimitive(h),d}intersectsBox(t,e){return dc.set(t.min,t.max,e),dc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>dc.intersectsBox(r),intersectsTriangle:r=>dc.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),dc.set(t.boundingBox.min,t.boundingBox.max,e),dc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,h=t.index,d=no.getPrimitive(),f=no.getPrimitive(),p=fv,m=c8,g=null,y=null;n&&(g=u8,y=h8);let v=1/0,x=null,w=null;return zh.copy(e).invert(),bp.matrix.copy(zh),this.shapecast({boundsTraverseOrder:S=>dc.distanceToBox(S),intersectsBounds:(S,A,E)=>E<v&&E<o?(A&&(bp.min.copy(S.min),bp.max.copy(S.max),bp.needsUpdate=!0),!0):!1,intersectsRange:(S,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>bp.distanceToBox(E),intersectsBounds:(E,b,M)=>M<v&&M<o,intersectsRange:(E,b)=>{for(let M=E*3,T=(E+b)*3;M<T;M+=3){Zi(f,M,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=S*3,P=(S+A)*3;C<P;C+=3){Zi(d,C,u,l),d.needsUpdate=!0;let D=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=C/3,w=M/3),D<s)return!0}}}});{let E=h?h.count:c.count;for(let b=0,M=E;b<M;b+=3){Zi(f,b,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let T=S*3,C=(S+A)*3;T<C;T+=3){Zi(d,T,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,x=T/3,w=b/3),P<s)return!0}}}}}),no.releasePrimitive(d),no.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=v,r.faceIndex=x,n&&(n.point?n.point.copy(y):n.point=y.clone(),n.point.applyMatrix4(zh),m.applyMatrix4(zh),n.distance=m.sub(n.point).length(),n.faceIndex=w),r)}closestPointToPoint(t,e={},r=0,n=1/0){let s=r*r,o=n*n,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(wp.copy(t).clamp(c.min,c.max),wp.distanceToSquared(t)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(t,wp);let d=t.distanceToSquared(wp);return d<a&&(fv.copy(wp),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(fv):e.point=fv.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{Ki(0,new Float32Array(r),F2),t.union(F2)}),t}};var Id=pn(V2());var d8=.5*(Math.sqrt(3)-1),Sp=(3-Math.sqrt(3))/6,f8=1/3,so=1/6,tde=(Math.sqrt(5)-1)/4,rde=(5-Math.sqrt(5))/20,Ap=i=>Math.floor(i)|0,z2=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]),wS=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 pv(i=Math.random){let t=G2(i),e=new Float64Array(t).map(n=>z2[n%12*2]),r=new Float64Array(t).map(n=>z2[n%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*d8,h=Ap(s+c),d=Ap(o+c),f=(h+d)*Sp,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let w=g-v+Sp,S=y-x+Sp,A=g-1+2*Sp,E=y-1+2*Sp,b=h&255,M=d&255,T=.5-g*g-y*y;if(T>=0){let D=b+t[M],I=e[D],R=r[D];T*=T,a=T*T*(I*g+R*y)}let C=.5-w*w-S*S;if(C>=0){let D=b+v+t[M+x],I=e[D],R=r[D];C*=C,l=C*C*(I*w+R*S)}let P=.5-A*A-E*E;if(P>=0){let D=b+1+t[M+1],I=e[D],R=r[D];P*=P,u=P*P*(I*A+R*E)}return 70*(a+l+u)}}function U2(i=Math.random){let t=G2(i),e=new Float64Array(t).map(s=>wS[s%12*3]),r=new Float64Array(t).map(s=>wS[s%12*3+1]),n=new Float64Array(t).map(s=>wS[s%12*3+2]);return function(o,a,l){let u,c,h,d,f=(o+a+l)*f8,p=Ap(o+f),m=Ap(a+f),g=Ap(l+f),y=(p+m+g)*so,v=p-y,x=m-y,w=g-y,S=o-v,A=a-x,E=l-w,b,M,T,C,P,D;S>=A?A>=E?(b=1,M=0,T=0,C=1,P=1,D=0):S>=E?(b=1,M=0,T=0,C=1,P=0,D=1):(b=0,M=0,T=1,C=1,P=0,D=1):A<E?(b=0,M=0,T=1,C=0,P=1,D=1):S<E?(b=0,M=1,T=0,C=0,P=1,D=1):(b=0,M=1,T=0,C=1,P=1,D=0);let I=S-b+so,R=A-M+so,U=E-T+so,F=S-C+2*so,V=A-P+2*so,G=E-D+2*so,H=S-1+3*so,Y=A-1+3*so,k=E-1+3*so,j=p&255,X=m&255,q=g&255,z=.6-S*S-A*A-E*E;if(z<0)u=0;else{let W=j+t[X+t[q]];z*=z,u=z*z*(e[W]*S+r[W]*A+n[W]*E)}let J=.6-I*I-R*R-U*U;if(J<0)c=0;else{let W=j+b+t[X+M+t[q+T]];J*=J,c=J*J*(e[W]*I+r[W]*R+n[W]*U)}let Z=.6-F*F-V*V-G*G;if(Z<0)h=0;else{let W=j+C+t[X+P+t[q+D]];Z*=Z,h=Z*Z*(e[W]*F+r[W]*V+n[W]*G)}let K=.6-H*H-Y*Y-k*k;if(K<0)d=0;else{let W=j+1+t[X+1+t[q+1]];K*=K,d=K*K*(e[W]*H+r[W]*Y+n[W]*k)}return 32*(u+c+h+d)}}function G2(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),s=e[r];e[r]=e[n],e[n]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var Ss=new dr,mv=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let n=0;n<t.count;n+=3){let s=1;Ss.a.fromBufferAttribute(t,n),Ss.b.fromBufferAttribute(t,n+1),Ss.c.fromBufferAttribute(t,n+2),s*=Ss.getArea(),e[n/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,s=-1;for(;r<=n;){let o=Math.ceil((r+n)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?n=o-1:r=o+1}return s}sampleFace(t,e,r){let n=this.randomFunction(),s=this.randomFunction();return n+s>1&&(n=1-n,s=1-s),Ss.a.fromBufferAttribute(this.positionAttribute,t*3),Ss.b.fromBufferAttribute(this.positionAttribute,t*3+1),Ss.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Ss.a,n).addScaledVector(Ss.b,s).addScaledVector(Ss.c,1-(n+s)),Ss.getNormal(r),this}};var j2=pn(SS()),p8=new ie,m8=new ie,g8=new ie,Uh;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(Uh||(Uh={}));var Gh=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ie;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ie;this.matrixWorldRigid=new ie;this.shearScale=new ie;this.shearScaleInv=new ie}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof gt&&(r=r.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===r)return!0;n=n.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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,r=!0);for(let n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){let s=this.parent;if(r&&s!==null&&s.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)),n)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,n=0){for(let s of this.children)Uh.is(s)&&s.traverseObject(r,n+1)}traverseObject(r,n=0){if(r(this,n)!==!0)for(let o of this.children)Uh.is(o)&&o.traverseObject(r,n+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,n=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,j2.SVD)(n),l=p8.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),u=m8.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=g8.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,n){this.updateWorldMatrix(!0,!1);let s=new ie().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ie?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),n!==void 0&&(this.children.pop(),this.children.splice(n,0,r)),this}copy(r,n=!1){return super.copy(r,n),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,n,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var AS=class extends Gh(gt){},y8=i=>i.type==="Mesh",mr=class extends AS{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new mr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix),n.expand(),e+=1,r=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 y8(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}};var fc=new _,pc=new _,Hh=new ie,q2=[new _(-1,1,1),new _(-1,-1,1),new _(1,-1,1),new _(1,1,1),new _(-1,1,-1),new _(-1,-1,-1),new _(1,-1,-1),new _(1,1,-1)],v8=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],x8=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],W2=(i,t,e)=>{i.updateEntityBoxSize(fc,pc),Hh.copy(t).multiply(i.matrixWorld),pc.x===0&&pc.y===0&&pc.z===0?e.push(new _(fc.x,fc.y,fc.z).applyMatrix4(Hh)):q2.forEach(r=>{e.push(r.clone().multiply(pc).add(fc).applyMatrix4(Hh))})},_p=class extends Pt{constructor(){super(...arguments);this.matrix=new ie;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let n=new ie().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let s=[];return n===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new _);return}W2(o,r,s)}}):W2(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Hh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(pc).multiplyScalar(.5),this.getCenter(fc),Hh.copy(this.matrix).setPosition(fc),this.vertices=q2.map(e=>e.clone().multiply(pc).applyMatrix4(Hh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=v8.map(([e,r])=>new nn(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new _))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=x8.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var As={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var ES=class extends zf{constructor(){super()}getPoints(t=12){let e=[],r,n=this.getCurveLengths(),o=n[n.length-1]/n.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?n[a]:n[a]-n[a-1],h=Math.ceil(t*c/o),d=u.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var MS=.001;function TS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=MS}function _S(i,t){let e=new _(...i.position),r=new _(...i.controlNext.position),n=new _(...t.controlPrevious.position),s=new _(...t.position);return TS(e,r,s)&&TS(e,n,s)}function yv(i){let t=i.points.map(c=>new _(...c.data.position)),e=[i.points[0]],r=new _(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)TS(r,t[c],t[c+1])||(e.push(i.points[c]),r=t[c]);e.push(i.points[i.points.length-1]);let n=i.isClosed,s=e.length-(n?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let h=e[c].data,d=new _(...h.position),f=new _(...h.controlPrevious.position),p=new _(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...m,removedLength:0};continue}let g=n&&c==0?o-1:c-1,y=n&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,w=new _(...v.position),S=new _(...x.position),A=w.clone().sub(d).normalize(),E=S.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:E});let b=_S(v,h),M=_S(h,x);if(!b||!M)a[c]={...m,removedLength:0};else{let T=A.clone().add(E).normalize(),C=T.clone().cross(A).length()/A.dot(T);a[c]={...m,tan:C,removedLength:h.roundness/C}}}for(let c=0;c<s;c++){let h=c,d=n&&c===o-1?0:c+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let h=c,d=n&&c===o-1?0:c+1,f=a[h],p=a[d],m=null;if(!_S(e[h].data,e[d].data))f.position.distanceTo(p.position)>MS&&(m=new ql(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>MS&&(m=new ql(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c<o;c++){let h=a[c];if(h.removedLength===0){l[2*c]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),w=g.clone().multiplyScalar(-m).add(x),S=d.distanceTo(w)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),E=A.clone().lerp(w,2),b=f.clone().lerp(A,4/3),M=p.clone().lerp(E,4/3);l[2*c]=new ql(f,b,M,p)}let u=new ES;return l.forEach(c=>{c&&u.add(c)}),u}var lt;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(lt||(lt={}));var oo=i=>lt.is(i),b8={type:"completeState",isfromEntity:!0},w8=["x","y","z"],CS=new _,S8=new _().set(0,1,0),jh=i=>class extends Gh(i){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 _p;this._recursiveBBox=new _p;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let n=this.children[r];if(lt.is(n))return n}entityChildrenCount(){let r=this.children.length;for(;r--;)if(lt.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let n=r.parent;if(lt.is(n))r=n;else return}return r}forInstancesRec(r){this.instances.forEach(n=>{n.disposed||r(n),n.forInstancesRec(r)})}super_Entity(r,n){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=n,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,n,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)ta.toOps(this.data,o.data).forEach(l=>{let u=wy.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,n)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=ta.patch(this.data,o),ta.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,n)}))}s&&this.updateTransformState(this.dataPatched,n),this.stateSelection=r,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(r,n){r.setScalar(0),n.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{oo(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let n;return this.traverseEntity(s=>{s.uuid===r&&(n=s)}),n}traverseSortNextHelper(){let r=this.parent;if(r){let n=r.children,s=n.indexOf(this)+1;if(lt.is(n[s]))return n[s];if(lt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&lt.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let n=this;for(;r>0&&n!==null;)n=n.parent,r-=1;return n}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let n=this.parent;for(;n;){if(r===n)return!0;n=n.parent}return!1}countToAccestor(r){let n=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,n+=1}return n}forEachEntity(r){for(let n of this.children)oo(n)&&r(n)}traverseEntityAncestors(r){this.traverseAncestors(n=>{lt.is(n)&&r(n)})}traverseConcreteEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)oo(o)&&o.isConcreteEntity&&o.traverseEntity(r,n+1)}traverseEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)oo(o)&&o.traverseEntity(r,n+1)}traverseVisibleEntity(r){r(this);for(let n of this.children)oo(n)&&n.visible&&n.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,n=!1){return super.copy(r,n),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>oo(r))}isAncestorOf(r){if(this.uuid===r)return!1;let n=!1;return this.traverseEntity(s=>{s.uuid===r&&(n=!0)}),n}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x*Se.RAD2DEG,this.rotation.y*Se.RAD2DEG,this.rotation.z*Se.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ih(n,r)}getTransformValues(r,n,s){return n[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,w8[a]])??o)}updateTransformState(r,n){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,n)),s=!0),r.rotation&&(CS.fromArray(this.getTransformValues("rotation",r,n)).multiplyScalar(Se.DEG2RAD),this.rotation.setFromVector3(CS),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,n)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Ya.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)lt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{lt.is(r)&&r.disposeRecursively()})}toState(r=[]){let n={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ih(n,r)}updateByObjUpdateOp(r,n){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},n,!1)}updateByOp(r,n,s,o){let a=this.data;this.data=n;let l=r,u=qn(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Rr.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:d,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:d,...f}=c;c=f}let h=Rr.removeOverridden(r.path,r.props,c);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,ta.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),qn(r.path,["overrides"])){let c=[],h=[...r.path];for(c.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)c.push(h[1]),h.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){c[c.length-1]=d;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[d],f.updateState(Xs.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...c]);if(d){let f=Rr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[m,g]of Object.entries(r.props))g===void 0&&(p===r.props&&(p={...r.props}),p[m]=f[m]);r={...r,props:p}}d.overrideData=xh.resolve(n.overrides,c),d.updateByOp(r,Lr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let h;for(let d of to.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(c={...r,props:h})}else for(let h of to.rootOverrideProps)if(qn(r.path,[h])){c=r;break}c!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Xs.filterOp(h.overrideData,c);d&&h.updateByOp(d,Lr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Xs.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=n:f=Lr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,n,s){if(this.dataPatched=n,r.path.length===0&&r.type===0)r.props.type!==void 0&&!bs.is(r.props.type)&&As.changeEntityProptotype(this,n,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){As.changeEntityProptotype(this,n,s);for(let o of this.children)lt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,n,s)}updateByPatchedOp(r,n,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),qn(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(n.pathSnapping),qn(r.path,["cloner"])!==null){let o=Lr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(n.cloner,s.scene):(this.setFromClonerState(n.cloner,s),this.expandCloner(s.scene)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let n=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(n===null)return;let l=r.find(n);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=yv(u.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=c.getPointAt(h),f=this.parent?this.parent?.matrixWorld:new ie;l.updateMatrixWorld();let p=new ie().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ie().extractRotation(l.matrixWorld),y=c.getTangentAt(h).applyMatrix4(g).add(d),v=new ie().lookAt(d,y,S8),x=CS.setFromEuler(new Zt().setFromRotationMatrix(v)).multiplyScalar(Se.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(b8)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let n=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return n=!0,!0}),n&&r.reloadSplats()}updateState_Entity(r,n){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(n?.scene),this.resetBBoxNeedsUpdate()),n&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,n),this.updateVisible(n.scene)),this.updateTransformState(r,n)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof As.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,n){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new As.Cloner(this,r),n.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,n.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}};var vv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=Se.clamp(e.thetaLength,0,360);let r=e.width/2,n=e.radiusTop??r,s=e.radiusBottom??r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ae,p.setAttribute("position",new be([],3))):h||f?p=new Ep(u,c,r,n,s,o,a,l*Math.PI/180,h,h,d,f):p=new Xl(u,c,r,n,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function ol(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Y2(i){return new N(i.y,-i.x)}var Ep=class extends Ae{constructor(t,e,r,n,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let p=[],m=[],g=[],y=[],v=0,x=r/2,w=new _,S=new _;f&&t==0&&(t=u),f&&e==0&&(e=c);let A=new N(t,x),E=new N(e,-x),b=null,M=null,T=null,C=null,P=A.clone().sub(E),D=0,I=0,R=0;d>0&&(D=Math.min(t,e)*(1-d),I=t-D,R=e-D);let U=A.clone();U.x-=D;let F=Math.PI-P.angle(),V=P.angle(),G=Math.tan(V/2),H=Math.tan(F/2),Y=G+H,k=d?Y:H,j=d?Y:G;if(u=Math.min(u,(t-I)/k,P.length()/Y),c=Math.min(c,(e-R)/j,P.length()/Y),u>0){let K=u/G;b=A.clone().sub(new N(K,u)),d&&(T=b.clone(),T.x-=D-Y*u),A.sub(P.clone().setLength(K))}if(c>0){let K=c/H;M=E.clone().sub(new N(K,-c)),E.add(P.clone().setLength(K)),d&&(C=M.clone(),C.x-=D-Y*c,U.sub(P.clone().setLength(K)))}P=A.clone().sub(E);let X=P.length()<.5,q=[];for(let K=0;K<=n;K++){let W=[],ye=K/n,fe=ye*l+a,se=new N(Math.sin(fe),Math.cos(fe));C&&M?(z(W,ye,se,F,c,C,-1,!0),z(W,ye,se,V,c,M,-1,!1)):M?(J(W,se,M.x,0,-1),z(W,ye,se,V,c,M,-1,!1)):o||J(W,se,e,R,-1);let _e=Y2(P).normalize();if(ol(_e,se,w),!X)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=P.clone().multiplyScalar(Oe).add(E);ol(Ie,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}if(T&&b?(z(W,ye,se,F,u,b,1,!1),z(W,ye,se,V,u,T,1,!0)):b?(z(W,ye,se,F,u,b,1,!1),J(W,se,b.x,0,1)):o||J(W,se,t,I,1),d&&!X){let xe=Y2(P).multiplyScalar(-1).normalize();ol(xe,se,w);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=P.clone().multiplyScalar(-Ie).add(U);ol(Pe,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}}d&&!o&&W.push(W[0]),q.push(W)}for(let K=0;K<q.length-1;K++)for(let W=0;W<q[0].length-1;W++){if(o&&d&&W==s)continue;let ye=q[K][W],fe=q[K+1][W],se=q[K+1][W+1],_e=q[K][W+1],xe=m[se*3+0],Oe=m[se*3+2];p.push(ye,fe,_e),(xe!=0||Oe!=0)&&p.push(fe,se,_e)}l<Math.PI*2&&(Z(-1,q[0],a),Z(1,q[q.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new be(m,3)),this.setAttribute("normal",new be(g,3)),this.setAttribute("uv",new be(y,2));function z(K,W,ye,fe,se,_e,xe,Oe){for(let Ie=0;Ie<h+1;Ie++){let Pe=Ie/h,Me=xe<0?Pe:1-Pe;Oe&&(Me-=1),Me*=fe;let ze=new N(Math.sin(Me),Math.cos(Me)*xe),Ue=ze.clone().multiplyScalar(se).add(_e);ol(Ue,ye,S),m.push(S.x,S.y,S.z),ol(ze,ye,w),g.push(w.x,w.y,w.z),y.push(W,.5+S.y/r),K.push(v++)}}function J(K,W,ye,fe,se){let _e=new _,xe=new N,Oe=[ye,fe];se<0&&Oe.reverse();for(let Ie of Oe)xe.set(Ie,x*se),ol(xe,W,_e),m.push(_e.x,_e.y,_e.z),g.push(0,se,0),y.push(.5,.5),K.push(v++)}function Z(K,W,ye){let fe=new N(Math.sin(ye),Math.cos(ye)),se=new N(-Math.cos(ye),Math.sin(ye)),_e=new _,xe=K<0?(Pe,Me,ze)=>p.push(Pe,Me,ze):(Pe,Me,ze)=>p.push(Pe,ze,Me),Oe=new N((t+e+I+R)/4,0);ol(Oe,fe,_e),m.push(_e.x,_e.y,_e.z),g.push(se.x,0,se.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let Me=m.slice(Pe*3,Pe*3+3);m.push(...Me),g.push(se.x,0,se.y);let ze=y.slice(Pe*2,Pe*2+2);y.push(...ze),v++}for(let Pe=Ie+1;Pe<v-1;Pe++)xe(Ie,Pe,Pe+1);xe(Ie,v-1,Ie+1)}}};var X2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=i.parameters,d;return l===0?(d=new Ae,d.setAttribute("position",new be([],3))):u>0||c>0||l<360?d=new Ep(0,t/2,r,n,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new fu(t/2,r,n,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var Q2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new yn(t,e,r,n,s,o):u=new DS(t,e,r,n,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},PS=Math.PI/2,DS=class extends Ae{constructor(t=1,e=1,r=1,n=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],h=[],d=[],f=[],p=0,m=0;g("z","y","x",-1,-1,r,e,t,o,s,0),g("z","y","x",1,-1,r,e,-t,o,s,1),g("x","z","y",1,1,t,r,e,n,o,2),g("x","z","y",1,-1,t,r,-e,n,o,3),g("x","y","z",1,-1,t,e,r,n,s,4),g("x","y","z",-1,-1,t,e,-r,n,s,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,o,0),y("z","y","x",1,-1,-1,r,e,t,o,1),y("z","y","x",-1,1,-1,r,e,t,o,1),y("z","y","x",1,1,1,r,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,r,n,0),y("x","y","z",1,-1,1,t,e,r,n,1),y("x","y","z",-1,1,1,t,e,r,n,0),y("x","y","z",1,1,-1,t,e,r,n,1),y("y","x","z",-1,-1,1,e,t,r,s,0),y("y","x","z",1,-1,-1,e,t,r,s,1),y("y","x","z",1,1,1,e,t,r,s,1),y("y","x","z",-1,1,-1,e,t,r,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(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function g(x,w,S,A,E,b,M,T,C,P,D){let I=(b-2*a)/C,R=(M-2*a)/P,U=b/2-a,F=M/2-a,V=T/2,G=C+1,H=P+1,Y=0,k=0,j=new _;for(let X=0;X<H;X++){let q=X*R-F;for(let z=0;z<G;z++){let J=z*I-U;j[x]=J*A,j[w]=q*E,j[S]=V,h.push(j.x,j.y,j.z),j[x]=0,j[w]=0,j[S]=T>0?1:-1,d.push(j.x,j.y,j.z),f.push(z/C),f.push(1-X/P),Y+=1}}for(let X=0;X<P;X++)for(let q=0;q<C;q++){let z=p+q+G*X,J=p+q+G*(X+1),Z=p+(q+1)+G*(X+1),K=p+(q+1)+G*X;c.push(z,J,K),c.push(J,Z,K),k+=6}u.addGroup(m,k,D),m+=k,p+=Y}function y(x,w,S,A,E,b,M,T,C,P,D){let I=(M-2*a)/P,R=M/2-a,U=T/2-a,F=C/2,V=P+1,G=0,H=0,Y=new _,k=new _;for(let j=0;j<l+1;j++){let X=j/l*PS,q=Math.sin(X)*a,z=(1-Math.cos(X))*a,J=Math.sin(X),Z=Math.cos(X);Y[w]=(U+q)*E,Y[S]=(F-z)*b,k[x]=0,k[w]=J*Math.sign(Y[w]),k[S]=Z*Math.sign(Y[S]);for(let K=0;K<V;K++){let W=K*I-R;Y[x]=W*A,h.push(Y.x,Y.y,Y.z),d.push(k.x,k.y,k.z),f.push(K/P),f.push(0),G+=1}}for(let j=0;j<l;j++)for(let X=0;X<P;X++){let q=p+X+V*j,z=p+X+V*(j+1),J=p+(X+1)+V*(j+1),Z=p+(X+1)+V*j;c.push(q,z,Z),c.push(z,J,Z),H+=6}u.addGroup(m,H,D),m+=H,p+=G}function v(x,w,S){let A=new _,E=new _(t/2,e/2,r/2);E.subScalar(a);let b=[],M=x*w*S>0?(C,P,D)=>c.push(C,P,D):(C,P,D)=>c.push(C,D,P);for(let C=0;C<=l;C++){let P=[],D=PS*(1-C/l),I=Math.cos(D),R=Math.sin(D),U=0;for(let F=0;F<=C;F++){let V=Math.cos(U),G=Math.sin(U);A.x=I*V,A.y=R,A.z=I*G;let H=E.clone().addScaledVector(A,a);h.push(x*H.x,w*H.y,S*H.z),d.push(x*A.x,w*A.y,S*A.z),f.push(0,0),P.push(p++),U+=PS/C}b.push(P)}let T=b.length-1;for(let C=0;C<T;C++){let P=b[C],D=b[C+1],I=P.length-1;M(P[0],D[1],D[0]);for(let R=1;R<=I;R++)M(P[R-1],P[R],D[R]),M(P[R],D[R+1],D[R])}}}};var al=class extends Ae{constructor(t=[],e=[],r="",n=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],p=new _,m=p.clone(),g=new dr,y=s*n,v=n-y,x=o+1,w=new _,S=(G,H)=>w.subVectors(G,H).normalize(),A=(G,H)=>Array(G).fill(void 0).map(H),E=A(t.length/3,(G,H)=>new _().fromArray(t,H*3).setLength(n)),b=[],M=1e6;for(let G=0;G<E.length;G++){let H=E[G],Y=[],k,j,X,q=1e10,z=-1;for(;(z=e.indexOf(G,z+1))!=-1;){let W=z-z%3;k=e[W+(z+1)%3],j=e[W+(z+2)%3],X=H.distanceToSquared(E[k]),q=Math.min(q,X),Y.push([k,j,X])}q+=1e-6;let J=[],Z=0,K=Y.length;for(let W=0;W<K;W++){[k,j,X]=Y[Z];let ye=b[k]?.includes(G)==!0;X<=q&&J.push(k+ +ye*M),Z=Y.findIndex(fe=>fe[0]==j)}b.push(J)}let T=[];{let G=0,H=0,Y,k,j=f==3;for(let X=0;X<=o;X++){Y=X*(X+1)/2,k=(X+1)*(X+2)/2;for(let q=0;q<o-X;q++)[G,H]=[Y+q+X+2,k+q+X+3],T.push(Y,k,...j?[H,Y]:[G,k],H,G),[Y,k]=[G,H];T.push(Y,k,Y+o+2)}}let C=p.clone(),P=p.clone(),D=p.clone(),I=p.clone(),R=p.clone(),U=[],F=A(E.length,()=>A(f,()=>p.clone()));for(let G=0;G<E.length;G++){p.copy(E[G]).normalize(),C.copy(p).multiplyScalar(v);let H=b[G];for(let J=0;J<H.length;J++){let Z=H[J],K=H[(J+1)%f];g.setFromPointsAndIndices(E,G,Z%M,K%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,F[G][J])}let Y=[],k=[],j=[],X=new _;o==0&&[...F[G]].reduce((J,Z)=>J.add(Z),X).multiplyScalar(1/f);for(let J=0;J<f;J++){let Z=[],K=(J-1+f)%f,W=F[G][K],ye=F[G][J];p.copy(W).sub(C),m.copy(ye).sub(C);let fe=C.angleTo(p),se=p.angleTo(m),_e=Math.cos(fe)*y;o==0?P.copy(X):P.copy(C).setLength(v+_e),k.push(_e);let xe=[P,W,ye];for(let Oe=0;Oe<2;Oe++){let Ie=xe[Oe],Pe=xe[Oe+1];I.subVectors(Ie,C),R.subVectors(Pe,C),D.crossVectors(I,R).normalize();for(let Me=0;Me<x;Me++){let ze=[fe,se][Oe]*Me/x;p.copy(I).applyAxisAngle(D,ze).add(C),Y.push(p.clone()),Oe&&(S(p,C),Z.push([Me==0?Ie:p.clone(),w.clone()]))}Oe&&(S(Pe,C),Z.push([Pe,w.clone()]))}j.push(Z)}U.push(j);let q=2*x,z=2;for(let J=0;J<f;J++){let Z=q*J,K=q*((J+1)%f),W=[Y[Z]];for(let fe=1;fe<x;fe++){I=Y[Z+fe],R=Y[K+fe],W.push(I);for(let se=1,_e=fe-z+1;se<=_e;se++)p.lerpVectors(I,R,se/(_e+1)),p.sub(C).setLength(k[J]).add(C),W.push(p.clone());W.push(R)}for(let fe=0;fe<x;fe++)W.push(Y[fe+x+Z]);W.push(Y[K+x]);let ye=T.map(fe=>W[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(S(fe,C),[w.x,w.y,w.z])).flat())}}let V=[];for(let G=0;G<b.length;G++)for(let H=0;H<f;H++){let Y=b[G][H];if(Y<M){let k=b[Y].findIndex(q=>q%M==G),j=U[G][H],X=U[Y][k];for(let q=0;q<x;q++){let z=j[q],J=X[x-q],Z=j[q+1],K=X[x-(q+1)];[z,J,Z,Z,J,K].forEach(W=>{a.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}V.push(j[0][0],X[x][0],j[x][0],X[0][0])}}for(;V.length;){let G,H,Y,k;[G,H]=V.splice(0,2);let j=[G];for(;G!=H;)j.push(H),Y=V.indexOf(H),k=Y%2,H=V.splice(Y-k,2)[1-k];w.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let X=w.dot(j[0])<0;X&&w.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +X],j[q+1-+X],j[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(w.x,w.y,w.z)})}}function h(){let d=new _;for(let E=0;E<a.length;E+=3){d.x=a[E+0],d.y=a[E+1],d.z=a[E+2];let b=S(d)/2/Math.PI+.5,M=A(d)/Math.PI+.5;l.push(b,1-M)}let f=new _,p=new _,m=new _,g=new _,y=new N,v=new N,x=new N,w=(E,b,M,T)=>{T<0&&E.x===1&&(l[b]=E.x-1),M.x===0&&M.z===0&&(l[b]=T/2/Math.PI+.5)};for(let E=0,b=0;E<a.length;E+=9,b+=6){f.set(a[E+0],a[E+1],a[E+2]),p.set(a[E+3],a[E+4],a[E+5]),m.set(a[E+6],a[E+7],a[E+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(p).add(m).divideScalar(3);let M=S(g);w(y,b+0,f,M),w(v,b+2,p,M),w(x,b+4,m,M)}for(let E=0;E<l.length;E+=6){let b=l[E+0],M=l[E+2],T=l[E+4],C=Math.max(b,M,T),P=Math.min(b,M,T);C>.9&&P<.1&&(b<.2&&(l[E+0]+=1),M<.2&&(l[E+2]+=1),T<.2&&(l[E+4]+=1))}function S(E){return Math.atan2(E.z,-E.x)}function A(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(t){return new al(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var K2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new Mp(t*.5,s,o):new mu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Mp=class extends al{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,o=[-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,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new Mp(t.radius,t.corner,t.cornerSides)}};var Tp=1e-12,Wh=class{constructor(t){this.position=new N;this.startPosition=new N;this.uuid=Se.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Wh(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},qh=class extends Wh{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new qh(this.parent).copy(this)}},_s=class extends Wh{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new qh(this),new qh(this))}static create(e,r){let n=new _s(e,new N(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,s=this.controls.length;n<s;n++){let o=this.controls[n];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.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 _s(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new N,r=new N){let[n,s]=this.computeTangents();return n&&s&&(Z2(n,e),Z2(s,r)),[e,r]}computeTangent(e=new N){let[r,n]=this.computeTangents();return r&&n&&e.copy(r).add(n).normalize(),e}computeNormal(e=new N){let[r,n]=this.computeNormals();return e.copy(r).add(n).normalize(),e}};function Z2(i,t=new N){let e=i.length();return t.set(-i.y/e,i.x/e)}var OS=i=>i,Yh=new N,xv=new N,A8=new N,_8=new N,E8=new N,M8=new N,$2=new _,eD=new _;function tD(i){let t=new N;t.addVectors(i.v0,Yh.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new N;return e.addVectors(i.v2,xv.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new jn(i.v0,t,e,i.v2)}function Cp(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function T8(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function C8(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function RS(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function rD(i,t,e){return J2(i,t)&&J2(t,e)&&IS(i.position,t.position,e.position)}function IS(i,t,e){return Yh.copy(t).sub(i).cross(xv.copy(e).sub(i))===0}function nD(i,t,e,r,n){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return r.set(a+l,o+u),n.set(a-l,o-u),[r,n]}function iD(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function sD(i,t,e,r,n,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,u=e.y-i.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return RS(t,i,e)>Math.PI&&(c*=-1),Cp(u,a)?h=(a+u)*(r/c-.5)*8/3/(o-l):h=(o+l)*(r/c-.5)*8/3/(u-a),n.set(t.x-h*a,t.y+h*o),s.set(e.x+h*u,e.y-h*l),[n,s]}function LS(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function J2(i,t){return IS(i.position,i.controls[1].position,t.position)&&IS(i.position,t.controls[0].position,t.position)}function oD(i,t,e,r,n=.5){let s=Yh.subVectors(t,i).multiplyScalar(n).add(i),o=xv.subVectors(e,t).multiplyScalar(n).add(t),a=A8.subVectors(r,e).multiplyScalar(n).add(e),l=s,u=_8.subVectors(o,s).multiplyScalar(n).add(s),c=E8.subVectors(a,o).multiplyScalar(n).add(o),h=a,d=M8.subVectors(c,u).multiplyScalar(n).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,r.x,r.y]}function aD(i,t,e=12,r=!0){let n=eD.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=OS(t[l]),c=Yh,h=ll(u,e);a.push(h);for(let d=0;d<=h;d++)if(u instanceof jn||u instanceof Ii||u instanceof Wn){if(u.getPoint(d/h,c),n.set(c.x,c.y,0),s!==void 0&&C8(s,n))continue;s===void 0&&(s=$2),s.copy(n),i.setXYZ(o,n.x,n.y,n.z),o++}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function lD(i,t,e,r=12,n=!0){let s=eD.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=OS(t[l]),h=Yh,d=ll(c,r);a.push(d);for(let f=0;f<=d;f++)if(c instanceof jn||c instanceof Ii||c instanceof Wn){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=$2:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function NS(i,t=12,e=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let o=i[n],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=ll(o.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=ll(o.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=ll(i[0].roundedCurveCorner,t)*.5),r}function ll(i,t=12){return i&&i instanceof Wl?t*2:i&&(i instanceof Wn||i instanceof Vf)?1:i&&i instanceof hu?t*i.points.length:t}function cD(i,t,e=12,r=!0){let n,s=0;for(let o=0;o<t.length;o++){let a=OS(t[o]),l=ll(a,e),u=Yh;for(let c=0;c<=l;c++)if(a instanceof jn||a instanceof Ii||a instanceof Wn){if(a.getPoint(c/l,u),n!==void 0&&T8(n,u,Tp))continue;n===void 0&&(n=xv),n.copy(u),i.push(u.x,u.y),s++}}return Cp(i[0],i[i.length-2],Tp)&&Cp(i[1],i[i.length-1],Tp)&&(i.pop(),i.pop()),r&&s>1&&!(Cp(i[s-1],i[1],Tp)&&Cp(i[s-2],i[0],Tp))&&(i.push(i[0],i[1]),s++),i}var BS=new N,P8=new N,D8=new N,I8=new N,O8=new N,R8=new N,Ot=class extends Wo{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Or(new _(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=Se.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let s=new Ot;return s.isClosed=e.isClosed,s.points=e.points.map(o=>_s.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Ot.createFromState(o)),r!==void 0&&n!==void 0&&s.applySize(r,n),s.update(),s}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 r=0,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,n=this.points.findIndex(s=>s.uuid===e);if(n<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return n}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=BS.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(n),a.controls[0].position.multiply(n),a.controls[1].position.multiply(n)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,n=Se.generateUUID()){let s;e instanceof N?s=e:s=new N(e,r);let o=new _s(n,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,n=this.shapeHoles.length;r<n;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=n?this.roundedCurveDivisions:this.curveDivisions;return aD(e,n?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=NS(this.points,e,!1),this.roundedCurveDivisions=NS(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return lD(e,this.curves,r,n,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),cD(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=ll(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<n+c)return[l,(a-n+1)/c];n+=c}return[0,1]}getCurveT(e,r,n){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(LS(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(BS.set(n.x,n.y))/h}let u=0;for(let h=0;h<e;h++)u+=a[h];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){LS(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let s=n.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(r,n)}if(this.points.length>2){let r=0;for(let n=0,s=this.points.length;n<s;n++){let o=this.points[n],a=this.points[n-1]??this.points[this.points.length-1],l=this.points[n+1]??this.points[0],u=o.roundness,c=a&&l&&rD(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/m,S=x/g,A=h.getPointAt(w,BS),E=d.getPointAt(S,P8);this._subSplitCurve(h,f,w,A,void 0),this._subSplitCurve(d,p,S,void 0,E);let b;if(this.useCubicForRoundedCorners){let M=RS(A,o.position,E)/2,T=Math.tan(M)*A.distanceTo(o.position),[C,P]=nD(A,E,T,D8,I8),D=iD(C,P,o.position),[I,R]=sD(D,A,E,T,O8,R8);b=new jn(A.clone(),I.clone(),R.clone(),E.clone())}else b=new Ii(A.clone(),o.position.clone(),E.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(n+r,0,b),r++}}}}_subSplitCurve(e,r,n,s,o){if(e instanceof Wn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,u=a.getUtoTmapping(n,0),c=oD(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new Ot(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let n=0;n<r;n++){let s=n*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new _s(Se.generateUUID(),new N(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(n=>{let s=new Ot;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(o,a)=>{a instanceof jn&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,u;for(l=0,u=o.length;l<u;l++)o[l]instanceof Ii&&(o[l]=tD(o[l]));for(l=0,u=o.length;l<u;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof jn?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof Wn&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&n(p,f),a.push(p))}let c=o[o.length-1],h=!1;return c instanceof jn?c.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(c.v2),h=!0):c instanceof Wn&&c.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof Wo&&(this.shapeHoles=e.holes.map(o=>{let a=new Ot;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var kS=Math.PI*2;function FS({x:i,y:t},e,r,n,s){return{x:i*e+n,y:t*r+s}}function L8(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function uD(i,t,e,r){let n=i*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(s)}function N8(i,t,e,r,n,s,o,a,l,u){let c=Math.pow(n,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=c*h-c*f-h*d;p<0&&(p=0),p/=c*f+h*d,p=Math.sqrt(p)*(l===u?-1:1);let m=p*n/s*a,g=p*-s/n*o,y=m+(i+e)/2,v=g+(t+r)/2,x=(o-m)/n,w=(a-g)/s,S=(-o-m)/n,A=(-a-g)/s,E=uD(1,0,x,w),b=uD(x,w,S,A);return!u&&b>0&&(b-=kS),u&&b<0&&(b+=kS),{centerx:y,centery:v,ang1:E,ang2:b}}function hD({px:i,py:t,cx:e,cy:r,rx:n,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(n===0||s===0)return[];let u=(i-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];n=Math.abs(n),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(n,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(n*=Math.sqrt(h),s*=Math.sqrt(h));let d=N8(i,t,e,r,n,s,u,c,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(kS/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(L8(f,p)),f+=p;return l.map(x=>{let{x:w,y:S}=FS(x[0],n,s,m,g),{x:A,y:E}=FS(x[1],n,s,m,g),{x:b,y:M}=FS(x[2],n,s,m,g);return{x1:w,y1:S,x2:A,y2:E,x:b,y:M}})}var St;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(St||(St={}));var br;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(br||(br={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Ze=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){nt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?n<s?e.t-t.t+(t.t-r.t)*(n/(n+s)):e.t-r.t+(r.t-t.t)*(s/(n+s)):0},i.edgeSign=function(t,e,r){nt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?(e.t-r.t)*n+(e.t-t.t)*s:0},i.transEval=function(t,e,r){nt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?n<s?e.s-t.s+(t.s-r.s)*(n/(n+s)):e.s-r.s+(r.s-t.s)*(s/(n+s)):0},i.transSign=function(t,e,r){nt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?(e.s-r.s)*n+(e.s-t.s)*s:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(o=i.edgeEval(t,r,e),a=i.edgeEval(r,e,n),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,e.s)):(o=i.edgeSign(t,r,e),a=-i.edgeSign(t,n,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,n.s)):s.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(o=i.transEval(t,r,e),a=i.transEval(r,e,n),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,e.t)):(o=i.transSign(t,r,e),a=-i.transSign(t,n,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,n.t)):s.t=(r.t+e.t)/2},i}(),Pp=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),bv=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Xh=function(){function i(){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 i}(),dD=function(){function i(){var t=new Xh,e=new Pp,r=new bv(0),n=new bv(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new bv(0),r=new bv(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;nt(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e;var o=e;do o.Org=n,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;nt(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var o=e;do o.Lface=n,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new Xh,e=new Xh,r=new Pp,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var s=new Xh;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new Pp;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=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 n=new Pp;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new Xh;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.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},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),s=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(s,e),n.Org=t.Dst,s.Org=e.Org,n.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new Pp;this.makeFace_(o,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,s,o,a;n=e.Lnext;do r=n,n=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Ze.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Ze.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,s,o,a,l,u;for(s=t,s=t;(n=s.next)!==t;s=n){nt(n.prev===s),l=n.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Lface===n),l=l.Lnext;while(l!==n.anEdge)}for(nt(n.prev===s&&n.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){nt(o.prev===a),l=o.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(nt(o.prev===a&&o.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)nt(l.Sym.next===u.Sym),nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Org!==null),nt(l.Dst!==null),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l);nt(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),fD=function(){function i(){this.handle=null}return i}(),pD=function(){function i(){this.key=null,this.node=0}return i}(),B8=function(){function i(t,e){this.leq=e,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 fD,this.handles[r]=new pD;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,nt(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[n].key,r[s].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new fD;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new pD}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;nt(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),VS=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),mD=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),F8=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new mD,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new mD;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),k8=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,s=e.eUp,o=r.eUp;if(s.Dst===n)return o.Dst===n?Ze.vertLeq(s.Org,o.Org)?Ze.edgeSign(o.Dst,s.Org,o.Org)<=0:Ze.edgeSign(s.Dst,o.Org,s.Org)>=0:Ze.edgeSign(o.Dst,n,o.Org)<=0;if(o.Dst===n)return Ze.edgeSign(s.Dst,n,s.Org)>=0;var a=Ze.edgeEval(s.Dst,n,s.Org),l=Ze.edgeEval(o.Dst,n,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&nt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new VS;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case St.ODD:return(e&1)!==0;case St.NONZERO:return e!==0;case St.POSITIVE:return e>0;case St.NEGATIVE:return e<0;case St.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),n=s.eUp,n.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}n=t.mesh.connect(a.Lprev,n.Sym),i.fixUpperEdge(t,s,n)}a.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(a,n)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,r,n,s,o){var a,l,u,c,h=!0;u=r;do nt(Ze.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==n);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,nt(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Ze.vertL1dist(e,t),s=Ze.vertL1dist(r,t),o=.5*s/(n+s),a=.5*n/(n+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},i.getIntersectData=function(t,e,r,n,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp;if(Ze.vertLeq(n.Org,s.Org)){if(Ze.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;Ze.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,n)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(n,s.Oprev),e.dirty=r.dirty=!0)}else{if(Ze.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o;if(nt(!Ze.vertEq(n.Dst,s.Dst)),Ze.vertLeq(n.Dst,s.Dst)){if(Ze.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(n),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Ze.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(n.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o=n.Org,a=s.Org,l=n.Dst,u=s.Dst,c,h,d=new Xh,f,p;if(nt(!Ze.vertEq(u,l)),nt(Ze.edgeSign(l,t.event,o)<=0),nt(Ze.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(Ze.vertLeq(o,a)){if(Ze.edgeSign(u,o,a)>0)return!1}else if(Ze.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Ze.intersect(l,o,u,a,d),nt(Math.min(o.t,l.t)<=d.t),nt(d.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=d.s),nt(d.s<=Math.max(a.s,o.s)),Ze.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=Ze.vertLeq(o,a)?o:a,Ze.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Ze.vertEq(d,o)||Ze.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!Ze.vertEq(l,t.event)&&Ze.edgeSign(l,t.event,d)>=0||!Ze.vertEq(u,t.event)&&Ze.edgeSign(u,t.event,d)<=0?u===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Lnext,s.Oprev),r=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,s.Onext,n.Rprev,p,!0),!0):(Ze.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Ze.edgeSign(u,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,n),n.Org.s=d.s,n.Org.t=d.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,s;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(s),r=i.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,s=r.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Ze.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Ze.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,r.Onext,s,s,!0);return}Ze.vertLeq(l.Org,a.Org)?n=l.Oprev:n=a,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,s,o,a,l;if(n=e.eUp,Ze.vertEq(n.Org,r)){nt(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Ze.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}nt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(nt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),Ze.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var r,n,s,o,a,l,u=new VS;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,n=i.regionBelow(r),!!n){if(o=r.eUp,a=n.eUp,Ze.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(s=Ze.vertLeq(a.Dst,o.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);nt(n!==null);var s=i.regionBelow(n),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,n,a):i.addRightEdges(t,n,a.Onext,o,o,!0)},i.addSentinel=function(t,e,r,n){var s=new VS,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=n,o.Dst.s=e,o.Dst.t=n,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new F8(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,n,s,o),i.addSentinel(t,n,s,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++r===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,n=e.Lnext,Ze.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,s=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,e=t.pq=new B8(s,Ze.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,s;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,s=r.anEdge,nt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Ze.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),V8=function(){function i(){this.mesh=new dD,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=St.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 i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],n=f[v],c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-n.coords[0],h[1]=e.coords[1]-n.coords[1],h[2]=e.coords[2]-n.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,s=0,o=t.next;o!==t;o=o.next)if(n=o.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,n=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,n[o]=0,n[(o+1)%3]=0,n[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,n);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ze.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(Ze.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Ze.edgeGoesLeft(n.Lnext)||Ze.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=t.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Ze.edgeGoesRight(r.Lprev)||Ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=t.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,s=t.eHead.next;s!==t.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===br.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*n,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var h=u.n*n;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],n>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===br.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){n=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,n=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==n);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new dD),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,s,o){if(t===void 0&&(t=St.ODD),e===void 0&&(e=br.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),k8.computeInterior(this,o);var a=this.mesh;return e===br.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===br.BOUNDARY_CONTOURS?this.outputContours_(a,n):this.outputPolymesh_(a,e,r,n),!0},i}();function Es(i){var t=i.windingRule,e=t===void 0?St.ODD:t,r=i.elementType,n=r===void 0?br.POLYGONS:r,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new V8;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,n,o,l,c,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Dfe=St.ODD,Ife=St.NONZERO,Ofe=St.POSITIVE,Rfe=St.NEGATIVE,Lfe=St.ABS_GEQ_TWO,Nfe=br.POLYGONS,Bfe=br.CONNECTED_POLYGONS,Ffe=br.BOUNDARY_CONTOURS;var wv=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*wv.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*wv.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(n,o*s,3*t);o+=3*t;let l=new Float32Array(n,o*s,3*t);o+=3*t;let u=new Float32Array(n,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=n,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Dp=wv;Dp.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var xD=pn(vD()),Ip={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},jS={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},WS={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},HS=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),ul=class extends Ae{constructor(e,r,n=0,s=12,o=3,a=St.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let P=C.extractShapePointsToFlatArray([],s),D=[];for(let I=P.length-1;I>=1;I-=2){let R=P[I-1],U=P[I-0];D.push(R,U)}return D}),h=[],d=[];for(let C=0;C<u.length;C+=2)d.push([u[C],u[C+1]]);h.push(d);for(let C=0;C<c.length;C++){let P=c[C],D=[];for(let I=0;I<P.length;I+=2)D.push([P[I],P[I+1]]);h.push(D)}let f;e.isText?f=new Tu().setFromPoints(e.points.map(P=>P.position)).getSize(new N).length()*.1:h[0].length===0?f=n:f=(0,xD.default)(h).distance,n<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(n,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=Es({windingRule:a,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=Ip}let m;try{m=Es({windingRule:St.ODD,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=jS}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let C=0;C<m.elements.length;C++){let P=m.elements[C],D=C%2===0?p.vertexCount:0;p.elements.push(P+D)}for(let C=0;C<m.vertexIndices.length;C++){let P=m.vertexIndices[C],D=p.vertexCount;p.vertexIndices.push(P+D)}for(let C=0;C<m.vertices.length;C++){let P=m.vertices[C];p.vertices.push(P)}}let y=1/0,v=-1/0,x=1/0,w=-1/0;for(let C=0,P=p.vertexCount;C<P;C++){let D=C*2,I=p.vertices[D+0],R=p.vertices[D+1];I<y&&(y=I),I>v&&(v=I),R<x&&(x=R),R>w&&(w=R)}this._minX=y,this._minY=x,this._width=v-y,this._height=w-x,this._buffer=new Dp(this._computeBufferEstimatedSize(p));let S=[],A=[];for(let C=p.elementCount-1;C>=0;C--){let P=C>=g,D=C*2,I=p.elements[D+0],R=p.elements[D+1],U=I+R,F={start:I,count:R,normals:[],continuous:[],concave:[]},V=I,G=U-1,H=I+1,Y=this._shape.roundedCurves.length;do{let z=V-I,J=p.vertices[G*2+0],Z=p.vertices[G*2+1],K=p.vertices[V*2+0],W=p.vertices[V*2+1],ye=p.vertices[H*2+0],fe=p.vertices[H*2+1],se=K-J,_e=W-Z,xe=Math.sqrt(se*se+_e*_e);se/=xe,_e/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,F.normals[z*2+0]=-Ie,F.normals[z*2+1]=Oe,F.concave[z]=se*Ie-_e*Oe>0;let Me=p.vertexIndices[V];if(Array.isArray(Me))F.continuous[z]=!1;else{let[ze,Ue]=this._shape.getCurveIndexFromVertexId(Me-1,!0);if(Ue>0&&Ue<1)F.continuous[z]=!0;else{let L=Ue===1?ze+1:ze-1;L=(L+Y)%Y;let O=Ue===1?0:1,re=this._shape.roundedCurves[ze].getTangent(Ue),ue=this._shape.roundedCurves[L].getTangent(O);F.continuous[z]=re.dot(ue)>.95}}P&&(F.normals[z*2+0]*=-1,F.normals[z*2+1]*=-1),[G,V,H]=[V,H,H+1],H>=U&&(H-=R)}while(H!==I+1);let k=[];k.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,U*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((z,J)=>[J,J]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,U*2)});let j=0;for(let z=1;z<=this._bevelSegments;z++){let J=z/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(J))*this._bevel,K=[],W=[],ye=[],fe=[],se=0;for(let xe=0;xe<R;xe++){let Oe=xe*2,Ie=(xe-1+R)%R*2,Pe=p.vertices[F.start*2+Oe+0],Me=p.vertices[F.start*2+Oe+1],ze=-F.normals[Ie+0]*Z,Ue=-F.normals[Ie+1]*Z,L=-F.normals[Oe+0]*Z,O=-F.normals[Oe+1]*Z;if(F.concave[xe]||!F.concave[xe]&&P){let re=Math.atan2(Ue,ze),ue=Math.atan2(O,L);ue>re&&(ue-=Math.PI*2);let me=ue-re;if(F.continuous[xe]||P){let De=re+me/2,Te=Math.cos(De)*Z,Ee=Math.sin(De)*Z;K[2*se+0]=Pe+Te*(P?-1:1),K[2*se+1]=Me+Ee*(P?-1:1),fe[se]=xe,se++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Te=0;Te<=De;Te++){let Ee=re+me*(Te/De),le=Math.cos(Ee)*Z,Ke=Math.sin(Ee)*Z;K[2*se+0]=Pe+le,K[2*se+1]=Me+Ke,fe[se]=xe,se++}}}else K[2*se+0]=Pe+ze,K[2*se+1]=Me+Ue,fe[se]=xe,W[xe]=se,se++,K[2*se+0]=Pe,K[2*se+1]=Me,fe[se]=xe,se++,K[2*se+0]=Pe+L,K[2*se+1]=Me+O,fe[se]=xe,ye[xe]=se,se++}let _e=Es({windingRule:St.POSITIVE,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],Me=fe[(Ie+1)%fe.length];xe.idx=[Pe,Me],xe.Sym.idx=[Me,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!_e)throw console.log("Error"),new Error(`error generating bevel geometry for ${z}'th loop`);if(!_e.vertexCount){let xe=(z-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<_e.vertexIndices.length;xe++){let[Oe,Ie]=_e.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie<Oe&&(Pe+=R);for(let Me=Oe;Me<Pe;Me++){let ze=Me%R,Ue=(Me+1)%R;if(!F.continuous[ze]||!F.continuous[Ue]){_e.vertexIndices[xe]=[Oe,ze],_e.vertexIndices.splice(xe+1,0,[Ue,Ie]),_e.vertices.splice((xe+1)*2,0,_e.vertices[xe*2],_e.vertices[xe*2+1]);break}}}k.push({bevelI:z,angle:J,size:Z,boundary:_e,reverseMap:fe,insetPoints:K})}let X=(z,J,Z)=>{let K=0,W=z.boundary.vertexIndices.length;for(;K<W&&Z(z.boundary.vertexIndices[J]);)J=(J+1)%W,K++;return K},q=S.length;for(let z=1;z<k.length;z++){let J=k[z-1],Z=k[z],K=J.boundary.vertexIndices.length,W=Z.boundary.vertexIndices.length;if(!K||!W)break;let ye=F.concave.length,fe=0,se=HS(fe,R);for(;!J.boundary.vertexIndices.filter(se).length||!Z.boundary.vertexIndices.filter(se).length;)fe++,se=HS(fe,R);let _e=J.boundary.vertexIndices.findIndex(se),xe=Z.boundary.vertexIndices.findIndex(se);do _e=(_e+1)%K;while(se(J.boundary.vertexIndices[_e]));do xe=(xe+1)%W;while(se(Z.boundary.vertexIndices[xe]));fe=(fe+1)%R;let Oe=fe,Ie=0,Pe=this._buildBevelVert(F,J,(_e-1+K)%K,void 0,Ie),Me=this._buildBevelVert(F,Z,(xe-1+W)%W,void 0,Ie),ze=Pe,Ue=Me,L,O,re=!1;do{Ie=(fe||ye)/ye,se=HS(fe,R);let ue=X(J,_e,se),me=X(Z,xe,se),De=re;if(re=!1,ue&&!me){for(let Te=0;Te<ue;Te++)L=this._buildBevelVert(F,J,(_e+Te)%K,Te/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L;re=!0}else if(!ue&&me)for(let Te=0;Te<me;Te++)O=this._buildBevelVert(F,Z,(xe+Te)%W,Te/(me-1),Ie),S.push(Ue.topN,ze.topP,O.topP),l===!1&&S.push(ze.bottomP,Ue.bottomN,O.bottomP),Ue=O;else if(ue&&me)if(L=this._buildBevelVert(F,J,_e,0,Ie),O=this._buildBevelVert(F,Z,xe,0,Ie),De?(S.push(ze.topN,O.topP,Ue.topN),S.push(ze.topN,L.topP,O.topP),l===!1&&(S.push(O.bottomP,ze.bottomN,Ue.bottomN),S.push(O.bottomP,L.bottomP,ze.bottomN))):(S.push(Ue.topN,ze.topN,L.topP),S.push(Ue.topN,L.topP,O.topP),l===!1&&(S.push(L.bottomP,ze.bottomN,Ue.bottomN),S.push(L.bottomP,Ue.bottomN,O.bottomP))),ze=L,Ue=O,ue===me)for(let Te=1;Te<ue;Te++)L=this._buildBevelVert(F,J,(_e+Te)%K,Te/(ue-1),Ie),O=this._buildBevelVert(F,Z,(xe+Te)%W,Te/(me-1),Ie),S.push(ze.topN,L.topP,Ue.topN),S.push(Ue.topN,L.topP,O.topP),l===!1&&(S.push(L.bottomP,ze.bottomN,Ue.bottomN),S.push(L.bottomP,Ue.bottomN,O.bottomP)),ze=L,Ue=O;else if(ue>me){let Te=ue/me,Ee=0;for(let le=1;le<ue;le++)L=this._buildBevelVert(F,J,(_e+le)%K,le/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L,le>(Ee+1)*Te&&(Ee++,O=this._buildBevelVert(F,Z,(xe+Ee)%W,Ee/(me-1),Ie),S.push(Ue.topN,L.topP,O.topP),l===!1&&S.push(L.bottomP,Ue.bottomN,O.bottomP),Ue=O)}else{let Te=me/ue,Ee=0;for(let le=1;le<me;le++)O=this._buildBevelVert(F,Z,(xe+le)%W,le/(me-1),Ie),S.push(Ue.topN,L.topP,O.topP),l===!1&&S.push(L.bottomP,Ue.bottomN,O.bottomP),Ue=O,le>(Ee+1)*Te&&(Ee++,L=this._buildBevelVert(F,J,(_e+Ee)%K,Ee/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L)}_e=(_e+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(k,F,S),P){let z=[];for(let J=S.length-1;J>=q+2;J-=3){let Z=S[J-2],K=S[J-1],W=S[J-0];z.push(W,K,Z)}S.splice(q,S.length-q,...z)}if(P){let z=[];for(let J=k[k.length-1].boundary.vertices.length-1;J>=1;J-=2){let Z=k[k.length-1].boundary.vertices[J-1],K=k[k.length-1].boundary.vertices[J-0];z.push(Z,K)}A.push(z)}if(!P){let z=k[k.length-1],J;try{J=Es({windingRule:k.length>1?St.POSITIVE:St.ODD,elementType:br.POLYGONS,vertexSize:2,strict:!0,contours:[z.insetPoints,...A]})}catch{J=WS}if(!J)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<J.elementCount*3;Z+=3){let K=this._buildSurfaceVert(J,J.elements[Z+0],j),W=this._buildSurfaceVert(J,J.elements[Z+1],j),ye=this._buildSurfaceVert(J,J.elements[Z+2],j);S.push(K.top,W.top,ye.top),l===!1&&S.push(ye.bottom,W.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let E=new Ge(Uint32Array.from(S),1),b=new Ge(this._buffer.positions,3),M=new Ge(this._buffer.normals,3),T=new Ge(this._buffer.uvs,2);b.needsUpdate=!0,M.needsUpdate=!0,T.needsUpdate=!0,E.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",M),this.setAttribute("uv",T),this.setIndex(E)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),u=this._buildBevelVert(r,s,(o+1)%a);n.push(u.topP,l.topN,l.bottomN),n.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,n){let s=r.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],l=(o-this._minX)/this._width,u=(a-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),h=c*3,d=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-n,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=u,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=n,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=u),this.vertexCache[s]=f,f}_buildBevelVert(e,r,n,s=1,o){let a=`${r.bevelI}:${n}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,u]=r.boundary.vertexIndices[n],c,h,d,f;l!==u?(h=l,c=u,f=!1,d=e.continuous[h]&&e.continuous[c]):(c=l,h=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,d=e.continuous[c]||f);let p=Math.cos(r.angle),m=Math.sin(r.angle),g=n*2,y=c*2,v=h*2,x=r.boundary.vertices[g+0],w=r.boundary.vertices[g+1],S=(1-m)*this._bevel,A=(x-this._minX)/this._width,E=(w-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),E=1);let b=e.normals[y+0],M=e.normals[y+1],T=e.normals[v+0],C=e.normals[v+1];if(f){let U=T-b,F=C-M;b=b+U*(1-s),M=M+F*(1-s);let V=Math.sqrt(b*b+M*M);b/=V,M/=V}let P=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),D=P*3,I=P*2,R={i:n,fi:c,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1,pathBevelUCoord:o};return this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=b*p,this._buffer.normals[D+1]=M*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=b*p,this._buffer.normals[D+4]=M*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A),d||(this.forPathBevel?(P+=1,D+=3,I+=2):(P+=2,D+=6,I+=4),R.topP=P+0,R.bottomP=P+1,this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=T*p,this._buffer.normals[D+1]=C*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=T*p,this._buffer.normals[D+4]=C*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A)),this.vertexCache[a]=R,R}clone(){let e=new ul(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var Qh=class extends Ae{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=St.ODD;this.elementType=br.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:St.ODD,elementType:br.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),h!==void 0&&v!==h&&(u=!1),c=y,h=v,!l&&!u)break}if(!l&&!u)try{a=Es({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Ip}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let w=0,S=d;w<S;w++){let A=w*2,E=a.vertices[A+0],b=a.vertices[A+1];E<p&&(p=E),E>m&&(m=E),b<g&&(g=b),b>y&&(y=b)}let v=m-p,x=y-g;for(let w=0,S=d;w<S;w++){let A=w*2,E=a.vertices[A+0],b=a.vertices[A+1],M=(E-p)/v,T=(b-g)/x;this._positionAttribute.setXYZ(w,E,b,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,M,T)}for(let w=0,S=f;w<S;w++){let A=w*3,E=a.elements[A+0],b=a.elements[A+1],M=a.elements[A+2];this._indexAttribute.setX(A+0,E),this._indexAttribute.setX(A+1,b),this._indexAttribute.setX(A+2,M)}}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 Qh(this._shape,this._curveSegments);return e.userData=Zo(this.userData),e}};var Kh=class extends ul{constructor(e,r,n=0,s=12,o=3,a=St.ODD){super(e,r,n,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),u=this._buildBevelVert(r,s,(o+1)%a);n.push(u.topP,l.topN,l.bottomN),n.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Kh(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var yi=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:St.ODD},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Ot?(o.width!==r||o.height!==n)&&o.applySize(r,n):o=new Ot(r,n).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Ot(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new Qh(i.shape,n,{windingRule:o}):a=new Kh(i.shape,t,e,n,r,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var wD=Math.PI*2,Jh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Se.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,h=e*.5,d=j8(u,c,h,n*Math.PI/180,r,s);u.isClosed=!0,u.update();let f;return n===0?(f=new Ae,f.setAttribute("position",new be([],3))):f=yi.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function j8(i,t,e,r,n,s){if(r>=wD)return n>30||n%4===0?(q8(i,t,e,s),Math.round(n/4)):bD(i,r,n,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=hD({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%u.length===0?W8(i,o.x,o.y,u,n,t,e,s):bD(i,r,n,t,e,s)}function W8(i,t,e,r,n,s,o,a){let l=Math.round(n/r.length);i.addPoint(Zh(t,e));for(let u=0,c=r.length;u<c;u++){let h=r[u],d=i.points[u],f=Zh(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),i.addPoint(f)}return a>0?SD(i,s,o,a):i.addPoint(Zh(0,0)),l}function bD(i,t,e,r,n,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*r,c=Math.cos(l)*n;i.addPoint(Zh(u,c))}return t<wD?s>0?SD(i,r,n,s):i.addPoint(Zh(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&AD(i,r,n,s)),1}function q8(i,t,e,r=0,n=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Av(n-t,s,n-t,s-l,n-t,s+l)),i.addPoint(Av(n,s+e,n-a,s+e,n+a,s+e)),i.addPoint(Av(n+t,s,n+t,s+l,n+t,s-l)),i.addPoint(Av(n,s-e,n+a,s-e,n-a,s-e)),r>0&&AD(i,t,e,r)}function Zh(i,t){return new _s(Se.generateUUID(),new N(i,t))}function Av(i,t,e,r,n,s){let o=Zh(i,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(n,s),o}function SD(i,t,e,r){_D(i,t,e,r).forEach(s=>i.addPoint(s))}function AD(i,t,e,r){let n=_D(i,t,e,r),s=new Ot;n.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function _D(i,t,e,r){let n=r*t/100,s=n*(Math.abs(e)/Math.abs(t)),o=new N(n/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Se.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var ED=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:n,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=i.parameters,d=new Op(!1,t,e,r,n,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},qS=new Ws([0,0,0],1),Op=class extends Ae{constructor(t=!0,e=1,r=1,n=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new _,m=new _,g=p(),y=p(),v=p(),x,w,S,A,E,b,M,T,C=p(),P=p(),D=p(),I=p(),R=p(),U=p(),F=p(),V=p(),G=r-2*l+.001,H=G/o,Y=Math.ceil(a*o),k=Y+1,j=G/Y,X=-G/2,q=c+1,z=2*Math.PI/c,J=Math.PI/2/d,Z=.01,K=Math.min((1-h/100)*l,l-Z),W=l-K,ye=0,fe=2,se=d*fe+fe,_e=q*se/fe,xe=_e+q*k,Oe=Math.max(0,q*(k+se)),[Ie,Pe,Me]=[3,3,2].map(ke=>Array(Oe*ke).fill(0)),ze=[],Ue=s-l;function L(ke,Ne){let We=Math.PI/2;b=Ne*j,T=2*Math.PI*(b%H)/H+We,b+=X,M=Math.sin(T)*Ue,E=Math.cos(T)*Ue,t?ke.set(E,M,b):ke.set(E,b,M)}L(m,-1e-10),L(g,0),C.copy(m),L(m,1);let O=m.distanceTo(g),re=f?0:W+K,ue=O*Y+2*re,me=K,De=ue-re;for(let ke=0;ke<=Y;ke++){L(y,ke),V.subVectors(y,C).normalize(),C.copy(y),U.copy(y).setComponent(+t+1,0).normalize(),F.crossVectors(V,U).normalize();let Ne=ke===0,We=ke===Y,$e=Ne?3*Math.PI/2:J,_t=Ne?me:De,ir=Ne?q:xe,Gr=Ne?0:Oe-q,Q=V.clone().multiplyScalar(Ne?-W:W).add(y),ce=V.clone().multiplyScalar(Ne?-1:1).normalize();for(let ve=0;ve<q;ve++){let Ve=ve*z;if(P.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Ve)),g.copy(F).multiplyScalar(l*Math.sin(Ve))),D.copy(P).normalize(),Ne||We){f||(ye=Gr+ve,[0,1,2].forEach(Fe=>{Ie[ye*3+Fe]=Q.getComponent(Fe),Pe[ye*3+Fe]=ce.getComponent(Fe)}),Me[ye*2]=+We,Me[ye*2+1]=ve/c),g.copy(D).multiplyScalar(K),v.addVectors(y,g);for(let Fe=0;Fe<d;Fe++){let Et=Fe*J+$e;I.addVectors(m.copy(V).multiplyScalar(W*Math.sin(Et)),g.copy(D).multiplyScalar(W*Math.cos(Et))),R.copy(I).normalize(),g.addVectors(v,I),I.normalize(),ye=ir+Fe*q+ve,[0,1,2].forEach(Pr=>{Ie[ye*3+Pr]=g.getComponent(Pr),Pe[ye*3+Pr]=R.getComponent(Pr)});let Hr=+Ne+Math.sin(Et);Me[ye*2]=(_t+W*Hr)/ue,Me[ye*2+1]=ve/c}}g.addVectors(y,P),ye=_e+ke*q+ve,[0,1,2].forEach(Fe=>{Ie[ye*3+Fe]=g.getComponent(Fe),Pe[ye*3+Fe]=D.getComponent(Fe)}),Me[ye*2]=(re+ke*O)/ue,Me[ye*2+1]=ve/c}}let Te=k+2*d+fe,Ee=1,[le,Ke]=[+f,Te-1];for(let ke=le;ke<=Ke-1;ke++){let Ne=f&&ke===Ke-1;for(let We=0;We<q-1;We++)x=ke*q+We,w=x+1,S=(Ne?We:x)+q,A=(Ne?We+1:w)+q,ke===0?ze.push(w,A,S):ke===Te-2?ze.push(x,w,S):ze.push(x,w,S,w,A,S)}this.setIndex(ze),this.setAttribute("position",new be(Ie,3)),this.setAttribute("normal",new be(Pe,3)),this.setAttribute("uv",new be(Me,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,n=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,h=c===e;for(let d=0;d<t.radialSegments;d++)s=c*r+d,o=s+1,a=(h?d:s)+r,l=(h?d+1:o)+r,n[u++]=s,n[u++]=o,n[u++]=a,n[u++]=o,n[u++]=l,n[u++]=a;return n.length=u,qS.array=n,qS.count=n.length,qS}};var MD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new Rp(t*.5,s,o):new yu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},Rp=class extends al{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,r),this.type=a}static fromJSON(t){return new Rp(t.radius,t.corner,t.cornerSides)}};var TD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=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}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new Wo;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new du(n.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var ao=new ie,YS=new gt,_v=new _,hl=class extends Yt{constructor(){super(),this.uuid=Se.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(t){let e=new Gt().getNormalMatrix(t);for(let r=0,n=this.vertices.length;r<n;r++)this.vertices[r].applyMatrix4(t);for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return ao.makeRotationX(t),this.applyMatrix4(ao),this}rotateY(t){return ao.makeRotationY(t),this.applyMatrix4(ao),this}rotateZ(t){return ao.makeRotationZ(t),this.applyMatrix4(ao),this}translate(t,e,r){return ao.makeTranslation(t,e,r),this.applyMatrix4(ao),this}scale(t,e,r){return ao.makeScale(t,e,r),this.applyMatrix4(ao),this}lookAt(t){return YS.lookAt(t),YS.updateMatrix(),this.applyMatrix4(YS.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,n=t.attributes;if(n.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=n.position,o=n.normal,a=n.color,l=n.uv,u=n.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new _().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new Re().fromBufferAttribute(a,d));function c(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new _().fromBufferAttribute(o,d),new _().fromBufferAttribute(o,f),new _().fromBufferAttribute(o,p)],v=new $h(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new N().fromBufferAttribute(l,d),new N().fromBufferAttribute(l,f),new N().fromBufferAttribute(l,p)]),u!==void 0&&e.faceVertexUvs[1].push([new N().fromBufferAttribute(u,d),new N().fromBufferAttribute(u,f),new N().fromBufferAttribute(u,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)r!==void 0?c(r.getX(g),r.getX(g+1),r.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)c(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_v).negate(),this.translate(_v.x,_v.y,_v.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,n=new ie;return n.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(n),this}computeFaceNormals(){let t=new _,e=new _;for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,n=this.vertices.length;r<n;r++)e[r]=new _;if(t){let r=new _,n=new _;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];r.subVectors(c,u),n.subVectors(l,u),r.cross(n),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let r=0,n=this.vertices.length;r<n;r++)e[r].normalize();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],n=r.vertexNormals;n.length===3?(n[0].copy(r.normal),n[1].copy(r.normal),n[2].copy(r.normal)):(n[0]=r.normal.clone(),n[1]=r.normal.clone(),n[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]);for(let s=0,o=n.vertexNormals.length;s<o;s++)n.__originalVertexNormals[s]?n.__originalVertexNormals[s].copy(n.vertexNormals[s]):n.__originalVertexNormals[s]=n.vertexNormals[s].clone()}let t=new hl;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new _,c={a:new _,b:new _,c:new _};s.push(u),o.push(c)}}let n=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=n.faceNormals[s],u=n.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Pt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fr),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let n,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,h=t.colors;e!==void 0&&(n=new Gt().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let p=u[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new $h(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),n!==void 0&&x.normal.applyMatrix3(n).normalize();for(let w=0,S=y.length;w<S;w++)m=y[w].clone(),n!==void 0&&m.applyMatrix3(n).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let w=0,S=v.length;w<S;w++)g=v[w],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,w=y.length;x<w;x++)v.push(y[x].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],n=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[h]===void 0?(e[h]=l,r.push(this.vertices[l]),n[l]=r.length-1):n[l]=n[e[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=n[c.a],c.b=n[c.b],c.c=n[c.c];let h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let n=t[e];this.vertices.push(new _(n.x,n.y,n.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,u){return l.materialIndex-u.materialIndex}t.sort(r);let n=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;n&&n.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(n[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let r=[],n=[],s={},o=[],a={},l=[],u={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,w=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,E=0;if(E=c(E,0,0),E=c(E,1,g),E=c(E,2,y),E=c(E,3,v),E=c(E,4,x),E=c(E,5,w),E=c(E,6,S),E=c(E,7,A),r.push(E),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let b=this.faceVertexUvs[0][p];r.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&r.push(h(m.normal)),w){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(S&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function c(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=n.length/3,n.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(p.x,p.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=n,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new hl().copy(this)}copy(t){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=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let n=t.faces;for(let d=0,f=n.length;d<f;d++)this.faces.push(n[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,w=y.length;x<w;x++){let S=y[x];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=t.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new XS().fromGeometry(this),e=new Ae,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Ev.call(new Ge(r,3),t.vertices)),t.normals.length>0){let n=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ev.call(new Ge(n,3),t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);e.setAttribute("color",CD.call(new Ge(n,3),t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);e.setAttribute("uv",PD.call(new Ge(n,2),t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",PD.call(new Ge(n,2),t.uvs2))}e.groups=t.groups;for(let n in t.morphTargets){let s=[],o=t.morphTargets[n];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new be(u.data.length*3,3);c.name=u.name,s.push(Ev.call(c,u.data))}e.morphAttributes[n]=s}if(t.skinIndices.length>0){let n=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",DD.call(n,t.skinIndices))}if(t.skinWeights.length>0){let n=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",DD.call(n,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ae,r=t.geometry;if(t.isPoints||t.isLine){let n=new be(r.vertices.length*3,3),s=new be(r.colors.length*3,3);if(e.setAttribute("position",Ev.call(n,r.vertices)),e.setAttribute("color",CD.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new be(r.lineDistances.length,1);e.setAttribute("lineDistance",Y8.call(o,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};hl.prototype.isGeometry=!0;var XS=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(t){let e=[],r,n,s,o=t.faces;for(n=0;n<o.length;n++){let a=o[n];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=n*3-r.start,e.push(r)),r={start:n*3,materialIndex:s})}r!==void 0&&(r.count=n*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,n=t.faceVertexUvs,s=n[0]&&n[0].length>0,o=n[1]&&n[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,h=c.length,d;if(h>0){d=[];for(let y=0;y<h;y++)d[y]={name:c[y].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,m=f.length===r.length,g=p.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(r[v.a],r[v.b],r[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=n[0][y];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new N,new N,new N))}if(o===!0){let S=n[1][y];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new N,new N,new N))}for(let S=0;S<l;S++){let A=a[S].vertices;u[S].data.push(A[v.a],A[v.b],A[v.c])}for(let S=0;S<h;S++){let A=c[S].vertexNormals[y];d[S].data.push(A.a,A.b,A.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},$h=class{constructor(t,e,r,n,s,o=0){this.a=t,this.b=e,this.c=r,this.normal=n&&n.isVector3?n:new _,this.vertexNormals=Array.isArray(n)?n:[],this.color=s&&s.isColor?s:new Re,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function Y8(i){return this.array.set(i),this}function CD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new Re),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function PD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new N),t[e++]=s.x,t[e++]=s.y}return this}function Ev(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new _),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function DD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Xe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var X8=["a","b","c"];function Q8(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function QS(i,t,e){let r=Math.min(i,t),n=Math.max(i,t),s=r+"_"+n;return e.get(s)}function KS(i,t,e,r,n,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(r.has(l))u=r.get(l);else{let c=e[o],h=e[a];u={a:c,b:h,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(n),s[i].edges.push(u),s[t].edges.push(u)}function K8(i,t,e,r){let n,s,o;for(n=0,s=i.length;n<s;n++)e[n]={edges:[]};for(n=0,s=t.length;n<s;n++)o=t[n],KS(o.a,o.b,i,r,o,e),KS(o.b,o.c,i,r,o,e),KS(o.c,o.a,i,r,o,e)}function Mv(i,t,e,r,n){i.push(new $h(t,e,r,void 0,void 0,n))}function ed(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Tv(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Cv=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ae?t=new hl().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new _,r,n,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;K8(l,u,d,f);let p=[],m,g,y,v,x,w,S;for(let Z of Array.from(f.keys())){for(g=f.get(Z),y=new _,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(m=l[Q8(v,X8[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(w),y.add(e),g.newEdge=p.length,p.push(y)}let A,E,b,M,T,C,P,D=[];for(n=0,s=l.length;n<s;n++){for(C=l[n],T=d[n].edges,r=T.length,r==3?A=3/16:r>3&&(A=3/(8*r)),E=1-r*Number(A),b=A,r<=2&&(r==2?(E=3/4,b=1/8):r==1||r==0),P=C.clone().multiplyScalar(E),e.set(0,0,0),o=0;o<r;o++)M=T[o],m=M.a!==C?M.a:M.b,e.add(m);e.multiplyScalar(Number(b)),P.add(e),D.push(P)}let I=D.concat(p),R=D.length,U,F,V,G=[],H=[],Y,k,j,X,q=new N,z=new N,J=new N;for(n=0,s=u.length;n<s;n++)v=u[n],U=Number(QS(v.a,v.b,f).newEdge)+R,F=Number(QS(v.b,v.c,f).newEdge)+R,V=Number(QS(v.c,v.a,f).newEdge)+R,Mv(G,U,F,V,v.materialIndex),Mv(G,v.a,U,V,v.materialIndex),Mv(G,v.b,F,U,v.materialIndex),Mv(G,v.c,V,F,v.materialIndex),h&&(Y=c[n],k=Y[0],j=Y[1],X=Y[2],q.set(ed(k.x,j.x),ed(k.y,j.y)),z.set(ed(j.x,X.x),ed(j.y,X.y)),J.set(ed(k.x,X.x),ed(k.y,X.y)),Tv(H,q,z,J),Tv(H,k,q,J),Tv(H,j,z,q),Tv(H,X,J,z));t.vertices=I,t.faces=G,h&&(t.faceVertexUvs[0]=H)}};var ln=new _,ID=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ae().copy(new yn(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(ln),r={width:ln.x,height:ln.y,depth:ln.z,subdivisions:0}):r=t.parameters;let n={...r,...i.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,s=i.geometry??new Ae().copy(new yn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(ln)):ln.set(o.width,o.height,o.depth),(t!==ln.x||e!==ln.y||r!==ln.z)&&s.scale(ln.x===0?1:t/ln.x,ln.y===0?1:e/ln.y,ln.z===0?1:r/ln.z);let a=s.originalGeometry;try{n>0?(a===void 0||o?.subdivisions!==n)&&(a===void 0&&(a=s),s=new Cv(n).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Eu(e).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(ln);let o=100/ln.x;Object.assign(s.parameters,{width:100,height:ln.y*o,depth:ln.z*o}),t(this.build(s))})}};var Pv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,h=0,d=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let g=f*m,y=h+Math.sin(g)*u,v=d+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=n;l.roundness=n,l.update();let p=yi.create({shape:l,parameters:{roundness:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var OD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new JS(t*.5,e,n,s,o,a,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function Lp(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function ZS(i,t,e,r,n,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===n){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,r/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,n/Math.sin(u)),s.addScaledVector(a,r/Math.sin(u))}}function Z8(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var JS=class extends Ae{constructor(t=.5,e=1,r=4,n=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),a=Math.floor(a);let l=[],u=[],c=[],h=[],d=0,f=e/2,p=Math.PI/r,m=t*Math.cos(Math.PI/r),g=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,x=new _(0,-f,0),w=new _(0,f,0),S=new N(t,-f),A=new N(m,-f),E=new N(0,w.y).sub(A),b=new N(0,w.y).sub(S),M=new N(E.y,-E.x).normalize(),T=new N(b.y,-b.x).normalize(),P=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;o=Math.min(o,P);let D;{let H=new _(M.x,M.y,0),Y=new _(Math.cos(g)*H.x,H.y,Math.sin(g)*H.x);D=H.angleTo(Y)}let I=o/Math.tan((Math.PI-E.angle())/2),R=o/Math.tan((Math.PI-D)/2),U=new _;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),h.push(0,0);let H=d++,Y=[],k=S.clone(),j=I/Math.cos(Math.PI/r);k.x-=j;for(let X=0;X<r;X++){let q=X/r*Math.PI*2+p,z=new N(Math.sin(q),Math.cos(q));Lp(k,z,U),u.push(U.x,U.y,U.z),c.push(0,-1,0),h.push(0,0),Y.push(d++)}for(let X=0;X<Y.length;X++)l.push(Y[X],H,Y[(X+1)%Y.length])}let F=[];{let H=new _,Y=new _,k=new _,j=new _,X=new _,q=new _;for(let z=0;z<r;z++){let J=z/r*Math.PI*2+p,Z=(z+.5)/r*Math.PI*2+p,K=(z+1)/r*Math.PI*2+p,W=new N(Math.sin(J),Math.cos(J)),ye=new N(Math.sin(Z),Math.cos(Z)),fe=new N(Math.sin(K),Math.cos(K));Lp(S,W,Y),Lp(S,fe,k),Lp(M,ye,H),ZS(w,Y,k,R,R,j),u.push(j.x,j.y,j.z),ZS(Y,w,k,R,I,X),u.push(X.x,X.y,X.z),ZS(k,Y,w,I,R,q),u.push(q.x,q.y,q.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),h.push(0,0),h.push(0,0),h.push(0,0);let se=d++,_e=d++,xe=d++;if(l.push(se,_e,xe),o>0){{let Pe=Y.clone().add(k).multiplyScalar(.5),Me=w.clone().sub(Pe).normalize(),Ue=x.clone().sub(Pe).normalize().add(Me).normalize().multiplyScalar(-1),L=q.clone().sub(X);V(Pe,L,Ue,E.angle())}let Oe,Ie;{let Pe=new _;Lp(T,fe,Pe);let Me=q.clone().add(j).multiplyScalar(.5);Me=Z8(Me,k,w);let ze=q.clone().sub(j);[Oe,Ie]=V(Me,ze,Pe,D,j.y)}{let Pe=Oe,Me=Pe.clone().setY(0).normalize(),ze=new _(0,-1,0),Ue=Me.clone().cross(ze);G(Pe,Me,ze,Ue)}F.concat(Ie);{let Pe=E.angle(),Me=Math.PI-Pe,ze=w.clone();ze.y-=o/Math.sin(Pe-Math.PI/2);let Ue=new _,L=[];for(let re=0;re<a;re++){let ue=[],me=Math.PI/2-Me*re/a,De=Math.cos(me),Te=Math.sin(me),Ee=Z;for(let le=0;le<=re;le++){let Ke=Math.cos(Ee),ke=Math.sin(Ee);H.x=De*ke,H.y=Te,H.z=De*Ke,Ue.copy(ze).addScaledVector(H,o),u.push(Ue.x,Ue.y,Ue.z),c.push(H.x,H.y,H.z),h.push(0,0),ue.push(d++),Ee+=Math.PI*2/re/r}L.push(ue)}Ie.reverse(),L.push(Ie);let O=L.length-1;for(let re=0;re<O;re++){let ue=L[re],me=L[re+1],De=ue.length-1;l.push(me[1],ue[0],me[0]);for(let Te=1;Te<=De;Te++)l.push(ue[Te],ue[Te-1],me[Te]),l.push(me[Te+1],ue[Te],me[Te])}}}}}this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(h,2));function V(H,Y,k,j,X){let q=-j/2,z=(Math.PI-j)/2,J=Y.clone().normalize().cross(k);H.addScaledVector(k,-o/Math.sin(z));let Z=new _,K=new _,W=1,ye=d,fe=[];for(let se=0;se<=a;se++){let _e=q+se/a*j;K.set(0,0,0),K.addScaledVector(J,Math.sin(_e)),K.addScaledVector(k,Math.cos(_e));for(let xe=0;xe<=W;xe++){let Oe=xe/W-.5;if(Z.copy(H),Z.addScaledVector(Y,Oe),Z.addScaledVector(K,o),X!=null){let Ie=Math.max(0,Z.y-X);Z.addScaledVector(Y,-Ie/Y.y)}u.push(Z.x,Z.y,Z.z),c.push(K.x,K.y,K.z),h.push(0,0),xe===0&&fe.push(d),d++}}for(let se=0;se<a;se++)for(let _e=0;_e<W;_e++){let xe=ye+_e+(W+1)*se,Oe=xe+(W+1),Ie=Oe+1,Pe=xe+1;l.push(xe,Oe,Pe),l.push(Oe,Ie,Pe)}return[H.clone().addScaledVector(Y,.5),fe]}function G(H,Y,k,j){let X=Math.PI/2,q=b.angle()-X,z=[],J=new _,Z=new _;for(let W=0;W<=a;W++){let ye=[],fe=W/a;for(let se=0;se<=W;se++){let xe=((W?se/W:0)-.5)*v,Oe=Math.cos(xe),Ie=Math.sin(xe),Pe=Math.atan(Math.tan(q)*Oe),Me=(X+Pe)*fe,ze=Math.cos(Me),Ue=Math.sin(Me);J.set(0,0,0),J.addScaledVector(Y,Ue*Oe),J.addScaledVector(k,ze),J.addScaledVector(j,Ue*Ie),Z.copy(H).addScaledVector(J,o),u.push(Z.x,Z.y,Z.z),c.push(J.x,J.y,J.z),h.push(0,0),ye.push(d++)}z.push(ye)}let K=z.length-1;for(let W=0;W<K;W++){let ye=z[W],fe=z[W+1],se=ye.length-1;l.push(ye[0],fe[1],fe[0]);for(let _e=1;_e<=se;_e++)l.push(ye[_e-1],ye[_e],fe[_e]),l.push(ye[_e],fe[_e+1],fe[_e])}}}};var Dv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function d(w,S,A){return S>e&&A>r?Math.min(w*e/S,w*r/A):S>e?w*e/S:A>r?w*r/A:w}let f=[];f[0]=n[0]===0?0:d(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:d(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:d(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:d(n[3],n[3]+n[0],n[3]+n[2]);let p=c.x,m=h.x,g=h.y,y=c.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let w=0,S=t.points.length;w<S;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=yi.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var RD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ae,c.setAttribute("position",new be([],3))):c=new Kl(.5*t,n,s,o,a,l,u*Se.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var LD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new jo(t,e,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var ND=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:s,cornerSegments:o}=i.parameters,a=new $S(t,e,r,n,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},$S=class extends Ae{constructor(t=1,e=1,r=1,n=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),n=Math.min(180-c,n),n*=Math.PI/180;let h=[],d=Math.PI/2,f=(Z=0,K=0,W=0)=>new _(Z,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,w=+y,[S,A,E]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(Z,K=!1)=>Math.sin(Z-Math.PI/(1+ +K)),M=(Z,K=!1)=>Math.cos(Z-Math.PI/(1+ +K));E.y=Math.sin(n)*e-g;let T=Math.cos(n)*e-v,C=S.z-c;n<=d?(E.z=Math.min(T,C),E.z==C&&(E.y-=(T-C)/Math.tan(d-n))):A.z=Math.min(A.z-T-v,S.z-c),p.subVectors(S,A),m.subVectors(E,A);let P=Math.min(p.length(),m.length())*s/100,D=P*Math.tan(n/2),I=P/Math.cos(n/2),R=p.clone().normalize().add(m.normalize()).setLength(I).add(A);p.set(0,b(n,!0),M(n,!0)),h.push([E,p.clone()]);let U=(Math.PI-n)/o;for(let Z=0;Z<=o;Z++){let K=d+n+Z*U;p.set(0,Math.sin(K)*D,Math.cos(K)*D),p.add(R),m.set(0,b(K),M(K)),h.push([p.clone(),m.clone()])}h.push([S,f(0,1,0)]);let F=Math.sin(U/2)*D*2,V=h.length-1,G=h[0][0].distanceTo(h[1][0]),H=h[V-1][0].distanceTo(h[V][0]),Y=G+F*o+H;h[0].push(1);for(let Z=0;Z<=o;Z++)h[Z+1].push(1-(G+Z*F)/Y);h[V].push(0);let[k,j,X]=h[0],q,z,J;for(let Z=1;Z<h.length;Z++)[q,z,J]=h[Z],a.push(x,k.y,k.z,x,q.y,q.z,w,k.y,k.z,w,k.y,k.z,x,q.y,q.z,w,q.y,q.z),l.push(0,j.y,j.z,0,z.y,z.z,0,j.y,j.z,0,j.y,j.z,0,z.y,z.z,0,z.y,z.z),u.push(0,X,0,J,1,X,1,X,0,J,1,J),[k,j,X]=[q,z,J];this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(l,3)),this.setAttribute("uv",new be(u,2))}};var Iv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,h=t*.5,d=e*.5,f=0,p=0,m=o*Math.PI/360/n,g=Math.PI/2*3*-1,y=h*r/100,v=d*r/100;if(n===3&&r===50){m=2*Math.PI/n;for(let w=0;w<n;w++){let S=m*w,A=f+Math.sin(S)*h,E=p+Math.cos(S)*d;c.addPoint(c.createPoint(A,E))}}else for(let w=0;w<n;w++){let S=f+Math.cos(g)*h,A=p+Math.sin(g)*d;c.addPoint(c.createPoint(S,A)),g+=m,S=f+Math.cos(g)*y,A=p+Math.sin(g)*v,w<=n,c.addPoint(c.createPoint(S,A)),g+=m}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let x=yi.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var BD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new jo(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var FD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:n,depth:s})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=J8(t,e,r,t*.5,o,s,0,0,n,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function J8(i,t,e,r,n,s,o,a,l,u,c){[t,e]=[e,t],o=t/2;let h=Se.clamp(n/360,0,1);if(h===0){let d=new Ae;return d.setAttribute("position",new be([],3)),d}return h===1&&(u=0),new Op(!0,i,t,e,r,h,s,o,a,l,u,c)}var kD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new vu(a,e,r,n,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var VD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=yi.create({shape:l,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...i,type:"TriangleGeometry"}})}};function zD(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var eA=class{add(t,e,r){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(n){this[n]=this[n]||[],e&&this[n][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},tA=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ae=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ae.version}static addUnaryOp(t){return ae.max_unop_len=Math.max(t.length,ae.max_unop_len),ae.unary_ops[t]=1,ae}static addBinaryOp(t,e,r){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,r?ae.right_associative.add(t):ae.right_associative.delete(t),ae}static addIdentifierChar(t){return ae.additional_identifier_chars.add(t),ae}static addLiteral(t,e){return ae.literals[t]=e,ae}static removeUnaryOp(t){return delete ae.unary_ops[t],t.length===ae.max_unop_len&&(ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops)),ae}static removeAllUnaryOps(){return ae.unary_ops={},ae.max_unop_len=0,ae}static removeIdentifierChar(t){return ae.additional_identifier_chars.delete(t),ae}static removeBinaryOp(t){return delete ae.binary_ops[t],t.length===ae.max_binop_len&&(ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops)),ae.right_associative.delete(t),ae}static removeAllBinaryOps(){return ae.binary_ops={},ae.max_binop_len=0,ae}static removeLiteral(t){return delete ae.literals[t],ae}static removeAllLiterals(){return ae.literals={},ae}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new ae(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return ae.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ae.binary_ops[String.fromCharCode(t)]||ae.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ae.isIdentifierStart(t)||ae.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(ae.hooks[t]){let r={context:this,node:e};return ae.hooks.run(t,r),r.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ae.SPACE_CODE||t===ae.TAB_CODE||t===ae.LF_CODE||t===ae.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:ae.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,n;for(;this.index<this.expr.length;)if(r=this.code,r===ae.SEMCOL_CODE||r===ae.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())e.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,ae.max_binop_len),e=t.length;for(;e>0;){if(ae.binary_ops.hasOwnProperty(t)&&(!ae.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,n,s,o,a,l,u;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:ae.binaryPrecedence(e),right_a:ae.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),n=[o,s,a];e=this.gobbleBinaryOp();){if(r=ae.binaryPrecedence(e),r===0){this.index-=e.length;break}s={value:e,prec:r,right_a:ae.right_associative.has(e)},u=e;let c=h=>s.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;n.length>2&&c(n[n.length-2]);)a=n.pop(),e=n.pop().value,o=n.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),n.push(s,t)}for(l=n.length-1,t=n[l];l>1;)t={type:ae.BINARY_EXP,operator:n[l-1].value,left:n[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)n=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),r=e.length;r>0;){if(ae.unary_ops.hasOwnProperty(e)&&(!ae.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ae.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--r)}ae.isIdentifierStart(t)?(n=this.gobbleIdentifier(),ae.literals.hasOwnProperty(n.name)?n={type:ae.LITERAL,value:ae.literals[n.name],raw:n.name}:n.name===ae.this_str&&(n={type:ae.THIS_EXP})):t===ae.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===ae.PERIOD_CODE||e===ae.OBRACK_CODE||e===ae.OPAREN_CODE||e===ae.QUMARK_CODE;){let r;if(e===ae.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ae.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===ae.OBRACK_CODE?(t={type:ae.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==ae.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===ae.OPAREN_CODE?t={type:ae.CALL_EXP,arguments:this.gobbleArguments(ae.CPAREN_CODE),callee:t}:(e===ae.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:ae.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===ae.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,ae.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===ae.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===ae.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ae.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===r){n=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
3152
+ }`;function fz(i,t,e){let r=new Bf,n=new N,s=new N,o=new Xe,a=new Ff({depthPacking:Jb}),l=new Cb,u={},c=e.maxTextureSize,h={[Pi]:Qr,[Qr]:Pi,[Ln]:Ln},d=new at({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new N},radius:{value:4}},vertexShader:hz,fragmentShader:dz}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ae;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new _r(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ng,this.render=function(w,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let E=i.getRenderTarget(),b=i.getActiveCubeFace(),M=i.getActiveMipmapLevel(),T=i.state;T.setBlending(Vt),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let C=0,P=w.length;C<P;C++){let D=w[C],I=D.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",D,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;n.copy(I.mapSize);let R=I.getFrameExtents();if(n.multiply(R),s.copy(I.mapSize),(n.x>c||n.y>c)&&(n.x>c&&(s.x=Math.floor(c/R.x),n.x=s.x*R.x,I.mapSize.x=s.x),n.y>c&&(s.y=Math.floor(c/R.y),n.y=s.y*R.y,I.mapSize.y=s.y)),I.map===null){let F=this.type!==Mf?{minFilter:kt,magFilter:kt}:{};I.map=new ht(n.x,n.y,F),I.map.texture.name=D.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let U=I.getViewportCount();for(let F=0;F<U;F++){let V=I.getViewport(F);o.set(s.x*V.x,s.y*V.y,s.x*V.z,s.y*V.w),T.viewport(o),I.updateMatrices(D,F),r=I.getFrustum(),x(S,A,I.camera,D,this.type)}I.isPointLightShadow!==!0&&this.type===Mf&&y(I,A),I.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(E,b,M)};function y(w,S){let A=t.update(m);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ht(n.x,n.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(S,null,A,d,m,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(S,null,A,f,m,null)}function v(w,S,A,E,b,M){let T=null,C=A.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0)T=C;else if(T=A.isPointLight===!0?l:a,i.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let P=T.uuid,D=S.uuid,I=u[P];I===void 0&&(I={},u[P]=I);let R=I[D];R===void 0&&(R=T.clone(),I[D]=R),T=R}return T.visible=S.visible,T.wireframe=S.wireframe,M===Mf?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:h[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,A.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(A.matrixWorld),T.nearDistance=E,T.farDistance=b),T}function x(w,S,A,E,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===Mf)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,w.matrixWorld);let C=t.update(w),P=w.material;if(Array.isArray(P)){let D=C.groups;for(let I=0,R=D.length;I<R;I++){let U=D[I],F=P[U.materialIndex];if(F&&F.visible){let V=v(w,F,E,A.near,A.far,b);i.renderBufferDirect(A,null,C,V,w,U)}}}else if(P.visible){let D=v(w,P,E,A.near,A.far,b);i.renderBufferDirect(A,null,C,D,w,null)}}let T=w.children;for(let C=0,P=T.length;C<P;C++)x(T[C],S,A,E,b)}}function pz(i,t,e){let r=e.isWebGL2;function n(){let Q=!1,ce=new Xe,ve=null,Ve=new Xe(0,0,0,0);return{setMask:function(Fe){ve!==Fe&&!Q&&(i.colorMask(Fe,Fe,Fe,Fe),ve=Fe)},setLocked:function(Fe){Q=Fe},setClear:function(Fe,Et,Hr,Pr,Dl){Dl===!0&&(Fe*=Pr,Et*=Pr,Hr*=Pr),ce.set(Fe,Et,Hr,Pr),Ve.equals(ce)===!1&&(i.clearColor(Fe,Et,Hr,Pr),Ve.copy(ce))},reset:function(){Q=!1,ve=null,Ve.set(-1,0,0,0)}}}function s(){let Q=!1,ce=null,ve=null,Ve=null;return{setTest:function(Fe){Fe?J(2929):Z(2929)},setMask:function(Fe){ce!==Fe&&!Q&&(i.depthMask(Fe),ce=Fe)},setFunc:function(Fe){if(ve!==Fe){switch(Fe){case W3:i.depthFunc(512);break;case q3:i.depthFunc(519);break;case Y3:i.depthFunc(513);break;case fb:i.depthFunc(515);break;case X3:i.depthFunc(514);break;case Q3:i.depthFunc(518);break;case K3:i.depthFunc(516);break;case Z3:i.depthFunc(517);break;default:i.depthFunc(515)}ve=Fe}},setLocked:function(Fe){Q=Fe},setClear:function(Fe){Ve!==Fe&&(i.clearDepth(Fe),Ve=Fe)},reset:function(){Q=!1,ce=null,ve=null,Ve=null}}}function o(){let Q=!1,ce=null,ve=null,Ve=null,Fe=null,Et=null,Hr=null,Pr=null,Dl=null;return{setTest:function(hr){Q||(hr?J(2960):Z(2960))},setMask:function(hr){ce!==hr&&!Q&&(i.stencilMask(hr),ce=hr)},setFunc:function(hr,Io,Vi){(ve!==hr||Ve!==Io||Fe!==Vi)&&(i.stencilFunc(hr,Io,Vi),ve=hr,Ve=Io,Fe=Vi)},setOp:function(hr,Io,Vi){(Et!==hr||Hr!==Io||Pr!==Vi)&&(i.stencilOp(hr,Io,Vi),Et=hr,Hr=Io,Pr=Vi)},setLocked:function(hr){Q=hr},setClear:function(hr){Dl!==hr&&(i.clearStencil(hr),Dl=hr)},reset:function(){Q=!1,ce=null,ve=null,Ve=null,Fe=null,Et=null,Hr=null,Pr=null,Dl=null}}}let a=new n,l=new s,u=new o,c=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,w=null,S=null,A=null,E=null,b=null,M=!1,T=null,C=null,P=null,D=null,I=null,R=i.getParameter(35661),U=!1,F=0,V=i.getParameter(7938);V.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(V)[1]),U=F>=1):V.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),U=F>=2);let G=null,H={},Y=i.getParameter(3088),k=i.getParameter(2978),j=new Xe().fromArray(Y),X=new Xe().fromArray(k);function q(Q,ce,ve){let Ve=new Uint8Array(4),Fe=i.createTexture();i.bindTexture(Q,Fe),i.texParameteri(Q,10241,9728),i.texParameteri(Q,10240,9728);for(let Et=0;Et<ve;Et++)i.texImage2D(ce+Et,0,6408,1,1,0,6408,5121,Ve);return Fe}let z={};z[3553]=q(3553,3553,1),z[34067]=q(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),J(2929),l.setFunc(fb),Oe(!1),Ie(S_),J(2884),_e(Vt);function J(Q){d[Q]!==!0&&(i.enable(Q),d[Q]=!0)}function Z(Q){d[Q]!==!1&&(i.disable(Q),d[Q]=!1)}function K(Q,ce){return f[Q]!==ce?(i.bindFramebuffer(Q,ce),f[Q]=ce,r&&(Q===36009&&(f[36160]=ce),Q===36160&&(f[36009]=ce)),!0):!1}function W(Q,ce){let ve=m,Ve=!1;if(Q)if(ve=p.get(ce),ve===void 0&&(ve=[],p.set(ce,ve)),Q.isWebGLMultipleRenderTargets){let Fe=Q.texture;if(ve.length!==Fe.length||ve[0]!==36064){for(let Et=0,Hr=Fe.length;Et<Hr;Et++)ve[Et]=36064+Et;ve.length=Fe.length,Ve=!0}}else ve[0]!==36064&&(ve[0]=36064,Ve=!0);else ve[0]!==1029&&(ve[0]=1029,Ve=!0);Ve&&(e.isWebGL2?i.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ye(Q){return g!==Q?(i.useProgram(Q),g=Q,!0):!1}let fe={[eu]:32774,[L3]:32778,[N3]:32779};if(r)fe[M_]=32775,fe[T_]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(fe[M_]=Q.MIN_EXT,fe[T_]=Q.MAX_EXT)}let se={[B3]:0,[F3]:1,[k3]:768,[$E]:770,[j3]:776,[G3]:774,[z3]:772,[V3]:769,[eM]:771,[H3]:775,[U3]:773};function _e(Q,ce,ve,Ve,Fe,Et,Hr,Pr){if(Q===Vt){y===!0&&(Z(3042),y=!1);return}if(y===!1&&(J(3042),y=!0),Q!==R3){if(Q!==v||Pr!==M){if((x!==eu||A!==eu)&&(i.blendEquation(32774),x=eu,A=eu),Pr)switch(Q){case _a:i.blendFuncSeparate(1,771,1,771);break;case A_:i.blendFunc(1,1);break;case __:i.blendFuncSeparate(0,769,0,1);break;case E_:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case _a:i.blendFuncSeparate(770,771,1,771);break;case A_:i.blendFunc(770,1);break;case __:i.blendFuncSeparate(0,769,0,1);break;case E_:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}w=null,S=null,E=null,b=null,v=Q,M=Pr}return}Fe=Fe||ce,Et=Et||ve,Hr=Hr||Ve,(ce!==x||Fe!==A)&&(i.blendEquationSeparate(fe[ce],fe[Fe]),x=ce,A=Fe),(ve!==w||Ve!==S||Et!==E||Hr!==b)&&(i.blendFuncSeparate(se[ve],se[Ve],se[Et],se[Hr]),w=ve,S=Ve,E=Et,b=Hr),v=Q,M=!1}function xe(Q,ce){Q.side===Ln?Z(2884):J(2884);let ve=Q.side===Qr;ce&&(ve=!ve),Oe(ve),Q.blending===_a&&Q.transparent===!1?_e(Vt):_e(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let Ve=Q.stencilWrite;u.setTest(Ve),Ve&&(u.setMask(Q.stencilWriteMask),u.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),u.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),Me(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?J(32926):Z(32926)}function Oe(Q){T!==Q&&(Q?i.frontFace(2304):i.frontFace(2305),T=Q)}function Ie(Q){Q!==D3?(J(2884),Q!==C&&(Q===S_?i.cullFace(1029):Q===I3?i.cullFace(1028):i.cullFace(1032))):Z(2884),C=Q}function Pe(Q){Q!==P&&(U&&i.lineWidth(Q),P=Q)}function Me(Q,ce,ve){Q?(J(32823),(D!==ce||I!==ve)&&(i.polygonOffset(ce,ve),D=ce,I=ve)):Z(32823)}function ze(Q){Q?J(3089):Z(3089)}function Ue(Q){Q===void 0&&(Q=33984+R-1),G!==Q&&(i.activeTexture(Q),G=Q)}function L(Q,ce,ve){ve===void 0&&(G===null?ve=33984+R-1:ve=G);let Ve=H[ve];Ve===void 0&&(Ve={type:void 0,texture:void 0},H[ve]=Ve),(Ve.type!==Q||Ve.texture!==ce)&&(G!==ve&&(i.activeTexture(ve),G=ve),i.bindTexture(Q,ce||z[Q]),Ve.type=Q,Ve.texture=ce)}function O(){let Q=H[G];Q!==void 0&&Q.type!==void 0&&(i.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function re(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ue(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function me(){try{i.texSubImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function De(){try{i.texSubImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Te(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ee(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function le(){try{i.texStorage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ke(){try{i.texStorage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ke(){try{i.texImage2D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ne(){try{i.texImage3D.apply(i,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function We(Q){j.equals(Q)===!1&&(i.scissor(Q.x,Q.y,Q.z,Q.w),j.copy(Q))}function $e(Q){X.equals(Q)===!1&&(i.viewport(Q.x,Q.y,Q.z,Q.w),X.copy(Q))}function _t(Q,ce){let ve=h.get(ce);ve===void 0&&(ve=new WeakMap,h.set(ce,ve));let Ve=ve.get(Q);Ve===void 0&&(Ve=i.getUniformBlockIndex(ce,Q.name),ve.set(Q,Ve))}function ir(Q,ce){let Ve=h.get(ce).get(Q);c.get(ce)!==Ve&&(i.uniformBlockBinding(ce,Ve,Q.__bindingPointIndex),c.set(ce,Ve))}function Gr(){i.disable(3042),i.disable(2884),i.disable(2929),i.disable(32823),i.disable(3089),i.disable(2960),i.disable(32926),i.blendEquation(32774),i.blendFunc(1,0),i.blendFuncSeparate(1,0,1,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(513),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(519,0,4294967295),i.stencilOp(7680,7680,7680),i.clearStencil(0),i.cullFace(1029),i.frontFace(2305),i.polygonOffset(0,0),i.activeTexture(33984),i.bindFramebuffer(36160,null),r===!0&&(i.bindFramebuffer(36009,null),i.bindFramebuffer(36008,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),d={},G=null,H={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,w=null,S=null,A=null,E=null,b=null,M=!1,T=null,C=null,P=null,D=null,I=null,j.set(0,0,i.canvas.width,i.canvas.height),X.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:J,disable:Z,bindFramebuffer:K,drawBuffers:W,useProgram:ye,setBlending:_e,setMaterial:xe,setFlipSided:Oe,setCullFace:Ie,setLineWidth:Pe,setPolygonOffset:Me,setScissorTest:ze,activeTexture:Ue,bindTexture:L,unbindTexture:O,compressedTexImage2D:re,compressedTexImage3D:ue,texImage2D:ke,texImage3D:Ne,updateUBOMapping:_t,uniformBlockBinding:ir,texStorage2D:le,texStorage3D:Ke,texSubImage2D:me,texSubImage3D:De,compressedTexSubImage2D:Te,compressedTexSubImage3D:Ee,scissor:We,viewport:$e,reset:Gr}}function mz(i,t,e,r,n,s,o){let a=n.isWebGL2,l=n.maxTextures,u=n.maxCubemapSize,c=n.maxTextureSize,h=n.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(L,O){return y?new OffscreenCanvas(L,O):fg("canvas")}function x(L,O,re,ue){let me=1;if((L.width>ue||L.height>ue)&&(me=ue/Math.max(L.width,L.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let De=O?dg:Math.floor,Te=De(me*L.width),Ee=De(me*L.height);m===void 0&&(m=v(Te,Ee));let le=re?v(Te,Ee):m;return le.width=Te,le.height=Ee,le.getContext("2d").drawImage(L,0,0,Te,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+Te+"x"+Ee+")."),le}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function w(L){return xb(L.width)&&xb(L.height)}function S(L){return a?!1:L.wrapS!==sr||L.wrapT!==sr||L.minFilter!==kt&&L.minFilter!==Je}function A(L,O){return L.generateMipmaps&&O&&L.minFilter!==kt&&L.minFilter!==Je}function E(L){i.generateMipmap(L)}function b(L,O,re,ue,me=!1){if(a===!1)return O;if(L!==null){if(i[L]!==void 0)return i[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let De=O;return O===6403&&(re===5126&&(De=33326),re===5131&&(De=33325),re===5121&&(De=33321)),O===33319&&(re===5126&&(De=33328),re===5131&&(De=33327),re===5121&&(De=33323)),O===6408&&(re===5126&&(De=34836),re===5131&&(De=34842),re===5121&&(De=ue===et&&me===!1?35907:32856),re===32819&&(De=32854),re===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function M(L,O,re){return A(L,re)===!0||L.isFramebufferTexture&&L.minFilter!==kt&&L.minFilter!==Je?Math.log2(Math.max(O.width,O.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?O.mipmaps.length:1}function T(L){return L===kt||L===C_||L===Dx?9728:9729}function C(L){let O=L.target;O.removeEventListener("dispose",C),D(O),O.isVideoTexture&&p.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),R(O)}function D(L){let O=r.get(L);if(O.__webglInit===void 0)return;let re=L.source,ue=g.get(re);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(L),Object.keys(ue).length===0&&g.delete(re)}r.remove(L)}function I(L){let O=r.get(L);i.deleteTexture(O.__webglTexture);let re=L.source,ue=g.get(re);delete ue[O.__cacheKey],o.memory.textures--}function R(L){let O=L.texture,re=r.get(L),ue=r.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(re.__webglFramebuffer[me]),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(re.__webglFramebuffer),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer),re.__webglMultisampledFramebuffer&&i.deleteFramebuffer(re.__webglMultisampledFramebuffer),re.__webglColorRenderbuffer)for(let me=0;me<re.__webglColorRenderbuffer.length;me++)re.__webglColorRenderbuffer[me]&&i.deleteRenderbuffer(re.__webglColorRenderbuffer[me]);re.__webglDepthRenderbuffer&&i.deleteRenderbuffer(re.__webglDepthRenderbuffer)}if(L.isWebGLMultipleRenderTargets)for(let me=0,De=O.length;me<De;me++){let Te=r.get(O[me]);Te.__webglTexture&&(i.deleteTexture(Te.__webglTexture),o.memory.textures--),r.remove(O[me])}r.remove(O),r.remove(L)}let U=0;function F(){U=0}function V(){let L=U;return L>=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),U+=1,L}function G(L){let O=[];return O.push(L.wrapS),O.push(L.wrapT),O.push(L.wrapR||0),O.push(L.magFilter),O.push(L.minFilter),O.push(L.anisotropy),O.push(L.internalFormat),O.push(L.format),O.push(L.type),O.push(L.generateMipmaps),O.push(L.premultiplyAlpha),O.push(L.flipY),O.push(L.unpackAlignment),O.push(L.encoding),O.join()}function H(L,O){let re=r.get(L);if(L.isVideoTexture&&ze(L),L.isRenderTargetTexture===!1&&L.version>0&&re.__version!==L.version){let ue=L.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(re,L,O);return}}e.bindTexture(3553,re.__webglTexture,33984+O)}function Y(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(35866,re.__webglTexture,33984+O)}function k(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(32879,re.__webglTexture,33984+O)}function j(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){K(re,L,O);return}e.bindTexture(34067,re.__webglTexture,33984+O)}let X={[ms]:10497,[sr]:33071,[gb]:33648},q={[kt]:9728,[C_]:9984,[Dx]:9986,[Je]:9729,[sN]:9985,[Ul]:9987};function z(L,O,re){if(re?(i.texParameteri(L,10242,X[O.wrapS]),i.texParameteri(L,10243,X[O.wrapT]),(L===32879||L===35866)&&i.texParameteri(L,32882,X[O.wrapR]),i.texParameteri(L,10240,q[O.magFilter]),i.texParameteri(L,10241,q[O.minFilter])):(i.texParameteri(L,10242,33071),i.texParameteri(L,10243,33071),(L===32879||L===35866)&&i.texParameteri(L,32882,33071),(O.wrapS!==sr||O.wrapT!==sr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(L,10240,T(O.magFilter)),i.texParameteri(L,10241,T(O.minFilter)),O.minFilter!==kt&&O.minFilter!==Je&&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 ue=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===kt||O.minFilter!==Dx&&O.minFilter!==Ul||O.type===Xr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===Go&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(i.texParameterf(L,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,n.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function J(L,O){let re=!1;L.__webglInit===void 0&&(L.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=G(O);if(De!==L.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,re=!0),me[De].usedTimes++;let Te=me[L.__cacheKey];Te!==void 0&&(me[L.__cacheKey].usedTimes--,Te.usedTimes===0&&I(O)),L.__cacheKey=De,L.__webglTexture=me[De].texture}return re}function Z(L,O,re){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=J(L,O),De=O.source;e.bindTexture(ue,L.__webglTexture,33984+re);let Te=r.get(De);if(De.version!==Te.__version||me===!0){e.activeTexture(33984+re),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Ee=S(O)&&w(O.image)===!1,le=x(O.image,Ee,!1,c);le=Ue(O,le);let Ke=w(le)||a,ke=s.convert(O.format,O.encoding),Ne=s.convert(O.type),We=b(O.internalFormat,ke,Ne,O.encoding,O.isVideoTexture);z(ue,O,Ke);let $e,_t=O.mipmaps,ir=a&&O.isVideoTexture!==!0,Gr=Te.__version===void 0||me===!0,Q=M(O,le,Ke);if(O.isDepthTexture)We=6402,a?O.type===Xr?We=36012:O.type===ps?We=33190:O.type===Ea?We=35056:We=33189:O.type===Xr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Vl&&We===6402&&O.type!==nM&&O.type!==ps&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=ps,Ne=s.convert(O.type)),O.format===Ca&&We===6402&&(We=34041,O.type!==Ea&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Ea,Ne=s.convert(O.type))),Gr&&(ir?e.texStorage2D(3553,1,We,le.width,le.height):e.texImage2D(3553,0,We,le.width,le.height,0,ke,Ne,null));else if(O.isDataTexture)if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],ir?e.texSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,Ne,$e.data):e.texImage2D(3553,ce,We,$e.width,$e.height,0,ke,Ne,$e.data);O.generateMipmaps=!1}else ir?(Gr&&e.texStorage2D(3553,Q,We,le.width,le.height),e.texSubImage2D(3553,0,0,0,le.width,le.height,ke,Ne,le.data)):e.texImage2D(3553,0,We,le.width,le.height,0,ke,Ne,le.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){ir&&Gr&&e.texStorage3D(35866,Q,We,_t[0].width,_t[0].height,le.depth);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],O.format!==$n?ke!==null?ir?e.compressedTexSubImage3D(35866,ce,0,0,0,$e.width,$e.height,le.depth,ke,$e.data,0,0):e.compressedTexImage3D(35866,ce,We,$e.width,$e.height,le.depth,0,$e.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ir?e.texSubImage3D(35866,ce,0,0,0,$e.width,$e.height,le.depth,ke,Ne,$e.data):e.texImage3D(35866,ce,We,$e.width,$e.height,le.depth,0,ke,Ne,$e.data)}else{ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],O.format!==$n?ke!==null?ir?e.compressedTexSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,$e.data):e.compressedTexImage2D(3553,ce,We,$e.width,$e.height,0,$e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ir?e.texSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,Ne,$e.data):e.texImage2D(3553,ce,We,$e.width,$e.height,0,ke,Ne,$e.data)}else if(O.isDataArrayTexture)ir?(Gr&&e.texStorage3D(35866,Q,We,le.width,le.height,le.depth),e.texSubImage3D(35866,0,0,0,0,le.width,le.height,le.depth,ke,Ne,le.data)):e.texImage3D(35866,0,We,le.width,le.height,le.depth,0,ke,Ne,le.data);else if(O.isData3DTexture)ir?(Gr&&e.texStorage3D(32879,Q,We,le.width,le.height,le.depth),e.texSubImage3D(32879,0,0,0,0,le.width,le.height,le.depth,ke,Ne,le.data)):e.texImage3D(32879,0,We,le.width,le.height,le.depth,0,ke,Ne,le.data);else if(O.isFramebufferTexture){if(Gr)if(ir)e.texStorage2D(3553,Q,We,le.width,le.height);else{let ce=le.width,ve=le.height;for(let Ve=0;Ve<Q;Ve++)e.texImage2D(3553,Ve,We,ce,ve,0,ke,Ne,null),ce>>=1,ve>>=1}}else if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],ir?e.texSubImage2D(3553,ce,0,0,ke,Ne,$e):e.texImage2D(3553,ce,We,ke,Ne,$e);O.generateMipmaps=!1}else ir?(Gr&&e.texStorage2D(3553,Q,We,le.width,le.height),e.texSubImage2D(3553,0,0,0,ke,Ne,le)):e.texImage2D(3553,0,We,ke,Ne,le);A(O,Ke)&&E(ue),Te.__version=De.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function K(L,O,re){if(O.image.length!==6)return;let ue=J(L,O),me=O.source;e.bindTexture(34067,L.__webglTexture,33984+re);let De=r.get(me);if(me.version!==De.__version||ue===!0){e.activeTexture(33984+re),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Te=O.isCompressedTexture||O.image[0].isCompressedTexture,Ee=O.image[0]&&O.image[0].isDataTexture,le=[];for(let ce=0;ce<6;ce++)!Te&&!Ee?le[ce]=x(O.image[ce],!1,!0,u):le[ce]=Ee?O.image[ce].image:O.image[ce],le[ce]=Ue(O,le[ce]);let Ke=le[0],ke=w(Ke)||a,Ne=s.convert(O.format,O.encoding),We=s.convert(O.type),$e=b(O.internalFormat,Ne,We,O.encoding),_t=a&&O.isVideoTexture!==!0,ir=De.__version===void 0||ue===!0,Gr=M(O,Ke,ke);z(34067,O,ke);let Q;if(Te){_t&&ir&&e.texStorage2D(34067,Gr,$e,Ke.width,Ke.height);for(let ce=0;ce<6;ce++){Q=le[ce].mipmaps;for(let ve=0;ve<Q.length;ve++){let Ve=Q[ve];O.format!==$n?Ne!==null?_t?e.compressedTexSubImage2D(34069+ce,ve,0,0,Ve.width,Ve.height,Ne,Ve.data):e.compressedTexImage2D(34069+ce,ve,$e,Ve.width,Ve.height,0,Ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_t?e.texSubImage2D(34069+ce,ve,0,0,Ve.width,Ve.height,Ne,We,Ve.data):e.texImage2D(34069+ce,ve,$e,Ve.width,Ve.height,0,Ne,We,Ve.data)}}}else{Q=O.mipmaps,_t&&ir&&(Q.length>0&&Gr++,e.texStorage2D(34067,Gr,$e,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(Ee){_t?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Ne,We,le[ce].data):e.texImage2D(34069+ce,0,$e,le[ce].width,le[ce].height,0,Ne,We,le[ce].data);for(let ve=0;ve<Q.length;ve++){let Fe=Q[ve].image[ce].image;_t?e.texSubImage2D(34069+ce,ve+1,0,0,Fe.width,Fe.height,Ne,We,Fe.data):e.texImage2D(34069+ce,ve+1,$e,Fe.width,Fe.height,0,Ne,We,Fe.data)}}else{_t?e.texSubImage2D(34069+ce,0,0,0,Ne,We,le[ce]):e.texImage2D(34069+ce,0,$e,Ne,We,le[ce]);for(let ve=0;ve<Q.length;ve++){let Ve=Q[ve];_t?e.texSubImage2D(34069+ce,ve+1,0,0,Ne,We,Ve.image[ce]):e.texImage2D(34069+ce,ve+1,$e,Ne,We,Ve.image[ce])}}}A(O,ke)&&E(34067),De.__version=me.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function W(L,O,re,ue,me){let De=s.convert(re.format,re.encoding),Te=s.convert(re.type),Ee=b(re.internalFormat,De,Te,re.encoding);r.get(O).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Ee,O.width,O.height,O.depth,0,De,Te,null):e.texImage2D(me,0,Ee,O.width,O.height,0,De,Te,null)),e.bindFramebuffer(36160,L),Me(O)?d.framebufferTexture2DMultisampleEXT(36160,ue,me,r.get(re).__webglTexture,0,Pe(O)):(me===3553||me>=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,r.get(re).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(L,O,re){if(i.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(re||Me(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===Xr?ue=36012:me.type===ps&&(ue=33190));let De=Pe(O);Me(O)?d.renderbufferStorageMultisampleEXT(36161,De,ue,O.width,O.height):i.renderbufferStorageMultisample(36161,De,ue,O.width,O.height)}else i.renderbufferStorage(36161,ue,O.width,O.height);i.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);re&&Me(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):Me(O)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,L)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<ue.length;me++){let De=ue[me],Te=s.convert(De.format,De.encoding),Ee=s.convert(De.type),le=b(De.internalFormat,Te,Ee,De.encoding),Ke=Pe(O);re&&Me(O)===!1?i.renderbufferStorageMultisample(36161,Ke,le,O.width,O.height):Me(O)?d.renderbufferStorageMultisampleEXT(36161,Ke,le,O.width,O.height):i.renderbufferStorage(36161,le,O.width,O.height)}}i.bindRenderbuffer(36161,null)}function fe(L,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,L),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),H(O.depthTexture,0);let ue=r.get(O.depthTexture).__webglTexture,me=Pe(O);if(O.depthTexture.format===Vl)Me(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,me):i.framebufferTexture2D(36160,36096,3553,ue,0);else if(O.depthTexture.format===Ca)Me(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,me):i.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function se(L){let O=r.get(L),re=L.isWebGLCubeRenderTarget===!0;if(L.depthTexture&&!O.__autoAllocateDepthBuffer){if(re)throw new Error("target.depthTexture not supported in Cube render targets");fe(O.__webglFramebuffer,L)}else if(re){O.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)e.bindFramebuffer(36160,O.__webglFramebuffer[ue]),O.__webglDepthbuffer[ue]=i.createRenderbuffer(),ye(O.__webglDepthbuffer[ue],L,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=i.createRenderbuffer(),ye(O.__webglDepthbuffer,L,!1);e.bindFramebuffer(36160,null)}function _e(L,O,re){let ue=r.get(L);O!==void 0&&W(ue.__webglFramebuffer,L,L.texture,36064,3553),re!==void 0&&se(L)}function xe(L){let O=L.texture,re=r.get(L),ue=r.get(O);L.addEventListener("dispose",P),L.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=O.version,o.memory.textures++);let me=L.isWebGLCubeRenderTarget===!0,De=L.isWebGLMultipleRenderTargets===!0,Te=w(L)||a;if(me){re.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)re.__webglFramebuffer[Ee]=i.createFramebuffer()}else{if(re.__webglFramebuffer=i.createFramebuffer(),De)if(n.drawBuffers){let Ee=L.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=r.get(Ee[le]);ke.__webglTexture===void 0&&(ke.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&L.samples>0&&Me(L)===!1){let Ee=De?O:[O];re.__webglMultisampledFramebuffer=i.createFramebuffer(),re.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,re.__webglMultisampledFramebuffer);for(let le=0;le<Ee.length;le++){let Ke=Ee[le];re.__webglColorRenderbuffer[le]=i.createRenderbuffer(),i.bindRenderbuffer(36161,re.__webglColorRenderbuffer[le]);let ke=s.convert(Ke.format,Ke.encoding),Ne=s.convert(Ke.type),We=b(Ke.internalFormat,ke,Ne,Ke.encoding,L.isXRRenderTarget===!0),$e=Pe(L);i.renderbufferStorageMultisample(36161,$e,We,L.width,L.height),i.framebufferRenderbuffer(36160,36064+le,36161,re.__webglColorRenderbuffer[le])}i.bindRenderbuffer(36161,null),L.depthBuffer&&(re.__webglDepthRenderbuffer=i.createRenderbuffer(),ye(re.__webglDepthRenderbuffer,L,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ue.__webglTexture),z(34067,O,Te);for(let Ee=0;Ee<6;Ee++)W(re.__webglFramebuffer[Ee],L,O,36064,34069+Ee);A(O,Te)&&E(34067),e.unbindTexture()}else if(De){let Ee=L.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=Ee[le],Ne=r.get(ke);e.bindTexture(3553,Ne.__webglTexture),z(3553,ke,Te),W(re.__webglFramebuffer,L,ke,36064+le,3553),A(ke,Te)&&E(3553)}e.unbindTexture()}else{let Ee=3553;(L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(a?Ee=L.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Ee,ue.__webglTexture),z(Ee,O,Te),W(re.__webglFramebuffer,L,O,36064,Ee),A(O,Te)&&E(Ee),e.unbindTexture()}L.depthBuffer&&se(L)}function Oe(L){let O=w(L)||a,re=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ue=0,me=re.length;ue<me;ue++){let De=re[ue];if(A(De,O)){let Te=L.isWebGLCubeRenderTarget?34067:3553,Ee=r.get(De).__webglTexture;e.bindTexture(Te,Ee),E(Te),e.unbindTexture()}}}function Ie(L){if(a&&L.samples>0&&Me(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],re=L.width,ue=L.height,me=16384,De=[],Te=L.stencilBuffer?33306:36096,Ee=r.get(L),le=L.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke<O.length;Ke++)e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,null),e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,null,0);e.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let Ke=0;Ke<O.length;Ke++){De.push(36064+Ke),L.depthBuffer&&De.push(Te);let ke=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(ke===!1&&(L.depthBuffer&&(me|=256),L.stencilBuffer&&(me|=1024)),le&&i.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[Ke]),ke===!0&&(i.invalidateFramebuffer(36008,[Te]),i.invalidateFramebuffer(36009,[Te])),le){let Ne=r.get(O[Ke]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Ne,0)}i.blitFramebuffer(0,0,re,ue,0,0,re,ue,me,9728),f&&i.invalidateFramebuffer(36008,De)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),le)for(let Ke=0;Ke<O.length;Ke++){e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,Ee.__webglColorRenderbuffer[Ke]);let ke=r.get(O[Ke]).__webglTexture;e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,ke,0)}e.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function Pe(L){return Math.min(h,L.samples)}function Me(L){let O=r.get(L);return a&&L.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ze(L){let O=o.render.frame;p.get(L)!==O&&(p.set(L,O),L.update())}function Ue(L,O){let re=L.encoding,ue=L.format,me=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===vb||re!==Di&&(re===et?a===!1?t.has("EXT_sRGB")===!0&&ue===$n?(L.format=vb,L.minFilter=Je,L.generateMipmaps=!1):O=pg.sRGBToLinear(O):(ue!==$n||me!==lr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",re)),O}this.allocateTextureUnit=V,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=Y,this.setTexture3D=k,this.setTextureCube=j,this.rebindTextures=_e,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=W,this.useMultisampledRTT=Me}function gz(i,t,e){let r=e.isWebGL2;function n(s,o=null){let a;if(s===lr)return 5121;if(s===cN)return 32819;if(s===uN)return 32820;if(s===oN)return 5120;if(s===aN)return 5122;if(s===nM)return 5123;if(s===lN)return 5124;if(s===ps)return 5125;if(s===Xr)return 5126;if(s===Go)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===hN)return 6406;if(s===$n)return 6408;if(s===dN)return 6409;if(s===fN)return 6410;if(s===Vl)return 6402;if(s===Ca)return 34041;if(s===vb)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===pN)return 6403;if(s===mN)return 36244;if(s===Pu)return 33319;if(s===gN)return 33320;if(s===Xb)return 36249;if(s===Ix||s===Ox||s===Rx||s===Lx)if(o===et)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ix)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ix)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===P_||s===D_||s===I_||s===O_)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===P_)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===D_)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===I_)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===O_)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===yN)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===R_||s===L_)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===R_)return o===et?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===L_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===N_||s===B_||s===F_||s===k_||s===V_||s===z_||s===U_||s===G_||s===H_||s===j_||s===W_||s===q_||s===Y_||s===X_)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===N_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===B_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===F_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===k_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===V_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===z_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===U_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===G_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===H_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===j_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===W_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===q_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Y_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===X_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Nx)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Nx)return o===et?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===vN||s===Q_||s===K_||s===Z_)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Nx)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Q_)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===K_)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Z_)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ea?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:n}}var Pb=class extends Ir{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},js=class extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}},yz={type:"move"},Df=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new js,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 js,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new _,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new _),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new js,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new _,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new _),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let r of t.hand.values())this._getHandJoint(e,r)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,r){let n=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(u,m);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,p=.005;u.inputState.pinching&&d>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&d<=f-p&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(n=e.getPose(t.targetRaySpace,r),n===null&&s!==null&&(n=s),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(yz)))}return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new js;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},Gi=class extends or{constructor(t,e,r,n,s,o,a,l,u,c){if(c=c!==void 0?c:Vl,c!==Vl&&c!==Ca)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&c===Vl&&(r=ps),r===void 0&&c===Ca&&(r=Ea),super(null,n,s,o,a,l,c,r,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:kt,this.minFilter=l!==void 0?l:kt,this.flipY=!1,this.generateMipmaps=!1}},Db=class extends Yt{constructor(t,e){super();let r=this,n=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,A=new Ir;A.layers.enable(1),A.viewport=new Xe;let E=new Ir;E.layers.enable(2),E.viewport=new Xe;let b=[A,E],M=new Pb;M.layers.enable(1),M.layers.enable(2);let T=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(k){let j=v[k];return j===void 0&&(j=new Df,v[k]=j),j.getTargetRaySpace()},this.getControllerGrip=function(k){let j=v[k];return j===void 0&&(j=new Df,v[k]=j),j.getGripSpace()},this.getHand=function(k){let j=v[k];return j===void 0&&(j=new Df,v[k]=j),j.getHandSpace()};function P(k){let j=x.indexOf(k.inputSource);if(j===-1)return;let X=v[j];X!==void 0&&X.dispatchEvent({type:k.type,data:k.inputSource})}function D(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",D),n.removeEventListener("inputsourceschange",I);for(let k=0;k<v.length;k++){let j=x[k];j!==null&&(x[k]=null,v[k].disconnect(j))}T=null,C=null,t.setRenderTarget(g),f=null,d=null,h=null,n=null,y=null,Y.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(k){s=k,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(k){a=k,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(k){u=k},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(k){if(n=k,n!==null){if(g=t.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",D),n.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),n.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let j={antialias:n.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,j),n.updateRenderState({baseLayer:f}),y=new ht(f.framebufferWidth,f.framebufferHeight,{format:$n,type:lr,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let j=null,X=null,q=null;m.depth&&(q=m.stencil?35056:33190,j=m.stencil?Ca:Vl,X=m.stencil?Ea:ps);let z={colorFormat:32856,depthFormat:q,scaleFactor:s};h=new XRWebGLBinding(n,e),d=h.createProjectionLayer(z),n.updateRenderState({layers:[d]}),y=new ht(d.textureWidth,d.textureHeight,{format:$n,type:lr,depthTexture:new Gi(d.textureWidth,d.textureHeight,X,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.antialias?4:0});let J=t.properties.get(y);J.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await n.requestReferenceSpace(a),Y.setContext(n),Y.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function I(k){for(let j=0;j<k.removed.length;j++){let X=k.removed[j],q=x.indexOf(X);q>=0&&(x[q]=null,v[q].disconnect(X))}for(let j=0;j<k.added.length;j++){let X=k.added[j],q=x.indexOf(X);if(q===-1){for(let J=0;J<v.length;J++)if(J>=x.length){x.push(X),q=J;break}else if(x[J]===null){x[J]=X,q=J;break}if(q===-1)break}let z=v[q];z&&z.connect(X)}}let R=new _,U=new _;function F(k,j,X){R.setFromMatrixPosition(j.matrixWorld),U.setFromMatrixPosition(X.matrixWorld);let q=R.distanceTo(U),z=j.projectionMatrix.elements,J=X.projectionMatrix.elements,Z=z[14]/(z[10]-1),K=z[14]/(z[10]+1),W=(z[9]+1)/z[5],ye=(z[9]-1)/z[5],fe=(z[8]-1)/z[0],se=(J[8]+1)/J[0],_e=Z*fe,xe=Z*se,Oe=q/(-fe+se),Ie=Oe*-fe;j.matrixWorld.decompose(k.position,k.quaternion,k.scale),k.translateX(Ie),k.translateZ(Oe),k.matrixWorld.compose(k.position,k.quaternion,k.scale),k.matrixWorldInverse.copy(k.matrixWorld).invert();let Pe=Z+Oe,Me=K+Oe,ze=_e-Ie,Ue=xe+(q-Ie),L=W*K/Me*Pe,O=ye*K/Me*Pe;k.projectionMatrix.makePerspective(ze,Ue,L,O,Pe,Me)}function V(k,j){j===null?k.matrixWorld.copy(k.matrix):k.matrixWorld.multiplyMatrices(j.matrixWorld,k.matrix),k.matrixWorldInverse.copy(k.matrixWorld).invert()}this.updateCamera=function(k){if(n===null)return;M.near=E.near=A.near=k.near,M.far=E.far=A.far=k.far,(T!==M.near||C!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,C=M.far);let j=k.parent,X=M.cameras;V(M,j);for(let z=0;z<X.length;z++)V(X[z],j);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),k.matrix.copy(M.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale);let q=k.children;for(let z=0,J=q.length;z<J;z++)q[z].updateMatrixWorld(!0);X.length===2?F(M,A,E):M.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(k){l=k,d!==null&&(d.fixedFoveation=k),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=k)},this.getPlanes=function(){return w};let G=null;function H(k,j){if(c=j.getViewerPose(u||o),p=j,c!==null){let X=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let q=!1;X.length!==M.cameras.length&&(M.cameras.length=0,q=!0);for(let z=0;z<X.length;z++){let J=X[z],Z=null;if(f!==null)Z=f.getViewport(J);else{let W=h.getViewSubImage(d,J);Z=W.viewport,z===0&&(t.setRenderTargetTextures(y,W.colorTexture,d.ignoreDepthValues?void 0:W.depthStencilTexture),t.setRenderTarget(y))}let K=b[z];K===void 0&&(K=new Ir,K.layers.enable(z),K.viewport=new Xe,b[z]=K),K.matrix.fromArray(J.transform.matrix),K.projectionMatrix.fromArray(J.projectionMatrix),K.viewport.set(Z.x,Z.y,Z.width,Z.height),z===0&&M.matrix.copy(K.matrix),q===!0&&M.cameras.push(K)}}for(let X=0;X<v.length;X++){let q=x[X],z=v[X];q!==null&&z!==void 0&&z.update(q,j,u||o)}if(G&&G(k,j),j.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:j.detectedPlanes});let X=null;for(let q of w)j.detectedPlanes.has(q)||(X===null&&(X=[]),X.push(q));if(X!==null)for(let q of X)w.delete(q),S.delete(q),r.dispatchEvent({type:"planeremoved",data:q});for(let q of j.detectedPlanes)if(!w.has(q))w.add(q),S.set(q,j.lastChangedTime),r.dispatchEvent({type:"planeadded",data:q});else{let z=S.get(q);q.lastChangedTime>z&&(S.set(q,q.lastChangedTime),r.dispatchEvent({type:"planechanged",data:q}))}}p=null}let Y=new cM;Y.setAnimationLoop(H),this.setAnimationLoop=function(k){G=k},this.dispose=function(){}}};function vz(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,lM(i)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?n(m,g):g.isMeshToonMaterial?(n(m,g),c(m,g)):g.isMeshPhongMaterial?(n(m,g),u(m,g)):g.isMeshStandardMaterial?(n(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(n(m,g),f(m,g)):g.isMeshDepthMaterial?n(m,g):g.isMeshDistanceMaterial?(n(m,g),p(m,g)):g.isMeshNormalMaterial?n(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function n(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===Qr&&(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===Qr&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.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 w=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.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 s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.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 y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(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 d(m,g,y){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===Qr&&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=y.texture,m.transmissionSamplerSize.value.set(y.width,y.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 f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function xz(i,t,e,r){let n={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let w=x.program;r.uniformBlockBinding(v,w)}function u(v,x){let w=n[v.id];w===void 0&&(p(v),w=c(v),n[v.id]=w,v.addEventListener("dispose",g));let S=x.program;r.updateUBOMapping(v,S);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function c(v){let x=h();v.__bindingPointIndex=x;let w=i.createBuffer(),S=v.__size,A=v.usage;return i.bindBuffer(35345,w),i.bufferData(35345,S,A),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,w),w}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=n[v.id],w=v.uniforms,S=v.__cache;i.bindBuffer(35345,x);for(let A=0,E=w.length;A<E;A++){let b=w[A];if(f(b,A,S)===!0){let M=b.__offset,T=Array.isArray(b.value)?b.value:[b.value],C=0;for(let P=0;P<T.length;P++){let D=T[P],I=m(D);typeof D=="number"?(b.__data[0]=D,i.bufferSubData(35345,M+C,b.__data)):D.isMatrix3?(b.__data[0]=D.elements[0],b.__data[1]=D.elements[1],b.__data[2]=D.elements[2],b.__data[3]=D.elements[0],b.__data[4]=D.elements[3],b.__data[5]=D.elements[4],b.__data[6]=D.elements[5],b.__data[7]=D.elements[0],b.__data[8]=D.elements[6],b.__data[9]=D.elements[7],b.__data[10]=D.elements[8],b.__data[11]=D.elements[0]):(D.toArray(b.__data,C),C+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,M,b.__data)}}i.bindBuffer(35345,null)}function f(v,x,w){let S=v.value;if(w[x]===void 0){if(typeof S=="number")w[x]=S;else{let A=Array.isArray(S)?S:[S],E=[];for(let b=0;b<A.length;b++)E.push(A[b].clone());w[x]=E}return!0}else if(typeof S=="number"){if(w[x]!==S)return w[x]=S,!0}else{let A=Array.isArray(w[x])?w[x]:[w[x]],E=Array.isArray(S)?S:[S];for(let b=0;b<A.length;b++){let M=A[b];if(M.equals(E[b])===!1)return M.copy(E[b]),!0}}return!1}function p(v){let x=v.uniforms,w=0,S=16,A=0;for(let E=0,b=x.length;E<b;E++){let M=x[E],T={boundary:0,storage:0},C=Array.isArray(M.value)?M.value:[M.value];for(let P=0,D=C.length;P<D;P++){let I=C[P],R=m(I);T.boundary+=R.boundary,T.storage+=R.storage}if(M.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=w,E>0){A=w%S;let P=S-A;A!==0&&P-T.boundary<0&&(w+=S-A,M.__offset=w)}w+=T.storage}return A=w%S,A>0&&(w+=S-A),v.__size=w,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),i.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function y(){for(let v in n)i.deleteBuffer(n[v]);o=[],n={},s={}}return{bind:l,update:u,dispose:y}}function bz(){let i=fg("canvas");return i.style.display="block",i}function tw(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:bz(),e=i.context!==void 0?i.context:null,r=i.depth!==void 0?i.depth:!0,n=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.alpha:!1;let h=null,d=null,f=[],p=[];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=Di,this.physicallyCorrectLights=!1,this.toneMapping=Uo,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,w=-1,S=null,A=new Xe,E=new Xe,b=null,M=t.width,T=t.height,C=1,P=null,D=null,I=new Xe(0,0,M,T),R=new Xe(0,0,M,T),U=!1,F=new Bf,V=!1,G=!1,H=null,Y=new ie,k=new N,j=new _,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let z=e;function J(B,te){for(let he=0;he<B.length;he++){let ee=B[he],pe=t.getContext(ee,te);if(pe!==null)return pe}return null}try{let B={alpha:!0,depth:r,stencil:n,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${qo}`),t.addEventListener("webglcontextlost",We,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",_t,!1),z===null){let te=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&te.shift(),z=J(te,B),z===null)throw J(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let Z,K,W,ye,fe,se,_e,xe,Oe,Ie,Pe,Me,ze,Ue,L,O,re,ue,me,De,Te,Ee,le,Ke;function ke(){Z=new Uk(z),K=new Nk(z,Z,i),Z.init(K),Ee=new gz(z,Z,K),W=new pz(z,Z,K),ye=new jk,fe=new rz,se=new mz(z,Z,W,fe,K,Ee,ye),_e=new Fk(m),xe=new zk(m),Oe=new $N(z,K),le=new Rk(z,Z,Oe,K),Ie=new Gk(z,Oe,ye,le),Pe=new Xk(z,Ie,Oe,ye),me=new Yk(z,K,se),O=new Bk(fe),Me=new tz(m,_e,xe,Z,K,le,O),ze=new vz(m,fe),Ue=new iz,L=new uz(Z,K),ue=new Ok(m,_e,xe,W,Pe,c,o),re=new fz(m,Pe,K),Ke=new xz(z,ye,K,W),De=new Lk(z,Z,ye,K),Te=new Hk(z,Z,ye,K),ye.programs=Me.programs,m.capabilities=K,m.extensions=Z,m.properties=fe,m.renderLists=Ue,m.shadowMap=re,m.state=W,m.info=ye}ke();let Ne=new Db(m,z);this.xr=Ne,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let B=Z.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=Z.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(B){B!==void 0&&(C=B,this.setSize(M,T,!1))},this.getSize=function(B){return B.set(M,T)},this.setSize=function(B,te,he){if(Ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=B,T=te,t.width=Math.floor(B*C),t.height=Math.floor(te*C),he!==!1&&(t.style.width=B+"px",t.style.height=te+"px"),this.setViewport(0,0,B,te)},this.getDrawingBufferSize=function(B){return B.set(M*C,T*C).floor()},this.setDrawingBufferSize=function(B,te,he){M=B,T=te,C=he,t.width=Math.floor(B*he),t.height=Math.floor(te*he),this.setViewport(0,0,B,te)},this.getCurrentViewport=function(B){return B.copy(A)},this.getViewport=function(B){return B.copy(I)},this.setViewport=function(B,te,he,ee){B.isVector4?I.set(B.x,B.y,B.z,B.w):I.set(B,te,he,ee),W.viewport(A.copy(I).multiplyScalar(C).floor())},this.getScissor=function(B){return B.copy(R)},this.setScissor=function(B,te,he,ee){B.isVector4?R.set(B.x,B.y,B.z,B.w):R.set(B,te,he,ee),W.scissor(E.copy(R).multiplyScalar(C).floor())},this.getScissorTest=function(){return U},this.setScissorTest=function(B){W.setScissorTest(U=B)},this.setOpaqueSort=function(B){P=B},this.setTransparentSort=function(B){D=B},this.getClearColor=function(B){return B.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(B=!0,te=!0,he=!0){let ee=0;B&&(ee|=16384),te&&(ee|=256),he&&(ee|=1024),z.clear(ee)},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",We,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",_t,!1),Ue.dispose(),L.dispose(),fe.dispose(),_e.dispose(),xe.dispose(),Pe.dispose(),le.dispose(),Ke.dispose(),Me.dispose(),Ne.dispose(),Ne.removeEventListener("sessionstart",Ve),Ne.removeEventListener("sessionend",Fe),H&&(H.dispose(),H=null),Et.stop()};function We(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function $e(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let B=ye.autoReset,te=re.enabled,he=re.autoUpdate,ee=re.needsUpdate,pe=re.type;ke(),ye.autoReset=B,re.enabled=te,re.autoUpdate=he,re.needsUpdate=ee,re.type=pe}function _t(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function ir(B){let te=B.target;te.removeEventListener("dispose",ir),Gr(te)}function Gr(B){Q(B),fe.remove(B)}function Q(B){let te=fe.get(B).programs;te!==void 0&&(te.forEach(function(he){Me.releaseProgram(he)}),B.isShaderMaterial&&Me.releaseShaderCache(B))}this.renderBufferDirect=function(B,te,he,ee,pe,st){te===null&&(te=X);let dt=pe.isMesh&&pe.matrixWorld.determinant()<0,mt=x3(B,te,he,ee,pe);W.setMaterial(ee,dt);let xt=he.index,Lt=1;ee.wireframe===!0&&(xt=Ie.getWireframeAttribute(he),Lt=2);let Mt=he.drawRange,Tt=he.attributes.position,jr=Mt.start*Lt,Ei=(Mt.start+Mt.count)*Lt;st!==null&&(jr=Math.max(jr,st.start*Lt),Ei=Math.min(Ei,(st.start+st.count)*Lt)),xt!==null?(jr=Math.max(jr,0),Ei=Math.min(Ei,xt.count)):Tt!=null&&(jr=Math.max(jr,0),Ei=Math.min(Ei,Tt.count));let Oo=Ei-jr;if(Oo<0||Oo===1/0)return;le.setup(pe,ee,mt,he,xt);let Il,Wr=De;if(xt!==null&&(Il=Oe.get(xt),Wr=Te,Wr.setIndex(Il)),pe.isMesh)ee.wireframe===!0?(W.setLineWidth(ee.wireframeLinewidth*q()),Wr.setMode(1)):Wr.setMode(4);else if(pe.isLine){let Ct=ee.linewidth;Ct===void 0&&(Ct=1),W.setLineWidth(Ct*q()),pe.isLineSegments?Wr.setMode(1):pe.isLineLoop?Wr.setMode(2):Wr.setMode(3)}else pe.isPoints?Wr.setMode(0):pe.isSprite&&Wr.setMode(4);if(pe.isInstancedMesh)Wr.renderInstances(jr,Oo,pe.count);else if(he.isInstancedBufferGeometry){let Ct=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,Mx=Math.min(he.instanceCount,Ct);Wr.renderInstances(jr,Oo,Mx)}else Wr.render(jr,Oo)},this.compile=function(B,te){function he(ee,pe,st){ee.transparent===!0&&ee.side===Ln&&ee.forceSinglePass===!1?(ee.side=Qr,ee.needsUpdate=!0,Vi(ee,pe,st),ee.side=Pi,ee.needsUpdate=!0,Vi(ee,pe,st),ee.side=Ln):Vi(ee,pe,st)}d=L.get(B),d.init(),p.push(d),B.traverseVisible(function(ee){ee.isLight&&ee.layers.test(te.layers)&&(d.pushLight(ee),ee.castShadow&&d.pushShadow(ee))}),d.setupLights(m.physicallyCorrectLights),B.traverse(function(ee){let pe=ee.material;if(pe)if(Array.isArray(pe))for(let st=0;st<pe.length;st++){let dt=pe[st];he(dt,B,ee)}else he(pe,B,ee)}),p.pop(),d=null};let ce=null;function ve(B){ce&&ce(B)}function Ve(){Et.stop()}function Fe(){Et.start()}let Et=new cM;Et.setAnimationLoop(ve),typeof self<"u"&&Et.setContext(self),this.setAnimationLoop=function(B){ce=B,Ne.setAnimationLoop(B),B===null?Et.stop():Et.start()},Ne.addEventListener("sessionstart",Ve),Ne.addEventListener("sessionend",Fe),this.render=function(B,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(te),te=Ne.getCamera()),B.isScene===!0&&B.onBeforeRender(m,B,te,x),d=L.get(B,p.length),d.init(),p.push(d),Y.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),F.setFromProjectionMatrix(Y),G=this.localClippingEnabled,V=O.init(this.clippingPlanes,G),h=Ue.get(B,f.length),h.init(),f.push(h),Hr(B,te,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(P,D),V===!0&&O.beginShadows();let he=d.state.shadowsArray;if(re.render(he,B,te),V===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(h,B),d.setupLights(m.physicallyCorrectLights),te.isArrayCamera){let ee=te.cameras;for(let pe=0,st=ee.length;pe<st;pe++){let dt=ee[pe];Pr(h,B,dt,dt.viewport)}}else Pr(h,B,te);x!==null&&(se.updateMultisampleRenderTarget(x),se.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(m,B,te),le.resetDefaultState(),w=-1,S=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Hr(B,te,he,ee){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)he=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)d.pushLight(B),B.castShadow&&d.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||F.intersectsSprite(B)){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Y);let dt=Pe.update(B),mt=B.material;mt.visible&&h.push(B,dt,mt,he,j.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==ye.render.frame&&(B.skeleton.update(),B.skeleton.frame=ye.render.frame),!B.frustumCulled||F.intersectsObject(B))){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Y);let dt=Pe.update(B),mt=B.material;if(Array.isArray(mt)){let xt=dt.groups;for(let Lt=0,Mt=xt.length;Lt<Mt;Lt++){let Tt=xt[Lt],jr=mt[Tt.materialIndex];jr&&jr.visible&&h.push(B,dt,jr,he,j.z,Tt)}}else mt.visible&&h.push(B,dt,mt,he,j.z,null)}}let st=B.children;for(let dt=0,mt=st.length;dt<mt;dt++)Hr(st[dt],te,he,ee)}function Pr(B,te,he,ee){let pe=B.opaque,st=B.transmissive,dt=B.transparent;d.setupLightsView(he),V===!0&&O.setGlobalState(m.clippingPlanes,he),st.length>0&&Dl(pe,te,he),ee&&W.viewport(A.copy(ee)),pe.length>0&&hr(pe,te,he),st.length>0&&hr(st,te,he),dt.length>0&&hr(dt,te,he),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Dl(B,te,he){let ee=K.isWebGL2;H===null&&(H=new ht(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?Go:lr,minFilter:Ul,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(k),ee?H.setSize(k.x,k.y):H.setSize(dg(k.x),dg(k.y));let pe=m.getRenderTarget();m.setRenderTarget(H),m.clear();let st=m.toneMapping;m.toneMapping=Uo,hr(B,te,he),m.toneMapping=st,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),m.setRenderTarget(pe)}function hr(B,te,he){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,st=B.length;pe<st;pe++){let dt=B[pe],mt=dt.object,xt=dt.geometry,Lt=ee===null?dt.material:ee,Mt=dt.group;mt.layers.test(he.layers)&&Io(mt,te,he,xt,Lt,Mt)}}function Io(B,te,he,ee,pe,st){B.onBeforeRender(m,te,he,ee,pe,st),B.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),pe.onBeforeRender(m,te,he,ee,B,st),pe.transparent===!0&&pe.side===Ln&&pe.forceSinglePass===!1?(pe.side=Qr,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,B,st),pe.side=Pi,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,B,st),pe.side=Ln):m.renderBufferDirect(he,te,ee,pe,B,st),B.onAfterRender(m,te,he,ee,pe,st)}function Vi(B,te,he){te.isScene!==!0&&(te=X);let ee=fe.get(B),pe=d.state.lights,st=d.state.shadowsArray,dt=pe.state.version,mt=Me.getParameters(B,pe.state,st,te,he),xt=Me.getProgramCacheKey(mt),Lt=ee.programs;ee.environment=B.isMeshStandardMaterial?te.environment:null,ee.fog=te.fog,ee.envMap=(B.isMeshStandardMaterial?xe:_e).get(B.envMap||ee.environment),Lt===void 0&&(B.addEventListener("dispose",ir),Lt=new Map,ee.programs=Lt);let Mt=Lt.get(xt);if(Mt!==void 0){if(ee.currentProgram===Mt&&ee.lightsStateVersion===dt)return y_(B,mt),Mt}else mt.uniforms=Me.getUniforms(B),B.onBuild(he,mt,m),B.onBeforeCompile(mt,m),Mt=Me.acquireProgram(mt,xt),Lt.set(xt,Mt),ee.uniforms=mt.uniforms;let Tt=ee.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(Tt.clippingPlanes=O.uniform),y_(B,mt),ee.needsLights=w3(B),ee.lightsStateVersion=dt,ee.needsLights&&(Tt.ambientLightColor.value=pe.state.ambient,Tt.lightProbe.value=pe.state.probe,Tt.directionalLights.value=pe.state.directional,Tt.directionalLightShadows.value=pe.state.directionalShadow,Tt.spotLights.value=pe.state.spot,Tt.spotLightShadows.value=pe.state.spotShadow,Tt.rectAreaLights.value=pe.state.rectArea,Tt.ltc_1.value=pe.state.rectAreaLTC1,Tt.ltc_2.value=pe.state.rectAreaLTC2,Tt.pointLights.value=pe.state.point,Tt.pointLightShadows.value=pe.state.pointShadow,Tt.hemisphereLights.value=pe.state.hemi,Tt.directionalShadowMap.value=pe.state.directionalShadowMap,Tt.directionalShadowMatrix.value=pe.state.directionalShadowMatrix,Tt.spotShadowMap.value=pe.state.spotShadowMap,Tt.spotLightMatrix.value=pe.state.spotLightMatrix,Tt.spotLightMap.value=pe.state.spotLightMap,Tt.pointShadowMap.value=pe.state.pointShadowMap,Tt.pointShadowMatrix.value=pe.state.pointShadowMatrix);let jr=Mt.getUniforms(),Ei=su.seqWithValue(jr.seq,Tt);return ee.currentProgram=Mt,ee.uniformsList=Ei,Mt}function y_(B,te){let he=fe.get(B);he.outputEncoding=te.outputEncoding,he.instancing=te.instancing,he.skinning=te.skinning,he.morphTargets=te.morphTargets,he.morphNormals=te.morphNormals,he.morphColors=te.morphColors,he.morphTargetsCount=te.morphTargetsCount,he.numClippingPlanes=te.numClippingPlanes,he.numIntersection=te.numClipIntersection,he.vertexAlphas=te.vertexAlphas,he.vertexTangents=te.vertexTangents,he.toneMapping=te.toneMapping}function x3(B,te,he,ee,pe){te.isScene!==!0&&(te=X),se.resetTextureUnits();let st=te.fog,dt=ee.isMeshStandardMaterial?te.environment:null,mt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Di,xt=(ee.isMeshStandardMaterial?xe:_e).get(ee.envMap||dt),Lt=ee.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,Mt=!!ee.normalMap&&!!he.attributes.tangent,Tt=!!he.morphAttributes.position,jr=!!he.morphAttributes.normal,Ei=!!he.morphAttributes.color,Oo=ee.toneMapped?m.toneMapping:Uo,Il=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,Wr=Il!==void 0?Il.length:0,Ct=fe.get(ee),Mx=d.state.lights;if(V===!0&&(G===!0||B!==S)){let Mi=B===S&&ee.id===w;O.setState(ee,B,Mi)}let fn=!1;ee.version===Ct.__version?(Ct.needsLights&&Ct.lightsStateVersion!==Mx.state.version||Ct.outputEncoding!==mt||pe.isInstancedMesh&&Ct.instancing===!1||!pe.isInstancedMesh&&Ct.instancing===!0||pe.isSkinnedMesh&&Ct.skinning===!1||!pe.isSkinnedMesh&&Ct.skinning===!0||Ct.envMap!==xt||ee.fog===!0&&Ct.fog!==st||Ct.numClippingPlanes!==void 0&&(Ct.numClippingPlanes!==O.numPlanes||Ct.numIntersection!==O.numIntersection)||Ct.vertexAlphas!==Lt||Ct.vertexTangents!==Mt||Ct.morphTargets!==Tt||Ct.morphNormals!==jr||Ct.morphColors!==Ei||Ct.toneMapping!==Oo||K.isWebGL2===!0&&Ct.morphTargetsCount!==Wr)&&(fn=!0):(fn=!0,Ct.__version=ee.version);let Ol=Ct.currentProgram;fn===!0&&(Ol=Vi(ee,te,pe));let v_=!1,gf=!1,Tx=!1,Rn=Ol.getUniforms(),Rl=Ct.uniforms;if(W.useProgram(Ol.program)&&(v_=!0,gf=!0,Tx=!0),ee.id!==w&&(w=ee.id,gf=!0),v_||S!==B){if(Rn.setValue(z,"projectionMatrix",B.projectionMatrix),K.logarithmicDepthBuffer&&Rn.setValue(z,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),S!==B&&(S=B,gf=!0,Tx=!0),ee.isShaderMaterial||ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshStandardMaterial||ee.envMap){let Mi=Rn.map.cameraPosition;Mi!==void 0&&Mi.setValue(z,j.setFromMatrixPosition(B.matrixWorld))}(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&Rn.setValue(z,"isOrthographic",B.isOrthographicCamera===!0),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial||ee.isShadowMaterial||pe.isSkinnedMesh)&&Rn.setValue(z,"viewMatrix",B.matrixWorldInverse)}if(pe.isSkinnedMesh){Rn.setOptional(z,pe,"bindMatrix"),Rn.setOptional(z,pe,"bindMatrixInverse");let Mi=pe.skeleton;Mi&&(K.floatVertexTextures?(Mi.boneTexture===null&&Mi.computeBoneTexture(),Rn.setValue(z,"boneTexture",Mi.boneTexture,se),Rn.setValue(z,"boneTextureSize",Mi.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 Cx=he.morphAttributes;if((Cx.position!==void 0||Cx.normal!==void 0||Cx.color!==void 0&&K.isWebGL2===!0)&&me.update(pe,he,ee,Ol),(gf||Ct.receiveShadow!==pe.receiveShadow)&&(Ct.receiveShadow=pe.receiveShadow,Rn.setValue(z,"receiveShadow",pe.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(Rl.envMap.value=xt,Rl.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),gf&&(Rn.setValue(z,"toneMappingExposure",m.toneMappingExposure),Ct.needsLights&&b3(Rl,Tx),st&&ee.fog===!0&&ze.refreshFogUniforms(Rl,st),ze.refreshMaterialUniforms(Rl,ee,C,T,H),su.upload(z,Ct.uniformsList,Rl,se)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(su.upload(z,Ct.uniformsList,Rl,se),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&Rn.setValue(z,"center",pe.center),Rn.setValue(z,"modelViewMatrix",pe.modelViewMatrix),Rn.setValue(z,"normalMatrix",pe.normalMatrix),Rn.setValue(z,"modelMatrix",pe.matrixWorld),pe.previousModelViewMatrix&&Rn.setValue(z,"previousModelViewMatrix",pe.previousModelViewMatrix),B.previousProjectionMatrix&&Rn.setValue(z,"previousProjectionMatrix",B.previousProjectionMatrix),ee.isShaderMaterial||ee.isRawShaderMaterial){let Mi=ee.uniformsGroups;for(let Px=0,S3=Mi.length;Px<S3;Px++)if(K.isWebGL2){let x_=Mi[Px];Ke.update(x_,Ol),Ke.bind(x_,Ol)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ol}function b3(B,te){B.ambientLightColor.needsUpdate=te,B.lightProbe.needsUpdate=te,B.directionalLights.needsUpdate=te,B.directionalLightShadows.needsUpdate=te,B.pointLights.needsUpdate=te,B.pointLightShadows.needsUpdate=te,B.spotLights.needsUpdate=te,B.spotLightShadows.needsUpdate=te,B.rectAreaLights.needsUpdate=te,B.hemisphereLights.needsUpdate=te}function w3(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,te,he){fe.get(B.texture).__webglTexture=te,fe.get(B.depthTexture).__webglTexture=he;let ee=fe.get(B);ee.__hasExternalTextures=!0,ee.__hasExternalTextures&&(ee.__autoAllocateDepthBuffer=he===void 0,ee.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ee.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(B,te){let he=fe.get(B);he.__webglFramebuffer=te,he.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(B,te=0,he=0){x=B,y=te,v=he;let ee=!0,pe=null,st=!1,dt=!1;if(B){let xt=fe.get(B);xt.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(36160,null),ee=!1):xt.__webglFramebuffer===void 0?se.setupRenderTarget(B):xt.__hasExternalTextures&&se.rebindTextures(B,fe.get(B.texture).__webglTexture,fe.get(B.depthTexture).__webglTexture);let Lt=B.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(dt=!0);let Mt=fe.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(pe=Mt[te],st=!0):K.isWebGL2&&B.samples>0&&se.useMultisampledRTT(B)===!1?pe=fe.get(B).__webglMultisampledFramebuffer:pe=Mt,A.copy(B.viewport),E.copy(B.scissor),b=B.scissorTest}else A.copy(I).multiplyScalar(C).floor(),E.copy(R).multiplyScalar(C).floor(),b=U;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(B,pe),W.viewport(A),W.scissor(E),W.setScissorTest(b),st){let xt=fe.get(B.texture);z.framebufferTexture2D(36160,36064,34069+te,xt.__webglTexture,he)}else if(dt){let xt=fe.get(B.texture),Lt=te||0;z.framebufferTextureLayer(36160,36064,xt.__webglTexture,he||0,Lt)}w=-1},this.readRenderTargetPixels=function(B,te,he,ee,pe,st,dt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let mt=fe.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&dt!==void 0&&(mt=mt[dt]),mt){W.bindFramebuffer(36160,mt);try{let xt=B.texture,Lt=xt.format,Mt=xt.type;if(Lt!==$n&&Ee.convert(Lt)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Tt=Mt===Go&&(Z.has("EXT_color_buffer_half_float")||K.isWebGL2&&Z.has("EXT_color_buffer_float"));if(Mt!==lr&&Ee.convert(Mt)!==z.getParameter(35738)&&!(Mt===Xr&&(K.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!Tt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=B.width-ee&&he>=0&&he<=B.height-pe&&z.readPixels(te,he,ee,pe,Ee.convert(Lt),Ee.convert(Mt),st)}finally{let xt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,xt)}}},this.copyFramebufferToTexture=function(B,te,he=0){let ee=Math.pow(2,-he),pe=Math.floor(te.image.width*ee),st=Math.floor(te.image.height*ee);se.setTexture2D(te,0),z.copyTexSubImage2D(3553,he,0,0,B.x,B.y,pe,st),W.unbindTexture()},this.copyTextureToTexture=function(B,te,he,ee=0){let pe=te.image.width,st=te.image.height,dt=Ee.convert(he.format),mt=Ee.convert(he.type);se.setTexture2D(he,0),z.pixelStorei(37440,he.flipY),z.pixelStorei(37441,he.premultiplyAlpha),z.pixelStorei(3317,he.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,ee,B.x,B.y,pe,st,dt,mt,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,ee,B.x,B.y,te.mipmaps[0].width,te.mipmaps[0].height,dt,te.mipmaps[0].data):z.texSubImage2D(3553,ee,B.x,B.y,dt,mt,te.image),ee===0&&he.generateMipmaps&&z.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(B,te,he,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let st=B.max.x-B.min.x+1,dt=B.max.y-B.min.y+1,mt=B.max.z-B.min.z+1,xt=Ee.convert(ee.format),Lt=Ee.convert(ee.type),Mt;if(ee.isData3DTexture)se.setTexture3D(ee,0),Mt=32879;else if(ee.isDataArrayTexture)se.setTexture2DArray(ee,0),Mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,ee.flipY),z.pixelStorei(37441,ee.premultiplyAlpha),z.pixelStorei(3317,ee.unpackAlignment);let Tt=z.getParameter(3314),jr=z.getParameter(32878),Ei=z.getParameter(3316),Oo=z.getParameter(3315),Il=z.getParameter(32877),Wr=he.isCompressedTexture?he.mipmaps[0]:he.image;z.pixelStorei(3314,Wr.width),z.pixelStorei(32878,Wr.height),z.pixelStorei(3316,B.min.x),z.pixelStorei(3315,B.min.y),z.pixelStorei(32877,B.min.z),he.isDataTexture||he.isData3DTexture?z.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Wr.data)):z.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr),z.pixelStorei(3314,Tt),z.pixelStorei(32878,jr),z.pixelStorei(3316,Ei),z.pixelStorei(3315,Oo),z.pixelStorei(32877,Il),pe===0&&ee.generateMipmaps&&z.generateMipmap(Mt),W.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?se.setTextureCube(B,0):B.isData3DTexture?se.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?se.setTexture2DArray(B,0):se.setTexture2D(B,0),W.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,W.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Ib=class extends tw{};Ib.prototype.isWebGL1Renderer=!0;var cu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new Re(t),this.near=e,this.far=r}clone(){return new cu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Nn=class extends gt{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(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},wg=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=yb,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ui()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[r+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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}}},Zn=new _,Hl=class{constructor(t,e,r,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.applyMatrix4(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.applyNormalMatrix(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.transformDirection(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}setX(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=zo(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=zo(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=zo(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=zo(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this}setXYZW(t,e,r,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array),s=Kt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new Ge(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Hl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var kf=class extends gt{constructor(){super(),this.isBone=!0,this.type="Bone"}},li=class extends or{constructor(t=null,e=1,r=1,n,s,o,a,l,u=kt,c=kt,h,d){super(null,o,a,l,u,c,n,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},IE=new ie,wz=new ie,Pa=class{constructor(t=[],e=[]){this.uuid=Ui(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,n=this.bones.length;r<n;r++)this.boneInverses.push(new ie)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ie;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,n=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:wz;IE.multiplyMatrices(a,e[s]),IE.toArray(r,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Pa(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=sM(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new li(e,t,t,$n,Xr);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,n=t.bones.length;r<n;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new kf),this.bones.push(o),this.boneInverses.push(new ie().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let n=0,s=e.length;n<s;n++){let o=e[n];t.bones.push(o.uuid);let a=r[n];t.boneInverses.push(a.toArray())}return t}},uu=class extends Ge{constructor(t,e,r,n=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var Hi=class extends Gl{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Re(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},OE=new _,RE=new _,LE=new ie,ab=new gs,eg=new fr,jl=class extends gt{constructor(t=new Ae,e=new Hi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let n=1,s=e.count;n<s;n++)OE.fromBufferAttribute(e,n-1),RE.fromBufferAttribute(e,n),r[n]=r[n-1],r[n]+=OE.distanceTo(RE);t.setAttribute("lineDistance",new be(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),eg.copy(r.boundingSphere),eg.applyMatrix4(n),eg.radius+=s,t.ray.intersectsSphere(eg)===!1)return;LE.copy(n).invert(),ab.copy(t.ray).applyMatrix4(LE);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new _,c=new _,h=new _,d=new _,f=this.isLineSegments?2:1,p=r.index,g=r.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){let S=p.getX(x),A=p.getX(x+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,A),ab.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),ab.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},NE=new _,BE=new _,Da=class extends jl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let n=0,s=e.count;n<s;n+=2)NE.fromBufferAttribute(e,n),BE.fromBufferAttribute(e,n+1),r[n]=n===0?0:r[n-1],r[n+1]=r[n]+NE.distanceTo(BE);t.setAttribute("lineDistance",new be(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Sg=class extends or{constructor(t,e,r,n,s,o,a,l,u){super(t,e,r,n,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Je,this.magFilter=s!==void 0?s:Je,this.generateMipmaps=!1;let c=this;function h(){c.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var ji=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,n=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(n),e.push(s),n=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),n=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,u;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),u=r[n]-o,u<0)a=n+1;else if(u>0)l=n-1;else{l=n;break}if(n=l,r[n]===o)return n/(s-1);let c=r[n],d=r[n+1]-c,f=(o-c)/d;return(n+f)/(s-1)}getTangent(t,e){let n=t-1e-4,s=t+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=e||(o.isVector2?new N:new _);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new _,n=[],s=[],o=[],a=new _,l=new ie;for(let f=0;f<=t;f++){let p=f/t;n[f]=this.getTangentAt(p,new _)}s[0]=new _,o[0]=new _;let u=Number.MAX_VALUE,c=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);c<=u&&(u=c,r.set(1,0,0)),h<=u&&(u=h,r.set(0,1,0)),d<=u&&r.set(0,0,1),a.crossVectors(n[0],r).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(n[f-1],n[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Yr(n[f-1].dot(n[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(n[f],s[f])}if(e===!0){let f=Math.acos(Yr(s[0].dot(s[t]),-1,1));f/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(n[p],f*p)),o[p].crossVectors(n[p],s[p])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Wl=class extends ji{constructor(t=0,e=0,r=1,n=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new N,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(o?s=0:s=n),this.aClockwise===!0&&!o&&(s===n?s=-n:s=s-n);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+f*c+this.aY}return r.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},Ob=class extends Wl{constructor(t,e,r,n,s,o){super(t,e,r,r,n,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function rw(){let i=0,t=0,e=0,r=0;function n(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){n(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,n(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+r*a}}}var tg=new _,lb=new rw,cb=new rw,ub=new rw,Rb=class extends ji{constructor(t=[],e=!1,r="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=n}getPoint(t,e=new _){let r=e,n=this.points,s=n.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=n[(a-1)%s]:(tg.subVectors(n[0],n[1]).add(n[0]),u=tg);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2<s?c=n[(a+2)%s]:(tg.subVectors(n[s-1],n[s-2]).add(n[s-1]),c=tg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(u.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),lb.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,p,m,g),cb.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,p,m,g),ub.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(lb.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),cb.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),ub.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return r.set(lb.calc(l),cb.calc(l),ub.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new _().fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function FE(i,t,e,r,n){let s=(r-t)*.5,o=(n-e)*.5,a=i*i,l=i*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*i+e}function Sz(i,t){let e=1-i;return e*e*t}function Az(i,t){return 2*(1-i)*i*t}function _z(i,t){return i*i*t}function If(i,t,e,r){return Sz(i,t)+Az(i,e)+_z(i,r)}function Ez(i,t){let e=1-i;return e*e*e*t}function Mz(i,t){let e=1-i;return 3*e*e*i*t}function Tz(i,t){return 3*(1-i)*i*i*t}function Cz(i,t){return i*i*i*t}function Of(i,t,e,r,n){return Ez(i,t)+Mz(i,e)+Tz(i,r)+Cz(i,n)}var jn=class extends ji{constructor(t=new N,e=new N,r=new N,n=new N){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new N){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Of(t,n.x,s.x,o.x,a.x),Of(t,n.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},ql=class extends ji{constructor(t=new _,e=new _,r=new _,n=new _){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new _){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Of(t,n.x,s.x,o.x,a.x),Of(t,n.y,s.y,o.y,a.y),Of(t,n.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Wn=class extends ji{constructor(t=new N,e=new N){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new N){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let r=e||new N;return r.copy(this.v2).sub(this.v1).normalize(),r}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Vf=class extends ji{constructor(t=new _,e=new _){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new _){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ii=class extends ji{constructor(t=new N,e=new N,r=new N){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new N){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(If(t,n.x,s.x,o.x),If(t,n.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Lb=class extends ji{constructor(t=new _,e=new _,r=new _){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new _){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(If(t,n.x,s.x,o.x),If(t,n.y,s.y,o.y),If(t,n.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},hu=class extends ji{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new N){let r=e,n=this.points,s=(n.length-1)*t,o=Math.floor(s),a=s-o,l=n[o===0?o:o-1],u=n[o],c=n[o>n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return r.set(FE(a,l.x,u.x,c.x,h.x),FE(a,l.y,u.y,c.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new N().fromArray(n))}return this}},Pz=Object.freeze({__proto__:null,ArcCurve:Ob,CatmullRomCurve3:Rb,CubicBezierCurve:jn,CubicBezierCurve3:ql,EllipseCurve:Wl,LineCurve:Wn,LineCurve3:Vf,QuadraticBezierCurve:Ii,QuadraticBezierCurve3:Lb,SplineCurve:hu}),zf=class extends ji{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Wn(e,t))}getPoint(t,e){let r=t*this.getLength(),n=this.getCurveLengths(),s=0;for(;s<n.length;){if(n[s]>=r){let o=n[s]-r,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.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 t=[],e=0;for(let r=0,n=this.curves.length;r<n;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let n=0,s=this.curves;n<s.length;n++){let o=s[n],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];r&&r.equals(c)||(e.push(c),r=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(new Pz[n.type]().fromJSON(n))}return this}},Yl=class extends zf{constructor(t){super(),this.type="Path",this.currentPoint=new N,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new Wn(this.currentPoint.clone(),new N(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,n){let s=new Ii(this.currentPoint.clone(),new N(t,e),new N(r,n));return this.curves.push(s),this.currentPoint.set(r,n),this}bezierCurveTo(t,e,r,n,s,o){let a=new jn(this.currentPoint.clone(),new N(t,e),new N(r,n),new N(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new hu(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,n,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,n,s,o),this}absarc(t,e,r,n,s,o){return this.absellipse(t,e,r,r,n,s,o),this}ellipse(t,e,r,n,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,r,n,s,o,a,l),this}absellipse(t,e,r,n,s,o,a,l){let u=new Wl(t,e,r,n,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},du=class extends Ae{constructor(t=[new N(0,-.5),new N(.5,0),new N(0,.5)],e=12,r=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:n},e=Math.floor(e),n=Yr(n,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,h=new _,d=new N,f=new _,p=new _,m=new _,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=r+v*c*n,w=Math.sin(x),S=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*w,h.y=t[A].y,h.z=t[A].x*S,o.push(h.x,h.y,h.z),d.x=v/e,d.y=A/(t.length-1),a.push(d.x,d.y);let E=l[3*A+0]*w,b=l[3*A+1],M=l[3*A+0]*S;u.push(E,b,M)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let w=x+v*t.length,S=w,A=w+t.length,E=w+t.length+1,b=w+1;s.push(S,A,b),s.push(E,b,A)}this.setIndex(s),this.setAttribute("position",new be(o,3)),this.setAttribute("uv",new be(a,2)),this.setAttribute("normal",new be(u,3))}static fromJSON(t){return new du(t.points,t.segments,t.phiStart,t.phiLength)}};var Xl=class extends Ae{constructor(t=1,e=1,r=1,n=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;n=Math.floor(n),s=Math.floor(s);let c=[],h=[],d=[],f=[],p=0,m=[],g=r/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function v(){let w=new _,S=new _,A=0,E=(e-t)/r;for(let b=0;b<=s;b++){let M=[],T=b/s,C=T*(e-t)+t;for(let P=0;P<=n;P++){let D=P/n,I=D*l+a,R=Math.sin(I),U=Math.cos(I);S.x=C*R,S.y=-T*r+g,S.z=C*U,h.push(S.x,S.y,S.z),w.set(R,E,U).normalize(),d.push(w.x,w.y,w.z),f.push(D,1-T),M.push(p++)}m.push(M)}for(let b=0;b<n;b++)for(let M=0;M<s;M++){let T=m[M][b],C=m[M+1][b],P=m[M+1][b+1],D=m[M][b+1];c.push(T,C,D),c.push(C,P,D),A+=6}u.addGroup(y,A,0),y+=A}function x(w){let S=p,A=new N,E=new _,b=0,M=w===!0?t:e,T=w===!0?1:-1;for(let P=1;P<=n;P++)h.push(0,g*T,0),d.push(0,T,0),f.push(.5,.5),p++;let C=p;for(let P=0;P<=n;P++){let I=P/n*l+a,R=Math.cos(I),U=Math.sin(I);E.x=M*U,E.y=g*T,E.z=M*R,h.push(E.x,E.y,E.z),d.push(0,T,0),A.x=R*.5+.5,A.y=U*.5*T+.5,f.push(A.x,A.y),p++}for(let P=0;P<n;P++){let D=S+P,I=C+P;w===!0?c.push(I,I+1,D):c.push(I+1,I,D),b+=3}u.addGroup(y,b,w===!0?1:2),y+=b}}static fromJSON(t){return new Xl(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},fu=class extends Xl{constructor(t=1,e=1,r=32,n=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,n,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new fu(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},pu=class extends Ae{constructor(t=[],e=[],r=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n};let s=[],o=[];a(n),u(r),c(),this.setAttribute("position",new be(s,3)),this.setAttribute("normal",new be(s.slice(),3)),this.setAttribute("uv",new be(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new _,w=new _,S=new _;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],w),f(e[A+2],S),l(x,w,S,v)}function l(v,x,w,S){let A=S+1,E=[];for(let b=0;b<=A;b++){E[b]=[];let M=v.clone().lerp(w,b/A),T=x.clone().lerp(w,b/A),C=A-b;for(let P=0;P<=C;P++)P===0&&b===A?E[b][P]=M:E[b][P]=M.clone().lerp(T,P/C)}for(let b=0;b<A;b++)for(let M=0;M<2*(A-b)-1;M++){let T=Math.floor(M/2);M%2===0?(d(E[b][T+1]),d(E[b+1][T]),d(E[b][T])):(d(E[b][T+1]),d(E[b+1][T+1]),d(E[b+1][T]))}}function u(v){let x=new _;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function c(){let v=new _;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,S=y(v)/Math.PI+.5;o.push(w,1-S)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],S=o[v+4],A=Math.max(x,w,S),E=Math.min(x,w,S);A>.9&&E<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function p(){let v=new _,x=new _,w=new _,S=new _,A=new N,E=new N,b=new N;for(let M=0,T=0;M<s.length;M+=9,T+=6){v.set(s[M+0],s[M+1],s[M+2]),x.set(s[M+3],s[M+4],s[M+5]),w.set(s[M+6],s[M+7],s[M+8]),A.set(o[T+0],o[T+1]),E.set(o[T+2],o[T+3]),b.set(o[T+4],o[T+5]),S.copy(v).add(x).add(w).divideScalar(3);let C=g(S);m(A,T+0,v,C),m(E,T+2,x,C),m(b,T+4,w,C)}}function m(v,x,w,S){S<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new pu(t.vertices,t.indices,t.radius,t.details)}},mu=class extends pu{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=1/r,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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],o=[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,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new mu(t.radius,t.detail)}};var Wo=class extends Yl{constructor(t){super(t),this.uuid=Ui(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,n=this.holes.length;r<n;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(new Yl().fromJSON(n))}return this}},Dz={triangulate:function(i,t,e=2){let r=t&&t.length,n=r?t[0]*e:i.length,s=pM(i,0,n,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(r&&(s=Nz(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let p=e;p<n;p+=e)h=i[p],d=i[p+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return Uf(s,o,e,a,l,f,0),o}};function pM(i,t,e,r,n){let s,o;if(n===qz(i,t,e,r)>0)for(s=t;s<e;s+=r)o=kE(s,i[s],i[s+1],o);else for(s=e-r;s>=t;s-=r)o=kE(s,i[s],i[s+1],o);return o&&Fg(o,o.next)&&(Hf(o),o=o.next),o}function Ql(i,t){if(!i)return i;t||(t=i);let e=i,r;do if(r=!1,!e.steiner&&(Fg(e,e.next)||vr(e.prev,e,e.next)===0)){if(Hf(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Uf(i,t,e,r,n,s,o){if(!i)return;!o&&s&&zz(i,r,n,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?Oz(i,r,n,s):Iz(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),Hf(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=Rz(Ql(i),t,e),Uf(i,t,e,r,n,s,2)):o===2&&Lz(i,t,e,r,n,s):Uf(Ql(i),t,e,r,n,s,1);break}}}function Iz(i){let t=i.prev,e=i,r=i.next;if(vr(t,e,r)>=0)return!1;let n=t.x,s=e.x,o=r.x,a=t.y,l=e.y,u=r.y,c=n<s?n<o?n:o:s<o?s:o,h=a<l?a<u?a:u:l<u?l:u,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=r.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&iu(n,a,s,l,o,u,p.x,p.y)&&vr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Oz(i,t,e,r){let n=i.prev,s=i,o=i.next;if(vr(n,s,o)>=0)return!1;let a=n.x,l=s.x,u=o.x,c=n.y,h=s.y,d=o.y,f=a<l?a<u?a:u:l<u?l:u,p=c<h?c<d?c:d:h<d?h:d,m=a>l?a>u?a:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,y=Nb(f,p,t,e,r),v=Nb(m,g,t,e,r),x=i.prevZ,w=i.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&iu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&iu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&iu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&iu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Rz(i,t,e){let r=i;do{let n=r.prev,s=r.next.next;!Fg(n,s)&&mM(n,r,r.next,s)&&Gf(n,s)&&Gf(s,n)&&(t.push(n.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),Hf(r),Hf(r.next),r=i=s),r=r.next}while(r!==i);return Ql(r)}function Lz(i,t,e,r,n,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Hz(o,a)){let l=gM(o,a);o=Ql(o,o.next),l=Ql(l,l.next),Uf(o,t,e,r,n,s,0),Uf(l,t,e,r,n,s,0);return}a=a.next}o=o.next}while(o!==i)}function Nz(i,t,e,r){let n=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:i.length,u=pM(i,a,l,r,!1),u===u.next&&(u.steiner=!0),n.push(Gz(u));for(n.sort(Bz),s=0;s<n.length;s++)e=Fz(n[s],e);return e}function Bz(i,t){return i.x-t.x}function Fz(i,t){let e=kz(i,t);if(!e)return t;let r=gM(e,i);return Ql(r,r.next),Ql(e,e.next)}function kz(i,t){let e=t,r=-1/0,n,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,n=e.x<e.next.x?e:e.next,d===s))return n}e=e.next}while(e!==t);if(!n)return null;let a=n,l=n.x,u=n.y,c=1/0,h;e=n;do s>=e.x&&e.x>=l&&s!==e.x&&iu(o<u?s:r,o,l,u,o<u?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),Gf(e,i)&&(h<c||h===c&&(e.x>n.x||e.x===n.x&&Vz(n,e)))&&(n=e,c=h)),e=e.next;while(e!==a);return n}function Vz(i,t){return vr(i.prev,i,t.prev)<0&&vr(t.next,i,i.next)<0}function zz(i,t,e,r){let n=i;do n.z===0&&(n.z=Nb(n.x,n.y,t,e,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,Uz(n)}function Uz(i){let t,e,r,n,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<u&&(a++,r=r.nextZ,!!r);t++);for(l=u;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(n=e,e=e.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:i=n,n.prevZ=s,s=n;e=r}s.nextZ=null,u*=2}while(o>1);return i}function Nb(i,t,e,r,n){return i=(i-e)*n|0,t=(t-r)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Gz(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function iu(i,t,e,r,n,s,o,a){return(n-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(r-a)}function Hz(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!jz(i,t)&&(Gf(i,t)&&Gf(t,i)&&Wz(i,t)&&(vr(i.prev,i,t.prev)||vr(i,t.prev,t))||Fg(i,t)&&vr(i.prev,i,i.next)>0&&vr(t.prev,t,t.next)>0)}function vr(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Fg(i,t){return i.x===t.x&&i.y===t.y}function mM(i,t,e,r){let n=ng(vr(i,t,e)),s=ng(vr(i,t,r)),o=ng(vr(e,r,i)),a=ng(vr(e,r,t));return!!(n!==s&&o!==a||n===0&&rg(i,e,t)||s===0&&rg(i,r,t)||o===0&&rg(e,i,r)||a===0&&rg(e,t,r))}function rg(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function ng(i){return i>0?1:i<0?-1:0}function jz(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&mM(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Gf(i,t){return vr(i.prev,i,i.next)<0?vr(i,t,i.next)>=0&&vr(i,i.prev,t)>=0:vr(i,t,i.prev)<0||vr(i,i.next,t)<0}function Wz(i,t){let e=i,r=!1,n=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function gM(i,t){let e=new Bb(i.i,i.x,i.y),r=new Bb(t.i,t.x,t.y),n=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function kE(i,t,e,r){let n=new Bb(i,t,e);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Hf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Bb(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qz(i,t,e,r){let n=0;for(let s=t,o=e-r;s<e;s+=r)n+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return n}var gu=class{static area(t){let e=t.length,r=0;for(let n=e-1,s=0;s<e;n=s++)r+=t[n].x*t[s].y-t[s].x*t[n].y;return r*.5}static isClockWise(t){return gu.area(t)<0}static triangulateShape(t,e){let r=[],n=[],s=[];VE(t),zE(r,t);let o=t.length;e.forEach(VE);for(let l=0;l<e.length;l++)n.push(o),o+=e[l].length,zE(r,e[l]);let a=Dz.triangulate(r,n);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function VE(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function zE(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var yu=class extends pu{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=[-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],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(n,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new yu(t.radius,t.detail)}};var Kl=class extends Ae{constructor(t=1,e=32,r=16,n=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new _,d=new _,f=[],p=[],m=[],g=[];for(let y=0;y<=r;y++){let v=[],x=y/r,w=0;y==0&&o==0?w=.5/e:y==r&&l==Math.PI&&(w=-.5/e);for(let S=0;S<=e;S++){let A=S/e;h.x=-t*Math.cos(n+A*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(n+A*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(A+w,1-x),v.push(u++)}c.push(v)}for(let y=0;y<r;y++)for(let v=0;v<e;v++){let x=c[y][v+1],w=c[y][v],S=c[y+1][v],A=c[y+1][v+1];(y!==0||o>0)&&f.push(x,w,A),(y!==r-1||l<Math.PI)&&f.push(w,S,A)}this.setIndex(f),this.setAttribute("position",new be(p,3)),this.setAttribute("normal",new be(m,3)),this.setAttribute("uv",new be(g,2))}static fromJSON(t){return new Kl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var vu=class extends Ae{constructor(t=1,e=.4,r=64,n=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o},r=Math.floor(r),n=Math.floor(n);let a=[],l=[],u=[],c=[],h=new _,d=new _,f=new _,p=new _,m=new _,g=new _,y=new _;for(let x=0;x<=r;++x){let w=x/r*s*Math.PI*2;v(w,s,o,t,f),v(w+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let S=0;S<=n;++S){let A=S/n*Math.PI*2,E=-e*Math.cos(A),b=e*Math.sin(A);h.x=f.x+(E*y.x+b*m.x),h.y=f.y+(E*y.y+b*m.y),h.z=f.z+(E*y.z+b*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(x/r),c.push(S/n)}}for(let x=1;x<=r;x++)for(let w=1;w<=n;w++){let S=(n+1)*(x-1)+(w-1),A=(n+1)*x+(w-1),E=(n+1)*x+w,b=(n+1)*(x-1)+w;a.push(S,A,b),a.push(A,E,b)}this.setIndex(a),this.setAttribute("position",new be(l,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(c,2));function v(x,w,S,A,E){let b=Math.cos(x),M=Math.sin(x),T=S/w*x,C=Math.cos(T);E.x=A*(2+C)*.5*b,E.y=A*(2+C)*M*.5,E.z=A*Math.sin(T)*.5}}static fromJSON(t){return new vu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Aa(i,t,e){return yM(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function ig(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function yM(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Yz(i){function t(n,s){return i[n]-i[s]}let e=i.length,r=new Array(e);for(let n=0;n!==e;++n)r[n]=n;return r.sort(t),r}function UE(i,t,e){let r=i.length,n=new i.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)n[o++]=i[a+l]}return n}function vM(i,t,e,r){let n=1,s=i[0];for(;s!==void 0&&s[r]===void 0;)s=i[n++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[n++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=i[n++];while(s!==void 0)}var xu=class{constructor(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,n=e[r],s=e[r-1];e:{t:{let o;r:{n:if(!(t<n)){for(let a=r+2;;){if(n===void 0){if(t<s)break n;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=n,n=e[++r],t<n)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(n=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(n=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,n)}return this.interpolate_(r,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=t*n;for(let o=0;o!==n;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Fb=class extends xu{constructor(t,e,r,n){super(t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:tu,endingEnd:tu}}intervalChanged_(t,e,r){let n=this.parameterPositions,s=t-2,o=t+1,a=n[s],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case ru:s=t,a=2*e-r;break;case hg:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case ru:o=t,l=2*r-e;break;case hg:o=1,l=r+n[1]-n[0];break;default:o=t-1,l=e}let u=(r-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-r),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(r-e)/(n-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,w=f*g-f*m;for(let S=0;S!==a;++S)s[S]=y*o[c+S]+v*o[u+S]+x*o[l+S]+w*o[h+S];return s}},Ag=class extends xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(r-e)/(n-e),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},kb=class extends xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t){return this.copySampleValue_(t-1)}},Wi=class{constructor(t,e,r,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ig(e,this.TimeBufferType),this.values=ig(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:ig(t.times,Array),values:ig(t.values,Array)};let n=t.getInterpolation();n!==t.DefaultInterpolation&&(r.interpolation=n)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new kb(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ag(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Fb(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case cg:e=this.InterpolantFactoryMethodDiscrete;break;case ug:e=this.InterpolantFactoryMethodLinear;break;case Bx:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return cg;case this.InterpolantFactoryMethodLinear:return ug;case this.InterpolantFactoryMethodSmooth:return Bx}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]*=t}return this}trim(t,e){let r=this.times,n=r.length,s=0,o=n-1;for(;s!==n&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Aa(r,s,o),this.values=Aa(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,n=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(n!==void 0&&yM(n))for(let a=0,l=n.length;a!==l;++a){let u=n[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Aa(this.times),e=Aa(this.values),r=this.getValueSize(),n=this.getInterpolation()===Bx,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(n)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let p=0;p!==r;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,u=0;u!==r;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Aa(t,0,o),this.values=Aa(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Aa(this.times,0),e=Aa(this.values,0),r=this.constructor,n=new r(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}};Wi.prototype.TimeBufferType=Float32Array;Wi.prototype.ValueBufferType=Float32Array;Wi.prototype.DefaultInterpolation=ug;var Ia=class extends Wi{};Ia.prototype.ValueTypeName="bool";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=cg;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;var _g=class extends Wi{};_g.prototype.ValueTypeName="color";var bu=class extends Wi{};bu.prototype.ValueTypeName="number";var Vb=class extends xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(n-e),u=t*a;for(let c=u+a;u!==c;u+=4)He.slerpFlat(s,0,o,u-a,o,u,l);return s}},Zl=class extends Wi{InterpolantFactoryMethodLinear(t){return new Vb(this.times,this.values,this.getValueSize(),t)}};Zl.prototype.ValueTypeName="quaternion";Zl.prototype.DefaultInterpolation=ug;Zl.prototype.InterpolantFactoryMethodSmooth=void 0;var Oa=class extends Wi{};Oa.prototype.ValueTypeName="string";Oa.prototype.ValueBufferType=Array;Oa.prototype.DefaultInterpolation=cg;Oa.prototype.InterpolantFactoryMethodLinear=void 0;Oa.prototype.InterpolantFactoryMethodSmooth=void 0;var wu=class extends Wi{};wu.prototype.ValueTypeName="vector";var Su=class{constructor(t,e=-1,r,n=Zb){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=Ui(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,n=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(Qz(r[o]).scale(n));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(Wi.toJSON(r[s]));return n}static CreateFromMorphTargetSequence(t,e,r,n){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],u=[];l.push((a+s-1)%s,a,(a+1)%s),u.push(0,1,0);let c=Yz(l);l=UE(l,1,c),u=UE(u,1,c),!n&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new bu(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let n=t;r=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<r.length;n++)if(r[n].name===e)return r[n];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let u=t[a],c=u.name.match(s);if(c&&c.length>1){let h=c[1],d=n[h];d||(n[h]=d=[]),d.push(u)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,p,m){if(f.length!==0){let g=[],y=[];vM(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},n=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let h=0;h<u.length;h++){let d=u[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}n.push(new bu(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(wu,f+".position",d,"pos",n),r(Zl,f+".quaternion",d,"rot",n),r(wu,f+".scale",d,"scl",n)}}return n.length===0?null:new this(s,l,n,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,n=t.length;r!==n;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function Xz(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return bu;case"vector":case"vector2":case"vector3":case"vector4":return wu;case"color":return _g;case"quaternion":return Zl;case"bool":case"boolean":return Ia;case"string":return Oa}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Qz(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Xz(i.type);if(i.times===void 0){let e=[],r=[];vM(i.keys,e,r,"value"),i.times=e,i.values=r}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var GE={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},jf=class{constructor(t,e,r){let n=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(c){a++,s===!1&&n.onStart!==void 0&&n.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,n.onProgress!==void 0&&n.onProgress(c,o,a),o===a&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(c){n.onError!==void 0&&n.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],p=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}},Kz=new jf,Au=class{constructor(t){this.manager=t!==void 0?t:Kz,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(n,s){r.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},ko={},zb=class extends Error{constructor(t,e){super(t),this.response=e}},_u=class extends Au{constructor(t){super(t)}load(t,e,r,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=GE.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(ko[t]!==void 0){ko[t].push({onLoad:e,onProgress:r,onError:n});return}ko[t]=[],ko[t].push({onLoad:e,onProgress:r,onError:n});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=ko[t],h=u.body.getReader(),d=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:w})=>{if(x)y.close();else{m+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,E=c.length;A<E;A++){let b=c[A];b.onProgress&&b.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw new zb(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{GE.add(t,u);let c=ko[t];delete ko[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=ko[t];if(c===void 0)throw this.manager.itemError(t),u;delete ko[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Ra=class extends gt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Eg=class extends Ra{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Re(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},hb=new ie,HE=new _,jE=new _,Wf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new N(512,512),this.map=null,this.mapPass=null,this.matrix=new ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Bf,this._frameExtents=new N(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;HE.setFromMatrixPosition(t.matrixWorld),e.position.copy(HE),jE.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(jE),e.updateMatrixWorld(),hb.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hb),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(hb)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},Ub=class extends Wf{constructor(){super(new Ir(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Lf*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Mg=class extends Ra{constructor(t,e,r=0,n=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=r,this.angle=n,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Ub}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},WE=new ie,Ef=new _,db=new _,Gb=class extends Wf{constructor(){super(new Ir(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new N(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new _(1,0,0),new _(-1,0,0),new _(0,0,1),new _(0,0,-1),new _(0,1,0),new _(0,-1,0)],this._cubeUps=[new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,0,1),new _(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,n=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Ef.setFromMatrixPosition(t.matrixWorld),r.position.copy(Ef),db.copy(r.position),db.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(db),r.updateMatrixWorld(),n.makeTranslation(-Ef.x,-Ef.y,-Ef.z),WE.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(WE)}},Tg=class extends Ra{constructor(t,e,r=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=n,this.shadow=new Gb}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},Hb=class extends Wf{constructor(){super(new lu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Cg=class extends Ra{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new Hb}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var qf=class extends Ae{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Eu=class extends Au{constructor(t){super(t)}load(t,e,r,n){let s=this,o=new _u(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),s.manager.itemError(t)}},r,n)}parse(t){let e={},r={};function n(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=Nm(g.type,y),x=new wg(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return r[p]=y,y}let o=t.isInstancedBufferGeometry?new qf:new Ae,a=t.data.index;if(a!==void 0){let f=Nm(a.type,a.array);o.setIndex(new Ge(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=n(t.data,p.data);m=new Hl(g,p.itemSize,p.offset,p.normalized)}else{let g=Nm(p.type,p.array),y=p.isInstancedBufferAttribute?uu:Ge;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let u=t.data.morphAttributes;if(u)for(let f in u){let p=u[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let w=n(t.data,v.data);x=new Hl(w,v.itemSize,v.offset,v.normalized)}else{let w=Nm(v.type,v.array);x=new Ge(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new _;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new fr(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Pg=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=qE(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=qE();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function qE(){return(typeof performance>"u"?Date:performance).now()}var jb=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let n,s,o;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:n=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,n=this.valueSize,s=t*n+n,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,n=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,n=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,n,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(r[l]!==r[l+e]){a.setValue(r,n);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let s=r,o=n;s!==o;++s)e[s]=e[n+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,n,s){if(n>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,n){He.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,s){let o=this._workIndex*s;He.multiplyQuaternionsFlat(t,o,t,e,t,r),He.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,r,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*n}}_lerpAdditive(t,e,r,n,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*n}}},nw="\\[\\]\\.:\\/",Zz=new RegExp("["+nw+"]","g"),iw="[^"+nw+"]",Jz="[^"+nw.replace("\\.","")+"]",$z=/((?:WC+[\/:])*)/.source.replace("WC",iw),eU=/(WCOD+)?/.source.replace("WCOD",Jz),tU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",iw),rU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",iw),nU=new RegExp("^"+$z+eU+tU+rU+"$"),iU=["material","materials","bones","map"],Wb=class{constructor(t,e,r){let n=r||Ft.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,n=this._bindings[r];n!==void 0&&n.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=r.length;n!==s;++n)r[n].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},Ft=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Ft.parseTrackName(e),this.node=Ft.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new Ft.Composite(t,e,r):new Ft(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Zz,"")}static parseTrackName(t){let e=nU.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=r.nodeName.substring(n+1);iU.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},n=r(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)t[e++]=r[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,n=e.propertyName,s=e.propertyIndex;if(t||(t=Ft.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(r){let u=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[n];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+n+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ft.Composite=Wb;Ft.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ft.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ft.prototype.GetterByBindingType=[Ft.prototype._getValue_direct,Ft.prototype._getValue_array,Ft.prototype._getValue_arrayElement,Ft.prototype._getValue_toArray];Ft.prototype.SetterByBindingTypeAndVersioning=[[Ft.prototype._setValue_direct,Ft.prototype._setValue_direct_setNeedsUpdate,Ft.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_array,Ft.prototype._setValue_array_setNeedsUpdate,Ft.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_arrayElement,Ft.prototype._setValue_arrayElement_setNeedsUpdate,Ft.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_fromArray,Ft.prototype._setValue_fromArray_setNeedsUpdate,Ft.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var qb=class{constructor(t,e,r=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=n;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:tu,endingEnd:tu};for(let u=0;u!==o;++u){let c=s[u].createInterpolant(null);a[u]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Kb,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let n=this._clip.duration,s=t._clip.duration,o=s/n,a=n/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let n=this._mixer,s=n.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+r,u[0]=t/o,u[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,n){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case xN:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case Zb:default:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulate(n,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,n=this.time+t,s=this._loopCount,o=r===Xf;if(t===0)return s===-1?n:o&&(s&1)===1?e-n:n;if(r===Qb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=e||n<0){let a=Math.floor(n/e);n-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return e-n}return n}_setEndings(t,e,r){let n=this._interpolantSettings;r?(n.endingStart=ru,n.endingEnd=ru):(t?n.endingStart=this.zeroSlopeAtStart?ru:tu:n.endingStart=hg,e?n.endingEnd=this.zeroSlopeAtEnd?ru:tu:n.endingEnd=hg)}_scheduleFading(t,e,r){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},sU=new Float32Array(1),Dg=class extends Yt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,n=t._clip.tracks,s=n.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let h=0;h!==s;++h){let d=n[h],f=d.name,p=c[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new jb(Ft.create(r,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,r)}let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let n=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=n.length,n.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],n=t._cacheIndex;r._cacheIndex=n,e[n]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,u=l[l.length-1],c=t._byClipCacheIndex;u._byClipCacheIndex=c,l[c]=u,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let n=this._bindingsByRootAndName,s=this._bindings,o=n[e];o===void 0&&(o={},n[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,n=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[n],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[n]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new Ag(new Float32Array(2),new Float32Array(2),1,sU),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let n=e||this._root,s=n.uuid,o=typeof t=="string"?Su.findByName(n,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(r===void 0&&(o!==null?r=o.blendMode:r=Zb),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new qb(this,o,e,r);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let r=e||this._root,n=r.uuid,s=typeof t=="string"?Su.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,n=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==r;++u)e[u]._update(n,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,n=this._actionsByClip,s=n[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let u=o[a];this._deactivateAction(u);let c=u._cacheIndex,h=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,h._cacheIndex=c,e[c]=h,e.pop(),this._removeInactiveBindingsForAction(u)}delete n[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},oe=class{constructor(t){this.value=t}clone(){return new oe(this.value.clone===void 0?this.value:this.value.clone())}};var Mu=class{constructor(t,e,r=0,n=1/0){this.ray=new gs(t,e),this.near=r,this.far=n,this.camera=null,this.layers=new Nf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,r=[]){return Yb(t,this,r,e),r.sort(YE),r}intersectObjects(t,e=!0,r=[]){for(let n=0,s=t.length;n<s;n++)Yb(t[n],this,r,e);return r.sort(YE),r}};function YE(i,t){return i.distance-t.distance}function Yb(i,t,e,r){if(i.layers.test(t.layers)&&i.raycast(t,e),r===!0){let n=i.children;for(let s=0,o=n.length;s<o;s++)Yb(n[s],t,e,!0)}}var Yf=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(Yr(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var XE=new N,Tu=class{constructor(t=new N(1/0,1/0),e=new N(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=XE.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return XE.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},QE=new _,sg=new _,nn=class{constructor(t=new _,e=new _){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){QE.subVectors(t,this.start),sg.subVectors(this.end,this.start);let r=sg.dot(sg),s=sg.dot(QE)/r;return e&&(s=Yr(s,0,1)),s}closestPointToPoint(t,e,r){let n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},KE=new _,Ig=class extends gt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ae,n=[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 o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;n.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}r.setAttribute("position",new be(n,3));let s=new Hi({fog:!1,toneMapped:!1});this.cone=new Da(r,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 t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),KE.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(KE),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Og=class extends _r{constructor(t,e,r){let n=new Kl(e,4,2),s=new Ho({wireframe:!0,fog:!1,toneMapped:!1});super(n,s),this.light=t,this.color=r,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)}};var ZE=new _,og=new _,JE=new _,Rg=class extends gt{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let n=new Ae;n.setAttribute("position",new be([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Hi({fog:!1,toneMapped:!1});this.lightPlane=new jl(n,s),this.add(this.lightPlane),n=new Ae,n.setAttribute("position",new be([0,0,0,0,0,1],3)),this.targetLine=new jl(n,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),ZE.setFromMatrixPosition(this.light.matrixWorld),og.setFromMatrixPosition(this.light.target.matrixWorld),JE.subVectors(og,ZE),this.lightPlane.lookAt(og),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(og),this.targetLine.scale.z=JE.length()}},ag=new _,Ar=new ys,La=class extends Da{constructor(t){let e=new Ae,r=new Hi({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,m){l(p),l(m)}function l(p){n.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(n.length/3-1)}e.setAttribute("position",new be(n,3)),e.setAttribute("color",new be(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Re(16755200),c=new Re(16711680),h=new Re(43775),d=new Re(16777215),f=new Re(3355443);this.setColors(u,c,h,d,f)}setColors(t,e,r,n,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.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 t=this.geometry,e=this.pointMap,r=1,n=1;Ar.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Dr("c",e,t,Ar,0,0,-1),Dr("t",e,t,Ar,0,0,1),Dr("n1",e,t,Ar,-r,-n,-1),Dr("n2",e,t,Ar,r,-n,-1),Dr("n3",e,t,Ar,-r,n,-1),Dr("n4",e,t,Ar,r,n,-1),Dr("f1",e,t,Ar,-r,-n,1),Dr("f2",e,t,Ar,r,-n,1),Dr("f3",e,t,Ar,-r,n,1),Dr("f4",e,t,Ar,r,n,1),Dr("u1",e,t,Ar,r*.7,n*1.1,-1),Dr("u2",e,t,Ar,-r*.7,n*1.1,-1),Dr("u3",e,t,Ar,0,n*2,-1),Dr("cf1",e,t,Ar,-r,0,1),Dr("cf2",e,t,Ar,r,0,1),Dr("cf3",e,t,Ar,0,-n,1),Dr("cf4",e,t,Ar,0,n,1),Dr("cn1",e,t,Ar,-r,0,-1),Dr("cn2",e,t,Ar,r,0,-1),Dr("cn3",e,t,Ar,0,-n,-1),Dr("cn4",e,t,Ar,0,n,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Dr(i,t,e,r,n,s,o){ag.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],ag.x,ag.y,ag.z)}}var Na=class extends Da{constructor(t,e=16776960){let r=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]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ae;s.setIndex(new Ge(r,1)),s.setAttribute("position",new be(n,3)),super(s,new Hi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var Lg=class extends Da{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new Ae;n.setAttribute("position",new be(e,3)),n.setAttribute("color",new be(r,3));let s=new Hi({vertexColors:!0,toneMapped:!1});super(n,s),this.type="AxesHelper"}setColors(t,e,r){let n=new Re,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(r),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var Vo=oU();function oU(){let i=new ArrayBuffer(4),t=new Float32Array(i),e=new Uint32Array(i),r=new Uint32Array(512),n=new Uint32Array(512);for(let l=0;l<256;++l){let u=l-127;u<-27?(r[l]=0,r[l|256]=32768,n[l]=24,n[l|256]=24):u<-14?(r[l]=1024>>-u-14,r[l|256]=1024>>-u-14|32768,n[l]=-u-1,n[l|256]=-u-1):u<=15?(r[l]=u+15<<10,r[l|256]=u+15<<10|32768,n[l]=13,n[l|256]=13):u<128?(r[l]=31744,r[l|256]=64512,n[l]=24,n[l|256]=24):(r[l]=31744,r[l|256]=64512,n[l]=13,n[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:r,shiftTable:n,mantissaTable:s,exponentTable:o,offsetTable:a}}function aU(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=Yr(i,-65504,65504),Vo.floatView[0]=i;let t=Vo.uint32View[0],e=t>>23&511;return Vo.baseTable[e]+((t&8388607)>>Vo.shiftTable[e])}function lU(i){let t=i>>10;return Vo.uint32View[0]=Vo.mantissaTable[Vo.offsetTable[t]+(i&1023)]+Vo.exponentTable[t],Vo.floatView[0]}var xM=Object.freeze({__proto__:null,fromHalfFloat:lU,toHalfFloat:aU});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qo);var Iu=".",Qf=Symbol("target"),sw=Symbol("unsubscribe");function Kf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function bM(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Ri=Array.isArray;function Jl(i){return typeof i=="symbol"}var cU={after:(i,t)=>Ri(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>Ri(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=Iu),Jl(t)?i+t.toString():i+t):i,initial:i=>{if(Ri(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(Iu);return t===-1?"":i.slice(0,t)},last:i=>{if(Ri(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(Iu);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(Ri(i))for(let e of i)t(e);else if(i!==""){let e=0,r=i.indexOf(Iu);if(r===-1)t(i);else for(;e<i.length;)r===-1&&(r=i.length),t(i.slice(e,r)),e=r+1,r=i.indexOf(Iu,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},ei=cU;function ow(i){return typeof i=="object"&&typeof i.next=="function"}function aw(i,t,e,r,n){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],t,o.value[0],r),o.value[1]=n(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[Qf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,t,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,t,o.value,r)),o};return i}function kg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Jl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Zf=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),n=r[e];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(t,e),r[e]=n),n}getProxy(t,e,r,n){if(this.isUnsubscribed)return t;let s=t[n],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,ei.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,n,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,n):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(t);n&&(delete n[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let n=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&n!==void 0&&Object.is(t.value,n.value)&&(t.writable||!1)===(n.writable||!1)&&(t.enumerable||!1)===(n.enumerable||!1)&&(t.configurable||!1)===(n.configurable||!1)&&t.get===n.get&&t.set===n.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Ou(i){return toString.call(i)==="[object Object]"}function Ru(){return!0}function Ba(i,t){return i.length!==t.length||i.some((e,r)=>t[r]!==e)}var Vg=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var uU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),lw={push:Ru,pop:Ru,shift:Ru,unshift:Ru,copyWithin:Ba,reverse:Ba,sort:Ba,splice:Ba,flat:Ba,fill:Ba},wM=new Set([...Vg,...uU,...Object.keys(lw)]);function Lu(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var cw=["keys","values","entries"],uw=new Set(["has","toString"]),hw={add:Lu,clear:Lu,delete:Lu,forEach:Lu},SM=new Set([...uw,...Object.keys(hw),...cw]);function Nu(i,t){if(i.size!==t.size)return!0;let e;for(let[r,n]of i)if(e=t.get(r),e!==n||e===void 0&&!t.has(r))return!0;return!1}var hU=new Set([...uw,"get"]),dw={set:Nu,clear:Nu,delete:Nu,forEach:Nu},AM=new Set([...hU,...Object.keys(dw),...cw]);var xn=class{constructor(t,e,r,n){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Vg.has(t)}_shallowClone(t){let e=t;if(Ou(t))e={...t};else if(Ri(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,n]of t.entries())e.set(r,this._shallowClone(n))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,n){return t?(Ri(n)?this._onIsChanged=lw[e]:n instanceof Set?this._onIsChanged=hw[e]:n instanceof Map&&(this._onIsChanged=dw[e]),n):r}update(t,e,r){let n=ei.after(t,this._path);if(e!=="length"){let s=this.clone;ei.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],ei.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Bu=class extends xn{static isHandledMethod(t){return wM.has(t)}};var Jf=class extends xn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Fu=class extends xn{static isHandledMethod(t){return SM.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var ku=class extends xn{static isHandledMethod(t){return AM.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var $f=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var ep=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var xs=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Ou(t)||Ri(t)||Kf(t)}static isHandledMethod(t,e){return Ou(t)?xn.isHandledMethod(e):Ri(t)?Bu.isHandledMethod(e):t instanceof Set?Fu.isHandledMethod(e):t instanceof Map?ku.isHandledMethod(e):Kf(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let n=xn;Ri(t)?n=Bu:t instanceof Date?n=Jf:t instanceof Set?n=Fu:t instanceof Map?n=ku:t instanceof WeakSet?n=$f:t instanceof WeakMap&&(n=ep),this._stack.push(new n(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:n}=t,s=xs.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var dU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},fw=(i,t,e={})=>{e={...dU,...e};let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=e,l=new Zf(n),u=typeof e.onValidate=="function",c=new xs(u),h=(v,x,w,S,A)=>!u||c.isCloning||e.onValidate(ei.concat(l.getPath(v),x),w,S,A)===!0,d=(v,x,w,S)=>{!kg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,A)=>{c.isCloning?c.update(v,x,S):t(ei.concat(v,x),w,S,A)},p=v=>v&&(v[r]||v),m=(v,x,w,S)=>bM(v)||w==="constructor"||s&&!xs.isHandledMethod(x,w)||kg(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,ei.concat(S,w),g,r)),g={get(v,x,w){if(Jl(x)){if(x===r||x===Qf)return v;if(x===sw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Kf(v)?Reflect.get(v,x):Reflect.get(v,x,w);return m(S,v,x)},set(v,x,w,S){w=p(w);let A=v[r]||v,E=A[x];if(n(E,w)&&x in v)return!0;let b=h(v,x,w,E);return b&&l.setProperty(A,x,w,S,E)?(d(v,x,v[x],E),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];h(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&d(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=h(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(d(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&xs.isHandledType(S)){let A=ei.initial(l.getPath(v)),E=xs.isHandledMethod(S,v.name);c.start(S,A,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),E?w.map(C=>p(C)):w),M=c.isChanged(S,n),T=c.stop();if(xs.isHandledType(b)&&E&&(x instanceof Map&&v.name==="get"&&(A=ei.concat(A,w[0])),b=l.getProxy(b,A,g)),M){let C={name:v.name,args:w,result:b},P=c.isCloning?ei.initial(A):A,D=c.isCloning?ei.last(A):"";h(ei.get(i,P),D,S,T,C)?f(P,D,S,T,C):c.undo(S)}return(x instanceof Map||x instanceof Set)&&ow(b)?aw(b,v,x,A,m):b}return Reflect.apply(v,x,w)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};fw.target=i=>i&&i[Qf]||i;fw.unsubscribe=i=>i[sw]||i;var pw=fw;var fU=typeof global=="object"&&global&&global.Object===Object&&global,zg=fU;var pU=typeof self=="object"&&self&&self.Object===Object&&self,mU=zg||pU||Function("return this")(),Er=mU;var gU=Er.Symbol,bn=gU;var _M=Object.prototype,yU=_M.hasOwnProperty,vU=_M.toString,tp=bn?bn.toStringTag:void 0;function xU(i){var t=yU.call(i,tp),e=i[tp];try{i[tp]=void 0;var r=!0}catch{}var n=vU.call(i);return r&&(t?i[tp]=e:delete i[tp]),n}var EM=xU;var bU=Object.prototype,wU=bU.toString;function SU(i){return wU.call(i)}var MM=SU;var AU="[object Null]",_U="[object Undefined]",TM=bn?bn.toStringTag:void 0;function EU(i){return i==null?i===void 0?_U:AU:TM&&TM in Object(i)?EM(i):MM(i)}var Li=EU;function MU(i){return i!=null&&typeof i=="object"}var Bn=MU;var TU="[object Symbol]";function CU(i){return typeof i=="symbol"||Bn(i)&&Li(i)==TU}var Fa=CU;function PU(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var Ug=PU;var DU=Array.isArray,sn=DU;var IU=1/0,CM=bn?bn.prototype:void 0,PM=CM?CM.toString:void 0;function DM(i){if(typeof i=="string")return i;if(sn(i))return Ug(i,DM)+"";if(Fa(i))return PM?PM.call(i):"";var t=i+"";return t=="0"&&1/i==-IU?"-0":t}var IM=DM;var OU=/\s/;function RU(i){for(var t=i.length;t--&&OU.test(i.charAt(t)););return t}var OM=RU;var LU=/^\s+/;function NU(i){return i&&i.slice(0,OM(i)+1).replace(LU,"")}var RM=NU;function BU(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Kr=BU;var LM=0/0,FU=/^[-+]0x[0-9a-f]+$/i,kU=/^0b[01]+$/i,VU=/^0o[0-7]+$/i,zU=parseInt;function UU(i){if(typeof i=="number")return i;if(Fa(i))return LM;if(Kr(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Kr(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=RM(i);var e=kU.test(i);return e||VU.test(i)?zU(i.slice(2),e?2:8):FU.test(i)?LM:+i}var mw=UU;function GU(i){return i}var NM=GU;var HU="[object AsyncFunction]",jU="[object Function]",WU="[object GeneratorFunction]",qU="[object Proxy]";function YU(i){if(!Kr(i))return!1;var t=Li(i);return t==jU||t==WU||t==HU||t==qU}var Gg=YU;var XU=Er["__core-js_shared__"],Hg=XU;var BM=function(){var i=/[^.]+$/.exec(Hg&&Hg.keys&&Hg.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function QU(i){return!!BM&&BM in i}var FM=QU;var KU=Function.prototype,ZU=KU.toString;function JU(i){if(i!=null){try{return ZU.call(i)}catch{}try{return i+""}catch{}}return""}var Yo=JU;var $U=/[\\^$.*+?()[\]{}|]/g,eG=/^\[object .+?Constructor\]$/,tG=Function.prototype,rG=Object.prototype,nG=tG.toString,iG=rG.hasOwnProperty,sG=RegExp("^"+nG.call(iG).replace($U,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function oG(i){if(!Kr(i)||FM(i))return!1;var t=Gg(i)?sG:eG;return t.test(Yo(i))}var kM=oG;function aG(i,t){return i?.[t]}var VM=aG;function lG(i,t){var e=VM(i,t);return kM(e)?e:void 0}var ci=lG;var cG=ci(Er,"WeakMap"),jg=cG;var zM=Object.create,uG=function(){function i(){}return function(t){if(!Kr(t))return{};if(zM)return zM(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),UM=uG;function hG(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var GM=hG;function dG(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var HM=dG;var fG=800,pG=16,mG=Date.now;function gG(i){var t=0,e=0;return function(){var r=mG(),n=pG-(r-e);if(e=r,n>0){if(++t>=fG)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var jM=gG;function yG(i){return function(){return i}}var WM=yG;var vG=function(){try{var i=ci(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Vu=vG;var xG=Vu?function(i,t){return Vu(i,"toString",{configurable:!0,enumerable:!1,value:WM(t),writable:!0})}:NM,qM=xG;var bG=jM(qM),YM=bG;function wG(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var XM=wG;var SG=9007199254740991,AG=/^(?:0|[1-9]\d*)$/;function _G(i,t){var e=typeof i;return t=t??SG,!!t&&(e=="number"||e!="symbol"&&AG.test(i))&&i>-1&&i%1==0&&i<t}var zu=_G;function EG(i,t,e){t=="__proto__"&&Vu?Vu(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Wg=EG;function MG(i,t){return i===t||i!==i&&t!==t}var Uu=MG;var TG=Object.prototype,CG=TG.hasOwnProperty;function PG(i,t,e){var r=i[t];(!(CG.call(i,t)&&Uu(r,e))||e===void 0&&!(t in i))&&Wg(i,t,e)}var Gu=PG;function DG(i,t,e,r){var n=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),n?Wg(e,a,l):Gu(e,a,l)}return e}var qs=DG;var QM=Math.max;function IG(i,t,e){return t=QM(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,s=QM(r.length-t,0),o=Array(s);++n<s;)o[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=e(o),GM(i,this,a)}}var KM=IG;var OG=9007199254740991;function RG(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=OG}var Hu=RG;function LG(i){return i!=null&&Hu(i.length)&&!Gg(i)}var qg=LG;var NG=Object.prototype;function BG(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||NG;return i===e}var ju=BG;function FG(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var ZM=FG;var kG="[object Arguments]";function VG(i){return Bn(i)&&Li(i)==kG}var gw=VG;var JM=Object.prototype,zG=JM.hasOwnProperty,UG=JM.propertyIsEnumerable,GG=gw(function(){return arguments}())?gw:function(i){return Bn(i)&&zG.call(i,"callee")&&!UG.call(i,"callee")},Wu=GG;function HG(){return!1}var $M=HG;var rT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,eT=rT&&typeof module=="object"&&module&&!module.nodeType&&module,jG=eT&&eT.exports===rT,tT=jG?Er.Buffer:void 0,WG=tT?tT.isBuffer:void 0,qG=WG||$M,$l=qG;var YG="[object Arguments]",XG="[object Array]",QG="[object Boolean]",KG="[object Date]",ZG="[object Error]",JG="[object Function]",$G="[object Map]",e4="[object Number]",t4="[object Object]",r4="[object RegExp]",n4="[object Set]",i4="[object String]",s4="[object WeakMap]",o4="[object ArrayBuffer]",a4="[object DataView]",l4="[object Float32Array]",c4="[object Float64Array]",u4="[object Int8Array]",h4="[object Int16Array]",d4="[object Int32Array]",f4="[object Uint8Array]",p4="[object Uint8ClampedArray]",m4="[object Uint16Array]",g4="[object Uint32Array]",cr={};cr[l4]=cr[c4]=cr[u4]=cr[h4]=cr[d4]=cr[f4]=cr[p4]=cr[m4]=cr[g4]=!0;cr[YG]=cr[XG]=cr[o4]=cr[QG]=cr[a4]=cr[KG]=cr[ZG]=cr[JG]=cr[$G]=cr[e4]=cr[t4]=cr[r4]=cr[n4]=cr[i4]=cr[s4]=!1;function y4(i){return Bn(i)&&Hu(i.length)&&!!cr[Li(i)]}var nT=y4;function v4(i){return function(t){return i(t)}}var qu=v4;var iT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rp=iT&&typeof module=="object"&&module&&!module.nodeType&&module,x4=rp&&rp.exports===iT,yw=x4&&zg.process,b4=function(){try{var i=rp&&rp.require&&rp.require("util").types;return i||yw&&yw.binding&&yw.binding("util")}catch{}}(),Xo=b4;var sT=Xo&&Xo.isTypedArray,w4=sT?qu(sT):nT,Yg=w4;var S4=Object.prototype,A4=S4.hasOwnProperty;function _4(i,t){var e=sn(i),r=!e&&Wu(i),n=!e&&!r&&$l(i),s=!e&&!r&&!n&&Yg(i),o=e||r||n||s,a=o?ZM(i.length,String):[],l=a.length;for(var u in i)(t||A4.call(i,u))&&!(o&&(u=="length"||n&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||zu(u,l)))&&a.push(u);return a}var Xg=_4;function E4(i,t){return function(e){return i(t(e))}}var Qg=E4;var M4=Qg(Object.keys,Object),oT=M4;var T4=Object.prototype,C4=T4.hasOwnProperty;function P4(i){if(!ju(i))return oT(i);var t=[];for(var e in Object(i))C4.call(i,e)&&e!="constructor"&&t.push(e);return t}var aT=P4;function D4(i){return qg(i)?Xg(i):aT(i)}var Yu=D4;function I4(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var lT=I4;var O4=Object.prototype,R4=O4.hasOwnProperty;function L4(i){if(!Kr(i))return lT(i);var t=ju(i),e=[];for(var r in i)r=="constructor"&&(t||!R4.call(i,r))||e.push(r);return e}var cT=L4;function N4(i){return qg(i)?Xg(i,!0):cT(i)}var qi=N4;var B4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,F4=/^\w*$/;function k4(i,t){if(sn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Fa(i)?!0:F4.test(i)||!B4.test(i)||t!=null&&i in Object(t)}var uT=k4;var V4=ci(Object,"create"),Qo=V4;function z4(){this.__data__=Qo?Qo(null):{},this.size=0}var hT=z4;function U4(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var dT=U4;var G4="__lodash_hash_undefined__",H4=Object.prototype,j4=H4.hasOwnProperty;function W4(i){var t=this.__data__;if(Qo){var e=t[i];return e===G4?void 0:e}return j4.call(t,i)?t[i]:void 0}var fT=W4;var q4=Object.prototype,Y4=q4.hasOwnProperty;function X4(i){var t=this.__data__;return Qo?t[i]!==void 0:Y4.call(t,i)}var pT=X4;var Q4="__lodash_hash_undefined__";function K4(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Qo&&t===void 0?Q4:t,this}var mT=K4;function Xu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Xu.prototype.clear=hT;Xu.prototype.delete=dT;Xu.prototype.get=fT;Xu.prototype.has=pT;Xu.prototype.set=mT;var vw=Xu;function Z4(){this.__data__=[],this.size=0}var gT=Z4;function J4(i,t){for(var e=i.length;e--;)if(Uu(i[e][0],t))return e;return-1}var ka=J4;var $4=Array.prototype,eH=$4.splice;function tH(i){var t=this.__data__,e=ka(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():eH.call(t,e,1),--this.size,!0}var yT=tH;function rH(i){var t=this.__data__,e=ka(t,i);return e<0?void 0:t[e][1]}var vT=rH;function nH(i){return ka(this.__data__,i)>-1}var xT=nH;function iH(i,t){var e=this.__data__,r=ka(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var bT=iH;function Qu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Qu.prototype.clear=gT;Qu.prototype.delete=yT;Qu.prototype.get=vT;Qu.prototype.has=xT;Qu.prototype.set=bT;var Va=Qu;var sH=ci(Er,"Map"),za=sH;function oH(){this.size=0,this.__data__={hash:new vw,map:new(za||Va),string:new vw}}var wT=oH;function aH(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var ST=aH;function lH(i,t){var e=i.__data__;return ST(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ua=lH;function cH(i){var t=Ua(this,i).delete(i);return this.size-=t?1:0,t}var AT=cH;function uH(i){return Ua(this,i).get(i)}var _T=uH;function hH(i){return Ua(this,i).has(i)}var ET=hH;function dH(i,t){var e=Ua(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var MT=dH;function Ku(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Ku.prototype.clear=wT;Ku.prototype.delete=AT;Ku.prototype.get=_T;Ku.prototype.has=ET;Ku.prototype.set=MT;var ec=Ku;var fH="Expected a function";function xw(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(fH);var e=function(){var r=arguments,n=t?t.apply(this,r):r[0],s=e.cache;if(s.has(n))return s.get(n);var o=i.apply(this,r);return e.cache=s.set(n,o)||s,o};return e.cache=new(xw.Cache||ec),e}xw.Cache=ec;var TT=xw;var pH=500;function mH(i){var t=TT(i,function(r){return e.size===pH&&e.clear(),r}),e=t.cache;return t}var CT=mH;var gH=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,yH=/\\(\\)?/g,vH=CT(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(gH,function(e,r,n,s){t.push(n?s.replace(yH,"$1"):r||e)}),t}),PT=vH;function xH(i){return i==null?"":IM(i)}var DT=xH;function bH(i,t){return sn(i)?i:uT(i,t)?[i]:PT(DT(i))}var Yi=bH;var wH=1/0;function SH(i){if(typeof i=="string"||Fa(i))return i;var t=i+"";return t=="0"&&1/i==-wH?"-0":t}var Ga=SH;function AH(i,t){t=Yi(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Ga(t[e++])];return e&&e==r?i:void 0}var Kg=AH;function _H(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var Zu=_H;var IT=bn?bn.isConcatSpreadable:void 0;function EH(i){return sn(i)||Wu(i)||!!(IT&&i&&i[IT])}var OT=EH;function RT(i,t,e,r,n){var s=-1,o=i.length;for(e||(e=OT),n||(n=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?RT(a,t-1,e,r,n):Zu(n,a):r||(n[n.length]=a)}return n}var LT=RT;function MH(i){var t=i==null?0:i.length;return t?LT(i,1):[]}var NT=MH;function TH(i){return YM(KM(i,void 0,NT),i+"")}var Zg=TH;var CH=Qg(Object.getPrototypeOf,Object),Ju=CH;var PH="[object Object]",DH=Function.prototype,IH=Object.prototype,BT=DH.toString,OH=IH.hasOwnProperty,RH=BT.call(Object);function LH(i){if(!Bn(i)||Li(i)!=PH)return!1;var t=Ju(i);if(t===null)return!0;var e=OH.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&BT.call(e)==RH}var FT=LH;function NH(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+t];return s}var kT=NH;function BH(){this.__data__=new Va,this.size=0}var VT=BH;function FH(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var zT=FH;function kH(i){return this.__data__.get(i)}var UT=kH;function VH(i){return this.__data__.has(i)}var GT=VH;var zH=200;function UH(i,t){var e=this.__data__;if(e instanceof Va){var r=e.__data__;if(!za||r.length<zH-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new ec(r)}return e.set(i,t),this.size=e.size,this}var HT=UH;function $u(i){var t=this.__data__=new Va(i);this.size=t.size}$u.prototype.clear=VT;$u.prototype.delete=zT;$u.prototype.get=UT;$u.prototype.has=GT;$u.prototype.set=HT;var eh=$u;function GH(i,t){return i&&qs(t,Yu(t),i)}var jT=GH;function HH(i,t){return i&&qs(t,qi(t),i)}var WT=HH;var QT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qT=QT&&typeof module=="object"&&module&&!module.nodeType&&module,jH=qT&&qT.exports===QT,YT=jH?Er.Buffer:void 0,XT=YT?YT.allocUnsafe:void 0;function WH(i,t){if(t)return i.slice();var e=i.length,r=XT?XT(e):new i.constructor(e);return i.copy(r),r}var KT=WH;function qH(i,t){for(var e=-1,r=i==null?0:i.length,n=0,s=[];++e<r;){var o=i[e];t(o,e,i)&&(s[n++]=o)}return s}var ZT=qH;function YH(){return[]}var Jg=YH;var XH=Object.prototype,QH=XH.propertyIsEnumerable,JT=Object.getOwnPropertySymbols,KH=JT?function(i){return i==null?[]:(i=Object(i),ZT(JT(i),function(t){return QH.call(i,t)}))}:Jg,th=KH;function ZH(i,t){return qs(i,th(i),t)}var $T=ZH;var JH=Object.getOwnPropertySymbols,$H=JH?function(i){for(var t=[];i;)Zu(t,th(i)),i=Ju(i);return t}:Jg,$g=$H;function e5(i,t){return qs(i,$g(i),t)}var eC=e5;function t5(i,t,e){var r=t(i);return sn(i)?r:Zu(r,e(i))}var ey=t5;function r5(i){return ey(i,Yu,th)}var np=r5;function n5(i){return ey(i,qi,$g)}var ty=n5;var i5=ci(Er,"DataView"),ry=i5;var s5=ci(Er,"Promise"),ny=s5;var o5=ci(Er,"Set"),iy=o5;var tC="[object Map]",a5="[object Object]",rC="[object Promise]",nC="[object Set]",iC="[object WeakMap]",sC="[object DataView]",l5=Yo(ry),c5=Yo(za),u5=Yo(ny),h5=Yo(iy),d5=Yo(jg),tc=Li;(ry&&tc(new ry(new ArrayBuffer(1)))!=sC||za&&tc(new za)!=tC||ny&&tc(ny.resolve())!=rC||iy&&tc(new iy)!=nC||jg&&tc(new jg)!=iC)&&(tc=function(i){var t=Li(i),e=t==a5?i.constructor:void 0,r=e?Yo(e):"";if(r)switch(r){case l5:return sC;case c5:return tC;case u5:return rC;case h5:return nC;case d5:return iC}return t});var Ko=tc;var f5=Object.prototype,p5=f5.hasOwnProperty;function m5(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&p5.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var oC=m5;var g5=Er.Uint8Array,rh=g5;function y5(i){var t=new i.constructor(i.byteLength);return new rh(t).set(new rh(i)),t}var nh=y5;function v5(i,t){var e=t?nh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var aC=v5;var x5=/\w*$/;function b5(i){var t=new i.constructor(i.source,x5.exec(i));return t.lastIndex=i.lastIndex,t}var lC=b5;var cC=bn?bn.prototype:void 0,uC=cC?cC.valueOf:void 0;function w5(i){return uC?Object(uC.call(i)):{}}var hC=w5;function S5(i,t){var e=t?nh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var dC=S5;var A5="[object Boolean]",_5="[object Date]",E5="[object Map]",M5="[object Number]",T5="[object RegExp]",C5="[object Set]",P5="[object String]",D5="[object Symbol]",I5="[object ArrayBuffer]",O5="[object DataView]",R5="[object Float32Array]",L5="[object Float64Array]",N5="[object Int8Array]",B5="[object Int16Array]",F5="[object Int32Array]",k5="[object Uint8Array]",V5="[object Uint8ClampedArray]",z5="[object Uint16Array]",U5="[object Uint32Array]";function G5(i,t,e){var r=i.constructor;switch(t){case I5:return nh(i);case A5:case _5:return new r(+i);case O5:return aC(i,e);case R5:case L5:case N5:case B5:case F5:case k5:case V5:case z5:case U5:return dC(i,e);case E5:return new r;case M5:case P5:return new r(i);case T5:return lC(i);case C5:return new r;case D5:return hC(i)}}var fC=G5;function H5(i){return typeof i.constructor=="function"&&!ju(i)?UM(Ju(i)):{}}var pC=H5;var j5="[object Map]";function W5(i){return Bn(i)&&Ko(i)==j5}var mC=W5;var gC=Xo&&Xo.isMap,q5=gC?qu(gC):mC,yC=q5;var Y5="[object Set]";function X5(i){return Bn(i)&&Ko(i)==Y5}var vC=X5;var xC=Xo&&Xo.isSet,Q5=xC?qu(xC):vC,bC=Q5;var K5=1,Z5=2,J5=4,wC="[object Arguments]",$5="[object Array]",ej="[object Boolean]",tj="[object Date]",rj="[object Error]",SC="[object Function]",nj="[object GeneratorFunction]",ij="[object Map]",sj="[object Number]",AC="[object Object]",oj="[object RegExp]",aj="[object Set]",lj="[object String]",cj="[object Symbol]",uj="[object WeakMap]",hj="[object ArrayBuffer]",dj="[object DataView]",fj="[object Float32Array]",pj="[object Float64Array]",mj="[object Int8Array]",gj="[object Int16Array]",yj="[object Int32Array]",vj="[object Uint8Array]",xj="[object Uint8ClampedArray]",bj="[object Uint16Array]",wj="[object Uint32Array]",ar={};ar[wC]=ar[$5]=ar[hj]=ar[dj]=ar[ej]=ar[tj]=ar[fj]=ar[pj]=ar[mj]=ar[gj]=ar[yj]=ar[ij]=ar[sj]=ar[AC]=ar[oj]=ar[aj]=ar[lj]=ar[cj]=ar[vj]=ar[xj]=ar[bj]=ar[wj]=!0;ar[rj]=ar[SC]=ar[uj]=!1;function sy(i,t,e,r,n,s){var o,a=t&K5,l=t&Z5,u=t&J5;if(e&&(o=n?e(i,r,n,s):e(i)),o!==void 0)return o;if(!Kr(i))return i;var c=sn(i);if(c){if(o=oC(i),!a)return HM(i,o)}else{var h=Ko(i),d=h==SC||h==nj;if($l(i))return KT(i,a);if(h==AC||h==wC||d&&!n){if(o=l||d?{}:pC(i),!a)return l?eC(i,WT(o,i)):$T(i,jT(o,i))}else{if(!ar[h])return n?i:{};o=fC(i,h,a)}}s||(s=new eh);var f=s.get(i);if(f)return f;s.set(i,o),bC(i)?i.forEach(function(g){o.add(sy(g,t,e,g,i,s))}):yC(i)&&i.forEach(function(g,y){o.set(y,sy(g,t,e,y,i,s))});var p=u?l?ty:np:l?qi:Yu,m=c?void 0:p(i);return XM(m||i,function(g,y){m&&(y=g,g=i[y]),Gu(o,y,sy(g,t,e,y,i,s))}),o}var oy=sy;var Sj=1,Aj=4;function _j(i){return oy(i,Sj|Aj)}var Zo=_j;var Ej="__lodash_hash_undefined__";function Mj(i){return this.__data__.set(i,Ej),this}var _C=Mj;function Tj(i){return this.__data__.has(i)}var EC=Tj;function ay(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new ec;++t<e;)this.add(i[t])}ay.prototype.add=ay.prototype.push=_C;ay.prototype.has=EC;var MC=ay;function Cj(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var TC=Cj;function Pj(i,t){return i.has(t)}var CC=Pj;var Dj=1,Ij=2;function Oj(i,t,e,r,n,s){var o=e&Dj,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var h=-1,d=!0,f=e&Ij?new MC:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],m=t[h];if(r)var g=o?r(m,p,h,t,i,s):r(p,m,h,i,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!TC(t,function(y,v){if(!CC(f,v)&&(p===y||n(p,y,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||n(p,m,e,r,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var ly=Oj;function Rj(i){var t=-1,e=Array(i.size);return i.forEach(function(r,n){e[++t]=[n,r]}),e}var PC=Rj;function Lj(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var DC=Lj;var Nj=1,Bj=2,Fj="[object Boolean]",kj="[object Date]",Vj="[object Error]",zj="[object Map]",Uj="[object Number]",Gj="[object RegExp]",Hj="[object Set]",jj="[object String]",Wj="[object Symbol]",qj="[object ArrayBuffer]",Yj="[object DataView]",IC=bn?bn.prototype:void 0,bw=IC?IC.valueOf:void 0;function Xj(i,t,e,r,n,s,o){switch(e){case Yj:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case qj:return!(i.byteLength!=t.byteLength||!s(new rh(i),new rh(t)));case Fj:case kj:case Uj:return Uu(+i,+t);case Vj:return i.name==t.name&&i.message==t.message;case Gj:case jj:return i==t+"";case zj:var a=PC;case Hj:var l=r&Nj;if(a||(a=DC),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;r|=Bj,o.set(i,t);var c=ly(a(i),a(t),r,n,s,o);return o.delete(i),c;case Wj:if(bw)return bw.call(i)==bw.call(t)}return!1}var OC=Xj;var Qj=1,Kj=Object.prototype,Zj=Kj.hasOwnProperty;function Jj(i,t,e,r,n,s){var o=e&Qj,a=np(i),l=a.length,u=np(t),c=u.length;if(l!=c&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:Zj.call(t,d)))return!1}var f=s.get(i),p=s.get(t);if(f&&p)return f==t&&p==i;var m=!0;s.set(i,t),s.set(t,i);for(var g=o;++h<l;){d=a[h];var y=i[d],v=t[d];if(r)var x=o?r(v,y,d,t,i,s):r(y,v,d,i,t,s);if(!(x===void 0?y===v||n(y,v,e,r,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var w=i.constructor,S=t.constructor;w!=S&&"constructor"in i&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(m=!1)}return s.delete(i),s.delete(t),m}var RC=Jj;var $j=1,LC="[object Arguments]",NC="[object Array]",cy="[object Object]",eW=Object.prototype,BC=eW.hasOwnProperty;function tW(i,t,e,r,n,s){var o=sn(i),a=sn(t),l=o?NC:Ko(i),u=a?NC:Ko(t);l=l==LC?cy:l,u=u==LC?cy:u;var c=l==cy,h=u==cy,d=l==u;if(d&&$l(i)){if(!$l(t))return!1;o=!0,c=!1}if(d&&!c)return s||(s=new eh),o||Yg(i)?ly(i,t,e,r,n,s):OC(i,t,l,e,r,n,s);if(!(e&$j)){var f=c&&BC.call(i,"__wrapped__"),p=h&&BC.call(t,"__wrapped__");if(f||p){var m=f?i.value():i,g=p?t.value():t;return s||(s=new eh),n(m,g,e,r,s)}}return d?(s||(s=new eh),RC(i,t,e,r,n,s)):!1}var FC=tW;function kC(i,t,e,r,n){return i===t?!0:i==null||t==null||!Bn(i)&&!Bn(t)?i!==i&&t!==t:FC(i,t,e,r,kC,n)}var VC=kC;function rW(i,t){return i!=null&&t in Object(i)}var zC=rW;function nW(i,t,e){t=Yi(t,i);for(var r=-1,n=t.length,s=!1;++r<n;){var o=Ga(t[r]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++r!=n?s:(n=i==null?0:i.length,!!n&&Hu(n)&&zu(o,n)&&(sn(i)||Wu(i)))}var UC=nW;function iW(i,t){return i!=null&&UC(i,t,zC)}var GC=iW;var sW=function(){return Er.Date.now()},uy=sW;var oW="Expected a function",aW=Math.max,lW=Math.min;function cW(i,t,e){var r,n,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(oW);t=mw(t)||0,Kr(e)&&(c=!!e.leading,h="maxWait"in e,s=h?aW(mw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var E=r,b=n;return r=n=void 0,u=A,o=i.apply(b,E),o}function p(A){return u=A,a=setTimeout(y,t),c?f(A):o}function m(A){var E=A-l,b=A-u,M=t-E;return h?lW(M,s-b):M}function g(A){var E=A-l,b=A-u;return l===void 0||E>=t||E<0||h&&b>=s}function y(){var A=uy();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=n=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,r=l=n=a=void 0}function w(){return a===void 0?o:v(uy())}function S(){var A=uy(),E=g(A);if(r=arguments,n=this,l=A,E){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return S.cancel=x,S.flush=w,S}var rc=cW;function uW(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var HC=uW;function hW(i,t){return t.length<2?i:Kg(i,kT(t,0,-1))}var jC=hW;function dW(i,t){return VC(i,t)}var ip=dW;function fW(i,t){return t=Yi(t,i),i=jC(i,t),i==null||delete i[Ga(HC(t))]}var WC=fW;function pW(i){return FT(i)?void 0:i}var qC=pW;var mW=1,gW=2,yW=4,vW=Zg(function(i,t){var e={};if(i==null)return e;var r=!1;t=Ug(t,function(s){return s=Yi(s,i),r||(r=s.length>1),s}),qs(i,ty(i),e),r&&(e=oy(e,mW|gW|yW,qC));for(var n=t.length;n--;)WC(e,t[n]);return e}),ih=vW;function xW(i,t,e,r){if(!Kr(i))return i;t=Yi(t,i);for(var n=-1,s=t.length,o=s-1,a=i;a!=null&&++n<s;){var l=Ga(t[n]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(n!=o){var c=a[l];u=r?r(c,l,a):void 0,u===void 0&&(u=Kr(c)?c:zu(t[n+1])?[]:{})}Gu(a,l,u),a=a[l]}return i}var YC=xW;function bW(i,t,e){for(var r=-1,n=t.length,s={};++r<n;){var o=t[r],a=Kg(i,o);e(a,o)&&YC(s,Yi(o,i),a)}return s}var XC=bW;function wW(i,t){return XC(i,t,function(e,r){return GC(i,r)})}var QC=wW;var SW=Zg(function(i,t){return i==null?{}:QC(i,t)}),Ni=SW;var AW="Expected a function";function _W(i,t,e){var r=!0,n=!0;if(typeof i!="function")throw new TypeError(AW);return Kr(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),rc(i,t,{leading:r,maxWait:t,trailing:n})}var ww=_W;function KC(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function ui(i,t){return Object.setPrototypeOf(i,t),i}var EW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),MW=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),TW=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||nc&&"ontouchend"in document,CW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,PW=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,DW=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},IW=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},OW=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},RW=EW(),Kse=RW?OW():void 0,nc=MW(),sh=TW(),ZC=CW(),on=PW(),Sw=DW(),Aw=Number(IW());function hy(i){return Array.isArray(i)?i:[i]}function JC(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function sp(i){return nc?i.metaKey:i.ctrlKey}var qe=[],fy={},op={},dy={};function $C(i){qe.includes(i)||qe.push(i)}function oh(i){delete fy[i.pointerId];for(let t=0;t<qe.length;t++)if(qe[t].pointerId===i.pointerId){qe.splice(t,1);break}}function eP(){qe.splice(0,qe.length)}function py(i){if(i.pointerType!=="touch")return;let t=fy[i.pointerId];t===void 0&&(t={x:0,y:0},fy[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function my(i){let t=i.pointerId===qe[0].pointerId?qe[1]:qe[0];return fy[t.pointerId]}function tP(i){op[i.key]=!0,dy[i.key]=dy[i.key]===void 0?1:dy[i.key]+1}function rP(i){if(nc&&op.Meta)for(let t in op)op[t]=!1;else op[i.key]=!1;dy={}}function nP(i){i.addEventListener("pointerdown",$C,!0),i.addEventListener("pointerdown",py,!0),i.addEventListener("pointermove",py,!0),i.addEventListener("pointerup",oh,!0),i.addEventListener("pointercancel",oh,!0),i.addEventListener("pointerleave",oh,!0),window.addEventListener("keydown",tP,!0),window.addEventListener("keyup",rP,!0)}function iP(i){i.removeEventListener("pointerdown",$C,!0),i.removeEventListener("pointerdown",py,!0),i.removeEventListener("pointermove",py,!0),i.removeEventListener("pointerup",oh,!0),i.removeEventListener("pointercancel",oh,!0),i.removeEventListener("pointerleave",oh,!0),window.removeEventListener("keydown",tP,!0),window.removeEventListener("keyup",rP,!0)}var sP,oP=new Promise(i=>{sP=i});var gy;function aP(){if(gy)return gy;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.518/build",n=import("./navmesh.js"),[s,o]=await Promise.all([n,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});sP(l)}return gy=i(),gy}var lP,cP=new Promise(i=>{lP=i});var yy;function uP(){if(yy)return yy;async function i(){let e=await import("./physics.js");await e.init(),lP(e)}return yy=i(),yy}var rt=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,rt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,rt.prototype),{data:a,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,rt.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:n}}}}return null}};function ap(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&ap(r)}return Object.freeze(i)}function hP(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ah=class extends Error{};function vy(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ys(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let r=[],n=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*n;r.push(o)}return r}function lh(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function dP(){return typeof process<"u"}function fP(i,t){for(let e of i)t(e.id,e.data)!==!0&&fP(e.children,t)}function pP(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)pP(e,t)}var pr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,pr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ap(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let n of e.children)this.fillCaches0(n,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,r){if(!this.has(e))return!0;for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}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,r){if(e===null)this.traverse(r);else{let n=this.get(e);n&&pP(n,r)}}traverse(e){fP(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let n=e,s=r;for(;n!==null;){let a=s,l=n;if(n=this.parent(n),n===void 0)throw new Error;s=this.childrenArray(n);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,pr.prototype);let o=s;return o.fillCaches(),o}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:r}){if(this.get(e)!==void 0)return!0;for(let n of r)if(this.checkDuplicatedIdRec(n))return!0;return!1}addOp(e){let{parent:r,fi:n,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:n,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let s=this.childrenArray(n),o=s.findIndex(u=>u.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(n,s),actual:e,reverse:{type:7,...a,parent:n}}}}moveOp(e){let{parent:r,fi:n,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new ah("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:n},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let n=null;for(let s of this.childrenArray(e)){if(s.id===r)return n;n=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)+1;if(s<n.length)return n[s].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(n[s].id):r}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push({...n,...s})}r.sort((n,s)=>hP(n.sortKey,s.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)n.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:n}}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let s=this.childrenArray(e);if(r===null){if(s.length===0)return Ys(0,n,n);{let o=s[0].fi;return Ys(o-n,o,n)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ys(l,l+n,n)}else return Ys(o.fi,a.fi,n)}}};var ch;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let n=r.props,s={},o=[...e],a=!1;if(n)for(let l of Object.keys(n)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=n[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let n=r.props,s={},o={...e},a=!1;if(n)for(let l of Object.keys(n)){s[l]=o[l];let u=n[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=i})(ch||(ch={}));var Le=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Le.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ap(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Le.prototype);let r=e;return dP()||r.fillCaches(),r}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:r,id:n,data:s}=e,o=this,a={fi:r,id:n,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,s=n.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,n=[...n];let o=n.splice(s,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:n}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===n);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return Ys(0,r,r);{let s=n[0].fi;return Ys(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=n.find(a=>a.fi>s.fi);if(o===void 0){let a=n[n.length-1].fi;return Ys(a,a+r,r)}else return Ys(s.fi,o.fi,r)}}};function uh(i){return i&&typeof i=="object"&&i instanceof Jt}var Jt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,n=0,s={};for(;n<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!uh(r))return null;n+=1}r=r?vy(r):new Jt;for(let[l,u]of Object.entries(t.props)){let c=r[l];s[l]=c,u===void 0?delete r[l]:r[l]=u}for(;n>0;){if(Object.keys(r).length===0){let l=e[n-1];l&&(r=vy(l),delete r[t.path[n-1]])}else{let l=e[n-1];if(l){let u=vy(l);u[t.path[n-1]]=r,r=u}else{let u=new Jt;u[t.path[n-1]]=r,r=u}}n-=1}let o=Object.setPrototypeOf(r,Jt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Xs;(r=>{function i(n,s){return lp(n,s)??n}r.apply=i;function t(n,s){return Ew(n,s)}r.merge=t;function e(n,s){let o=0,a=s.path,l=n;for(;o<a.length&&l!==void 0;){if(l=Rr.zoomOnce(l,a[o]),l===void 0)return s;if(!uh(l))return;o+=1}if(l===void 0)return s;if(!!uh(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=_w([s],l);return u?(console.log(u),u):s}else return s}r.filterOp=e})(Xs||(Xs={}));function _w(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=lp(n.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=n.data),n.children){let a=_w(n.children,t);return a!==void 0?e=!0:a=n.children,{...n,id:s,data:o,children:a}}else return{...n,id:s,data:o}});if(e)return r}function LW(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=lp(n.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=n.data),{...n,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function lp(i,t){if(!uh(t))return t;if(i instanceof pr){let e=_w(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Le)return LW(i,t);if(Array.isArray(i)){let e=!1,r=i.map((n,s)=>{let o=lp(n,t[s]);return e=e||o!==void 0,o===void 0&&(o=n),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof Jt)return Ew(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[n,s]of Object.entries(i)){let o=lp(s,t[n]);r=r||o!==void 0,o===void 0&&(o=s),e[n]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Ew(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!uh(t))return t;if(!uh(i))return Xs.apply(i,t);let e=new Set;for(let n of Object.keys(i))e.add(n);for(let n of Object.keys(t))e.add(n);let r=new Jt;for(let n of e){let s=Ew(i===void 0?void 0:i[n],t===void 0?void 0:t[n]);r[n]=s}return r}function mP(i,t){let e={cur:[],result:[],len:0};return i=cp(i,t,e)??i,[i,e.result]}function xy(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function by(i){i&&(i.len-=1)}function NW(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function gP(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=cp(s.data,t,xy(e,o));by(e),r=r||l!==void 0,l===void 0&&(l=s.data);let u=gP(s.children,t,e);return u!==void 0?r=!0:u=s.children,{...s,id:o,data:l,children:u}});if(r)return n}function BW(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=cp(s.data,t,xy(e,o));return by(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function cp(i,t,e){if(i instanceof pr){let r=gP(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof Le)return BW(i,t,e);if(Array.isArray(i)){let r=!1,n=i.map((s,o)=>{let a=cp(s,t,xy(e,o));return by(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(i&&typeof i=="object"&&!lh(i)){let r={},n=!1;for(let[s,o]of Object.entries(i))if(s!=="name"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");n=!0,s=a}let l=cp(o,t,xy(e,s));by(e),n=n||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&NW(e),r}else return}}var wy;(t=>{function i(e,r){let n=Rr.zoom(r,e.path);if(typeof n=="object"){let s={};for(let o of Object.keys(e.props))s[o]=n[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(wy||(wy={}));var Lr;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Jt&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===c.length&&(l instanceof pr||l instanceof Le||l instanceof rt?d=l.runOp(u):d=ch.runOp(l,u)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=c[g],v=h[g];if(v instanceof pr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Le){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof rt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Jt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Jt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],p;if(l instanceof pr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Le){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function r(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=r;function n(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=n;function s(l,u){return r(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&n(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(Lr||(Lr={}));var up;(l=>{function i(){return[]}l.empty=i;function t(u,c){let h=[];for(let d of u){let[f,...p]=d.path;f===c&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function n(u,c){return[...u.filter(d=>!c.some(f=>Lr.subsumed(d,f))),...c]}l.compress=n;function s(u,c){return u.every(h=>c.every(d=>Lr.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let p of c)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Rr.zoom(h,[...p.path,p.id]),y=Lr.apply(h,{...p,type:2})):(m=Rr.zoom(h,[...p.path,p.id,"value"]),y=Lr.apply(h,p)),y!==null){h=y.data;let[v,x]=mP(h,{[p.id]:m});h=v;for(let w=0;w<x.length;w++){let S=x[w],A=S.pop();if(typeof A=="number"){let E=[A];for(let M=w+1;M<x.length;M++){let T=x[M],C=T[T.length-1];if(typeof C=="number"&&Rr.equal(S,T.slice(0,T.length-1)))E.push(C),x.splice(M,1);else break}let b=Rr.zoom(h,S);g=b.map((M,T)=>E.includes(T)?p.id:M),m=b,A=S.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let E=m,b=Rr.zoom(h,S.slice(0,S.length-2)),M=b.layers.map(T=>T.id===S[S.length-1]?{...T,data:{...T.data,[A]:E}}:T);Object.setPrototypeOf(M,Object.getPrototypeOf(b.layers)),b.layers=M}g=p.id}d.push({type:0,path:S,props:{[A]:m}}),f.push({type:0,path:S,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Lr.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ah)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(up||(up={}));var yP=Symbol(),FW=Symbol(),Ay=Symbol(),ic=class{reportOp(t,e,r=[]){let n=this;if(e===null)return;n._current=e.data;let s=r;for(;!(n instanceof Sy);){let o=n._path,a=n._current;if(o!==""&&s.splice(0,0,o),n=n._parent,n===null)return;n.update(o,a)}n.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ay];r&&r(),delete this._children[t]}}}},Tw=class extends ic{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,ch.runOp(this._current,t),t.path)}},Cw=class extends ic{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,rt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},vP={get(i,t){if(t===Ay)return()=>{i._parent=null};if(t===yP)return i._current;if(t===FW)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e[t],o=_y(i,t,s);return o!==s?(r===void 0&&(r={},i._children=r),r[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},kW={...vP,set(i,t,e){let r={type:0,props:{[t]:xr(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},VW={...vP,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},hh=class extends ic{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ay]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=_y(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,n,s){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}moveBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},dh=class extends ic{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ay]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),n,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id;if(t(this.data(n),n))return this.get(n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=_y(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Mw(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Rr.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Sy=class extends ic{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,n){Mw(this.ts,e,t),Mw(this.actual,r,t),Mw(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _y(i,t,e){return e instanceof pr?new hh(i,t,e):e instanceof Le?new dh(i,t,e):e instanceof rt?new Proxy(new Cw(i,t,e),VW):e!==null&&typeof e=="object"?lh(e)?e:new Proxy(new Tw(i,t,e),kW):e}function Pw(i){let t=new Sy(i);return[_y(t,"",i),t]}function Ha(i,t){let[e,r]=Pw(i);return t(e),r.result()}function xr(i){return i instanceof hh||i instanceof dh?i._current:i!==null&&typeof i=="object"?i[yP]:i}var Rr;(n=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}n.equal=i;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}n.removeOverridden=t;function e(s,o){if((s instanceof pr||s instanceof hh)&&typeof o=="string")return s.data(o);if((s instanceof Le||s instanceof dh)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}n.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}n.zoom=r})(Rr||(Rr={}));function xP(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function qn(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var Ey=class{},hp=class extends Ey{constructor(e){super();this.id=e}},dp=class extends Ey{constructor(e){super();this.data=e}};var Iw;try{Iw=new TextDecoder}catch{}var Be,Wa,$=0;var TP=[],Ow=TP,Rw=0,hi={},Nt,ja,Xi=0,Qs=0,Bi,Jo,ti=[],Ht,bP={useRecords:!1,mapsAsObjects:!0},fp=class{},Nw=new fp;Nw.name="MessagePack 0xC1";var fh=!1,Ks=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Be)return OP(()=>(Ty(),this?this.unpack(t,e):Ks.prototype.unpack.call(bP,t,e)));Wa=e>-1?e:t.length,$=0,Rw=0,Qs=0,ja=null,Ow=TP,Bi=null,Be=t;try{Ht=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Be=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ks){if(hi=this,this.structures)return Nt=this.structures,My();(!Nt||Nt.length>0)&&(Nt=[])}else hi=bP,(!Nt||Nt.length>0)&&(Nt=[]);return My()}unpackMultiple(t,e){let r,n=0;try{fh=!0;let s=t.length,o=this?this.unpack(t,s):Dy.unpack(t,s);if(e){for(e(o);$<s;)if(n=$,e(My())===!1)return}else{for(r=[o];$<s;)n=$,r.push(My());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{fh=!1,Ty()}}_mergeStructures(t,e){t=t||[];for(let r=0,n=t.length;r<n;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],s=e[r];s&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function My(){try{if(!hi.trusted&&!fh){let t=Nt.sharedLength||0;t<Nt.length&&(Nt.length=t)}let i=Mr();if($==Wa)Nt.restoreStructures&&wP(),Nt=null,Be=null,Jo&&(Jo=null);else if($>Wa){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!fh)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Nt.restoreStructures&&wP(),Ty(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function wP(){for(let i in Nt.restoreStructures)Nt[i]=Nt.restoreStructures[i];Nt.restoreStructures=null}function Mr(){let i=Be[$++];if(i<160)if(i<128){if(i<64)return i;{let t=Nt[i&63]||hi.getStructures&&CP()[i&63];return t?(t.read||(t.read=Bw(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,hi.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DP()]=Mr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mr(),Mr());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mr();return t}else if(i<192){let t=i-160;if(Qs>=$)return ja.slice($-Xi,($+=t)-Xi);if(Qs==0&&Wa<140){let e=t<16?Fw(t):PP(t);if(e!=null)return e}return Lw(t)}else{let t;switch(i){case 192:return null;case 193:return Bi?(t=Mr(),t>0?Bi[1].slice(Bi.position1,Bi.position1+=t):Bi[0].slice(Bi.position0,Bi.position0-=t)):Nw;case 194:return!1;case 195:return!0;case 196:return Dw(Be[$++]);case 197:return t=Ht.getUint16($),$+=2,Dw(t);case 198:return t=Ht.getUint32($),$+=4,Dw(t);case 199:return sc(Be[$++]);case 200:return t=Ht.getUint16($),$+=2,sc(t);case 201:return t=Ht.getUint32($),$+=4,sc(t);case 202:if(t=Ht.getFloat32($),hi.useFloat32>2){let e=Py[(Be[$]&127)<<1|Be[$+1]>>7];return $+=4,(e*t+(t>0?.5:-.5)>>0)/e}return $+=4,t;case 203:return t=Ht.getFloat64($),$+=8,t;case 204:return Be[$++];case 205:return t=Ht.getUint16($),$+=2,t;case 206:return t=Ht.getUint32($),$+=4,t;case 207:return hi.int64AsNumber?(t=Ht.getUint32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigUint64($),$+=8,t;case 208:return Ht.getInt8($++);case 209:return t=Ht.getInt16($),$+=2,t;case 210:return t=Ht.getInt32($),$+=4,t;case 211:return hi.int64AsNumber?(t=Ht.getInt32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigInt64($),$+=8,t;case 212:if(t=Be[$++],t==114)return MP(Be[$++]&63);{let e=ti[t];if(e)return e.read?($++,e.read(Mr())):e.noBuffer?($++,e()):e(Be.subarray($,++$));throw new Error("Unknown extension "+t)}case 213:return t=Be[$],t==114?($++,MP(Be[$++]&63,Be[$++])):sc(2);case 214:return sc(4);case 215:return sc(8);case 216:return sc(16);case 217:return t=Be[$++],Qs>=$?ja.slice($-Xi,($+=t)-Xi):UW(t);case 218:return t=Ht.getUint16($),$+=2,Qs>=$?ja.slice($-Xi,($+=t)-Xi):GW(t);case 219:return t=Ht.getUint32($),$+=4,Qs>=$?ja.slice($-Xi,($+=t)-Xi):HW(t);case 220:return t=Ht.getUint16($),$+=2,AP(t);case 221:return t=Ht.getUint32($),$+=4,AP(t);case 222:return t=Ht.getUint16($),$+=2,_P(t);case 223:return t=Ht.getUint32($),$+=4,_P(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var zW=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Bw(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>zW.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Mr);return i.highByte===0&&(i.read=SP(t,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let o=i[n];r[o]=Mr()}return r}return e.count=0,i.highByte===0?SP(t,e):e}var SP=(i,t)=>function(){let e=Be[$++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=Nt[r]||CP()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=Bw(n,i)),n.read()};function CP(){let i=OP(()=>(Be=null,hi.getStructures()));return Nt=hi._mergeStructures(i,Nt)}var Lw=Cy,UW=Cy,GW=Cy,HW=Cy;function Cy(i){let t;if(i<16&&(t=Fw(i)))return t;if(i>64&&Iw)return Iw.decode(Be.subarray($,$+=i));let e=$+i,r=[];for(t="";$<e;){let n=Be[$++];if((n&128)===0)r.push(n);else if((n&224)===192){let s=Be[$++]&63;r.push((n&31)<<6|s)}else if((n&240)===224){let s=Be[$++]&63,o=Be[$++]&63;r.push((n&31)<<12|s<<6|o)}else if((n&248)===240){let s=Be[$++]&63,o=Be[$++]&63,a=Be[$++]&63,l=(n&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(n);r.length>=4096&&(t+=Sn.apply(String,r),r.length=0)}return r.length>0&&(t+=Sn.apply(String,r)),t}function AP(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mr();return t}function _P(i){if(hi.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DP()]=Mr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mr(),Mr());return t}}var Sn=String.fromCharCode;function PP(i){let t=$,e=new Array(i);for(let r=0;r<i;r++){let n=Be[$++];if((n&128)>0){$=t;return}e[r]=n}return Sn.apply(String,e)}function Fw(i){if(i<4)if(i<2){if(i===0)return"";{let t=Be[$++];if((t&128)>1){$-=1;return}return Sn(t)}}else{let t=Be[$++],e=Be[$++];if((t&128)>0||(e&128)>0){$-=2;return}if(i<3)return Sn(t,e);let r=Be[$++];if((r&128)>0){$-=3;return}return Sn(t,e,r)}else{let t=Be[$++],e=Be[$++],r=Be[$++],n=Be[$++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){$-=4;return}if(i<6){if(i===4)return Sn(t,e,r,n);{let s=Be[$++];if((s&128)>0){$-=5;return}return Sn(t,e,r,n,s)}}else if(i<8){let s=Be[$++],o=Be[$++];if((s&128)>0||(o&128)>0){$-=6;return}if(i<7)return Sn(t,e,r,n,s,o);let a=Be[$++];if((a&128)>0){$-=7;return}return Sn(t,e,r,n,s,o,a)}else{let s=Be[$++],o=Be[$++],a=Be[$++],l=Be[$++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){$-=8;return}if(i<10){if(i===8)return Sn(t,e,r,n,s,o,a,l);{let u=Be[$++];if((u&128)>0){$-=9;return}return Sn(t,e,r,n,s,o,a,l,u)}}else if(i<12){let u=Be[$++],c=Be[$++];if((u&128)>0||(c&128)>0){$-=10;return}if(i<11)return Sn(t,e,r,n,s,o,a,l,u,c);let h=Be[$++];if((h&128)>0){$-=11;return}return Sn(t,e,r,n,s,o,a,l,u,c,h)}else{let u=Be[$++],c=Be[$++],h=Be[$++],d=Be[$++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){$-=12;return}if(i<14){if(i===12)return Sn(t,e,r,n,s,o,a,l,u,c,h,d);{let f=Be[$++];if((f&128)>0){$-=13;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f)}}else{let f=Be[$++],p=Be[$++];if((f&128)>0||(p&128)>0){$-=14;return}if(i<15)return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p);let m=Be[$++];if((m&128)>0){$-=15;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p,m)}}}}}function Dw(i){return hi.copyBuffers?Uint8Array.prototype.slice.call(Be,$,$+=i):Be.subarray($,$+=i)}function sc(i){let t=Be[$++];if(ti[t])return ti[t](Be.subarray($,$+=i));throw new Error("Unknown extension type "+t)}var EP=new Array(4096);function DP(){let i=Be[$++];if(i>=160&&i<192){if(i=i-160,Qs>=$)return ja.slice($-Xi,($+=i)-Xi);if(!(Qs==0&&Wa<180))return Lw(i)}else return $--,Mr();let t=(i<<5^(i>1?Ht.getUint16($):i>0?Be[$]:0))&4095,e=EP[t],r=$,n=$+i-3,s,o=0;if(e&&e.bytes==i){for(;r<n;){if(s=Ht.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=Be[r++],s!=e[o++]){r=1879048192;break}if(r===n)return $=r,e.string;n-=3,r=$}for(e=[],EP[t]=e,e.bytes=i;r<n;)s=Ht.getUint32(r),e.push(s),r+=4;for(n+=3;r<n;)s=Be[r++],e.push(s);let a=i<16?Fw(i):PP(i);return a!=null?e.string=a:e.string=Lw(i)}var MP=(i,t)=>{var e=Mr();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=Nt[i];return n&&n.isShared&&((Nt.restoreStructures||(Nt.restoreStructures=[]))[i]=n),Nt[i]=e,e.read=Bw(e,r),e.read()},IP=typeof self=="object"?self:global;ti[0]=()=>{};ti[0].noBuffer=!0;ti[101]=()=>{let i=Mr();return(IP[i[0]]||Error)(i[1])};ti[105]=i=>{let t=Ht.getUint32($-4);Jo||(Jo=new Map);let e=Be[$],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};Jo.set(t,n);let s=Mr();return n.used?Object.assign(r,s):(n.target=s,s)};ti[112]=i=>{let t=Ht.getUint32($-4),e=Jo.get(t);return e.used=!0,e.target};ti[115]=()=>new Set(Mr());var kw=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");ti[116]=i=>{let t=i[0],e=kw[t];if(!e)throw new Error("Could not find typed array for code "+t);return new IP[e](Uint8Array.prototype.slice.call(i,1).buffer)};ti[120]=()=>{let i=Mr();return new RegExp(i[0],i[1])};ti[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=$;$+=t-4,Bi=[Mr(),Mr()],Bi.position0=0,Bi.position1=0;let r=$;$=e;try{return Mr()}finally{$=r}};ti[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function OP(i){let t=Wa,e=$,r=Rw,n=Xi,s=Qs,o=ja,a=Ow,l=Jo,u=Bi,c=new Uint8Array(Be.slice(0,Wa)),h=Nt,d=Nt.slice(0,Nt.length),f=hi,p=fh,m=i();return Wa=t,$=e,Rw=r,Xi=n,Qs=s,ja=o,Ow=a,Jo=l,Bi=u,Be=c,fh=p,Nt=h,Nt.splice(0,Nt.length,...d),hi=f,Ht=new DataView(Be.buffer,Be.byteOffset,Be.byteLength),m}function Ty(){Be=null,Jo=null,Nt=null}function RP(i){i.unpack?ti[i.type]=i.unpack:ti[i.type]=i}var Py=new Array(147);for(let i=0;i<256;i++)Py[i]=+("1e"+Math.floor(45.15-i*.30103));var Dy=new Ks({useRecords:!1}),jW=Dy.unpack,WW=Dy.unpackMultiple,qW=Dy.unpack,Iy={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},YW=new Float32Array(1),aae=new Uint8Array(YW.buffer,0,4);var Oy;try{Oy=new TextEncoder}catch{}var Ry,zw,Ly=typeof Buffer<"u",Vw=Ly?Buffer.allocUnsafeSlow:Uint8Array,FP=Ly?Buffer:Uint8Array,LP=Ly?4294967296:2144337920,de,Nr,ne=0,Zs,Js=null,XW=/[\u0080-\uFFFF]/,pp=Symbol("record-id"),oc=class extends Ks{constructor(t){super(t),this.offset=0;let e,r,n,s,o,a,l=0,u=FP.prototype.utf8Write?function(b,M,T){return de.utf8Write(b,M,T)}:Oy&&Oy.encodeInto?function(b,M){return Oy.encodeInto(b,de.subarray(M)).written}:!1,c=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,w=0;this.pack=this.encode=function(b,M){if(de||(de=new Vw(8192),Nr=new DataView(de.buffer,0,8192),ne=0),Zs=de.length-10,Zs-ne<2048?(de=new Vw(de.length),Nr=new DataView(de.buffer,0,de.length),Zs=de.length-10,ne=0):ne=ne+7&2147483640,r=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(Js=["",""],de[ne++]=214,de[ne++]=98,Js.position=ne-r,ne+=4):Js=null,n=c.structures,n){n.uninitialized&&(n=c._mergeStructures(c.getStructures()));let T=n.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let C=0;C<T;C++){let P=n[C];if(!P)continue;let D,I=n.transitions;for(let R=0,U=P.length;R<U;R++){let F=P[R];D=I[F],D||(D=I[F]=Object.create(null)),I=D}I[pp]=C+64}l=T}h||(n.nextId=T+64)}s&&(s=!1),o=n||[];try{if(S(b),Js){Nr.setUint32(Js.position+r,ne-Js.position-r);let T=Js;Js=null,S(T[0]),S(T[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>Zs&&E(ne),c.offset=ne;let T=KW(de.subarray(r,ne),a.idsToInsert);return a=null,T}return M&VP?(de.start=r,de.end=ne,de):de.subarray(r,ne)}finally{if(n){if(w<10&&w++,x>1e4)n.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let T=0,C=v.length;T<C;T++)v[T][pp]=0;v=[]}if(s&&c.saveStructures){let T=n.sharedLength||f;n.length>T&&(n=n.slice(0,T));let C=de.subarray(r,ne);return c.saveStructures(n,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,C)}}M&n6&&(ne=r)}};let S=b=>{ne>Zs&&(de=E(ne));var M=typeof b,T;if(M==="string"){let C=b.length;if(Js&&C>=8&&C<4096){let I=XW.test(b);Js[I?0:1]+=b,de[ne++]=193,S(I?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let D=C*3;if(ne+D>Zs&&(de=E(ne+D)),C<64||!u){let I,R,U,F=ne+P;for(I=0;I<C;I++)R=b.charCodeAt(I),R<128?de[F++]=R:R<2048?(de[F++]=R>>6|192,de[F++]=R&63|128):(R&64512)===55296&&((U=b.charCodeAt(I+1))&64512)===56320?(R=65536+((R&1023)<<10)+(U&1023),I++,de[F++]=R>>18|240,de[F++]=R>>12&63|128,de[F++]=R>>6&63|128,de[F++]=R&63|128):(de[F++]=R>>12|224,de[F++]=R>>6&63|128,de[F++]=R&63|128);T=F-ne-P}else T=u(b,ne+P,D);T<32?de[ne++]=160|T:T<256?(P<2&&de.copyWithin(ne+2,ne+1,ne+1+T),de[ne++]=217,de[ne++]=T):T<65536?(P<3&&de.copyWithin(ne+3,ne+2,ne+2+T),de[ne++]=218,de[ne++]=T>>8,de[ne++]=T&255):(P<5&&de.copyWithin(ne+5,ne+3,ne+3+T),de[ne++]=219,Nr.setUint32(ne,T),ne+=4),ne+=T}else if(M==="number")if(b>>>0===b)b<64?de[ne++]=b:b<256?(de[ne++]=204,de[ne++]=b):b<65536?(de[ne++]=205,de[ne++]=b>>8,de[ne++]=b&255):(de[ne++]=206,Nr.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?de[ne++]=256+b:b>=-128?(de[ne++]=208,de[ne++]=b+256):b>=-32768?(de[ne++]=209,Nr.setInt16(ne,b),ne+=2):(de[ne++]=210,Nr.setInt32(ne,b),ne+=4);else{let C;if((C=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){de[ne++]=202,Nr.setFloat32(ne,b);let P;if(C<4||(P=b*Py[(de[ne]&127)<<1|de[ne+1]>>7])>>0===P){ne+=4;return}else ne--}de[ne++]=203,Nr.setFloat64(ne,b),ne+=8}else if(M==="object")if(!b)de[ne++]=192;else{if(a){let P=a.get(b);if(P){if(!P.id){let D=a.idsToInsert||(a.idsToInsert=[]);P.id=D.push(P)}de[ne++]=214,de[ne++]=112,Nr.setUint32(ne,P.id),ne+=4;return}else a.set(b,{offset:ne-r})}let C=b.constructor;if(C===Object)A(b,!0);else if(C===Array){T=b.length,T<16?de[ne++]=144|T:T<65536?(de[ne++]=220,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=221,Nr.setUint32(ne,T),ne+=4);for(let P=0;P<T;P++)S(b[P])}else if(C===Map){T=b.size,T<16?de[ne++]=128|T:T<65536?(de[ne++]=222,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);for(let[P,D]of b)S(P),S(D)}else{for(let P=0,D=Ry.length;P<D;P++){let I=zw[P];if(b instanceof I){let R=Ry[P];if(R.write){R.type&&(de[ne++]=212,de[ne++]=R.type,de[ne++]=0),S(R.write.call(this,b));return}let U=de,F=Nr,V=ne;de=null;let G;try{G=R.pack.call(this,b,H=>(de=U,U=null,ne+=H,ne>Zs&&E(ne),{target:de,targetView:Nr,position:ne-H}),S)}finally{U&&(de=U,Nr=F,ne=V,Zs=de.length-10)}G&&(G.length+ne>Zs&&E(G.length+ne),ne=QW(G,de,ne,R.type));return}}A(b,!b.hasOwnProperty)}}else if(M==="boolean")de[ne++]=b?195:194;else if(M==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))de[ne++]=211,Nr.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)de[ne++]=207,Nr.setBigUint64(ne,b);else if(this.largeBigIntToFloat)de[ne++]=203,Nr.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(M==="undefined")this.encodeUndefinedAsNil?de[ne++]=192:(de[ne++]=212,de[ne++]=0,de[ne++]=0);else if(M==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?b=>{let M=Object.keys(b),T=M.length;T<16?de[ne++]=128|T:T<65536?(de[ne++]=222,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);let C;for(let P=0;P<T;P++)S(C=M[P]),S(b[C])}:(b,M)=>{de[ne++]=222;let T=ne-r;ne+=2;let C=0;for(let P in b)(M||b.hasOwnProperty(P))&&(S(P),S(b[P]),C++);de[T+++r]=C>>8,de[T+r]=C&255}:b=>{let M=Object.keys(b),T,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let I=0,R=M.length;I<R;I++){let U=M[I];T=C[U],T||(T=C[U]=Object.create(null),P++),C=T}let D=C[pp];if(D)D>=96&&m?(de[ne++]=((D-=96)&31)+96,de[ne++]=D>>5):de[ne++]=D;else{D=o.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(D=o.nextOwnId,D<y||(D=g),o.nextOwnId=D+1):(D>=y&&(D=g),o.nextId=D+1);let I=M.highByte=D>=96&&m?D-96>>5:-1;C[pp]=D,o[D-64]=M,D<g?(M.isShared=!0,o.sharedLength=D-63,s=!0,I>=0?(de[ne++]=(D&31)+96,de[ne++]=I):de[ne++]=D):(I>=0?(de[ne++]=213,de[ne++]=114,de[ne++]=(D&31)+96,de[ne++]=I):(de[ne++]=212,de[ne++]=114,de[ne++]=D),P&&(x+=w*P),v.length>=p&&(v.shift()[pp]=0),v.push(C),S(M))}for(let I=0,R=M.length;I<R;I++)S(b[M[I]])},E=b=>{let M;if(b>16777216){if(b-r>LP)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(LP,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(b-r<<2,de.length-1)>>12)+1<<12;let T=new Vw(M);return Nr=new DataView(T.buffer,0,M),de.copy?de.copy(T,0,r,b):T.set(de.slice(r,b)),ne-=r,r=0,Zs=T.length-10,de=T}}useBuffer(t){de=t,Nr=new DataView(de.buffer,de.byteOffset,de.byteLength),ne=0}};zw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,fp];Ry=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:o}=t(6);n[o++]=214,n[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:o}=t(10);n[o++]=215,n[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:n,targetView:s,position:o}=t(3);n[o++]=212,n[o++]=255,n[o++]=255}else{let{target:n,targetView:s,position:o}=t(15);n[o++]=199,n[o++]=12,n[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?NP(i,16,t):BP(Ly?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==FP&&this.structuredClone?NP(i,kw.indexOf(e.name),t):BP(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function NP(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:s,position:o}=e(4+n);s[o++]=199,s[o++]=n+1}else if(n+1<65536){var{target:s,position:o}=e(5+n);s[o++]=200,s[o++]=n+1>>8,s[o++]=n+1&255}else{var{target:s,position:o,targetView:a}=e(7+n);s[o++]=201,a.setUint32(o,n+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function BP(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:s}=t(e+5);r[n++]=198,s.setUint32(n,e),n+=4}r.set(i,n)}function QW(i,t,e,r){let n=i.length;switch(n){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function KW(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+r,s,n),r-=6;let a=s+r;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,n=s}return i}function qa(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");zw.unshift(i.Class),Ry.unshift(i)}RP(i)}var kP=new oc({useRecords:!1}),ZW=kP.pack,JW=kP.pack;var{NEVER:$W,ALWAYS:e6,DECIMAL_ROUND:t6,DECIMAL_FIT:r6}=Iy,VP=512,n6=1024;var zP=new oc({structuredClone:!0});qa({Class:rt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,rt.prototype),i}});qa({Class:Le.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Le.prototype),i}});qa({Class:pr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,pr.prototype),i}});qa({Class:hp.prototype.constructor,type:4,write(i){return i.id},read(i){return new hp(i)}});qa({Class:dp.prototype.constructor,type:5,write(i){return i.data},read(i){return new dp(i)}});qa({Class:Jt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Jt.prototype),i}});function i6(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Uw(i){if(lh(i))return i;if(Array.isArray(i))return i.map(Uw);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Uw(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var Ny;(r=>{function i(n){return zP.pack(n)}r.serialize=i;function t(n){return zP.unpack(n)}r.deserialize=t;function e(n){return i6(i(Uw(n))).toString()}r.checksum=e})(Ny||(Ny={}));var UP;(e=>{function i(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=i;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(UP||(UP={}));var di={["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","Reset","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"]},GP;(e=>{function i(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=i;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new Le}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new Le}}e.defaultData=t})(GP||(GP={}));var By;(e=>{function i(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(By||(By={}));var Gw;(r=>{function i(n){return{type:"Comparison",operator:"==",lOperand:By.propertyDefaultData(n),rOperand:{...By.valueDefaultData}}}r.comparisonDefaultData=i;function t(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}}r.distanceDefaultData=t;function e(n,s){return{type:"State",object:n??null,state:s??null}}r.stateDefaultData=e})(Gw||(Gw={}));var HP;(e=>{function i(r){return r.type==="Conditional"}e.is=i;function t(r){return{type:"Conditional",disabled:!1,inActions:new Le,outActions:new Le,condition:Gw.distanceDefaultData(r)}}e.defaultData=t})(HP||(HP={}));var jP;(t=>t.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 Le,drop:new Le}})(jP||(jP={}));var Fy;(t=>t.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 Le})(Fy||(Fy={}));var ky;(t=>t.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})(ky||(ky={}));var WP;(e=>{function i(r){return r.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Le}}e.defaultData=t})(WP||(WP={}));var qP;(e=>{function i(r){return r.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Le}}e.defaultData=t})(qP||(qP={}));var YP;(e=>{function i(r){return r.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Le}}e.defaultData=t})(YP||(YP={}));var XP;(e=>{function i(r){return r.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Le}}e.defaultData=t})(XP||(XP={}));var QP;(e=>{function i(r){return r.type==="Trigger"}e.is=i;function t(r,n){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Le,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(QP||(QP={}));var Vy;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function n(){let a={size:"mobile",operator:"<",actions:new Le},l={size:"tablet",operator:"<",actions:new Le},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Le},c=new Le;return c.push({id:Se.generateUUID(),fi:0,data:a},{id:Se.generateUUID(),fi:1,data:l},{id:Se.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=n;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Le}}o.defaultBreakpointData=s})(Vy||(Vy={}));var zy;(r=>{r.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(n){return n.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Le,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(zy||(zy={}));var Qi="personal camera",Xa="a218fcc3-276b-49b9-b485-49037fd14f5f",JP=2960946,an=5526619;var ac;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s]}e.lerp=t})(ac||(ac={}));var $s;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=r;function n(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=n;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})($s||($s={}));var mp;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}e.lerp=t})(mp||(mp={}));var Ya;(n=>{n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}n.isEqual=t;function e(s){return s??n.identity}n.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}n.applyMatrix4=r})(Ya||(Ya={}));var An;(c=>{function i(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function n(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}c.toRgb255a1=n;function s(h){return{r:h.r,g:h.g,b:h.b}}c.clone=s;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}c.fromHex=o;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}c.toHex=a;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}c.equals=l;function u(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f}}c.lerp=u})(An||(An={}));var ri;(a=>{a.white={...An.white,a:1},a.transparent={...An.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function r(l,u){return{...An.fromHex(l),a:u}}a.fromHexAndA=r;function n(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=n;function s(l,u){return An.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(ri||(ri={}));var Uy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Uy||(Uy={}));var KP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(KP||(KP={}));var ZP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(ZP||(ZP={}));var $o;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))($o||($o={}));function $P(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var bs;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(bs||(bs={}));var Qa;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}n.getZoom=r})(Qa||(Qa={}));var eo;(e=>{function i(r,n=.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]*n,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+n)),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=i;function t(r,n){let s={...r};if(Hw.forEach(o=>{Object.assign(s,{[o]:n[o]??r[o]})}),s.radial={...r.radial},n.radial){let o=r.radial,a=n.radial;jw.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},n.linear){let o=r.linear,a=n.linear;Ww.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},n.grid){let o=r.grid,a=n.grid;qw.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},n.toObject){let o=r.toObject,a=n.toObject;Yw.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},n.randomnessObject){let o=r.randomnessObject,a=n.randomnessObject;Xw.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(eo||(eo={}));var Gy;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(n,s){let o=[];n.count!==void 0&&o.push({type:0,path:s,props:{count:n.count}});for(let a of t){let l=n[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(Gy||(Gy={}));var Hw=["count"],jw=["radius","start","end","position","scale","rotation"],Ww=["position","scale","rotation"],qw=["count","size"],Yw=["count","position","scale","rotation"],Xw=["strength","scale","rotation","position","movement","seed","freqScale"];var Hy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Hy||(Hy={}));var jy;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:ri.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:ri.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:ri.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(jy||(jy={}));var Ka;(t=>t.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]})(Ka||(Ka={}));var Qw;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(Qw||(Qw={}));var Kw;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(Kw||(Kw={}));var Wy;(t=>t.defaultData={...Kw.defaultData,...Qw.defaultData})(Wy||(Wy={}));var e2;(t=>{function i(e,r){let n=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&n.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&n.push(o)}return n}t.getMaterialData=i})(e2||(e2={}));var ph;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ph||(ph={}));var t2;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(t2||(t2={}));function n2(i){return i.type!=="displace"}var r2;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(r2||(r2={}));var qy=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],i2=["wrapping","image","video","name"],_n;(n=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}n.patch=i;function t(s,o){return s==="light"&&o?e(o):r(s)}n.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,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{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ph.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:An.fromHex(an)};case"depth":return{...o,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{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,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{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...An.fromHex(6710886),a:1},colorB:{...An.fromHex(6710886),a:1},colorC:{...An.fromHex(16777215),a:1},colorD:{...An.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{...o,type:"fresnel",color:ri.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,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:ri.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:ri.fromHexAndA(0,1),contourColor:ri.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{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,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{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...An.fromHex(0),a:1},colorB:{...An.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}}}})(_n||(_n={}));var Br;(l=>{function i(u){return!u.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([d,f])=>{c+=`${d}${f}`,Array.isArray(f)?f.forEach(p=>c+=`${p}`):typeof f=="object"?Object.values(f).forEach(p=>{typeof p=="number"?c+=`${p.toFixed(4)}`:c+=`${p}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new Le}}l.defaultEmptyData=e;function r(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=r;function n(u,c){return{...u,name:c}}l.withName=n;function s(u,c="layer1",h="layer2"){let d=new Le;return d.push({fi:0,data:_n.defaultData("light",u),id:c}),d.push({fi:1,data:_n.defaultData("color"),id:h}),{layers:d}}l.defaultTwoLayerData=s;function o(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("video");Object.assign(f.texture,{video:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Br||(Br={}));var mh;(t=>{function i(){return{points:new Le,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(mh||(mh={}));var gh;(t=>{function i(){return{points:new Le,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(gh||(gh={}));var Zw={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Yy;(t=>{function i(e,r){let n={...e};return Jw.forEach(s=>{Object.assign(n,{[s]:r[s]??e[s]})}),n}t.merge=i})(Yy||(Yy={}));var Xy={shape:Zw,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},Jw=["depth","offset","angle","twist","startScale","endScale"];var gp;(e=>{function i(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=i;function t(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=t})(gp||(gp={}));var Qy;(t=>{function i(e,r){let n={...e};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...e.extrusion},Object.assign(n.extrusion,Yy.merge(n.extrusion,r.extrusion))),n}t.merge=i})(Qy||(Qy={}));var Za;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:gh.defaultData(),extrusion:Xy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:mh.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,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(e==="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")}t.defaultData=i})(Za||(Za={}));var $w=["width","height","depth"];var Ky;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:An.white,near:.1,far:2e3})(Ky||(Ky={}));var yh;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(yh||(yh={}));var eS;(t=>t.defaultData={softShadowQuality:"low"})(eS||(eS={}));var tS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(tS||(tS={}));var rS;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(rS||(rS={}));var Ja;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ja||(Ja={}));var nS;(t=>t.defaultData={playCamera:Qi,gameControlObject:null})(nS||(nS={}));var Zy;(t=>t.defaultData={backgroundColor:ri.fromHexAndA(JP,1),postprocessing:yh.defaultData,fog:Ky.defaultData,globalPhysics:Ja.defaultData,ambient:tS.defaultData,ao:rS.defaultData,shadow:eS.defaultData,publish:nS.defaultData})(Zy||(Zy={}));var s2;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(s2||(s2={}));var vh;(n=>{n.identity={...Uy.identity,hiddenMatrix:Ya.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}n.merge=e;function r(s,o){return KC({position:$s.isEqual(s.position,o.position)?void 0:o.position,rotation:$s.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:$s.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Ya.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}n.diff=r})(vh||(vh={}));var Fn;(t=>t.defaultData={states:new Le,events:new Le,visible:!0,raycastLock:!1,physics:Ka.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...vh.identity,cloner:null})(Fn||(Fn={}));var Jy;(t=>t.defaultData={type:"Empty",...Fn.defaultData})(Jy||(Jy={}));var o2;(t=>t.defaultData={type:"Component",...Fn.defaultData})(o2||(o2={}));var lc;(t=>t.defaultData={type:"Mesh",...Fn.defaultData,...Wy.defaultData})(lc||(lc={}));var cc;(t=>t.defaultData={...Fn.defaultData,...vh.identity,position:[0,0,Qa.DefaultTargetOffset],...Qa.defaultData})(cc||(cc={}));var $y;(e=>{function i(r){return{...Fn.defaultData,...jy.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($y||($y={}));var xh;(e=>{function i(r,n,s=0){for(;s<n.length;){let o=r?r[n[s]]:void 0;if(n.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(r,n,s=0){let o=i(r,n,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(xh||(xh={}));var to;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...Fn.defaultData,...a,component:o,overrides:new Jt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function n(o){let a=vh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=n})(to||(to={}));var ea;(t=>t.defaultData={type:"Page",...Fn.defaultData,physics:{...Ka.defaultData,fusedBody:!1},...Zy.defaultData,camera:cc.defaultData})(ea||(ea={}));var ev;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ya.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Ka.defaultData,states:new Le,events:new Le,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Qa.defaultData},s.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"]},s.defaultMeshObject={name:"Rectangle",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("RectangleGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("BooleanGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("TextGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")}))(ev||(ev={}));var ta;(n=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Jt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Jt})))):bs.is(s.type)&&(a.perspective={},a.orthographic={}),a}n.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Ha(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let h=l.layers.data(u);h&&_n.patch(h,c)}}).data),a.materials&&o.materials&&(a.materials=Ha(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[h,d]of Object.entries(c.layers)){let f=l[u]?.layers?.data(h);f&&_n.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...Gy.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))c(["materials",f],p);else if(u[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}n.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,vh.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),bs.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Qy.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:eo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:eo.merge(a.cloner,o.cloner)});else if(Hy.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=An.clone(l.color))}return a}n.patch=r})(ta||(ta={}));var wh;(t=>t.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})(wh||(wh={}));var ro;(t=>t.defaultData={orbitControls:wh.defaultData,playPage:Xa,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let n=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?n=30:(r===4||r===11||r===9)&&(n=-30),[120,[n,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})(ro||(ro={}));var iS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(iS||(iS={}));var sS;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(sS||(sS={}));var $a;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...iS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:sS.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))($a||($a={}));var el;(e=>{function i(r){return r.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,n,s){r.scene.objects.traverseFrom(n,(o,a)=>{if(a.type==="Instance"){let l=Sh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(el||(el={}));var tl;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=ev.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:$y.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let h=new pr;return h.push({fi:1,id:Xa,data:{...ea.defaultData,name:"Scene 1"},children:u}),h}a.defaultData={objects:t(),publish:ro.defaultData,styles:$a.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new pr,publish:ro.defaultData,styles:$a.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:ro.defaultData,styles:$a.defaultData()}};function s(l){return{...a.defaultData,objects:ui(l,pr.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(tl||(tl={}));var Ah;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ah||(Ah={}));var _h;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(_h||(_h={}));var En;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function n(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=n})(En||(En={}));var oS;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(oS||(oS={}));var a2;(t=>t.all=[...oS.all,"components"])(a2||(a2={}));var l2;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(l2||(l2={}));var rl;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(rl||(rl={}));var fi;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ui(o,rt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={..._h.emptyImage,name:"AI generated image"}),ui(a,rt.prototype)}s.defaultImages=t;function e(){return{catelogs:new rt,materials:new rt,images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,variables:new Le,lib:rl.defaultData()}}s.emptyData=e;function r(o){switch(o){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 a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,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",o)}}s.defaultVariables=r;function n(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),u=Math.floor((o-l*3600)/60),c=Math.round(o-l*3600-u*60);return{textValue:[l,u,c]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),u=Math.round(o-l*60);return{textValue:[l,u]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=n})(fi||(fi={}));var Eh;(t=>t.list=["idle","move","jump","run"])(Eh||(Eh={}));var Mh;(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 Le,move:new Le,jump:new Le,run:new Le},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:ri.fromHexAndA(3728051,1)}}))(Mh||(Mh={}));function c2(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,n=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)n.push(n[1]),s.push(1);let o={...Ni(xr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...xr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ra(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function na(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=Br.defaultData(),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&t(n.material)})})}function o6(i){Object.assign(i.scene.publish,{orbitControls:{...wh.defaultData,...xr(i.scene.publish.orbitControls)}})}function a6(i){Object.assign(i.scene.publish.settings,{video:{...ro.defaultData.settings.video,...xr(i.scene.publish.settings.video)}})}function l6(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[n,s]of Object.entries(r))if((qy.includes(n)||typeof s=="boolean")&&delete r[n],n==="texture")for(let[o,a]of Object.entries(s))(i2.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(n=>{let s=n;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function c6(i){i.scene.publish.withBackground=!0}function u6(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function h6(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(n=>n+1),r.linear.scale=r.linear.scale.map(n=>n+1))})}function d6(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function f6(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let n=xr(i.scene.objects.data(r));n&&n.type==="Mesh"&&n.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=xr(e).booleanExclude!==!0)}})}function p6(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function m6(i){function t(r){Object.setPrototypeOf(r,Jt.prototype),r.texture&&Object.setPrototypeOf(r.texture,Jt.prototype)}function e(r){Object.setPrototypeOf(r,Jt.prototype);for(let n in r)t(r[n])}i.scene.objects.traverse((r,n)=>{n.states.forEach(s=>{let o=s;if(o.material){let a=xr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=xr(l).layers;e(u),l.layers=u}})})}function u2(i){i.layers===void 0&&Object.assign(i,Br.defaultTwoLayerData("lambert"))}function aS(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...xr(t),colors:e,steps:r};Object.assign(t,n)}})}function g6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function h2(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&aS(r)}):"material"in e&&typeof e.material!="string"&&aS(e.material)}),Object.values(i.shared.materials).forEach(t=>aS(t))}function y6(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function v6(i){i.shared.audios=ui({},rt.prototype)}function x6(i){i.shared.videos=ui({},rt.prototype)}function b6(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let n={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,{[e]:n})}})}function w6(i){Object.entries(xr(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(xr(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function S6(i){i.scene.publish.settings.web.preload=!1}function d2(i){i.layers&&i.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 f2(i){i.layers&&i.layers.forEach(t=>{n2(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 A6(i){i.shared.fonts=ui({},rt.prototype)}function _6(i){return i.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function E6(i){let t=[];i.scene.objects.traverse((e,r)=>{let n=r;if(n.type==="TextFrame"){let s=Br.defaultTwoLayerData("phong"),o=typeof n.color=="string"?i.shared.colors[n.color]:n.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=n.alpha;let a=_6(n.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:n.name,...Fn.defaultData,...lc.defaultData,flatShading:!1,wireframe:!1,geometry:{...Za.defaultData("TextGeometry"),width:n.width,height:n.height,font:a,depth:0,horizontalAlign:n.horizontalAlign,verticalAlign:n.verticalAlign,fontSize:n.fontSize*1.40625,lineHeight:n.lineHeight/1.40625,letterSpacing:n.letterSpacing-1,text:n.text,textTransform:n.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:xr(n.states),events:xr(n.events),visible:n.visible,raycastLock:n.raycastLock,position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix},u=xr(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function M6(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(n=>{if(!!t[Number(n.type)])if(Object.assign(n,{type:t[Number(n.type)]}),n.type==="Audio"&&"audioEvent"in n&&(Object.assign(n,{playAudio:n.audioEvent}),delete n.audioEvent),n.type==="GameControl")Object.assign(n,{gameActions:{idle:new Le,move:new Le,jump:new Le}});else{let s=new Le;Object.assign(n,{actions:s}),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp")&&"url"in n&&s.push({fi:0,id:Se.generateUUID(),data:{type:"Link",url:n.url,delay:0}}),"targets"in n&&(n.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Ni(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Le({fi:0,id:Se.generateUUID(),data:u},{fi:1,id:Se.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete n.targets)}})})}function T6(i){i.scene.objects.traverse((t,e)=>{function r(n,s){let o=new Le,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Ni(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")&&(h={...Ni(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===n)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Se.generateUUID(),data:{type:n,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function p2(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=_n.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function m2(i){ra(i,p2),na(i,p2)}function C6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function P6(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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 D6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Br.defaultTwoLayerData("phong"))})}function I6(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function O6(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function R6(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function L6(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function N6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function B6(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function F6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Mh.defaultDataThirdPerson.navmesh)})})}function k6(i){i.scene.styles||(i.scene.styles=$a.defaultData())}function g2(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function V6(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),na(i,g2),ra(i,g2)}function z6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Le})})})}function U6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function y2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function v2(i,t){if(t<1&&(na(i,c2),ra(i,c2),i.schema=1),t<2&&(o6(i),i.schema=2),t<3&&(l6(i),i.schema=3),t<4&&(c6(i),i.schema=4),t<5&&(u6(i),i.schema=5),t<6&&(h6(i),i.schema=6),t<7&&(d6(i),i.schema=7),t<8&&(i.schema=8),t<9&&(h2(i),i.schema=9),t<10&&(g6(i),i.schema=10),t<11&&(y6(i),i.schema=11),t<12&&(h2(i),i.schema=12),t<13&&(v6(i),i.schema=13),t<14&&(b6(i),i.schema=14),t<15&&(w6(i),i.schema=15),t<16&&(S6(i),i.schema=16),t<17&&(na(i,d2),ra(i,d2),i.schema=17),t<18&&(na(i,u2),ra(i,u2),i.schema=18),t<19&&(a6(i),i.schema=19),t<20&&(A6(i),E6(i),i.schema=20),t<21&&(M6(i),T6(i),i.schema=21),t<22&&(m2(i),i.schema=22),t<23&&(C6(i),i.schema=23),t<24&&(P6(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(x6(i),t<25&&(i.schema=25)),t<26&&(f6(i),i.schema=26),t<27&&(p6(i),i.schema=27),t<28&&(m2(i),i.schema=28),t<29&&(m6(i),i.schema=29),t<30&&(D6(i),i.schema=30),t<31&&(I6(i),i.schema=31),t<33&&(O6(i),i.schema=33),t<34&&(R6(i),i.schema=34),t<35&&(L6(i),i.schema=35),t<36&&(N6(i),i.schema=36),t<37&&(B6(i),i.schema=37),t<38&&(na(i,f2),ra(i,f2),i.schema=38),t<39&&(F6(i),i.schema=39),t<40&&(k6(i),i.schema=40),t<41&&(V6(i),i.schema=41),t<42&&(z6(i),i.schema=42),t<43&&(U6(i),i.schema=43),t<99){na(i,y2),ra(i,y2),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Qi);let e=xr(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Xa,r.insertBefore(null,null,[{id:Xa,data:{...ea.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Ni(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Ni(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ja.defaultData,...Ni(i.scene.environment,"usePhysics","gravity")},camera:xr(i.scene.ownerCamera)??ea.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==tl.TRASH_CAN_ID&&r.move(Xa,o.fi,o.id);let n=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(n,2)],n+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Ka.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function x2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function G6(i){i.scene.objects.traverse((t,e)=>{let r=e.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 Th=180/Math.PI;function b2(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Th)}function w2(i){b2(i),i.type==="Page"&&b2(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Th))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Th),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Th),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Th,t.extrusion.twist*=Th),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(xr(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Once")})}function H6(i){i.shared.variables=ui({},rt.prototype)}function j6(i){let t=xr(i.shared.variables);i.shared.variables=ui(Object.entries(t??{}).map(([e,r],n)=>({fi:n,id:e,data:r})),Le.prototype)}var ia=107;function S2(i,t){t(i.data);for(let e of i.children)S2(e,t)}function W6(i){let t=i.schema??104;t!==ia&&t<105&&(S2(i.asset,w2),i.schema=105)}function tv(i){let t=i.schema??0;if(t!==ia){console.warn("updating from ",t,"to ",ia),v2(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=ro.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(na(i,x2),ra(i,x2),i.schema=101),t<102&&(G6(i),i.schema=102),t<104&&(i.shared.catelogs=new rt,i.shared.lib=rl.defaultData(),i.schema=104),t<105&&(H6(i),i.scene.objects.traverse((e,r)=>{w2(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))W6(e);t<106&&(j6(i),i.schema=106),t<107&&(i.shared.lib.variables=rl.defaultData().variables,i.schema=107)}}var Sh;(a=>{a.defaultData={schema:ia,scene:tl.defaultData,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors()}},a.emptyDataForImports=function(l){let u=tl.emptyDataWithPage(l);return{schema:ia,scene:u,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors(),images:fi.defaultImages(l)}}},a.emptyData=function(){return{schema:ia,scene:tl.emptyDataWithPage(),frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:fi.emptyData()}},a.collabHelper={...up,updateSchema(l){return(l.schema??0)<ia?Ha(l,tv):(l.schema??0)-ia}};function n(l){let u=a.collabHelper.updateSchema(l);return typeof u=="number"?u===0?l:null:u.data}a.updateSchemaDirectly=n;function s(l){return{...l,shared:{...l.shared,lib:rl.defaultData()}}}a.withoutLib=s;function o(l,u){let c=l.scene.objects.get(u);if(c&&c.data.type==="Component")return c;{let h=l.shared.lib.components[u];if(h)return h.asset}}a.getComponentData=o})(Sh||(Sh={}));function ws(i,t=!1){let e=i[0].index!==null,r=new Set(Object.keys(i[0].attributes)),n=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ae,u=0;for(let c=0;c<i.length;++c){let h=i[c],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,h=[];for(let d=0;d<i.length;++d){let f=i[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+c);c+=i[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=A2(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][d]);let p=A2(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(p)}}return l}function A2(i){let t,e,r,n=0;for(let a=0;a<i.length;++a){let l=i[a];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(e===void 0&&(e=l.itemSize),e!==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;n+=l.array.length}let s=new t(n),o=0;for(let a=0;a<i.length;++a)s.set(i[a].array,o),o+=i[a].array.length;return new Ge(s,e,r)}var _2=Math.pow(2,-24);var uc=class{constructor(){}};function Ki(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function lS(i){let t=-1,e=-1/0;for(let r=0;r<3;r++){let n=i[r+3]-i[r];n>e&&(e=n,t=r)}return t}function cS(i,t){t.set(i)}function uS(i,t,e){let r,n;for(let s=0;s<3;s++){let o=s+3;r=i[s],n=t[s],e[s]=r<n?r:n,r=i[o],n=t[o],e[o]=r>n?r:n}}function yp(i,t,e){for(let r=0;r<3;r++){let n=t[i+2*r],s=t[i+2*r+1],o=n-s,a=n+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function Ch(i){let t=i[3]-i[0],e=i[4]-i[1],r=i[5]-i[2];return 2*(t*e+e*r+r*t)}function X6(i,t){if(!i.index){let e=i.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n;e>65535?n=new Uint32Array(new r(4*e)):n=new Uint16Array(new r(2*e)),i.setIndex(new Ge(n,1));for(let s=0;s<e;s++)n[s]=s}}function Q6(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let n of i.groups)e.add(n.start),e.add(n.start+n.count);let r=Array.from(e.values()).sort((n,s)=>n-s);for(let n=0;n<r.length-1;n++){let s=r[n],o=r[n+1];t.push({offset:s/3,count:(o-s)/3})}return t}function dS(i,t,e,r,n=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=n!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let w=i[v+0],S=i[v+1],A=w-S,E=w+S;A<s&&(s=A),E>l&&(l=E),y&&w<h&&(h=w),y&&w>p&&(p=w);let b=i[v+2],M=i[v+3],T=b-M,C=b+M;T<o&&(o=T),C>u&&(u=C),y&&b<d&&(d=b),y&&b>m&&(m=b);let P=i[v+4],D=i[v+5],I=P-D,R=P+D;I<a&&(a=I),R>c&&(c=R),y&&P<f&&(f=P),y&&P>g&&(g=P)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=u,r[5]=c,y&&(n[0]=h,n[1]=d,n[2]=f,n[3]=p,n[4]=m,n[5]=g)}function K6(i,t,e,r){let n=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,h=(t+e)*6;c<h;c+=6){let d=i[c+0];d<n&&(n=d),d>a&&(a=d);let f=i[c+2];f<s&&(s=f),f>l&&(l=f);let p=i[c+4];p<o&&(o=p),p>u&&(u=p)}r[0]=n,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=u}function Z6(i,t,e,r,n){let s=e,o=e+r-1,a=n.pos,l=n.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=i[s*3+u];i[s*3+u]=i[o*3+u],i[o*3+u]=c;let h=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=h;let d=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=d}s++,o--}else return s}}var sa=32,J6=(i,t)=>i.candidate-t.candidate,nl=new Array(sa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),rv=new Float32Array(6);function $6(i,t,e,r,n,s){let o=-1,a=0;if(s===0)o=lS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=lS(i),o!==-1&&(a=e8(e,r,n,o));else if(s===2){let l=Ch(i),u=1.25*n,c=r*6,h=(r+n)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/sa;if(n<sa/4){let y=[...nl];y.length=n;let v=0;for(let w=c;w<h;w+=6,v++){let S=y[v];S.candidate=e[w+2*d],S.count=0;let{bounds:A,leftCacheBounds:E,rightCacheBounds:b}=S;for(let M=0;M<3;M++)b[M]=1/0,b[M+3]=-1/0,E[M]=1/0,E[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;yp(w,e,A)}y.sort(J6);let x=n;for(let w=0;w<x;w++){let S=y[w];for(;w+1<x&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),x--}for(let w=c;w<h;w+=6){let S=e[w+2*d];for(let A=0;A<x;A++){let E=y[A];S>=E.candidate?yp(w,e,E.rightCacheBounds):(yp(w,e,E.leftCacheBounds),E.count++)}}for(let w=0;w<x;w++){let S=y[w],A=S.count,E=n-S.count,b=S.leftCacheBounds,M=S.rightCacheBounds,T=0;A!==0&&(T=Ch(b)/l);let C=0;E!==0&&(C=Ch(M)/l);let P=1+1.25*(T*A+C*E);P<u&&(o=d,u=P,a=S.candidate)}}else{for(let x=0;x<sa;x++){let w=nl[x];w.count=0,w.candidate=f+g+x*g;let S=w.bounds;for(let A=0;A<3;A++)S[A]=1/0,S[A+3]=-1/0}for(let x=c;x<h;x+=6){let A=~~((e[x+2*d]-f)/g);A>=sa&&(A=sa-1);let E=nl[A];E.count++,yp(x,e,E.bounds)}let y=nl[sa-1];cS(y.bounds,y.rightCacheBounds);for(let x=sa-2;x>=0;x--){let w=nl[x],S=nl[x+1];uS(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;x<sa-1;x++){let w=nl[x],S=w.count,A=w.bounds,b=nl[x+1].rightCacheBounds;S!==0&&(v===0?cS(A,rv):uS(A,rv,rv)),v+=S;let M=0,T=0;v!==0&&(M=Ch(rv)/l);let C=n-v;C!==0&&(T=Ch(b)/l);let P=1+1.25*(M*v+T*C);P<u&&(o=d,u=P,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function e8(i,t,e,r){let n=0;for(let s=t,o=t+e;s<o;s++)n+=i[s*6+r*2];return n/e}function t8(i,t){let e=i.attributes.position,r=i.index.array,n=r.length/3,s=new Float32Array(n*6),o=e.normalized,a=e.array,l=e.offset||0,u=3;e.isInterleavedBufferAttribute&&(u=e.data.stride);let c=["getX","getY","getZ"];for(let h=0;h<n;h++){let d=h*3,f=h*6,p,m,g;o?(p=r[d+0],m=r[d+1],g=r[d+2]):(p=r[d+0]*u+l,m=r[d+1]*u+l,g=r[d+2]*u+l);for(let y=0;y<3;y++){let v,x,w;o?(v=e[c[y]](p),x=e[c[y]](m),w=e[c[y]](g)):(v=a[p+y],x=a[m+y],w=a[g+y]);let S=v;x<S&&(S=x),w<S&&(S=w);let A=v;x>A&&(A=x),w>A&&(A=w);let E=(A-S)/2,b=y*2;s[f+b+0]=S+E,s[f+b+1]=E+(Math.abs(S)+E)*_2,S<t[y]&&(t[y]=S),A>t[y+3]&&(t[y+3]=A)}}return s}function r8(i,t){function e(y){d&&d(y/f)}function r(y,v,x,w=null,S=0){if(!p&&S>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let A=$6(y.boundingData,w,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let E=Z6(a,o,v,x,A);if(E===v||E===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new uc,M=v,T=E-v;y.left=b,b.boundingData=new Float32Array(6),dS(o,M,T,b.boundingData,s),r(b,M,T,s,S+1);let C=new uc,P=E,D=x-T;y.right=C,C.boundingData=new Float32Array(6),dS(o,P,D,C.boundingData,s),r(C,P,D,s,S+1)}return y}X6(i,t);let n=new Float32Array(6),s=new Float32Array(6),o=t8(i,n),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,m=[],g=Q6(i);if(g.length===1){let y=g[0],v=new uc;v.boundingData=n,K6(o,y.offset,y.count,s),r(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new uc;v.boundingData=new Float32Array(6),dS(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function T2(i,t){let e=r8(i,t),r,n,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let h=e[c],d=l(h),f=new a(32*d);r=new Float32Array(f),n=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(p){let g=h.offset,y=h.count;return n[d+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=h.left,y=h.right,v=h.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=x/4,x=u(x,y),n[d+7]=v,x}}}var pi=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,n=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}setFromPoints(t,e){let r=1/0,n=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};pi.prototype.setFromBox=function(){let i=new _;return function(e,r){let n=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=n.x*l+s.x*(1-l),i.y=n.y*u+s.y*(1-u),i.z=n.z*c+s.z*(1-c);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var lhe=function(){let i=new pi;return function(e,r){let n=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,u=r.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(i.setFromPoints(d,n),h.isSeparated(i))return!1}}}();var n8=function(){let i=new _,t=new _,e=new _;return function(n,s,o){let a=n.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(n.end,n.start),t.subVectors(s.end,s.start);let h=e.dot(c),d=c.dot(l),f=c.dot(c),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),vp=function(){let i=new N,t=new _,e=new _;return function(n,s,o,a){n8(n,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){n.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),n.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?n.at(0,o):n.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=n.start:c=n.end;let h;u<0?h=s.start:h=s.end;let d=t,f=e;if(n.closestPointToPoint(h,!0,t),s.closestPointToPoint(c,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),C2=function(){let i=new _,t=new _,e=new Or,r=new nn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(r.start=u,r.end=c,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var i8=1e-15;function Ph(i){return Math.abs(i)<i8}var mi=class extends dr{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _),this.satBounds=new Array(4).fill().map(()=>new pi),this.points=[this.a,this.b,this.c],this.sphere=new fr,this.plane=new Or,this.needsUpdate=!0}intersectsSphere(t){return C2(t,this)}update(){let t=this.a,e=this.b,r=this.c,n=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,n);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,n);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,n);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};mi.prototype.closestPointToSegment=function(){let i=new _,t=new _,e=new nn;return function(n,s=null,o=null){let{start:a,end:l}=n,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(u[d]),e.end.copy(u[f]),vp(e,n,i,t),c=i.distanceToSquared(t),c<h&&(h=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(h)}}();mi.prototype.intersectsTriangle=function(){let i=new mi,t=new Array(3),e=new Array(3),r=new pi,n=new pi,s=new _,o=new _,a=new _,l=new _,u=new nn,c=new nn,h=new nn;return function(f,p=null,m=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let E=v[A],b=x[A];if(r.setFromPoints(b,e),E.isSeparated(r))return!1}let w=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let E=w[A],b=S[A];if(r.setFromPoints(b,t),E.isSeparated(r))return!1}for(let A=0;A<4;A++){let E=x[A];for(let b=0;b<4;b++){let M=S[b];if(s.crossVectors(E,M),r.setFromPoints(s,t),n.setFromPoints(s,e),r.isSeparated(n))return!1}}return p&&(m||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,x=!1,w=0;for(let I=0;I<3;I++){let R=v[I],U=v[(I+1)%3];u.start.copy(R),u.end.copy(U),u.delta(o);let F=x?c.start:c.end,V=Ph(y.distanceToPoint(R));if(Ph(y.normal.dot(o))&&V){c.copy(u),w=2;break}if((y.intersectLine(u,F)||V)&&!Ph(F.distanceTo(U))){if(w++,x)break;x=!0}}if(w===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(w!==2)return!1;let S=f.points,A=!1,E=0;for(let I=0;I<3;I++){let R=S[I],U=S[(I+1)%3];u.start.copy(R),u.end.copy(U),u.delta(a);let F=A?h.start:h.end,V=Ph(g.distanceToPoint(R));if(Ph(g.normal.dot(a))&&V){h.copy(u),E=2;break}if((g.intersectLine(u,F)||V)&&!Ph(F.distanceTo(U))){if(E++,A)break;A=!0}}if(E===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(E!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let b=c.start.dot(o),M=c.end.dot(o),T=h.start.dot(o),C=h.end.dot(o),P=M<T,D=b<C;return b!==C&&T!==M&&P===D?!1:(p&&(l.subVectors(c.start,h.start),l.dot(o)>0?p.start.copy(c.start):p.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(h.end)),!0)}}}();mi.prototype.distanceToPoint=function(){let i=new _;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();mi.prototype.distanceToTriangle=function(){let i=new _,t=new _,e=["a","b","c"],r=new nn,n=new nn;return function(o,a=null,l=null){let u=a||l?r:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),d<c&&(c=d,a&&a.copy(i),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,i),d=m.distanceToSquared(i),d<c&&(c=d,a&&a.copy(m),l&&l.copy(i))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];n.set(o[m],o[g]),vp(r,n,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var gi=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new _,this.max=new _,this.matrix=new ie,this.invMatrix=new ie,this.points=new Array(8).fill().map(()=>new _),this.satAxes=new Array(3).fill().map(()=>new _),this.satBounds=new Array(3).fill().map(()=>new pi),this.alignedSatBounds=new Array(3).fill().map(()=>new pi),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};gi.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,n=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=n[d];f.x=u?r.x:e.x,f.y=c?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=n[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<<u,f=n[d];c.subVectors(a,f),h.setFromPoints(c,n)}let l=this.alignedSatBounds;l[0].setFromPointsField(n,"x"),l[1].setFromPointsField(n,"y"),l[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();gi.prototype.intersectsBox=function(){let i=new pi;return function(e){this.needsUpdate&&this.update();let r=e.min,n=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=r.x,i.max=n.x,a[0].isSeparated(i)||(i.min=r.y,i.max=n.y,a[1].isSeparated(i))||(i.min=r.z,i.max=n.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(i.setFromBox(u,e),c.isSeparated(i))return!1}return!0}}();gi.prototype.intersectsTriangle=function(){let i=new mi,t=new Array(3),e=new pi,r=new pi,n=new _;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],p=c[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=c[p];if(n.crossVectors(f,m),e.setFromPoints(n,t),r.setFromPoints(n,h),e.isSeparated(r))return!1}}return!0}}();gi.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();gi.prototype.distanceToPoint=function(){let i=new _;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();gi.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new nn),e=new Array(12).fill().map(()=>new nn),r=new _,n=new _;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(n),this.closestPointToPoint(n,r),o.closestPointToPoint(r,n),l&&l.copy(r),u&&u.copy(n)),0;let c=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];n.copy(y).clamp(h,d);let v=y.distanceToSquared(n);if(v<p&&(p=v,l&&l.copy(y),u&&u.copy(n),v<c))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,w=(g+2)%3,S=y<<x|v<<w,A=1<<g|y<<x|v<<w,E=f[S],b=f[A];t[m].set(E,b);let T=i[g],C=i[x],P=i[w],D=e[m],I=D.start,R=D.end;I[T]=h[T],I[C]=y?h[C]:d[C],I[P]=v?h[P]:d[C],R[T]=d[T],R[C]=y?h[C]:d[C],R[P]=v?h[P]:d[C],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){n.x=g?d.x:h.x,n.y=y?d.y:h.y,n.z=v?d.z:h.z,this.closestPointToPoint(n,r);let x=n.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),u&&u.copy(n),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];vp(y,x,r,n);let w=r.distanceToSquared(n);if(w<p&&(p=w,l&&l.copy(r),u&&u.copy(n),w<c))return Math.sqrt(w)}}return Math.sqrt(p)}}();var Dh=new _,Ih=new _,Oh=new _,iv=new N,sv=new N,ov=new N,P2=new _,D2=new _,I2=new _,av=new _;function s8(i,t,e,r,n,s){let o;return s===Qr?o=i.intersectTriangle(r,e,t,!0,n):o=i.intersectTriangle(t,e,r,s!==Ln,n),o===null?null:{distance:i.origin.distanceTo(n),point:n.clone()}}function o8(i,t,e,r,n,s,o,a,l){Dh.fromBufferAttribute(t,s),Ih.fromBufferAttribute(t,o),Oh.fromBufferAttribute(t,a);let u=s8(i,Dh,Ih,Oh,av,l);if(u){r&&(iv.fromBufferAttribute(r,s),sv.fromBufferAttribute(r,o),ov.fromBufferAttribute(r,a),u.uv=dr.getInterpolation(av,Dh,Ih,Oh,iv,sv,ov,new N)),n&&(iv.fromBufferAttribute(n,s),sv.fromBufferAttribute(n,o),ov.fromBufferAttribute(n,a),u.uv1=dr.getInterpolation(av,Dh,Ih,Oh,iv,sv,ov,new N)),e&&(P2.fromBufferAttribute(e,s),D2.fromBufferAttribute(e,o),I2.fromBufferAttribute(e,a),u.normal=dr.getInterpolation(av,Dh,Ih,Oh,P2,D2,I2,new _),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new _,materialIndex:0};dr.getNormal(Dh,Ih,Oh,c.normal),u.face=c,u.faceIndex=s}return u}function pS(i,t,e,r,n){let s=r*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:h,uv1:d}=i.attributes,f=o8(e,u,c,h,d,o,a,l,t);return f?(f.faceIndex=r,n&&n.push(f),f):null}function O2(i,t,e,r,n,s){for(let o=r,a=r+n;o<a;o++)pS(i,t,e,o,s)}function R2(i,t,e,r,n){let s=1/0,o=null;for(let a=r,l=r+n;a<l;a++){let u=pS(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Zi(i,t,e,r){let n=i.a,s=i.b,o=i.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),n.x=r.getX(a),n.y=r.getY(a),n.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(u),o.y=r.getY(u),o.z=r.getZ(u)}function mS(i,t,e,r,n,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Zi(o,u*3,a,l),o.needsUpdate=!0,r(o,u,n,s))return!0;return!1}var Rh=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function oa(i,t){return t[i+15]===65535}function hc(i,t){return t[i+6]}function Lh(i,t){return t[i+14]}function Nh(i){return i+8}function Bh(i,t){return t[i+6]}function L2(i,t){return t[i+7]}var Fh=new Pt,cv=new _,l8=["x","y","z"];function uv(i,t,e,r,n){let s=i*2,o=kh,a=il,l=sl;if(oa(s,a)){let c=hc(i,l),h=Lh(s,a);O2(t,e,r,c,h,n)}else{let c=Nh(i);dv(c,o,r,cv)&&uv(c,t,e,r,n);let h=Bh(i,l);dv(h,o,r,cv)&&uv(h,t,e,r,n)}}function hv(i,t,e,r){let n=i*2,s=kh,o=il,a=sl;if(oa(n,o)){let u=hc(i,a),c=Lh(n,o);return R2(t,e,r,u,c)}else{let u=L2(i,a),c=l8[u],d=r.direction[c]>=0,f,p;d?(f=Nh(i),p=Bh(i,a)):(f=Bh(i,a),p=Nh(i));let g=dv(f,s,r,cv)?hv(f,t,e,r):null;if(g){let x=g.point[c];if(d?x<=s[p+u]:x>=s[p+u+3])return g}let v=dv(p,s,r,cv)?hv(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var N2=function(){let i,t,e=[],r=new Rh(()=>new Pt);return function(...o){i=r.getPrimitive(),t=r.getPrimitive(),e.push(i,t);let a=n(...o);r.releasePrimitive(i),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function n(s,o,a,l,u=null,c=0,h=0){function d(x){let w=x*2,S=il,A=sl;for(;!oa(w,S);)x=Nh(x),w=x*2;return hc(x,A)}function f(x){let w=x*2,S=il,A=sl;for(;!oa(w,S);)x=Bh(x,A),w=x*2;return hc(x,A)+Lh(w,S)}let p=s*2,m=kh,g=il,y=sl;if(oa(p,g)){let x=hc(s,y),w=Lh(p,g);return Ki(s,m,i),l(x,w,!1,h,c+s,i)}else{let x=Nh(s),w=Bh(s,y),S=x,A=w,E,b,M,T;if(u&&(M=i,T=t,Ki(S,m,M),Ki(A,m,T),E=u(M),b=u(T),b<E)){S=w,A=x;let F=E;E=b,b=F,M=T}M||(M=i,Ki(S,m,M));let C=oa(S*2,g),P=a(M,C,E,h+1,c+S),D;if(P===2){let F=d(S),G=f(S)-F;D=l(F,G,!0,h+1,c+S,M)}else D=P&&n(S,o,a,l,u,c,h+1);if(D)return!0;T=t,Ki(A,m,T);let I=oa(A*2,g),R=a(T,I,b,h+1,c+A),U;if(R===2){let F=d(A),G=f(A)-F;U=l(F,G,!0,h+1,c+A,T)}else U=R&&n(A,o,a,l,u,c,h+1);return!!U}}}(),B2=function(){let i=new mi,t=new mi,e=new ie,r=new gi,n=new gi;return function s(o,a,l,u,c=null){let h=o*2,d=kh,f=il,p=sl;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,u),c=r),oa(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,w=l.attributes.position,S=hc(o,p),A=Lh(h,f);if(e.copy(u).invert(),l.boundsTree)return Ki(o,d,n),n.matrix.copy(e),n.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>n.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let M=S*3,T=(A+S)*3;M<T;M+=3)if(Zi(t,M,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let E=S*3,b=A+S*3;E<b;E+=3){Zi(i,E,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let M=0,T=x.count;M<T;M+=3)if(Zi(t,M,x,w),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return Ki(g,d,Fh),!!(c.intersectsBox(Fh)&&s(g,a,l,u,c)||(Ki(y,d,Fh),c.intersectsBox(Fh)&&s(y,a,l,u,c)))}}}();function dv(i,t,e,r){return Ki(i,t,Fh),e.intersectBox(Fh,r)}var gS=[],lv,kh,il,sl;function Vh(i){lv&&gS.push(lv),lv=i,kh=new Float32Array(i),il=new Uint16Array(i),sl=new Uint32Array(i)}function xp(){lv=null,kh=null,il=null,sl=null,gS.length&&Vh(gS.pop())}var yS=Symbol("skip tree generation"),vS=new Pt,xS=new Pt,zh=new ie,dc=new gi,bp=new gi,wp=new _,fv=new _,c8=new _,u8=new _,h8=new _,F2=new Pt,no=new Rh(()=>new mi),io=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),io.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,n=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:n.map(a=>a.slice()),index:s.array.slice()}:o={roots:n,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),io.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:n,roots:s}=t,o=new io(e,{...r,[yS]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==n&&(a.array.set(n),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[yS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[yS]||(this._roots=T2(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Pt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,n=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let d=0,f=c.length;d<f;d++)s=c[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,u),u+=s.byteLength;function h(d,f,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,w=1/0,S=1/0,A=-1/0,E=-1/0,b=-1/0;for(let M=3*y,T=3*(y+v);M<T;M++){let C=r[M],P=n.getX(C),D=n.getY(C),I=n.getZ(C);P<x&&(x=P),P>A&&(A=P),D<w&&(w=D),D>E&&(E=D),I<S&&(S=I),I>b&&(b=I)}return l[d+0]!==x||l[d+1]!==w||l[d+2]!==S||l[d+3]!==A||l[d+4]!==E||l[d+5]!==b?(l[d+0]=x,l[d+1]=w,l[d+2]=S,l[d+3]=A,l[d+4]=E,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,w=v+f,S=p,A=!1,E=!1;t?S||(A=t.has(x),E=t.has(w),S=!A&&!E):(A=!0,E=!0);let b=S||A,M=S||E,T=!1;b&&(T=h(y,f,S));let C=!1;M&&(C=h(v,f,S));let P=T||C;if(P)for(let D=0;D<3;D++){let I=y+D,R=v+D,U=l[I],F=l[I+3],V=l[R],G=l[R+3];l[d+D]=U<V?U:V,l[d+D+3]=F>G?F:G}return P}}}traverse(t,e=0){let r=this._roots[e],n=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=n[a+6],d=s[u+14];t(l,c,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=n[a+6],f=n[a+7];t(l,c,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Pi){let r=this._roots,n=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=n.groups,u=o?e.side:e;for(let c=0,h=r.length;c<h;c++){let d=a?e[l[c].materialIndex].side:u,f=s.length;if(Vh(r[c]),uv(0,n,d,t,s),xp(),a){let p=l[c].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=Pi){let r=this._roots,n=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=n.groups,u=s?e.side:e;for(let c=0,h=r.length;c<h;c++){let d=o?e[l[c].materialIndex].side:u;Vh(r[c]);let f=hv(0,n,d,t);xp(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,n=!1;for(let s of this._roots)if(Vh(s),n=B2(0,r,t,e),xp(),n)break;return n}shapecast(t,e,r){let n=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,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=no.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:mS(f,p,n,u,m,g,s)}else l||(u?l=(d,f,p,m)=>mS(d,f,n,u,p,m,s):l=(d,f,p)=>p);let c=!1,h=0;for(let d of this._roots){if(Vh(d),c=N2(0,n,a,l,o,h),xp(),c)break;h+=d.byteLength}return no.releasePrimitive(s),c}bvhcast(t,e,r){let{intersectsRanges:n,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;zh.copy(e).invert();let c=no.getPrimitive(),h=no.getPrimitive();if(s){let f=function(p,m,g,y,v,x,w,S){for(let A=g,E=g+y;A<E;A++){Zi(h,A*3,l,u),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let b=p,M=p+m;b<M;b++)if(Zi(c,b*3,o,a),c.needsUpdate=!0,s(c,h,b,A,v,x,w,S))return!0}return!1};if(n){let p=n;n=function(m,g,y,v,x,w,S,A){return p(m,g,y,v,x,w,S,A)?!0:f(m,g,y,v,x,w,S,A)}}else n=f}t.getBoundingBox(xS),xS.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>xS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(vS.copy(v),vS.applyMatrix4(zh),t.shapecast({intersectsBounds:x=>vS.intersectsBox(x),intersectsRange:(x,w,S,A,E)=>n(f,p,x,w,g,y,A,E)}))});return no.releasePrimitive(c),no.releasePrimitive(h),d}intersectsBox(t,e){return dc.set(t.min,t.max,e),dc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>dc.intersectsBox(r),intersectsTriangle:r=>dc.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),dc.set(t.boundingBox.min,t.boundingBox.max,e),dc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,h=t.index,d=no.getPrimitive(),f=no.getPrimitive(),p=fv,m=c8,g=null,y=null;n&&(g=u8,y=h8);let v=1/0,x=null,w=null;return zh.copy(e).invert(),bp.matrix.copy(zh),this.shapecast({boundsTraverseOrder:S=>dc.distanceToBox(S),intersectsBounds:(S,A,E)=>E<v&&E<o?(A&&(bp.min.copy(S.min),bp.max.copy(S.max),bp.needsUpdate=!0),!0):!1,intersectsRange:(S,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>bp.distanceToBox(E),intersectsBounds:(E,b,M)=>M<v&&M<o,intersectsRange:(E,b)=>{for(let M=E*3,T=(E+b)*3;M<T;M+=3){Zi(f,M,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=S*3,P=(S+A)*3;C<P;C+=3){Zi(d,C,u,l),d.needsUpdate=!0;let D=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=C/3,w=M/3),D<s)return!0}}}});{let E=h?h.count:c.count;for(let b=0,M=E;b<M;b+=3){Zi(f,b,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let T=S*3,C=(S+A)*3;T<C;T+=3){Zi(d,T,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,x=T/3,w=b/3),P<s)return!0}}}}}),no.releasePrimitive(d),no.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=v,r.faceIndex=x,n&&(n.point?n.point.copy(y):n.point=y.clone(),n.point.applyMatrix4(zh),m.applyMatrix4(zh),n.distance=m.sub(n.point).length(),n.faceIndex=w),r)}closestPointToPoint(t,e={},r=0,n=1/0){let s=r*r,o=n*n,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(wp.copy(t).clamp(c.min,c.max),wp.distanceToSquared(t)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(t,wp);let d=t.distanceToSquared(wp);return d<a&&(fv.copy(wp),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(fv):e.point=fv.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{Ki(0,new Float32Array(r),F2),t.union(F2)}),t}};var Id=pn(V2());var d8=.5*(Math.sqrt(3)-1),Sp=(3-Math.sqrt(3))/6,f8=1/3,so=1/6,tde=(Math.sqrt(5)-1)/4,rde=(5-Math.sqrt(5))/20,Ap=i=>Math.floor(i)|0,z2=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]),wS=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 pv(i=Math.random){let t=G2(i),e=new Float64Array(t).map(n=>z2[n%12*2]),r=new Float64Array(t).map(n=>z2[n%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*d8,h=Ap(s+c),d=Ap(o+c),f=(h+d)*Sp,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let w=g-v+Sp,S=y-x+Sp,A=g-1+2*Sp,E=y-1+2*Sp,b=h&255,M=d&255,T=.5-g*g-y*y;if(T>=0){let D=b+t[M],I=e[D],R=r[D];T*=T,a=T*T*(I*g+R*y)}let C=.5-w*w-S*S;if(C>=0){let D=b+v+t[M+x],I=e[D],R=r[D];C*=C,l=C*C*(I*w+R*S)}let P=.5-A*A-E*E;if(P>=0){let D=b+1+t[M+1],I=e[D],R=r[D];P*=P,u=P*P*(I*A+R*E)}return 70*(a+l+u)}}function U2(i=Math.random){let t=G2(i),e=new Float64Array(t).map(s=>wS[s%12*3]),r=new Float64Array(t).map(s=>wS[s%12*3+1]),n=new Float64Array(t).map(s=>wS[s%12*3+2]);return function(o,a,l){let u,c,h,d,f=(o+a+l)*f8,p=Ap(o+f),m=Ap(a+f),g=Ap(l+f),y=(p+m+g)*so,v=p-y,x=m-y,w=g-y,S=o-v,A=a-x,E=l-w,b,M,T,C,P,D;S>=A?A>=E?(b=1,M=0,T=0,C=1,P=1,D=0):S>=E?(b=1,M=0,T=0,C=1,P=0,D=1):(b=0,M=0,T=1,C=1,P=0,D=1):A<E?(b=0,M=0,T=1,C=0,P=1,D=1):S<E?(b=0,M=1,T=0,C=0,P=1,D=1):(b=0,M=1,T=0,C=1,P=1,D=0);let I=S-b+so,R=A-M+so,U=E-T+so,F=S-C+2*so,V=A-P+2*so,G=E-D+2*so,H=S-1+3*so,Y=A-1+3*so,k=E-1+3*so,j=p&255,X=m&255,q=g&255,z=.6-S*S-A*A-E*E;if(z<0)u=0;else{let W=j+t[X+t[q]];z*=z,u=z*z*(e[W]*S+r[W]*A+n[W]*E)}let J=.6-I*I-R*R-U*U;if(J<0)c=0;else{let W=j+b+t[X+M+t[q+T]];J*=J,c=J*J*(e[W]*I+r[W]*R+n[W]*U)}let Z=.6-F*F-V*V-G*G;if(Z<0)h=0;else{let W=j+C+t[X+P+t[q+D]];Z*=Z,h=Z*Z*(e[W]*F+r[W]*V+n[W]*G)}let K=.6-H*H-Y*Y-k*k;if(K<0)d=0;else{let W=j+1+t[X+1+t[q+1]];K*=K,d=K*K*(e[W]*H+r[W]*Y+n[W]*k)}return 32*(u+c+h+d)}}function G2(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),s=e[r];e[r]=e[n],e[n]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var Ss=new dr,mv=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let n=0;n<t.count;n+=3){let s=1;Ss.a.fromBufferAttribute(t,n),Ss.b.fromBufferAttribute(t,n+1),Ss.c.fromBufferAttribute(t,n+2),s*=Ss.getArea(),e[n/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,s=-1;for(;r<=n;){let o=Math.ceil((r+n)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?n=o-1:r=o+1}return s}sampleFace(t,e,r){let n=this.randomFunction(),s=this.randomFunction();return n+s>1&&(n=1-n,s=1-s),Ss.a.fromBufferAttribute(this.positionAttribute,t*3),Ss.b.fromBufferAttribute(this.positionAttribute,t*3+1),Ss.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Ss.a,n).addScaledVector(Ss.b,s).addScaledVector(Ss.c,1-(n+s)),Ss.getNormal(r),this}};var j2=pn(SS()),p8=new ie,m8=new ie,g8=new ie,Uh;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(Uh||(Uh={}));var Gh=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ie;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ie;this.matrixWorldRigid=new ie;this.shearScale=new ie;this.shearScaleInv=new ie}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof gt&&(r=r.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===r)return!0;n=n.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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,r=!0);for(let n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){let s=this.parent;if(r&&s!==null&&s.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)),n)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,n=0){for(let s of this.children)Uh.is(s)&&s.traverseObject(r,n+1)}traverseObject(r,n=0){if(r(this,n)!==!0)for(let o of this.children)Uh.is(o)&&o.traverseObject(r,n+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,n=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,j2.SVD)(n),l=p8.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),u=m8.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=g8.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,n){this.updateWorldMatrix(!0,!1);let s=new ie().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ie?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),n!==void 0&&(this.children.pop(),this.children.splice(n,0,r)),this}copy(r,n=!1){return super.copy(r,n),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,n,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var AS=class extends Gh(gt){},y8=i=>i.type==="Mesh",mr=class extends AS{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new mr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix),n.expand(),e+=1,r=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 y8(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}};var fc=new _,pc=new _,Hh=new ie,q2=[new _(-1,1,1),new _(-1,-1,1),new _(1,-1,1),new _(1,1,1),new _(-1,1,-1),new _(-1,-1,-1),new _(1,-1,-1),new _(1,1,-1)],v8=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],x8=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],W2=(i,t,e)=>{i.updateEntityBoxSize(fc,pc),Hh.copy(t).multiply(i.matrixWorld),pc.x===0&&pc.y===0&&pc.z===0?e.push(new _(fc.x,fc.y,fc.z).applyMatrix4(Hh)):q2.forEach(r=>{e.push(r.clone().multiply(pc).add(fc).applyMatrix4(Hh))})},_p=class extends Pt{constructor(){super(...arguments);this.matrix=new ie;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let n=new ie().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let s=[];return n===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new _);return}W2(o,r,s)}}):W2(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Hh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(pc).multiplyScalar(.5),this.getCenter(fc),Hh.copy(this.matrix).setPosition(fc),this.vertices=q2.map(e=>e.clone().multiply(pc).applyMatrix4(Hh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=v8.map(([e,r])=>new nn(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new _))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=x8.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var As={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var ES=class extends zf{constructor(){super()}getPoints(t=12){let e=[],r,n=this.getCurveLengths(),o=n[n.length-1]/n.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?n[a]:n[a]-n[a-1],h=Math.ceil(t*c/o),d=u.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var MS=.001;function TS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=MS}function _S(i,t){let e=new _(...i.position),r=new _(...i.controlNext.position),n=new _(...t.controlPrevious.position),s=new _(...t.position);return TS(e,r,s)&&TS(e,n,s)}function yv(i){let t=i.points.map(c=>new _(...c.data.position)),e=[i.points[0]],r=new _(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)TS(r,t[c],t[c+1])||(e.push(i.points[c]),r=t[c]);e.push(i.points[i.points.length-1]);let n=i.isClosed,s=e.length-(n?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let h=e[c].data,d=new _(...h.position),f=new _(...h.controlPrevious.position),p=new _(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...m,removedLength:0};continue}let g=n&&c==0?o-1:c-1,y=n&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,w=new _(...v.position),S=new _(...x.position),A=w.clone().sub(d).normalize(),E=S.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:E});let b=_S(v,h),M=_S(h,x);if(!b||!M)a[c]={...m,removedLength:0};else{let T=A.clone().add(E).normalize(),C=T.clone().cross(A).length()/A.dot(T);a[c]={...m,tan:C,removedLength:h.roundness/C}}}for(let c=0;c<s;c++){let h=c,d=n&&c===o-1?0:c+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let h=c,d=n&&c===o-1?0:c+1,f=a[h],p=a[d],m=null;if(!_S(e[h].data,e[d].data))f.position.distanceTo(p.position)>MS&&(m=new ql(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>MS&&(m=new ql(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c<o;c++){let h=a[c];if(h.removedLength===0){l[2*c]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),w=g.clone().multiplyScalar(-m).add(x),S=d.distanceTo(w)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),E=A.clone().lerp(w,2),b=f.clone().lerp(A,4/3),M=p.clone().lerp(E,4/3);l[2*c]=new ql(f,b,M,p)}let u=new ES;return l.forEach(c=>{c&&u.add(c)}),u}var lt;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(lt||(lt={}));var oo=i=>lt.is(i),b8={type:"completeState",isfromEntity:!0},w8=["x","y","z"],CS=new _,S8=new _().set(0,1,0),jh=i=>class extends Gh(i){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 _p;this._recursiveBBox=new _p;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let n=this.children[r];if(lt.is(n))return n}entityChildrenCount(){let r=this.children.length;for(;r--;)if(lt.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let n=r.parent;if(lt.is(n))r=n;else return}return r}forInstancesRec(r){this.instances.forEach(n=>{n.disposed||r(n),n.forInstancesRec(r)})}super_Entity(r,n){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=n,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,n,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)ta.toOps(this.data,o.data).forEach(l=>{let u=wy.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,n)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=ta.patch(this.data,o),ta.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,n)}))}s&&this.updateTransformState(this.dataPatched,n),this.stateSelection=r,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(r,n){r.setScalar(0),n.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{oo(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let n;return this.traverseEntity(s=>{s.uuid===r&&(n=s)}),n}traverseSortNextHelper(){let r=this.parent;if(r){let n=r.children,s=n.indexOf(this)+1;if(lt.is(n[s]))return n[s];if(lt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&lt.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let n=this;for(;r>0&&n!==null;)n=n.parent,r-=1;return n}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let n=this.parent;for(;n;){if(r===n)return!0;n=n.parent}return!1}countToAccestor(r){let n=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,n+=1}return n}forEachEntity(r){for(let n of this.children)oo(n)&&r(n)}traverseEntityAncestors(r){this.traverseAncestors(n=>{lt.is(n)&&r(n)})}traverseConcreteEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)oo(o)&&o.isConcreteEntity&&o.traverseEntity(r,n+1)}traverseEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)oo(o)&&o.traverseEntity(r,n+1)}traverseVisibleEntity(r){r(this);for(let n of this.children)oo(n)&&n.visible&&n.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,n=!1){return super.copy(r,n),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>oo(r))}isAncestorOf(r){if(this.uuid===r)return!1;let n=!1;return this.traverseEntity(s=>{s.uuid===r&&(n=!0)}),n}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x*Se.RAD2DEG,this.rotation.y*Se.RAD2DEG,this.rotation.z*Se.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ih(n,r)}getTransformValues(r,n,s){return n[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,w8[a]])??o)}updateTransformState(r,n){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,n)),s=!0),r.rotation&&(CS.fromArray(this.getTransformValues("rotation",r,n)).multiplyScalar(Se.DEG2RAD),this.rotation.setFromVector3(CS),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,n)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Ya.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)lt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{lt.is(r)&&r.disposeRecursively()})}toState(r=[]){let n={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ih(n,r)}updateByObjUpdateOp(r,n){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},n,!1)}updateByOp(r,n,s,o){let a=this.data;this.data=n;let l=r,u=qn(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Rr.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:d,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:d,...f}=c;c=f}let h=Rr.removeOverridden(r.path,r.props,c);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,ta.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),qn(r.path,["overrides"])){let c=[],h=[...r.path];for(c.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)c.push(h[1]),h.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){c[c.length-1]=d;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[d],f.updateState(Xs.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...c]);if(d){let f=Rr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[m,g]of Object.entries(r.props))g===void 0&&(p===r.props&&(p={...r.props}),p[m]=f[m]);r={...r,props:p}}d.overrideData=xh.resolve(n.overrides,c),d.updateByOp(r,Lr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let h;for(let d of to.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(c={...r,props:h})}else for(let h of to.rootOverrideProps)if(qn(r.path,[h])){c=r;break}c!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Xs.filterOp(h.overrideData,c);d&&h.updateByOp(d,Lr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Xs.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=n:f=Lr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,n,s){if(this.dataPatched=n,r.path.length===0&&r.type===0)r.props.type!==void 0&&!bs.is(r.props.type)&&As.changeEntityProptotype(this,n,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){As.changeEntityProptotype(this,n,s);for(let o of this.children)lt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,n,s)}updateByPatchedOp(r,n,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),qn(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(n.pathSnapping),qn(r.path,["cloner"])!==null){let o=Lr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(n.cloner,s.scene):(this.setFromClonerState(n.cloner,s),this.expandCloner(s.scene)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let n=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(n===null)return;let l=r.find(n);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=yv(u.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=c.getPointAt(h);if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ie;l.updateMatrixWorld();let p=new ie().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ie().extractRotation(l.matrixWorld),y=c.getTangentAt(h).applyMatrix4(g).add(d),v=new ie().lookAt(d,y,S8),x=CS.setFromEuler(new Zt().setFromRotationMatrix(v)).multiplyScalar(Se.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(b8)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let n=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return n=!0,!0}),n&&r.reloadSplats()}updateState_Entity(r,n){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(n?.scene),this.resetBBoxNeedsUpdate()),n&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,n),this.updateVisible(n.scene)),this.updateTransformState(r,n)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof As.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,n){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new As.Cloner(this,r),n.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,n.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}};var vv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=Se.clamp(e.thetaLength,0,360);let r=e.width/2,n=e.radiusTop??r,s=e.radiusBottom??r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ae,p.setAttribute("position",new be([],3))):h||f?p=new Ep(u,c,r,n,s,o,a,l*Math.PI/180,h,h,d,f):p=new Xl(u,c,r,n,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function ol(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Y2(i){return new N(i.y,-i.x)}var Ep=class extends Ae{constructor(t,e,r,n,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let p=[],m=[],g=[],y=[],v=0,x=r/2,w=new _,S=new _;f&&t==0&&(t=u),f&&e==0&&(e=c);let A=new N(t,x),E=new N(e,-x),b=null,M=null,T=null,C=null,P=A.clone().sub(E),D=0,I=0,R=0;d>0&&(D=Math.min(t,e)*(1-d),I=t-D,R=e-D);let U=A.clone();U.x-=D;let F=Math.PI-P.angle(),V=P.angle(),G=Math.tan(V/2),H=Math.tan(F/2),Y=G+H,k=d?Y:H,j=d?Y:G;if(u=Math.min(u,(t-I)/k,P.length()/Y),c=Math.min(c,(e-R)/j,P.length()/Y),u>0){let K=u/G;b=A.clone().sub(new N(K,u)),d&&(T=b.clone(),T.x-=D-Y*u),A.sub(P.clone().setLength(K))}if(c>0){let K=c/H;M=E.clone().sub(new N(K,-c)),E.add(P.clone().setLength(K)),d&&(C=M.clone(),C.x-=D-Y*c,U.sub(P.clone().setLength(K)))}P=A.clone().sub(E);let X=P.length()<.5,q=[];for(let K=0;K<=n;K++){let W=[],ye=K/n,fe=ye*l+a,se=new N(Math.sin(fe),Math.cos(fe));C&&M?(z(W,ye,se,F,c,C,-1,!0),z(W,ye,se,V,c,M,-1,!1)):M?(J(W,se,M.x,0,-1),z(W,ye,se,V,c,M,-1,!1)):o||J(W,se,e,R,-1);let _e=Y2(P).normalize();if(ol(_e,se,w),!X)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=P.clone().multiplyScalar(Oe).add(E);ol(Ie,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}if(T&&b?(z(W,ye,se,F,u,b,1,!1),z(W,ye,se,V,u,T,1,!0)):b?(z(W,ye,se,F,u,b,1,!1),J(W,se,b.x,0,1)):o||J(W,se,t,I,1),d&&!X){let xe=Y2(P).multiplyScalar(-1).normalize();ol(xe,se,w);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=P.clone().multiplyScalar(-Ie).add(U);ol(Pe,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}}d&&!o&&W.push(W[0]),q.push(W)}for(let K=0;K<q.length-1;K++)for(let W=0;W<q[0].length-1;W++){if(o&&d&&W==s)continue;let ye=q[K][W],fe=q[K+1][W],se=q[K+1][W+1],_e=q[K][W+1],xe=m[se*3+0],Oe=m[se*3+2];p.push(ye,fe,_e),(xe!=0||Oe!=0)&&p.push(fe,se,_e)}l<Math.PI*2&&(Z(-1,q[0],a),Z(1,q[q.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new be(m,3)),this.setAttribute("normal",new be(g,3)),this.setAttribute("uv",new be(y,2));function z(K,W,ye,fe,se,_e,xe,Oe){for(let Ie=0;Ie<h+1;Ie++){let Pe=Ie/h,Me=xe<0?Pe:1-Pe;Oe&&(Me-=1),Me*=fe;let ze=new N(Math.sin(Me),Math.cos(Me)*xe),Ue=ze.clone().multiplyScalar(se).add(_e);ol(Ue,ye,S),m.push(S.x,S.y,S.z),ol(ze,ye,w),g.push(w.x,w.y,w.z),y.push(W,.5+S.y/r),K.push(v++)}}function J(K,W,ye,fe,se){let _e=new _,xe=new N,Oe=[ye,fe];se<0&&Oe.reverse();for(let Ie of Oe)xe.set(Ie,x*se),ol(xe,W,_e),m.push(_e.x,_e.y,_e.z),g.push(0,se,0),y.push(.5,.5),K.push(v++)}function Z(K,W,ye){let fe=new N(Math.sin(ye),Math.cos(ye)),se=new N(-Math.cos(ye),Math.sin(ye)),_e=new _,xe=K<0?(Pe,Me,ze)=>p.push(Pe,Me,ze):(Pe,Me,ze)=>p.push(Pe,ze,Me),Oe=new N((t+e+I+R)/4,0);ol(Oe,fe,_e),m.push(_e.x,_e.y,_e.z),g.push(se.x,0,se.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let Me=m.slice(Pe*3,Pe*3+3);m.push(...Me),g.push(se.x,0,se.y);let ze=y.slice(Pe*2,Pe*2+2);y.push(...ze),v++}for(let Pe=Ie+1;Pe<v-1;Pe++)xe(Ie,Pe,Pe+1);xe(Ie,v-1,Ie+1)}}};var X2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=i.parameters,d;return l===0?(d=new Ae,d.setAttribute("position",new be([],3))):u>0||c>0||l<360?d=new Ep(0,t/2,r,n,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new fu(t/2,r,n,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var Q2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new yn(t,e,r,n,s,o):u=new DS(t,e,r,n,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},PS=Math.PI/2,DS=class extends Ae{constructor(t=1,e=1,r=1,n=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],h=[],d=[],f=[],p=0,m=0;g("z","y","x",-1,-1,r,e,t,o,s,0),g("z","y","x",1,-1,r,e,-t,o,s,1),g("x","z","y",1,1,t,r,e,n,o,2),g("x","z","y",1,-1,t,r,-e,n,o,3),g("x","y","z",1,-1,t,e,r,n,s,4),g("x","y","z",-1,-1,t,e,-r,n,s,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,o,0),y("z","y","x",1,-1,-1,r,e,t,o,1),y("z","y","x",-1,1,-1,r,e,t,o,1),y("z","y","x",1,1,1,r,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,r,n,0),y("x","y","z",1,-1,1,t,e,r,n,1),y("x","y","z",-1,1,1,t,e,r,n,0),y("x","y","z",1,1,-1,t,e,r,n,1),y("y","x","z",-1,-1,1,e,t,r,s,0),y("y","x","z",1,-1,-1,e,t,r,s,1),y("y","x","z",1,1,1,e,t,r,s,1),y("y","x","z",-1,1,-1,e,t,r,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(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function g(x,w,S,A,E,b,M,T,C,P,D){let I=(b-2*a)/C,R=(M-2*a)/P,U=b/2-a,F=M/2-a,V=T/2,G=C+1,H=P+1,Y=0,k=0,j=new _;for(let X=0;X<H;X++){let q=X*R-F;for(let z=0;z<G;z++){let J=z*I-U;j[x]=J*A,j[w]=q*E,j[S]=V,h.push(j.x,j.y,j.z),j[x]=0,j[w]=0,j[S]=T>0?1:-1,d.push(j.x,j.y,j.z),f.push(z/C),f.push(1-X/P),Y+=1}}for(let X=0;X<P;X++)for(let q=0;q<C;q++){let z=p+q+G*X,J=p+q+G*(X+1),Z=p+(q+1)+G*(X+1),K=p+(q+1)+G*X;c.push(z,J,K),c.push(J,Z,K),k+=6}u.addGroup(m,k,D),m+=k,p+=Y}function y(x,w,S,A,E,b,M,T,C,P,D){let I=(M-2*a)/P,R=M/2-a,U=T/2-a,F=C/2,V=P+1,G=0,H=0,Y=new _,k=new _;for(let j=0;j<l+1;j++){let X=j/l*PS,q=Math.sin(X)*a,z=(1-Math.cos(X))*a,J=Math.sin(X),Z=Math.cos(X);Y[w]=(U+q)*E,Y[S]=(F-z)*b,k[x]=0,k[w]=J*Math.sign(Y[w]),k[S]=Z*Math.sign(Y[S]);for(let K=0;K<V;K++){let W=K*I-R;Y[x]=W*A,h.push(Y.x,Y.y,Y.z),d.push(k.x,k.y,k.z),f.push(K/P),f.push(0),G+=1}}for(let j=0;j<l;j++)for(let X=0;X<P;X++){let q=p+X+V*j,z=p+X+V*(j+1),J=p+(X+1)+V*(j+1),Z=p+(X+1)+V*j;c.push(q,z,Z),c.push(z,J,Z),H+=6}u.addGroup(m,H,D),m+=H,p+=G}function v(x,w,S){let A=new _,E=new _(t/2,e/2,r/2);E.subScalar(a);let b=[],M=x*w*S>0?(C,P,D)=>c.push(C,P,D):(C,P,D)=>c.push(C,D,P);for(let C=0;C<=l;C++){let P=[],D=PS*(1-C/l),I=Math.cos(D),R=Math.sin(D),U=0;for(let F=0;F<=C;F++){let V=Math.cos(U),G=Math.sin(U);A.x=I*V,A.y=R,A.z=I*G;let H=E.clone().addScaledVector(A,a);h.push(x*H.x,w*H.y,S*H.z),d.push(x*A.x,w*A.y,S*A.z),f.push(0,0),P.push(p++),U+=PS/C}b.push(P)}let T=b.length-1;for(let C=0;C<T;C++){let P=b[C],D=b[C+1],I=P.length-1;M(P[0],D[1],D[0]);for(let R=1;R<=I;R++)M(P[R-1],P[R],D[R]),M(P[R],D[R+1],D[R])}}}};var al=class extends Ae{constructor(t=[],e=[],r="",n=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],p=new _,m=p.clone(),g=new dr,y=s*n,v=n-y,x=o+1,w=new _,S=(G,H)=>w.subVectors(G,H).normalize(),A=(G,H)=>Array(G).fill(void 0).map(H),E=A(t.length/3,(G,H)=>new _().fromArray(t,H*3).setLength(n)),b=[],M=1e6;for(let G=0;G<E.length;G++){let H=E[G],Y=[],k,j,X,q=1e10,z=-1;for(;(z=e.indexOf(G,z+1))!=-1;){let W=z-z%3;k=e[W+(z+1)%3],j=e[W+(z+2)%3],X=H.distanceToSquared(E[k]),q=Math.min(q,X),Y.push([k,j,X])}q+=1e-6;let J=[],Z=0,K=Y.length;for(let W=0;W<K;W++){[k,j,X]=Y[Z];let ye=b[k]?.includes(G)==!0;X<=q&&J.push(k+ +ye*M),Z=Y.findIndex(fe=>fe[0]==j)}b.push(J)}let T=[];{let G=0,H=0,Y,k,j=f==3;for(let X=0;X<=o;X++){Y=X*(X+1)/2,k=(X+1)*(X+2)/2;for(let q=0;q<o-X;q++)[G,H]=[Y+q+X+2,k+q+X+3],T.push(Y,k,...j?[H,Y]:[G,k],H,G),[Y,k]=[G,H];T.push(Y,k,Y+o+2)}}let C=p.clone(),P=p.clone(),D=p.clone(),I=p.clone(),R=p.clone(),U=[],F=A(E.length,()=>A(f,()=>p.clone()));for(let G=0;G<E.length;G++){p.copy(E[G]).normalize(),C.copy(p).multiplyScalar(v);let H=b[G];for(let J=0;J<H.length;J++){let Z=H[J],K=H[(J+1)%f];g.setFromPointsAndIndices(E,G,Z%M,K%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,F[G][J])}let Y=[],k=[],j=[],X=new _;o==0&&[...F[G]].reduce((J,Z)=>J.add(Z),X).multiplyScalar(1/f);for(let J=0;J<f;J++){let Z=[],K=(J-1+f)%f,W=F[G][K],ye=F[G][J];p.copy(W).sub(C),m.copy(ye).sub(C);let fe=C.angleTo(p),se=p.angleTo(m),_e=Math.cos(fe)*y;o==0?P.copy(X):P.copy(C).setLength(v+_e),k.push(_e);let xe=[P,W,ye];for(let Oe=0;Oe<2;Oe++){let Ie=xe[Oe],Pe=xe[Oe+1];I.subVectors(Ie,C),R.subVectors(Pe,C),D.crossVectors(I,R).normalize();for(let Me=0;Me<x;Me++){let ze=[fe,se][Oe]*Me/x;p.copy(I).applyAxisAngle(D,ze).add(C),Y.push(p.clone()),Oe&&(S(p,C),Z.push([Me==0?Ie:p.clone(),w.clone()]))}Oe&&(S(Pe,C),Z.push([Pe,w.clone()]))}j.push(Z)}U.push(j);let q=2*x,z=2;for(let J=0;J<f;J++){let Z=q*J,K=q*((J+1)%f),W=[Y[Z]];for(let fe=1;fe<x;fe++){I=Y[Z+fe],R=Y[K+fe],W.push(I);for(let se=1,_e=fe-z+1;se<=_e;se++)p.lerpVectors(I,R,se/(_e+1)),p.sub(C).setLength(k[J]).add(C),W.push(p.clone());W.push(R)}for(let fe=0;fe<x;fe++)W.push(Y[fe+x+Z]);W.push(Y[K+x]);let ye=T.map(fe=>W[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(S(fe,C),[w.x,w.y,w.z])).flat())}}let V=[];for(let G=0;G<b.length;G++)for(let H=0;H<f;H++){let Y=b[G][H];if(Y<M){let k=b[Y].findIndex(q=>q%M==G),j=U[G][H],X=U[Y][k];for(let q=0;q<x;q++){let z=j[q],J=X[x-q],Z=j[q+1],K=X[x-(q+1)];[z,J,Z,Z,J,K].forEach(W=>{a.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}V.push(j[0][0],X[x][0],j[x][0],X[0][0])}}for(;V.length;){let G,H,Y,k;[G,H]=V.splice(0,2);let j=[G];for(;G!=H;)j.push(H),Y=V.indexOf(H),k=Y%2,H=V.splice(Y-k,2)[1-k];w.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let X=w.dot(j[0])<0;X&&w.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +X],j[q+1-+X],j[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(w.x,w.y,w.z)})}}function h(){let d=new _;for(let E=0;E<a.length;E+=3){d.x=a[E+0],d.y=a[E+1],d.z=a[E+2];let b=S(d)/2/Math.PI+.5,M=A(d)/Math.PI+.5;l.push(b,1-M)}let f=new _,p=new _,m=new _,g=new _,y=new N,v=new N,x=new N,w=(E,b,M,T)=>{T<0&&E.x===1&&(l[b]=E.x-1),M.x===0&&M.z===0&&(l[b]=T/2/Math.PI+.5)};for(let E=0,b=0;E<a.length;E+=9,b+=6){f.set(a[E+0],a[E+1],a[E+2]),p.set(a[E+3],a[E+4],a[E+5]),m.set(a[E+6],a[E+7],a[E+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(p).add(m).divideScalar(3);let M=S(g);w(y,b+0,f,M),w(v,b+2,p,M),w(x,b+4,m,M)}for(let E=0;E<l.length;E+=6){let b=l[E+0],M=l[E+2],T=l[E+4],C=Math.max(b,M,T),P=Math.min(b,M,T);C>.9&&P<.1&&(b<.2&&(l[E+0]+=1),M<.2&&(l[E+2]+=1),T<.2&&(l[E+4]+=1))}function S(E){return Math.atan2(E.z,-E.x)}function A(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(t){return new al(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var K2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new Mp(t*.5,s,o):new mu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Mp=class extends al{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,o=[-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,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new Mp(t.radius,t.corner,t.cornerSides)}};var Tp=1e-12,Wh=class{constructor(t){this.position=new N;this.startPosition=new N;this.uuid=Se.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Wh(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},qh=class extends Wh{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new qh(this.parent).copy(this)}},_s=class extends Wh{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new qh(this),new qh(this))}static create(e,r){let n=new _s(e,new N(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,s=this.controls.length;n<s;n++){let o=this.controls[n];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.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 _s(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new N,r=new N){let[n,s]=this.computeTangents();return n&&s&&(Z2(n,e),Z2(s,r)),[e,r]}computeTangent(e=new N){let[r,n]=this.computeTangents();return r&&n&&e.copy(r).add(n).normalize(),e}computeNormal(e=new N){let[r,n]=this.computeNormals();return e.copy(r).add(n).normalize(),e}};function Z2(i,t=new N){let e=i.length();return t.set(-i.y/e,i.x/e)}var OS=i=>i,Yh=new N,xv=new N,A8=new N,_8=new N,E8=new N,M8=new N,$2=new _,eD=new _;function tD(i){let t=new N;t.addVectors(i.v0,Yh.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new N;return e.addVectors(i.v2,xv.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new jn(i.v0,t,e,i.v2)}function Cp(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function T8(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function C8(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function RS(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function rD(i,t,e){return J2(i,t)&&J2(t,e)&&IS(i.position,t.position,e.position)}function IS(i,t,e){return Yh.copy(t).sub(i).cross(xv.copy(e).sub(i))===0}function nD(i,t,e,r,n){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return r.set(a+l,o+u),n.set(a-l,o-u),[r,n]}function iD(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function sD(i,t,e,r,n,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,u=e.y-i.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return RS(t,i,e)>Math.PI&&(c*=-1),Cp(u,a)?h=(a+u)*(r/c-.5)*8/3/(o-l):h=(o+l)*(r/c-.5)*8/3/(u-a),n.set(t.x-h*a,t.y+h*o),s.set(e.x+h*u,e.y-h*l),[n,s]}function LS(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function J2(i,t){return IS(i.position,i.controls[1].position,t.position)&&IS(i.position,t.controls[0].position,t.position)}function oD(i,t,e,r,n=.5){let s=Yh.subVectors(t,i).multiplyScalar(n).add(i),o=xv.subVectors(e,t).multiplyScalar(n).add(t),a=A8.subVectors(r,e).multiplyScalar(n).add(e),l=s,u=_8.subVectors(o,s).multiplyScalar(n).add(s),c=E8.subVectors(a,o).multiplyScalar(n).add(o),h=a,d=M8.subVectors(c,u).multiplyScalar(n).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,r.x,r.y]}function aD(i,t,e=12,r=!0){let n=eD.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=OS(t[l]),c=Yh,h=ll(u,e);a.push(h);for(let d=0;d<=h;d++)if(u instanceof jn||u instanceof Ii||u instanceof Wn){if(u.getPoint(d/h,c),n.set(c.x,c.y,0),s!==void 0&&C8(s,n))continue;s===void 0&&(s=$2),s.copy(n),i.setXYZ(o,n.x,n.y,n.z),o++}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function lD(i,t,e,r=12,n=!0){let s=eD.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=OS(t[l]),h=Yh,d=ll(c,r);a.push(d);for(let f=0;f<=d;f++)if(c instanceof jn||c instanceof Ii||c instanceof Wn){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=$2:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function NS(i,t=12,e=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let o=i[n],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=ll(o.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=ll(o.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=ll(i[0].roundedCurveCorner,t)*.5),r}function ll(i,t=12){return i&&i instanceof Wl?t*2:i&&(i instanceof Wn||i instanceof Vf)?1:i&&i instanceof hu?t*i.points.length:t}function cD(i,t,e=12,r=!0){let n,s=0;for(let o=0;o<t.length;o++){let a=OS(t[o]),l=ll(a,e),u=Yh;for(let c=0;c<=l;c++)if(a instanceof jn||a instanceof Ii||a instanceof Wn){if(a.getPoint(c/l,u),n!==void 0&&T8(n,u,Tp))continue;n===void 0&&(n=xv),n.copy(u),i.push(u.x,u.y),s++}}return Cp(i[0],i[i.length-2],Tp)&&Cp(i[1],i[i.length-1],Tp)&&(i.pop(),i.pop()),r&&s>1&&!(Cp(i[s-1],i[1],Tp)&&Cp(i[s-2],i[0],Tp))&&(i.push(i[0],i[1]),s++),i}var BS=new N,P8=new N,D8=new N,I8=new N,O8=new N,R8=new N,Ot=class extends Wo{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Or(new _(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=Se.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let s=new Ot;return s.isClosed=e.isClosed,s.points=e.points.map(o=>_s.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Ot.createFromState(o)),r!==void 0&&n!==void 0&&s.applySize(r,n),s.update(),s}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 r=0,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,n=this.points.findIndex(s=>s.uuid===e);if(n<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return n}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=BS.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(n),a.controls[0].position.multiply(n),a.controls[1].position.multiply(n)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,n=Se.generateUUID()){let s;e instanceof N?s=e:s=new N(e,r);let o=new _s(n,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,n=this.shapeHoles.length;r<n;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=n?this.roundedCurveDivisions:this.curveDivisions;return aD(e,n?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=NS(this.points,e,!1),this.roundedCurveDivisions=NS(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return lD(e,this.curves,r,n,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),cD(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=ll(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<n+c)return[l,(a-n+1)/c];n+=c}return[0,1]}getCurveT(e,r,n){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(LS(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(BS.set(n.x,n.y))/h}let u=0;for(let h=0;h<e;h++)u+=a[h];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){LS(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let s=n.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(r,n)}if(this.points.length>2){let r=0;for(let n=0,s=this.points.length;n<s;n++){let o=this.points[n],a=this.points[n-1]??this.points[this.points.length-1],l=this.points[n+1]??this.points[0],u=o.roundness,c=a&&l&&rD(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/m,S=x/g,A=h.getPointAt(w,BS),E=d.getPointAt(S,P8);this._subSplitCurve(h,f,w,A,void 0),this._subSplitCurve(d,p,S,void 0,E);let b;if(this.useCubicForRoundedCorners){let M=RS(A,o.position,E)/2,T=Math.tan(M)*A.distanceTo(o.position),[C,P]=nD(A,E,T,D8,I8),D=iD(C,P,o.position),[I,R]=sD(D,A,E,T,O8,R8);b=new jn(A.clone(),I.clone(),R.clone(),E.clone())}else b=new Ii(A.clone(),o.position.clone(),E.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(n+r,0,b),r++}}}}_subSplitCurve(e,r,n,s,o){if(e instanceof Wn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,u=a.getUtoTmapping(n,0),c=oD(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new Ot(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let n=0;n<r;n++){let s=n*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new _s(Se.generateUUID(),new N(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(n=>{let s=new Ot;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(o,a)=>{a instanceof jn&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,u;for(l=0,u=o.length;l<u;l++)o[l]instanceof Ii&&(o[l]=tD(o[l]));for(l=0,u=o.length;l<u;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof jn?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof Wn&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&n(p,f),a.push(p))}let c=o[o.length-1],h=!1;return c instanceof jn?c.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(c.v2),h=!0):c instanceof Wn&&c.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof Wo&&(this.shapeHoles=e.holes.map(o=>{let a=new Ot;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var kS=Math.PI*2;function FS({x:i,y:t},e,r,n,s){return{x:i*e+n,y:t*r+s}}function L8(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function uD(i,t,e,r){let n=i*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(s)}function N8(i,t,e,r,n,s,o,a,l,u){let c=Math.pow(n,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=c*h-c*f-h*d;p<0&&(p=0),p/=c*f+h*d,p=Math.sqrt(p)*(l===u?-1:1);let m=p*n/s*a,g=p*-s/n*o,y=m+(i+e)/2,v=g+(t+r)/2,x=(o-m)/n,w=(a-g)/s,S=(-o-m)/n,A=(-a-g)/s,E=uD(1,0,x,w),b=uD(x,w,S,A);return!u&&b>0&&(b-=kS),u&&b<0&&(b+=kS),{centerx:y,centery:v,ang1:E,ang2:b}}function hD({px:i,py:t,cx:e,cy:r,rx:n,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(n===0||s===0)return[];let u=(i-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];n=Math.abs(n),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(n,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(n*=Math.sqrt(h),s*=Math.sqrt(h));let d=N8(i,t,e,r,n,s,u,c,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(kS/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(L8(f,p)),f+=p;return l.map(x=>{let{x:w,y:S}=FS(x[0],n,s,m,g),{x:A,y:E}=FS(x[1],n,s,m,g),{x:b,y:M}=FS(x[2],n,s,m,g);return{x1:w,y1:S,x2:A,y2:E,x:b,y:M}})}var St;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(St||(St={}));var br;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(br||(br={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Ze=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){nt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?n<s?e.t-t.t+(t.t-r.t)*(n/(n+s)):e.t-r.t+(r.t-t.t)*(s/(n+s)):0},i.edgeSign=function(t,e,r){nt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?(e.t-r.t)*n+(e.t-t.t)*s:0},i.transEval=function(t,e,r){nt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?n<s?e.s-t.s+(t.s-r.s)*(n/(n+s)):e.s-r.s+(r.s-t.s)*(s/(n+s)):0},i.transSign=function(t,e,r){nt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?(e.s-r.s)*n+(e.s-t.s)*s:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(o=i.edgeEval(t,r,e),a=i.edgeEval(r,e,n),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,e.s)):(o=i.edgeSign(t,r,e),a=-i.edgeSign(t,n,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,n.s)):s.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(o=i.transEval(t,r,e),a=i.transEval(r,e,n),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,e.t)):(o=i.transSign(t,r,e),a=-i.transSign(t,n,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,n.t)):s.t=(r.t+e.t)/2},i}(),Pp=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),bv=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Xh=function(){function i(){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 i}(),dD=function(){function i(){var t=new Xh,e=new Pp,r=new bv(0),n=new bv(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new bv(0),r=new bv(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;nt(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e;var o=e;do o.Org=n,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;nt(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var o=e;do o.Lface=n,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new Xh,e=new Xh,r=new Pp,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var s=new Xh;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new Pp;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=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 n=new Pp;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new Xh;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.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},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),s=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(s,e),n.Org=t.Dst,s.Org=e.Org,n.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new Pp;this.makeFace_(o,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,s,o,a;n=e.Lnext;do r=n,n=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Ze.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Ze.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,s,o,a,l,u;for(s=t,s=t;(n=s.next)!==t;s=n){nt(n.prev===s),l=n.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Lface===n),l=l.Lnext;while(l!==n.anEdge)}for(nt(n.prev===s&&n.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){nt(o.prev===a),l=o.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(nt(o.prev===a&&o.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)nt(l.Sym.next===u.Sym),nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Org!==null),nt(l.Dst!==null),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l);nt(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),fD=function(){function i(){this.handle=null}return i}(),pD=function(){function i(){this.key=null,this.node=0}return i}(),B8=function(){function i(t,e){this.leq=e,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 fD,this.handles[r]=new pD;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,nt(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[n].key,r[s].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new fD;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new pD}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;nt(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),VS=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),mD=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),F8=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new mD,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new mD;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),k8=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,s=e.eUp,o=r.eUp;if(s.Dst===n)return o.Dst===n?Ze.vertLeq(s.Org,o.Org)?Ze.edgeSign(o.Dst,s.Org,o.Org)<=0:Ze.edgeSign(s.Dst,o.Org,s.Org)>=0:Ze.edgeSign(o.Dst,n,o.Org)<=0;if(o.Dst===n)return Ze.edgeSign(s.Dst,n,s.Org)>=0;var a=Ze.edgeEval(s.Dst,n,s.Org),l=Ze.edgeEval(o.Dst,n,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&nt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new VS;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case St.ODD:return(e&1)!==0;case St.NONZERO:return e!==0;case St.POSITIVE:return e>0;case St.NEGATIVE:return e<0;case St.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),n=s.eUp,n.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}n=t.mesh.connect(a.Lprev,n.Sym),i.fixUpperEdge(t,s,n)}a.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(a,n)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,r,n,s,o){var a,l,u,c,h=!0;u=r;do nt(Ze.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==n);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,nt(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Ze.vertL1dist(e,t),s=Ze.vertL1dist(r,t),o=.5*s/(n+s),a=.5*n/(n+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},i.getIntersectData=function(t,e,r,n,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp;if(Ze.vertLeq(n.Org,s.Org)){if(Ze.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;Ze.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,n)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(n,s.Oprev),e.dirty=r.dirty=!0)}else{if(Ze.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o;if(nt(!Ze.vertEq(n.Dst,s.Dst)),Ze.vertLeq(n.Dst,s.Dst)){if(Ze.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(n),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Ze.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(n.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o=n.Org,a=s.Org,l=n.Dst,u=s.Dst,c,h,d=new Xh,f,p;if(nt(!Ze.vertEq(u,l)),nt(Ze.edgeSign(l,t.event,o)<=0),nt(Ze.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(Ze.vertLeq(o,a)){if(Ze.edgeSign(u,o,a)>0)return!1}else if(Ze.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Ze.intersect(l,o,u,a,d),nt(Math.min(o.t,l.t)<=d.t),nt(d.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=d.s),nt(d.s<=Math.max(a.s,o.s)),Ze.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=Ze.vertLeq(o,a)?o:a,Ze.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Ze.vertEq(d,o)||Ze.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!Ze.vertEq(l,t.event)&&Ze.edgeSign(l,t.event,d)>=0||!Ze.vertEq(u,t.event)&&Ze.edgeSign(u,t.event,d)<=0?u===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Lnext,s.Oprev),r=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,s.Onext,n.Rprev,p,!0),!0):(Ze.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Ze.edgeSign(u,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,n),n.Org.s=d.s,n.Org.t=d.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,s;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(s),r=i.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,s=r.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Ze.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Ze.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,r.Onext,s,s,!0);return}Ze.vertLeq(l.Org,a.Org)?n=l.Oprev:n=a,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,s,o,a,l;if(n=e.eUp,Ze.vertEq(n.Org,r)){nt(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Ze.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}nt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(nt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),Ze.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var r,n,s,o,a,l,u=new VS;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,n=i.regionBelow(r),!!n){if(o=r.eUp,a=n.eUp,Ze.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(s=Ze.vertLeq(a.Dst,o.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);nt(n!==null);var s=i.regionBelow(n),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,n,a):i.addRightEdges(t,n,a.Onext,o,o,!0)},i.addSentinel=function(t,e,r,n){var s=new VS,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=n,o.Dst.s=e,o.Dst.t=n,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new F8(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,n,s,o),i.addSentinel(t,n,s,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++r===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,n=e.Lnext,Ze.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,s=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,e=t.pq=new B8(s,Ze.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,s;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,s=r.anEdge,nt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Ze.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),V8=function(){function i(){this.mesh=new dD,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=St.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 i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],n=f[v],c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-n.coords[0],h[1]=e.coords[1]-n.coords[1],h[2]=e.coords[2]-n.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,s=0,o=t.next;o!==t;o=o.next)if(n=o.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,n=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,n[o]=0,n[(o+1)%3]=0,n[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,n);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ze.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(Ze.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Ze.edgeGoesLeft(n.Lnext)||Ze.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=t.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Ze.edgeGoesRight(r.Lprev)||Ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=t.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,s=t.eHead.next;s!==t.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===br.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*n,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var h=u.n*n;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],n>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===br.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){n=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,n=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==n);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new dD),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,s,o){if(t===void 0&&(t=St.ODD),e===void 0&&(e=br.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),k8.computeInterior(this,o);var a=this.mesh;return e===br.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===br.BOUNDARY_CONTOURS?this.outputContours_(a,n):this.outputPolymesh_(a,e,r,n),!0},i}();function Es(i){var t=i.windingRule,e=t===void 0?St.ODD:t,r=i.elementType,n=r===void 0?br.POLYGONS:r,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new V8;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,n,o,l,c,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Dfe=St.ODD,Ife=St.NONZERO,Ofe=St.POSITIVE,Rfe=St.NEGATIVE,Lfe=St.ABS_GEQ_TWO,Nfe=br.POLYGONS,Bfe=br.CONNECTED_POLYGONS,Ffe=br.BOUNDARY_CONTOURS;var wv=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*wv.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*wv.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(n,o*s,3*t);o+=3*t;let l=new Float32Array(n,o*s,3*t);o+=3*t;let u=new Float32Array(n,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=n,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Dp=wv;Dp.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var xD=pn(vD()),Ip={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},jS={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},WS={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},HS=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),ul=class extends Ae{constructor(e,r,n=0,s=12,o=3,a=St.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let P=C.extractShapePointsToFlatArray([],s),D=[];for(let I=P.length-1;I>=1;I-=2){let R=P[I-1],U=P[I-0];D.push(R,U)}return D}),h=[],d=[];for(let C=0;C<u.length;C+=2)d.push([u[C],u[C+1]]);h.push(d);for(let C=0;C<c.length;C++){let P=c[C],D=[];for(let I=0;I<P.length;I+=2)D.push([P[I],P[I+1]]);h.push(D)}let f;e.isText?f=new Tu().setFromPoints(e.points.map(P=>P.position)).getSize(new N).length()*.1:h[0].length===0?f=n:f=(0,xD.default)(h).distance,n<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(n,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=Es({windingRule:a,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=Ip}let m;try{m=Es({windingRule:St.ODD,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=jS}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let C=0;C<m.elements.length;C++){let P=m.elements[C],D=C%2===0?p.vertexCount:0;p.elements.push(P+D)}for(let C=0;C<m.vertexIndices.length;C++){let P=m.vertexIndices[C],D=p.vertexCount;p.vertexIndices.push(P+D)}for(let C=0;C<m.vertices.length;C++){let P=m.vertices[C];p.vertices.push(P)}}let y=1/0,v=-1/0,x=1/0,w=-1/0;for(let C=0,P=p.vertexCount;C<P;C++){let D=C*2,I=p.vertices[D+0],R=p.vertices[D+1];I<y&&(y=I),I>v&&(v=I),R<x&&(x=R),R>w&&(w=R)}this._minX=y,this._minY=x,this._width=v-y,this._height=w-x,this._buffer=new Dp(this._computeBufferEstimatedSize(p));let S=[],A=[];for(let C=p.elementCount-1;C>=0;C--){let P=C>=g,D=C*2,I=p.elements[D+0],R=p.elements[D+1],U=I+R,F={start:I,count:R,normals:[],continuous:[],concave:[]},V=I,G=U-1,H=I+1,Y=this._shape.roundedCurves.length;do{let z=V-I,J=p.vertices[G*2+0],Z=p.vertices[G*2+1],K=p.vertices[V*2+0],W=p.vertices[V*2+1],ye=p.vertices[H*2+0],fe=p.vertices[H*2+1],se=K-J,_e=W-Z,xe=Math.sqrt(se*se+_e*_e);se/=xe,_e/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,F.normals[z*2+0]=-Ie,F.normals[z*2+1]=Oe,F.concave[z]=se*Ie-_e*Oe>0;let Me=p.vertexIndices[V];if(Array.isArray(Me))F.continuous[z]=!1;else{let[ze,Ue]=this._shape.getCurveIndexFromVertexId(Me-1,!0);if(Ue>0&&Ue<1)F.continuous[z]=!0;else{let L=Ue===1?ze+1:ze-1;L=(L+Y)%Y;let O=Ue===1?0:1,re=this._shape.roundedCurves[ze].getTangent(Ue),ue=this._shape.roundedCurves[L].getTangent(O);F.continuous[z]=re.dot(ue)>.95}}P&&(F.normals[z*2+0]*=-1,F.normals[z*2+1]*=-1),[G,V,H]=[V,H,H+1],H>=U&&(H-=R)}while(H!==I+1);let k=[];k.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,U*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((z,J)=>[J,J]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,U*2)});let j=0;for(let z=1;z<=this._bevelSegments;z++){let J=z/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(J))*this._bevel,K=[],W=[],ye=[],fe=[],se=0;for(let xe=0;xe<R;xe++){let Oe=xe*2,Ie=(xe-1+R)%R*2,Pe=p.vertices[F.start*2+Oe+0],Me=p.vertices[F.start*2+Oe+1],ze=-F.normals[Ie+0]*Z,Ue=-F.normals[Ie+1]*Z,L=-F.normals[Oe+0]*Z,O=-F.normals[Oe+1]*Z;if(F.concave[xe]||!F.concave[xe]&&P){let re=Math.atan2(Ue,ze),ue=Math.atan2(O,L);ue>re&&(ue-=Math.PI*2);let me=ue-re;if(F.continuous[xe]||P){let De=re+me/2,Te=Math.cos(De)*Z,Ee=Math.sin(De)*Z;K[2*se+0]=Pe+Te*(P?-1:1),K[2*se+1]=Me+Ee*(P?-1:1),fe[se]=xe,se++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Te=0;Te<=De;Te++){let Ee=re+me*(Te/De),le=Math.cos(Ee)*Z,Ke=Math.sin(Ee)*Z;K[2*se+0]=Pe+le,K[2*se+1]=Me+Ke,fe[se]=xe,se++}}}else K[2*se+0]=Pe+ze,K[2*se+1]=Me+Ue,fe[se]=xe,W[xe]=se,se++,K[2*se+0]=Pe,K[2*se+1]=Me,fe[se]=xe,se++,K[2*se+0]=Pe+L,K[2*se+1]=Me+O,fe[se]=xe,ye[xe]=se,se++}let _e=Es({windingRule:St.POSITIVE,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],Me=fe[(Ie+1)%fe.length];xe.idx=[Pe,Me],xe.Sym.idx=[Me,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!_e)throw console.log("Error"),new Error(`error generating bevel geometry for ${z}'th loop`);if(!_e.vertexCount){let xe=(z-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<_e.vertexIndices.length;xe++){let[Oe,Ie]=_e.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie<Oe&&(Pe+=R);for(let Me=Oe;Me<Pe;Me++){let ze=Me%R,Ue=(Me+1)%R;if(!F.continuous[ze]||!F.continuous[Ue]){_e.vertexIndices[xe]=[Oe,ze],_e.vertexIndices.splice(xe+1,0,[Ue,Ie]),_e.vertices.splice((xe+1)*2,0,_e.vertices[xe*2],_e.vertices[xe*2+1]);break}}}k.push({bevelI:z,angle:J,size:Z,boundary:_e,reverseMap:fe,insetPoints:K})}let X=(z,J,Z)=>{let K=0,W=z.boundary.vertexIndices.length;for(;K<W&&Z(z.boundary.vertexIndices[J]);)J=(J+1)%W,K++;return K},q=S.length;for(let z=1;z<k.length;z++){let J=k[z-1],Z=k[z],K=J.boundary.vertexIndices.length,W=Z.boundary.vertexIndices.length;if(!K||!W)break;let ye=F.concave.length,fe=0,se=HS(fe,R);for(;!J.boundary.vertexIndices.filter(se).length||!Z.boundary.vertexIndices.filter(se).length;)fe++,se=HS(fe,R);let _e=J.boundary.vertexIndices.findIndex(se),xe=Z.boundary.vertexIndices.findIndex(se);do _e=(_e+1)%K;while(se(J.boundary.vertexIndices[_e]));do xe=(xe+1)%W;while(se(Z.boundary.vertexIndices[xe]));fe=(fe+1)%R;let Oe=fe,Ie=0,Pe=this._buildBevelVert(F,J,(_e-1+K)%K,void 0,Ie),Me=this._buildBevelVert(F,Z,(xe-1+W)%W,void 0,Ie),ze=Pe,Ue=Me,L,O,re=!1;do{Ie=(fe||ye)/ye,se=HS(fe,R);let ue=X(J,_e,se),me=X(Z,xe,se),De=re;if(re=!1,ue&&!me){for(let Te=0;Te<ue;Te++)L=this._buildBevelVert(F,J,(_e+Te)%K,Te/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L;re=!0}else if(!ue&&me)for(let Te=0;Te<me;Te++)O=this._buildBevelVert(F,Z,(xe+Te)%W,Te/(me-1),Ie),S.push(Ue.topN,ze.topP,O.topP),l===!1&&S.push(ze.bottomP,Ue.bottomN,O.bottomP),Ue=O;else if(ue&&me)if(L=this._buildBevelVert(F,J,_e,0,Ie),O=this._buildBevelVert(F,Z,xe,0,Ie),De?(S.push(ze.topN,O.topP,Ue.topN),S.push(ze.topN,L.topP,O.topP),l===!1&&(S.push(O.bottomP,ze.bottomN,Ue.bottomN),S.push(O.bottomP,L.bottomP,ze.bottomN))):(S.push(Ue.topN,ze.topN,L.topP),S.push(Ue.topN,L.topP,O.topP),l===!1&&(S.push(L.bottomP,ze.bottomN,Ue.bottomN),S.push(L.bottomP,Ue.bottomN,O.bottomP))),ze=L,Ue=O,ue===me)for(let Te=1;Te<ue;Te++)L=this._buildBevelVert(F,J,(_e+Te)%K,Te/(ue-1),Ie),O=this._buildBevelVert(F,Z,(xe+Te)%W,Te/(me-1),Ie),S.push(ze.topN,L.topP,Ue.topN),S.push(Ue.topN,L.topP,O.topP),l===!1&&(S.push(L.bottomP,ze.bottomN,Ue.bottomN),S.push(L.bottomP,Ue.bottomN,O.bottomP)),ze=L,Ue=O;else if(ue>me){let Te=ue/me,Ee=0;for(let le=1;le<ue;le++)L=this._buildBevelVert(F,J,(_e+le)%K,le/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L,le>(Ee+1)*Te&&(Ee++,O=this._buildBevelVert(F,Z,(xe+Ee)%W,Ee/(me-1),Ie),S.push(Ue.topN,L.topP,O.topP),l===!1&&S.push(L.bottomP,Ue.bottomN,O.bottomP),Ue=O)}else{let Te=me/ue,Ee=0;for(let le=1;le<me;le++)O=this._buildBevelVert(F,Z,(xe+le)%W,le/(me-1),Ie),S.push(Ue.topN,L.topP,O.topP),l===!1&&S.push(L.bottomP,Ue.bottomN,O.bottomP),Ue=O,le>(Ee+1)*Te&&(Ee++,L=this._buildBevelVert(F,J,(_e+Ee)%K,Ee/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L)}_e=(_e+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(k,F,S),P){let z=[];for(let J=S.length-1;J>=q+2;J-=3){let Z=S[J-2],K=S[J-1],W=S[J-0];z.push(W,K,Z)}S.splice(q,S.length-q,...z)}if(P){let z=[];for(let J=k[k.length-1].boundary.vertices.length-1;J>=1;J-=2){let Z=k[k.length-1].boundary.vertices[J-1],K=k[k.length-1].boundary.vertices[J-0];z.push(Z,K)}A.push(z)}if(!P){let z=k[k.length-1],J;try{J=Es({windingRule:k.length>1?St.POSITIVE:St.ODD,elementType:br.POLYGONS,vertexSize:2,strict:!0,contours:[z.insetPoints,...A]})}catch{J=WS}if(!J)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<J.elementCount*3;Z+=3){let K=this._buildSurfaceVert(J,J.elements[Z+0],j),W=this._buildSurfaceVert(J,J.elements[Z+1],j),ye=this._buildSurfaceVert(J,J.elements[Z+2],j);S.push(K.top,W.top,ye.top),l===!1&&S.push(ye.bottom,W.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let E=new Ge(Uint32Array.from(S),1),b=new Ge(this._buffer.positions,3),M=new Ge(this._buffer.normals,3),T=new Ge(this._buffer.uvs,2);b.needsUpdate=!0,M.needsUpdate=!0,T.needsUpdate=!0,E.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",M),this.setAttribute("uv",T),this.setIndex(E)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),u=this._buildBevelVert(r,s,(o+1)%a);n.push(u.topP,l.topN,l.bottomN),n.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,n){let s=r.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],l=(o-this._minX)/this._width,u=(a-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),h=c*3,d=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-n,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=u,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=n,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=u),this.vertexCache[s]=f,f}_buildBevelVert(e,r,n,s=1,o){let a=`${r.bevelI}:${n}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,u]=r.boundary.vertexIndices[n],c,h,d,f;l!==u?(h=l,c=u,f=!1,d=e.continuous[h]&&e.continuous[c]):(c=l,h=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,d=e.continuous[c]||f);let p=Math.cos(r.angle),m=Math.sin(r.angle),g=n*2,y=c*2,v=h*2,x=r.boundary.vertices[g+0],w=r.boundary.vertices[g+1],S=(1-m)*this._bevel,A=(x-this._minX)/this._width,E=(w-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),E=1);let b=e.normals[y+0],M=e.normals[y+1],T=e.normals[v+0],C=e.normals[v+1];if(f){let U=T-b,F=C-M;b=b+U*(1-s),M=M+F*(1-s);let V=Math.sqrt(b*b+M*M);b/=V,M/=V}let P=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),D=P*3,I=P*2,R={i:n,fi:c,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1,pathBevelUCoord:o};return this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=b*p,this._buffer.normals[D+1]=M*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=b*p,this._buffer.normals[D+4]=M*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A),d||(this.forPathBevel?(P+=1,D+=3,I+=2):(P+=2,D+=6,I+=4),R.topP=P+0,R.bottomP=P+1,this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=T*p,this._buffer.normals[D+1]=C*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=T*p,this._buffer.normals[D+4]=C*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A)),this.vertexCache[a]=R,R}clone(){let e=new ul(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var Qh=class extends Ae{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=St.ODD;this.elementType=br.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:St.ODD,elementType:br.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),h!==void 0&&v!==h&&(u=!1),c=y,h=v,!l&&!u)break}if(!l&&!u)try{a=Es({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Ip}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let w=0,S=d;w<S;w++){let A=w*2,E=a.vertices[A+0],b=a.vertices[A+1];E<p&&(p=E),E>m&&(m=E),b<g&&(g=b),b>y&&(y=b)}let v=m-p,x=y-g;for(let w=0,S=d;w<S;w++){let A=w*2,E=a.vertices[A+0],b=a.vertices[A+1],M=(E-p)/v,T=(b-g)/x;this._positionAttribute.setXYZ(w,E,b,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,M,T)}for(let w=0,S=f;w<S;w++){let A=w*3,E=a.elements[A+0],b=a.elements[A+1],M=a.elements[A+2];this._indexAttribute.setX(A+0,E),this._indexAttribute.setX(A+1,b),this._indexAttribute.setX(A+2,M)}}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 Qh(this._shape,this._curveSegments);return e.userData=Zo(this.userData),e}};var Kh=class extends ul{constructor(e,r,n=0,s=12,o=3,a=St.ODD){super(e,r,n,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),u=this._buildBevelVert(r,s,(o+1)%a);n.push(u.topP,l.topN,l.bottomN),n.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Kh(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var yi=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:St.ODD},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Ot?(o.width!==r||o.height!==n)&&o.applySize(r,n):o=new Ot(r,n).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Ot(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new Qh(i.shape,n,{windingRule:o}):a=new Kh(i.shape,t,e,n,r,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var wD=Math.PI*2,Jh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Se.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,h=e*.5,d=j8(u,c,h,n*Math.PI/180,r,s);u.isClosed=!0,u.update();let f;return n===0?(f=new Ae,f.setAttribute("position",new be([],3))):f=yi.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function j8(i,t,e,r,n,s){if(r>=wD)return n>30||n%4===0?(q8(i,t,e,s),Math.round(n/4)):bD(i,r,n,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=hD({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%u.length===0?W8(i,o.x,o.y,u,n,t,e,s):bD(i,r,n,t,e,s)}function W8(i,t,e,r,n,s,o,a){let l=Math.round(n/r.length);i.addPoint(Zh(t,e));for(let u=0,c=r.length;u<c;u++){let h=r[u],d=i.points[u],f=Zh(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),i.addPoint(f)}return a>0?SD(i,s,o,a):i.addPoint(Zh(0,0)),l}function bD(i,t,e,r,n,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*r,c=Math.cos(l)*n;i.addPoint(Zh(u,c))}return t<wD?s>0?SD(i,r,n,s):i.addPoint(Zh(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&AD(i,r,n,s)),1}function q8(i,t,e,r=0,n=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Av(n-t,s,n-t,s-l,n-t,s+l)),i.addPoint(Av(n,s+e,n-a,s+e,n+a,s+e)),i.addPoint(Av(n+t,s,n+t,s+l,n+t,s-l)),i.addPoint(Av(n,s-e,n+a,s-e,n-a,s-e)),r>0&&AD(i,t,e,r)}function Zh(i,t){return new _s(Se.generateUUID(),new N(i,t))}function Av(i,t,e,r,n,s){let o=Zh(i,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(n,s),o}function SD(i,t,e,r){_D(i,t,e,r).forEach(s=>i.addPoint(s))}function AD(i,t,e,r){let n=_D(i,t,e,r),s=new Ot;n.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function _D(i,t,e,r){let n=r*t/100,s=n*(Math.abs(e)/Math.abs(t)),o=new N(n/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Se.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var ED=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:n,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=i.parameters,d=new Op(!1,t,e,r,n,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},qS=new Ws([0,0,0],1),Op=class extends Ae{constructor(t=!0,e=1,r=1,n=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new _,m=new _,g=p(),y=p(),v=p(),x,w,S,A,E,b,M,T,C=p(),P=p(),D=p(),I=p(),R=p(),U=p(),F=p(),V=p(),G=r-2*l+.001,H=G/o,Y=Math.ceil(a*o),k=Y+1,j=G/Y,X=-G/2,q=c+1,z=2*Math.PI/c,J=Math.PI/2/d,Z=.01,K=Math.min((1-h/100)*l,l-Z),W=l-K,ye=0,fe=2,se=d*fe+fe,_e=q*se/fe,xe=_e+q*k,Oe=Math.max(0,q*(k+se)),[Ie,Pe,Me]=[3,3,2].map(ke=>Array(Oe*ke).fill(0)),ze=[],Ue=s-l;function L(ke,Ne){let We=Math.PI/2;b=Ne*j,T=2*Math.PI*(b%H)/H+We,b+=X,M=Math.sin(T)*Ue,E=Math.cos(T)*Ue,t?ke.set(E,M,b):ke.set(E,b,M)}L(m,-1e-10),L(g,0),C.copy(m),L(m,1);let O=m.distanceTo(g),re=f?0:W+K,ue=O*Y+2*re,me=K,De=ue-re;for(let ke=0;ke<=Y;ke++){L(y,ke),V.subVectors(y,C).normalize(),C.copy(y),U.copy(y).setComponent(+t+1,0).normalize(),F.crossVectors(V,U).normalize();let Ne=ke===0,We=ke===Y,$e=Ne?3*Math.PI/2:J,_t=Ne?me:De,ir=Ne?q:xe,Gr=Ne?0:Oe-q,Q=V.clone().multiplyScalar(Ne?-W:W).add(y),ce=V.clone().multiplyScalar(Ne?-1:1).normalize();for(let ve=0;ve<q;ve++){let Ve=ve*z;if(P.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Ve)),g.copy(F).multiplyScalar(l*Math.sin(Ve))),D.copy(P).normalize(),Ne||We){f||(ye=Gr+ve,[0,1,2].forEach(Fe=>{Ie[ye*3+Fe]=Q.getComponent(Fe),Pe[ye*3+Fe]=ce.getComponent(Fe)}),Me[ye*2]=+We,Me[ye*2+1]=ve/c),g.copy(D).multiplyScalar(K),v.addVectors(y,g);for(let Fe=0;Fe<d;Fe++){let Et=Fe*J+$e;I.addVectors(m.copy(V).multiplyScalar(W*Math.sin(Et)),g.copy(D).multiplyScalar(W*Math.cos(Et))),R.copy(I).normalize(),g.addVectors(v,I),I.normalize(),ye=ir+Fe*q+ve,[0,1,2].forEach(Pr=>{Ie[ye*3+Pr]=g.getComponent(Pr),Pe[ye*3+Pr]=R.getComponent(Pr)});let Hr=+Ne+Math.sin(Et);Me[ye*2]=(_t+W*Hr)/ue,Me[ye*2+1]=ve/c}}g.addVectors(y,P),ye=_e+ke*q+ve,[0,1,2].forEach(Fe=>{Ie[ye*3+Fe]=g.getComponent(Fe),Pe[ye*3+Fe]=D.getComponent(Fe)}),Me[ye*2]=(re+ke*O)/ue,Me[ye*2+1]=ve/c}}let Te=k+2*d+fe,Ee=1,[le,Ke]=[+f,Te-1];for(let ke=le;ke<=Ke-1;ke++){let Ne=f&&ke===Ke-1;for(let We=0;We<q-1;We++)x=ke*q+We,w=x+1,S=(Ne?We:x)+q,A=(Ne?We+1:w)+q,ke===0?ze.push(w,A,S):ke===Te-2?ze.push(x,w,S):ze.push(x,w,S,w,A,S)}this.setIndex(ze),this.setAttribute("position",new be(Ie,3)),this.setAttribute("normal",new be(Pe,3)),this.setAttribute("uv",new be(Me,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,n=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,h=c===e;for(let d=0;d<t.radialSegments;d++)s=c*r+d,o=s+1,a=(h?d:s)+r,l=(h?d+1:o)+r,n[u++]=s,n[u++]=o,n[u++]=a,n[u++]=o,n[u++]=l,n[u++]=a;return n.length=u,qS.array=n,qS.count=n.length,qS}};var MD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new Rp(t*.5,s,o):new yu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},Rp=class extends al{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,r),this.type=a}static fromJSON(t){return new Rp(t.radius,t.corner,t.cornerSides)}};var TD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=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}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new Wo;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new du(n.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var ao=new ie,YS=new gt,_v=new _,hl=class extends Yt{constructor(){super(),this.uuid=Se.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(t){let e=new Gt().getNormalMatrix(t);for(let r=0,n=this.vertices.length;r<n;r++)this.vertices[r].applyMatrix4(t);for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return ao.makeRotationX(t),this.applyMatrix4(ao),this}rotateY(t){return ao.makeRotationY(t),this.applyMatrix4(ao),this}rotateZ(t){return ao.makeRotationZ(t),this.applyMatrix4(ao),this}translate(t,e,r){return ao.makeTranslation(t,e,r),this.applyMatrix4(ao),this}scale(t,e,r){return ao.makeScale(t,e,r),this.applyMatrix4(ao),this}lookAt(t){return YS.lookAt(t),YS.updateMatrix(),this.applyMatrix4(YS.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,n=t.attributes;if(n.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=n.position,o=n.normal,a=n.color,l=n.uv,u=n.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new _().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new Re().fromBufferAttribute(a,d));function c(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new _().fromBufferAttribute(o,d),new _().fromBufferAttribute(o,f),new _().fromBufferAttribute(o,p)],v=new $h(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new N().fromBufferAttribute(l,d),new N().fromBufferAttribute(l,f),new N().fromBufferAttribute(l,p)]),u!==void 0&&e.faceVertexUvs[1].push([new N().fromBufferAttribute(u,d),new N().fromBufferAttribute(u,f),new N().fromBufferAttribute(u,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)r!==void 0?c(r.getX(g),r.getX(g+1),r.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)c(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_v).negate(),this.translate(_v.x,_v.y,_v.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,n=new ie;return n.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(n),this}computeFaceNormals(){let t=new _,e=new _;for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,n=this.vertices.length;r<n;r++)e[r]=new _;if(t){let r=new _,n=new _;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];r.subVectors(c,u),n.subVectors(l,u),r.cross(n),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let r=0,n=this.vertices.length;r<n;r++)e[r].normalize();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],n=r.vertexNormals;n.length===3?(n[0].copy(r.normal),n[1].copy(r.normal),n[2].copy(r.normal)):(n[0]=r.normal.clone(),n[1]=r.normal.clone(),n[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]);for(let s=0,o=n.vertexNormals.length;s<o;s++)n.__originalVertexNormals[s]?n.__originalVertexNormals[s].copy(n.vertexNormals[s]):n.__originalVertexNormals[s]=n.vertexNormals[s].clone()}let t=new hl;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new _,c={a:new _,b:new _,c:new _};s.push(u),o.push(c)}}let n=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=n.faceNormals[s],u=n.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Pt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fr),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let n,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,h=t.colors;e!==void 0&&(n=new Gt().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let p=u[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new $h(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),n!==void 0&&x.normal.applyMatrix3(n).normalize();for(let w=0,S=y.length;w<S;w++)m=y[w].clone(),n!==void 0&&m.applyMatrix3(n).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let w=0,S=v.length;w<S;w++)g=v[w],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,w=y.length;x<w;x++)v.push(y[x].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],n=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[h]===void 0?(e[h]=l,r.push(this.vertices[l]),n[l]=r.length-1):n[l]=n[e[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=n[c.a],c.b=n[c.b],c.c=n[c.c];let h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let n=t[e];this.vertices.push(new _(n.x,n.y,n.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,u){return l.materialIndex-u.materialIndex}t.sort(r);let n=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;n&&n.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(n[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let r=[],n=[],s={},o=[],a={},l=[],u={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,w=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,E=0;if(E=c(E,0,0),E=c(E,1,g),E=c(E,2,y),E=c(E,3,v),E=c(E,4,x),E=c(E,5,w),E=c(E,6,S),E=c(E,7,A),r.push(E),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let b=this.faceVertexUvs[0][p];r.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&r.push(h(m.normal)),w){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(S&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function c(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=n.length/3,n.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(p.x,p.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=n,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new hl().copy(this)}copy(t){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=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let n=t.faces;for(let d=0,f=n.length;d<f;d++)this.faces.push(n[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,w=y.length;x<w;x++){let S=y[x];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=t.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new XS().fromGeometry(this),e=new Ae,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Ev.call(new Ge(r,3),t.vertices)),t.normals.length>0){let n=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ev.call(new Ge(n,3),t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);e.setAttribute("color",CD.call(new Ge(n,3),t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);e.setAttribute("uv",PD.call(new Ge(n,2),t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",PD.call(new Ge(n,2),t.uvs2))}e.groups=t.groups;for(let n in t.morphTargets){let s=[],o=t.morphTargets[n];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new be(u.data.length*3,3);c.name=u.name,s.push(Ev.call(c,u.data))}e.morphAttributes[n]=s}if(t.skinIndices.length>0){let n=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",DD.call(n,t.skinIndices))}if(t.skinWeights.length>0){let n=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",DD.call(n,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ae,r=t.geometry;if(t.isPoints||t.isLine){let n=new be(r.vertices.length*3,3),s=new be(r.colors.length*3,3);if(e.setAttribute("position",Ev.call(n,r.vertices)),e.setAttribute("color",CD.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new be(r.lineDistances.length,1);e.setAttribute("lineDistance",Y8.call(o,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};hl.prototype.isGeometry=!0;var XS=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(t){let e=[],r,n,s,o=t.faces;for(n=0;n<o.length;n++){let a=o[n];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=n*3-r.start,e.push(r)),r={start:n*3,materialIndex:s})}r!==void 0&&(r.count=n*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,n=t.faceVertexUvs,s=n[0]&&n[0].length>0,o=n[1]&&n[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,h=c.length,d;if(h>0){d=[];for(let y=0;y<h;y++)d[y]={name:c[y].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,m=f.length===r.length,g=p.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(r[v.a],r[v.b],r[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=n[0][y];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new N,new N,new N))}if(o===!0){let S=n[1][y];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new N,new N,new N))}for(let S=0;S<l;S++){let A=a[S].vertices;u[S].data.push(A[v.a],A[v.b],A[v.c])}for(let S=0;S<h;S++){let A=c[S].vertexNormals[y];d[S].data.push(A.a,A.b,A.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},$h=class{constructor(t,e,r,n,s,o=0){this.a=t,this.b=e,this.c=r,this.normal=n&&n.isVector3?n:new _,this.vertexNormals=Array.isArray(n)?n:[],this.color=s&&s.isColor?s:new Re,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function Y8(i){return this.array.set(i),this}function CD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new Re),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function PD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new N),t[e++]=s.x,t[e++]=s.y}return this}function Ev(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new _),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function DD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Xe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var X8=["a","b","c"];function Q8(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function QS(i,t,e){let r=Math.min(i,t),n=Math.max(i,t),s=r+"_"+n;return e.get(s)}function KS(i,t,e,r,n,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(r.has(l))u=r.get(l);else{let c=e[o],h=e[a];u={a:c,b:h,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(n),s[i].edges.push(u),s[t].edges.push(u)}function K8(i,t,e,r){let n,s,o;for(n=0,s=i.length;n<s;n++)e[n]={edges:[]};for(n=0,s=t.length;n<s;n++)o=t[n],KS(o.a,o.b,i,r,o,e),KS(o.b,o.c,i,r,o,e),KS(o.c,o.a,i,r,o,e)}function Mv(i,t,e,r,n){i.push(new $h(t,e,r,void 0,void 0,n))}function ed(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Tv(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Cv=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ae?t=new hl().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new _,r,n,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;K8(l,u,d,f);let p=[],m,g,y,v,x,w,S;for(let Z of Array.from(f.keys())){for(g=f.get(Z),y=new _,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(m=l[Q8(v,X8[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(w),y.add(e),g.newEdge=p.length,p.push(y)}let A,E,b,M,T,C,P,D=[];for(n=0,s=l.length;n<s;n++){for(C=l[n],T=d[n].edges,r=T.length,r==3?A=3/16:r>3&&(A=3/(8*r)),E=1-r*Number(A),b=A,r<=2&&(r==2?(E=3/4,b=1/8):r==1||r==0),P=C.clone().multiplyScalar(E),e.set(0,0,0),o=0;o<r;o++)M=T[o],m=M.a!==C?M.a:M.b,e.add(m);e.multiplyScalar(Number(b)),P.add(e),D.push(P)}let I=D.concat(p),R=D.length,U,F,V,G=[],H=[],Y,k,j,X,q=new N,z=new N,J=new N;for(n=0,s=u.length;n<s;n++)v=u[n],U=Number(QS(v.a,v.b,f).newEdge)+R,F=Number(QS(v.b,v.c,f).newEdge)+R,V=Number(QS(v.c,v.a,f).newEdge)+R,Mv(G,U,F,V,v.materialIndex),Mv(G,v.a,U,V,v.materialIndex),Mv(G,v.b,F,U,v.materialIndex),Mv(G,v.c,V,F,v.materialIndex),h&&(Y=c[n],k=Y[0],j=Y[1],X=Y[2],q.set(ed(k.x,j.x),ed(k.y,j.y)),z.set(ed(j.x,X.x),ed(j.y,X.y)),J.set(ed(k.x,X.x),ed(k.y,X.y)),Tv(H,q,z,J),Tv(H,k,q,J),Tv(H,j,z,q),Tv(H,X,J,z));t.vertices=I,t.faces=G,h&&(t.faceVertexUvs[0]=H)}};var ln=new _,ID=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ae().copy(new yn(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(ln),r={width:ln.x,height:ln.y,depth:ln.z,subdivisions:0}):r=t.parameters;let n={...r,...i.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,s=i.geometry??new Ae().copy(new yn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(ln)):ln.set(o.width,o.height,o.depth),(t!==ln.x||e!==ln.y||r!==ln.z)&&s.scale(ln.x===0?1:t/ln.x,ln.y===0?1:e/ln.y,ln.z===0?1:r/ln.z);let a=s.originalGeometry;try{n>0?(a===void 0||o?.subdivisions!==n)&&(a===void 0&&(a=s),s=new Cv(n).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Eu(e).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(ln);let o=100/ln.x;Object.assign(s.parameters,{width:100,height:ln.y*o,depth:ln.z*o}),t(this.build(s))})}};var Pv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,h=0,d=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let g=f*m,y=h+Math.sin(g)*u,v=d+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=n;l.roundness=n,l.update();let p=yi.create({shape:l,parameters:{roundness:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var OD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new JS(t*.5,e,n,s,o,a,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function Lp(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function ZS(i,t,e,r,n,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===n){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,r/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,n/Math.sin(u)),s.addScaledVector(a,r/Math.sin(u))}}function Z8(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var JS=class extends Ae{constructor(t=.5,e=1,r=4,n=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),a=Math.floor(a);let l=[],u=[],c=[],h=[],d=0,f=e/2,p=Math.PI/r,m=t*Math.cos(Math.PI/r),g=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,x=new _(0,-f,0),w=new _(0,f,0),S=new N(t,-f),A=new N(m,-f),E=new N(0,w.y).sub(A),b=new N(0,w.y).sub(S),M=new N(E.y,-E.x).normalize(),T=new N(b.y,-b.x).normalize(),P=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;o=Math.min(o,P);let D;{let H=new _(M.x,M.y,0),Y=new _(Math.cos(g)*H.x,H.y,Math.sin(g)*H.x);D=H.angleTo(Y)}let I=o/Math.tan((Math.PI-E.angle())/2),R=o/Math.tan((Math.PI-D)/2),U=new _;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),h.push(0,0);let H=d++,Y=[],k=S.clone(),j=I/Math.cos(Math.PI/r);k.x-=j;for(let X=0;X<r;X++){let q=X/r*Math.PI*2+p,z=new N(Math.sin(q),Math.cos(q));Lp(k,z,U),u.push(U.x,U.y,U.z),c.push(0,-1,0),h.push(0,0),Y.push(d++)}for(let X=0;X<Y.length;X++)l.push(Y[X],H,Y[(X+1)%Y.length])}let F=[];{let H=new _,Y=new _,k=new _,j=new _,X=new _,q=new _;for(let z=0;z<r;z++){let J=z/r*Math.PI*2+p,Z=(z+.5)/r*Math.PI*2+p,K=(z+1)/r*Math.PI*2+p,W=new N(Math.sin(J),Math.cos(J)),ye=new N(Math.sin(Z),Math.cos(Z)),fe=new N(Math.sin(K),Math.cos(K));Lp(S,W,Y),Lp(S,fe,k),Lp(M,ye,H),ZS(w,Y,k,R,R,j),u.push(j.x,j.y,j.z),ZS(Y,w,k,R,I,X),u.push(X.x,X.y,X.z),ZS(k,Y,w,I,R,q),u.push(q.x,q.y,q.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),h.push(0,0),h.push(0,0),h.push(0,0);let se=d++,_e=d++,xe=d++;if(l.push(se,_e,xe),o>0){{let Pe=Y.clone().add(k).multiplyScalar(.5),Me=w.clone().sub(Pe).normalize(),Ue=x.clone().sub(Pe).normalize().add(Me).normalize().multiplyScalar(-1),L=q.clone().sub(X);V(Pe,L,Ue,E.angle())}let Oe,Ie;{let Pe=new _;Lp(T,fe,Pe);let Me=q.clone().add(j).multiplyScalar(.5);Me=Z8(Me,k,w);let ze=q.clone().sub(j);[Oe,Ie]=V(Me,ze,Pe,D,j.y)}{let Pe=Oe,Me=Pe.clone().setY(0).normalize(),ze=new _(0,-1,0),Ue=Me.clone().cross(ze);G(Pe,Me,ze,Ue)}F.concat(Ie);{let Pe=E.angle(),Me=Math.PI-Pe,ze=w.clone();ze.y-=o/Math.sin(Pe-Math.PI/2);let Ue=new _,L=[];for(let re=0;re<a;re++){let ue=[],me=Math.PI/2-Me*re/a,De=Math.cos(me),Te=Math.sin(me),Ee=Z;for(let le=0;le<=re;le++){let Ke=Math.cos(Ee),ke=Math.sin(Ee);H.x=De*ke,H.y=Te,H.z=De*Ke,Ue.copy(ze).addScaledVector(H,o),u.push(Ue.x,Ue.y,Ue.z),c.push(H.x,H.y,H.z),h.push(0,0),ue.push(d++),Ee+=Math.PI*2/re/r}L.push(ue)}Ie.reverse(),L.push(Ie);let O=L.length-1;for(let re=0;re<O;re++){let ue=L[re],me=L[re+1],De=ue.length-1;l.push(me[1],ue[0],me[0]);for(let Te=1;Te<=De;Te++)l.push(ue[Te],ue[Te-1],me[Te]),l.push(me[Te+1],ue[Te],me[Te])}}}}}this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(h,2));function V(H,Y,k,j,X){let q=-j/2,z=(Math.PI-j)/2,J=Y.clone().normalize().cross(k);H.addScaledVector(k,-o/Math.sin(z));let Z=new _,K=new _,W=1,ye=d,fe=[];for(let se=0;se<=a;se++){let _e=q+se/a*j;K.set(0,0,0),K.addScaledVector(J,Math.sin(_e)),K.addScaledVector(k,Math.cos(_e));for(let xe=0;xe<=W;xe++){let Oe=xe/W-.5;if(Z.copy(H),Z.addScaledVector(Y,Oe),Z.addScaledVector(K,o),X!=null){let Ie=Math.max(0,Z.y-X);Z.addScaledVector(Y,-Ie/Y.y)}u.push(Z.x,Z.y,Z.z),c.push(K.x,K.y,K.z),h.push(0,0),xe===0&&fe.push(d),d++}}for(let se=0;se<a;se++)for(let _e=0;_e<W;_e++){let xe=ye+_e+(W+1)*se,Oe=xe+(W+1),Ie=Oe+1,Pe=xe+1;l.push(xe,Oe,Pe),l.push(Oe,Ie,Pe)}return[H.clone().addScaledVector(Y,.5),fe]}function G(H,Y,k,j){let X=Math.PI/2,q=b.angle()-X,z=[],J=new _,Z=new _;for(let W=0;W<=a;W++){let ye=[],fe=W/a;for(let se=0;se<=W;se++){let xe=((W?se/W:0)-.5)*v,Oe=Math.cos(xe),Ie=Math.sin(xe),Pe=Math.atan(Math.tan(q)*Oe),Me=(X+Pe)*fe,ze=Math.cos(Me),Ue=Math.sin(Me);J.set(0,0,0),J.addScaledVector(Y,Ue*Oe),J.addScaledVector(k,ze),J.addScaledVector(j,Ue*Ie),Z.copy(H).addScaledVector(J,o),u.push(Z.x,Z.y,Z.z),c.push(J.x,J.y,J.z),h.push(0,0),ye.push(d++)}z.push(ye)}let K=z.length-1;for(let W=0;W<K;W++){let ye=z[W],fe=z[W+1],se=ye.length-1;l.push(ye[0],fe[1],fe[0]);for(let _e=1;_e<=se;_e++)l.push(ye[_e-1],ye[_e],fe[_e]),l.push(ye[_e],fe[_e+1],fe[_e])}}}};var Dv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function d(w,S,A){return S>e&&A>r?Math.min(w*e/S,w*r/A):S>e?w*e/S:A>r?w*r/A:w}let f=[];f[0]=n[0]===0?0:d(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:d(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:d(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:d(n[3],n[3]+n[0],n[3]+n[2]);let p=c.x,m=h.x,g=h.y,y=c.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let w=0,S=t.points.length;w<S;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=yi.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var RD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ae,c.setAttribute("position",new be([],3))):c=new Kl(.5*t,n,s,o,a,l,u*Se.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var LD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new jo(t,e,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var ND=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:s,cornerSegments:o}=i.parameters,a=new $S(t,e,r,n,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},$S=class extends Ae{constructor(t=1,e=1,r=1,n=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),n=Math.min(180-c,n),n*=Math.PI/180;let h=[],d=Math.PI/2,f=(Z=0,K=0,W=0)=>new _(Z,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,w=+y,[S,A,E]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(Z,K=!1)=>Math.sin(Z-Math.PI/(1+ +K)),M=(Z,K=!1)=>Math.cos(Z-Math.PI/(1+ +K));E.y=Math.sin(n)*e-g;let T=Math.cos(n)*e-v,C=S.z-c;n<=d?(E.z=Math.min(T,C),E.z==C&&(E.y-=(T-C)/Math.tan(d-n))):A.z=Math.min(A.z-T-v,S.z-c),p.subVectors(S,A),m.subVectors(E,A);let P=Math.min(p.length(),m.length())*s/100,D=P*Math.tan(n/2),I=P/Math.cos(n/2),R=p.clone().normalize().add(m.normalize()).setLength(I).add(A);p.set(0,b(n,!0),M(n,!0)),h.push([E,p.clone()]);let U=(Math.PI-n)/o;for(let Z=0;Z<=o;Z++){let K=d+n+Z*U;p.set(0,Math.sin(K)*D,Math.cos(K)*D),p.add(R),m.set(0,b(K),M(K)),h.push([p.clone(),m.clone()])}h.push([S,f(0,1,0)]);let F=Math.sin(U/2)*D*2,V=h.length-1,G=h[0][0].distanceTo(h[1][0]),H=h[V-1][0].distanceTo(h[V][0]),Y=G+F*o+H;h[0].push(1);for(let Z=0;Z<=o;Z++)h[Z+1].push(1-(G+Z*F)/Y);h[V].push(0);let[k,j,X]=h[0],q,z,J;for(let Z=1;Z<h.length;Z++)[q,z,J]=h[Z],a.push(x,k.y,k.z,x,q.y,q.z,w,k.y,k.z,w,k.y,k.z,x,q.y,q.z,w,q.y,q.z),l.push(0,j.y,j.z,0,z.y,z.z,0,j.y,j.z,0,j.y,j.z,0,z.y,z.z,0,z.y,z.z),u.push(0,X,0,J,1,X,1,X,0,J,1,J),[k,j,X]=[q,z,J];this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(l,3)),this.setAttribute("uv",new be(u,2))}};var Iv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,h=t*.5,d=e*.5,f=0,p=0,m=o*Math.PI/360/n,g=Math.PI/2*3*-1,y=h*r/100,v=d*r/100;if(n===3&&r===50){m=2*Math.PI/n;for(let w=0;w<n;w++){let S=m*w,A=f+Math.sin(S)*h,E=p+Math.cos(S)*d;c.addPoint(c.createPoint(A,E))}}else for(let w=0;w<n;w++){let S=f+Math.cos(g)*h,A=p+Math.sin(g)*d;c.addPoint(c.createPoint(S,A)),g+=m,S=f+Math.cos(g)*y,A=p+Math.sin(g)*v,w<=n,c.addPoint(c.createPoint(S,A)),g+=m}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let x=yi.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var BD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new jo(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var FD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:n,depth:s})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=J8(t,e,r,t*.5,o,s,0,0,n,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function J8(i,t,e,r,n,s,o,a,l,u,c){[t,e]=[e,t],o=t/2;let h=Se.clamp(n/360,0,1);if(h===0){let d=new Ae;return d.setAttribute("position",new be([],3)),d}return h===1&&(u=0),new Op(!0,i,t,e,r,h,s,o,a,l,u,c)}var kD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new vu(a,e,r,n,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var VD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=yi.create({shape:l,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...i,type:"TriangleGeometry"}})}};function zD(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var eA=class{add(t,e,r){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(n){this[n]=this[n]||[],e&&this[n][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},tA=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ae=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ae.version}static addUnaryOp(t){return ae.max_unop_len=Math.max(t.length,ae.max_unop_len),ae.unary_ops[t]=1,ae}static addBinaryOp(t,e,r){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,r?ae.right_associative.add(t):ae.right_associative.delete(t),ae}static addIdentifierChar(t){return ae.additional_identifier_chars.add(t),ae}static addLiteral(t,e){return ae.literals[t]=e,ae}static removeUnaryOp(t){return delete ae.unary_ops[t],t.length===ae.max_unop_len&&(ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops)),ae}static removeAllUnaryOps(){return ae.unary_ops={},ae.max_unop_len=0,ae}static removeIdentifierChar(t){return ae.additional_identifier_chars.delete(t),ae}static removeBinaryOp(t){return delete ae.binary_ops[t],t.length===ae.max_binop_len&&(ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops)),ae.right_associative.delete(t),ae}static removeAllBinaryOps(){return ae.binary_ops={},ae.max_binop_len=0,ae}static removeLiteral(t){return delete ae.literals[t],ae}static removeAllLiterals(){return ae.literals={},ae}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new ae(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return ae.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ae.binary_ops[String.fromCharCode(t)]||ae.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ae.isIdentifierStart(t)||ae.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(ae.hooks[t]){let r={context:this,node:e};return ae.hooks.run(t,r),r.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ae.SPACE_CODE||t===ae.TAB_CODE||t===ae.LF_CODE||t===ae.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:ae.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,n;for(;this.index<this.expr.length;)if(r=this.code,r===ae.SEMCOL_CODE||r===ae.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())e.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,ae.max_binop_len),e=t.length;for(;e>0;){if(ae.binary_ops.hasOwnProperty(t)&&(!ae.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,n,s,o,a,l,u;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:ae.binaryPrecedence(e),right_a:ae.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),n=[o,s,a];e=this.gobbleBinaryOp();){if(r=ae.binaryPrecedence(e),r===0){this.index-=e.length;break}s={value:e,prec:r,right_a:ae.right_associative.has(e)},u=e;let c=h=>s.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;n.length>2&&c(n[n.length-2]);)a=n.pop(),e=n.pop().value,o=n.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),n.push(s,t)}for(l=n.length-1,t=n[l];l>1;)t={type:ae.BINARY_EXP,operator:n[l-1].value,left:n[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)n=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),r=e.length;r>0;){if(ae.unary_ops.hasOwnProperty(e)&&(!ae.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ae.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--r)}ae.isIdentifierStart(t)?(n=this.gobbleIdentifier(),ae.literals.hasOwnProperty(n.name)?n={type:ae.LITERAL,value:ae.literals[n.name],raw:n.name}:n.name===ae.this_str&&(n={type:ae.THIS_EXP})):t===ae.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===ae.PERIOD_CODE||e===ae.OBRACK_CODE||e===ae.OPAREN_CODE||e===ae.QUMARK_CODE;){let r;if(e===ae.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ae.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===ae.OBRACK_CODE?(t={type:ae.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==ae.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===ae.OPAREN_CODE?t={type:ae.CALL_EXP,arguments:this.gobbleArguments(ae.CPAREN_CODE),callee:t}:(e===ae.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:ae.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===ae.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,ae.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===ae.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===ae.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ae.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===r){n=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
3153
3153
  `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return n||this.throwError('Unclosed quote after "'+t+'"'),{type:ae.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(ae.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,ae.isIdentifierPart(t));)this.index++;return{type:ae.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){r=!0,this.index++,t===ae.CPAREN_CODE&&n&&n>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===ae.COMMA_CODE){if(this.index++,n++,n!==e.length){if(t===ae.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ae.CBRACK_CODE)for(let o=e.length;o<n;o++)e.push(null)}}else if(e.length!==n&&n!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===ae.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return r||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(ae.CPAREN_CODE);if(this.code===ae.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:ae.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ae.ARRAY_EXP,elements:this.gobbleArguments(ae.CBRACK_CODE)}}},$8=new eA;Object.assign(ae,{hooks:$8,plugins:new tA(ae),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"});ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops);ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops);var mc=i=>new ae(i).parse(),eq=Object.getOwnPropertyNames(ae);eq.forEach(i=>{mc[i]===void 0&&i!=="prototype"&&(mc[i]=ae[i])});mc.Jsep=ae;var tq="ConditionalExpression",rq={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let r=e.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:tq,test:r,consequent:n,alternate:s},r.operator&&i.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&i.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};mc.plugins.register(rq);var nq=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],iq=["0","1","2","3","4","5","6","7","8","9","."],sq=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function oq(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}mc.addBinaryOp("^",11,!0);function Ov(i,t,e="number"){let r="";for(let o=0;o<i.length;o++){let a=i[o];if("id"in a){let l=i[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",i);return}let u=t.getVariable(a.id),c=En.getDisplayedValue(u);e==="number"&&En.isTextValue(u)&&Array.isArray(u.textValue)&&u.textValue.length===1?c=parseFloat(c).toString():e==="boolean"&&En.isBoolean(u)?c=u?"true":"false":e==="boolean"&&En.isTextValue(u)&&!Array.isArray(u.textValue)&&(c='"'+c+'"'),r+=c;continue}else if(e==="string"){a.name!=='"'&&a.name!=="+"&&(r+=a.name),a.name==="+"&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+a.name);continue}if(a.name==="and"){r+="&&";continue}if(a.name==="or"){r+="||";continue}if(a.name==="True"){r+="true";continue}if(a.name==="False"){r+="false";continue}if(e==="boolean"&&!oq(a.name)&&!iq.includes(a.name)&&!nq.includes(a.name)&&!sq.includes(a.name.replace(/\($/g,""))){r+='"'+a.name+'"';continue}r+=a.name}if(e==="string")return r;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let n;try{n=mc(r)}catch(o){console.error(r,o);return}let s;try{s=Dt(n)}catch(o){console.error(r,n,o)}return s}function Dt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(Dt(i.left)===Dt(i.right));case"!=":return Number(Dt(i.left)!==Dt(i.right));case">":return Number(Dt(i.left)>Dt(i.right));case">=":return Number(Dt(i.left)>=Dt(i.right));case"<":return Number(Dt(i.left)<Dt(i.right));case"<=":return Number(Dt(i.left)<=Dt(i.right));case"+":return Dt(i.left)+Dt(i.right);case"-":return Dt(i.left)-Dt(i.right);case"*":return Dt(i.left)*Dt(i.right);case"/":return Dt(i.left)/Dt(i.right);case"%":return Dt(i.left)%Dt(i.right);case"&&":return Dt(i.left)&&Dt(i.right);case"||":return Dt(i.left)||Dt(i.right);case"^":return Math.pow(Dt(i.left),Dt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-Dt(i.argument);case"!":return Number(!Dt(i.argument));default:throw new Error("Unknown operator: "+i.operator)}case"Identifier":throw new Error("Unknown identifier: "+i.name);case"Literal":return i.value;case"CallExpression":if(i.callee.type==="Identifier"){if(i.callee.name==="random"){let t=0,e=1;if(i.arguments.length>=1)try{t=Dt(i.arguments[0])}catch(r){console.warn(r)}if(i.arguments.length>=2)try{e=Dt(i.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[i.callee.name].apply(null,i.arguments.map(Dt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var aq=new ie,lq=new ie;function cq(i,t,e){let r=[new _,new _,new _],n=[new _,new _,new _];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((s,o)=>{let a=n[o],l=Se.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ie().makeBasis(r[0],r[1],r[2])}var UD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Jh.create({parameters:Zw}).userData.shape;return{path:i.path??gh.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:s,extrusion:{...Xy,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new rA(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ae,{userData:{...i,type:"PathGeometry"}})}},rA=class extends Ae{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)||!zD(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:n,offset:s}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,1)),s=Math.max(0,Math.min(s,1));let o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((n+s)*o):Math.ceil(Math.min(1,n+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],h=[];for(let G=0;G<u;G++){let H=this.inputs.path.isClosed?(G+a)%e.length:Math.min(G+a,e.length-1);c.push(e[H].clone()),h.push(r[H].clone())}let d=(G,H,Y)=>{c[G]=c[G].clone().lerp(c[H],Y),h[G]=cq(h[G],h[H],Y)},f=0,p=s*o%1;(!this.inputs.path.isClosed||n<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+n)*o%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&s+n<1)&&g&&(m=g,d(c.length-1,c.length-2,1-m)),n===0){let G=c.length-1;c[G].copy(c[0]),h[G].copy(h[0])}this._applyPathModifiers(h,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:A,vertices:E}=this._computeShapePoints(w),b=0,M;x==="round"&&(M=new ul(this.inputs.shapeData,2*y,y,w,v,void 0,!0),b=M.getAttribute("position").count);let T=0,C=0;A.sort((G,H)=>G.start-H.start),A.forEach(G=>{G.verticesStart=T,G.verticesCount=G.continuous.reduce((H,Y,k)=>H+(k===0||!Y?2:1),0),C+=G.verticesCount,T=C});let P=C*u,D,I=0;if(this._isOpenEnded()&&x==="flat"){try{D=Es({windingRule:St.ODD,elementType:br.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{D=WS}I=D.vertexCount}let R=P+2*I+b*2,U=P+2*I,F={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},V=[];if(A.forEach(G=>{this._extrudeRegion(G,E,h,c,F,V,this._isGeometryClosed()&&!this._isOpenEnded())}),D&&(this._closeEnd(D,P,V,F,h[0],c[0],!1),this._closeEnd(D,P+I,V,F,h[h.length-1],c[c.length-1],!0)),M){F.positions.set(M.getAttribute("position").array,U*3),F.normals.set(M.getAttribute("normal").array,U*3),F.uvs.set(M.getAttribute("uv").array,U*2);let G=V.length;V.push(...M.getIndex().array.map(k=>k+U)),U+=b,F.positions.set(M.getAttribute("position").array,U*3),F.normals.set(M.getAttribute("normal").array,U*3),F.uvs.set(M.getAttribute("uv").array,U*2);let H=V.length;V.push(...M.getIndex().array.map(k=>k+U)),this.setAttribute("position",new Ge(F.positions,3)),this.setAttribute("normal",new Ge(F.normals,3)),this.setAttribute("uv",new Ge(F.uvs,2)),this.setIndex(V);let Y=aq;Y.copy(h[h.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(Y,U,R),Y.copy(h[0]).setPosition(c[0]).multiply(lq.makeScale(1,1,-1)),this.applyMatrix4OnRange(Y,U-b,U),this.reverseIndicesOnRange(G,H)}else this.setAttribute("position",new Ge(F.positions,3)),this.setAttribute("normal",new Ge(F.normals,3)),this.setAttribute("uv",new Ge(F.uvs,2)),this.setIndex(V)}_extractPathPoints(){let r=yv(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let n=[r[0]];return r.forEach(o=>{n[n.length-1].distanceToSquared(o)>.001&&n.push(o)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],n=e.length,s=this.inputs.path.isClosed,o=new _,a=new _,l=new _,u=new _,c=new _(0,1,0);for(let g=0;g<n;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===n-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let w=y.clone().sub(v).normalize(),S=x.clone().sub(y).normalize(),A=w.clone().add(S).normalize();l.copy(A),g===0&&(A.equals(c)||A.clone().negate().equals(c))&&c.set(0,0,1);let E=c.clone().cross(A).normalize(),b=A.clone().cross(E).normalize();c.copy(b),u.copy(E),g===0&&(o.copy(b),a.copy(A));let M=new ie().makeBasis(E,b,A);r.push(M)}let h=s?a:l,d=s?o:new _(0,1,0),f=h.clone().cross(u).normalize(),p=Math.acos(d.dot(f));if(isNaN(p))return r;let m=d.clone().cross(f);h.dot(m)>0&&(p*=-1);for(let g=1;g<r.length;g++){let y=new ie().makeRotationZ(p*g/r.length);r[g].multiply(y)}return r}_applyPathModifiers(e,r,n){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new ie,h=new ie;return e.forEach((d,f)=>{let p=f===0?0:f===s-1?1:(f-r)/(s-(n===0?0:1)-(r+(1-n)));c.makeRotationZ(Se.lerp(o,o+a,p)*Se.DEG2RAD);let m=Se.lerp(l,u,p);h.makeScale(m,m,m),d.multiply(c).multiply(h)}),e}_computeShapePoints(e=12,r=St.ODD){let n=this.inputs.shapeData,s=n.extractShapePointsToFlatArray([],e),o=n.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],w=g[v-0];y.push(x,w)}return y}),a;try{a=Es({windingRule:r,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Ip}let l;try{l=Es({windingRule:St.ODD,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=jS}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let g=l.elements[m],y=m%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let m=0;m<l.vertexIndices.length;m++){let g=l.vertexIndices[m],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let m=0;m<l.vertices.length;m++){let g=l.vertices[m];a.vertices.push(g)}}let c=1/0,h=-1/0,d=1/0,f=-1/0;for(let m=0,g=a.vertexCount;m<g;m++){let y=m*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>h&&(h=v),x<d&&(d=x),x>f&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=u,y=m*2,v=a.elements[y+0],x=a.elements[y+1],w=v+x,S={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(S);let A=v,E=w-1,b=v+1,M=n.roundedCurves.length;do{let T=A-v,C=a.vertices[E*2+0],P=a.vertices[E*2+1],D=a.vertices[A*2+0],I=a.vertices[A*2+1],R=a.vertices[b*2+0],U=a.vertices[b*2+1],F=D-C,V=I-P,G=Math.sqrt(F*F+V*V);F/=G,V/=G;let H=D-R,Y=I-U,k=Math.sqrt(H*H+Y*Y);H/=k,Y/=k,S.normals[T*2+0]=-Y,S.normals[T*2+1]=H;let j=a.vertexIndices[A];if(Array.isArray(j))S.continuous[T]=!1;else{let[X,q]=n.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)S.continuous[T]=!0;else{let z=q===1?X+1:X-1;z=(z+M)%M;let J=q===1?0:1,Z=n.roundedCurves[X].getTangent(q),K=n.roundedCurves[z].getTangent(J);S.continuous[T]=Z.dot(K)>.95}}g&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[E,A,b]=[A,b,b+1],b>=w&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,r,n,s,o){let a=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,r,n,s,o,a,l){let u=new _,c=new _,h=new _,d=new _,f=new N;n.forEach((m,g)=>{let y=s[g],v=e.verticesStart*n.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let w=(e.start+x)*2;if(u.set(r[w+0],r[w+1],0),h.copy(u).applyMatrix4(m).add(y),e.continuous[x])d.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let S=x===0?(e.start+e.count-1)*2:w-2;c.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(x===0?1:x/e.count,g/(n.length-1)),this._insertVertex(o,v,h,d,f),v++,!e.continuous[x]||x===0){if(x===0)d.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(n.length-1));else{let S=x===e.count-1?e.start*2:w+2;c.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(o,v,h,d,f),v++}}});let p=n.length-1;for(let m=0;m<p;m++){let g=e.verticesStart*n.length+e.verticesCount*m,y=e.verticesStart*n.length+e.verticesCount*(m+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let w=x===e.count-1?0:v+1,S=g+v,A=g+w,E=y+w,b=y+v;e.isHole?a.push(S,E,A,S,b,E):a.push(S,A,E,S,E,b),v++}}}_closeEnd(e,r,n,s,o,a,l){let u=e.vertexCount,c=new _(0,0,l?-1:1).applyMatrix4(o),h=new _,d=new N;for(let p=0;p<u;p++){let m=2*p;h.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(o).add(a),this._insertVertex(s,r+p,h,c,d)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let m=3*p,g=f[m+0]+r,y=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;n.push(g,y,v)}}applyMatrix4OnRange(e,r,n){let s=e.elements,o=new Gt().getNormalMatrix(e).elements,a,l,u,c,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,p=d.array,m=h.itemSize;for(let g=r*m,y=n*m;g<y;g+=m){if(g===r)debugger;a=f[g+0],l=f[g+1],u=f[g+2],c=1/(s[3]*a+s[7]*l+s[11]*u+s[15]),f[g+0]=(s[0]*a+s[4]*l+s[8]*u+s[12])*c,f[g+1]=(s[1]*a+s[5]*l+s[9]*u+s[13])*c,f[g+2]=(s[2]*a+s[6]*l+s[10]*u+s[14])*c,a=p[g+0],l=p[g+1],u=p[g+2],p[g+0]=o[0]*a+o[3]*l+o[6]*u,p[g+1]=o[1]*a+o[4]*l+o[7]*u,p[g+2]=o[2]*a+o[5]*l+o[8]*u}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let n=this.index;if(n){for(let s=e;s<r;s+=3){let o=n.getX(s),a=n.getX(s+1),l=n.getX(s+2);n.setXYZ(s,l,a,o)}n.needsUpdate=!0}}};function GD(){let i=new Ae;return i.setAttribute("position",new Ge(new Float32Array([]),3)),i.setIndex(new Ge(new Uint16Array([]),1)),i}var uq=GD().attributes,hq=12,dq=1,td=class extends Ae{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,uq),this.userData={parameters:e,type:"TextGeometry"};let n=r.getFont(e.font);n?.isLoaded?(this.font=n,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let n=r.getFont(e);n&&(this.font=n,await n.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,h=En.getDisplayedValue(u),d=c===2?h.toUpperCase():c===3?h.toLowerCase():h,f=fq(e,r,d),{shapes:p,charWidths:m,charCoords:g}=r.generateShapes(f,e),y=(typeof n=="number"?n:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(A=>new Ot().fromShape(A,!0));this.vectorShapes=x;let w=x.map(A=>yi.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?St.NONZERO:St.ODD,subdivisions:this.isLowResolution&&o>0?dq:hq}})),S=w.length?ws(w):GD();S.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([A,E])=>{this.setAttribute(A,E)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=ui(new Ae,td.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,n])=>{this.setAttribute(r,n)}),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 fq(i,t,e){let r=[""],n="";for(let s of e)n+=s,s===" "||s===`
3154
3154
  `?(r[r.length-1]+=n,n="",s===`
3155
- `&&r.push("")):t.getTextWidth(r[r.length-1]+n,i)>i.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+n,i)>i.width&&(n.length===1?(r[r.length-1]+=n,n=""):(r[r.length-1]+=n.slice(0,-1),n=n[n.length-1],r.push(""))));return r[r.length-1]+=n,r}var jD,rd=new Promise(i=>{jD=i}),HD=!1;var Rv;function WD(){if(HD)return;if(Rv)return Rv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.517/build",n=import("./process.js"),[s,o]=await Promise.all([n,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});jD(l),HD=!0}return Rv=i(),Rv}function gc(i,t,e,r){let n,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let u of o){let c=s;for(let h of u)c=c[h];for(n in c){let h=c[n];$P(h)&&(c[n]=t.getVariable(h,[r.uuid,"geometry",...u,n]))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Ot.createFromState(s.shape,s.width,s.height);a.shape=u}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),a.geometry=new Eu().parse(s);else if(s.type==="SubdivGeometry"){let u=new Fr(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new td(s,t);let l;try{l=nA(a)}catch(u){console.error(u)}if(!l){let u=Ot.createFromState(mh.defaultData(),100,100);a.shape=u,l=nA(a)}return l}var pq=new ie;function Np(i,t,e,r){let n=i.position.array,s=i.normal.array,o=pq.makeScale(t,e,r).invert().elements,a,l,u;for(var c=0,h=n.length;c<h;c+=3)n[c]*=t,n[c+1]*=e,n[c+2]*=r,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Lv=new Pt,nd=new _,tt;rd.then(i=>{tt=i});var qD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),YD=new Uint32Array([0,1,2,3]),XD=new Uint8Array([4]),Fr=class extends Ae{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked,s=$s.div(r,n);this.subdividedGeometry&&Np(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Np(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(nd.fromArray(s));let a=nd.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Fr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new yn(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Lv.setFromBufferAttribute(r),Lv.getCenter(n),e.boundingSphere.radius=n.distanceTo(Lv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lv.getSize(nd);let s={width:nd.x,height:nd.y,depth:nd.z};return this.userData.parameters=s,s}static build(e,r,n,s){let o,a,l,u=e?.phongAngle??35;n===!1&&(u=-1),r&&(tt.free_bvh(r),tt.free_subdivision_surface(r));try{o=Fr.allocate(e,s)}catch(c){console.error(c,e),o=Fr.allocate({positionWASM:qD,indexWASM:YD,verticesPerFaceWASM:XD},s)}if(tt.set_destination_refinement_level(o,0),a=Fr.buildLevel(o,!0,u),e.subdivisions>0)try{tt.set_destination_refinement_level(o,e.subdivisions),l=Fr.buildLevel(o,!1,u)}catch{try{tt.set_destination_refinement_level(o,e.subdivisions-1),l=Fr.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,n){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 s=e.shape!==void 0||e.path!==void 0?r.geometry:gc(e,n,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=yc(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:u}=aA(a,c,s,h),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,r){let n,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(n=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(n=qD,s=YD,o=XD);let u=n.length,c=s.length,h=o.length,d=n.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=tt._malloc(p),v=new Float32Array(tt.HEAPF32.buffer,y,d),x=new Uint32Array(tt.HEAPU32.buffer,y+m,f);v.set(n,0),v.set(a,n.length),v.set(l,n.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(A=>A!==1)&&(w=new ie().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let S=w?tt.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,w.elements):tt.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return tt._free(y),S}static buildLevel(e,r,n,s,o){let a=o?tt.get_mesh_data2(e,r?tt.Level.CONTROL:tt.Level.REFINED,n,o.elements):tt.get_mesh_data(e,r?tt.Level.CONTROL:tt.Level.REFINED,n),l=8,u=tt.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),h=0,d=tt.HEAPU32[u[h]>>2],f=tt.HEAPF32.subarray(d>>2,(d>>2)+c[h]);h++;let p=tt.HEAPU32[u[h]>>2],m=tt.HEAPF32.subarray(p>>2,(p>>2)+c[h]);h++;let g=tt.HEAPU32[u[h]>>2],y=tt.HEAPU32.subarray(g>>2,(g>>2)+c[h]);h++;let v=tt.HEAPU32[u[h]>>2],x=tt.HEAPU32.subarray(v>>2,(v>>2)+c[h]);if(h++,s===void 0){let w=new Ae;if(w.setIndex(new Ws(x,1)),w.setAttribute("position",new be(f,3)),w.setAttribute("normal",new be(m,3)),r){w.setAttribute("faceMap",new Ws(y,1));let S=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Ge(S,4))}return tt.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,tt.free_mesh_data(a)}static freeSubdivPointer(e){tt.free_bvh(e),tt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let s=tt.get_wireframe_data_for_base_level(e),o=4,a=tt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=tt.HEAPU32[a[u]>>2],h=tt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=tt.HEAPU32[a[u]>>2],f=tt.HEAPU32.subarray(d>>2,(d>>2)+l[u]);if(r===void 0){let p=new Ae;p.setAttribute("position",new be(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=n.r,m[g++]=n.g,m[g++]=n.b;return p.setAttribute("color",new Ge(m,3)),p.setIndex(new Ws(f,1)),tt.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,tt.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,n){let s=r===0;s||tt.set_destination_refinement_level(e,r);let o=n?tt.get_topological_data2(e,s?tt.Level.CONTROL:tt.Level.REFINED,n.elements):tt.get_topological_data(e,s?tt.Level.CONTROL:tt.Level.REFINED),a=6,l=tt.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,h=tt.HEAPU32[l[c]>>2],d=new Float32Array(tt.HEAPF32.subarray(h>>2,(h>>2)+u[c]));c++;let f=tt.HEAPU32[l[c]>>2],p=new Uint32Array(tt.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=tt.HEAPU32[l[c]>>2],g=new Uint8Array(tt.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return tt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var QD=["getX","getY","getZ"];function yc(i,t){let e={},r=t?t.count:i.count,n=0,s=[],o=[],a=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,h="";for(let d=0;d<3;d++)h+=`${~~(i[QD[d]](c)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(i[QD[d]](c));e[h]=n,s.push(n),n++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Nv=new _,iA=new _,sA=new _,oA=new _;function aA(i,t,e,r){let n=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let h=0;if(c<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),n.push(h++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),n.push(h++);return s.push(h),{indices:n,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[a]*3+2]===o||i[t[a]*3+2]===0)&&l++,(i[t[a+1]*3+2]===o||i[t[a+1]*3+2]===0)&&l++,(i[t[a+2]*3+2]===o||i[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Nv.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),iA.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),sA.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),oA.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),iA.sub(Nv).normalize(),sA.sub(Nv).normalize(),oA.sub(Nv).normalize();let l=iA.cross(sA).dot(oA);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:a>=r[c]&&a<r[c+1])?(n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(n.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let h=0,d=0;h<i.length;h+=3,d++)i[h+2]===0&&(l.push(d),c++),i[h+2]===o&&u.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=u[0];u[0]=u[1],u[1]=h}l.reverse(),n.push(...l,...u),s.push(c,c)}return{indices:n,verticesPerFace:s}}var Ji={};b_(Ji,{calcBoolean:()=>yq,calcBooleanTopological:()=>gq,freeMeshSet:()=>wq,getMeshSet:()=>vq,hasOpenEdges:()=>xq,transformMeshSet:()=>bq});var KD,ZD=new Promise(i=>{KD=i});var Bv;function JD(){if(Bv)return Bv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.517/build",n=import("./boolean.js"),[s,o]=await Promise.all([n,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});KD(l)}return Bv=i(),Bv}var ft,id;ZD.then(i=>ft=i);function mq(i,t,e){let r,n;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?n=i.getClosedTorusIndicesForBooleanOrSubdiv():n=i.getIndex();let{positions:s,triIndices:o}=yc(i.getAttribute("position"),n),a;if(t&&e){let{indices:l,verticesPerFace:u}=aA(s,o,i);a=u.length,r=[];for(let c=0,h=0;c<a;c++){r.push(u[c]);for(let d=0;d<u[c];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let u=0,c=0;c<r.length;)r[c++]=3,a++,r[c++]=o[u++],r[c++]=o[u++],r[c++]=o[u++]}return{positions:s,faceIndices:r,nFaces:a}}function $D(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,n=Number.isInteger(i[0])?e:r,s=ft._malloc(n);return(Number.isInteger(i[0])?new Uint32Array(ft.HEAPU32.buffer,s,t):new Float32Array(ft.HEAPF32.buffer,s,t)).set(i,0),s}function eI(i){switch(i){case 0:return ft.OP.UNION;case 1:return ft.OP.INTERSECTION;case 2:return ft.OP.A_MINUS_B;case 3:return ft.OP.B_MINUS_A;case 4:return ft.OP.SYMMETRIC_DIFFERENCE;case 5:return ft.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function gq(i,t){id===void 0&&(id=ft.init_csg());let e=$D(i),r=ft.csg_calc_topological(id,e,i.length,eI(t));ft._free(e);let n=6,s=ft.HEAPU32.subarray(r>>2,(r>>2)+n),o=s.subarray(3,3+3),a=0,l=ft.HEAPU32[s[a]>>2],u=new Float32Array(ft.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ft.HEAPU32[s[a]>>2],h=new Uint32Array(ft.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=ft.HEAPU32[s[a]>>2],f=new Uint8Array(ft.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return ft.free_mesh_data(r),{positions:u,indices:h,verticesPerFace:f}}function yq(i,t,e,r){id===void 0&&(id=ft.init_csg());let n=$D(i),s=ft.csg_calc(id,n,i.length,r,eI(t));ft._free(n);let o=5,a=ft.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ft.HEAPU32[a[u]>>2],h=ft.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=ft.HEAPU32[a[u]>>2],f=ft.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(h,3)),e.setAttribute("normal",new be(f,3));let m=ft.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new fr),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ft.free_mesh_data(s),p}function vq(i,t,e){if(ft===void 0)return-1;let r,n,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,r=g.positions,n=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){n[x++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)n[x++]=g.indices[v++]}}else({positions:r,faceIndices:n,nFaces:s}=mq(i,t,e));let o=r.length,a=n.length,l=r.length,u=n.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=ft._malloc(c),p=new Float32Array(ft.HEAPF32.buffer,f,l),m=new Uint32Array(ft.HEAPU32.buffer,f+h,u);return p.set(r,0),m.set(n,0),ft.get_csg_mesh(f,o,f+h,a,s)}function xq(i){return ft.has_open_edges(i)}function bq(i,t){try{ft.transform_csg_mesh(i,t.elements)}catch(e){console.error(e)}}function wq(i){ft.free_csg_mesh(i)}var Sq={ConeGeometry:X2,CubeGeometry:Q2,CylinderGeometry:vv,DodecahedronGeometry:K2,EllipseGeometry:Jh,HelixGeometry:ED,IcosahedronGeometry:MD,LatheGeometry:TD,NonParametricGeometry:ID,PolygonGeometry:Pv,PyramidGeometry:OD,RectangleGeometry:Dv,SphereGeometry:RD,PlaneGeometry:LD,BackdropGeometry:ND,StarGeometry:Iv,TextFrameGeometry:BD,TorusGeometry:FD,TorusKnotGeometry:kD,TriangleGeometry:VD,PathGeometry:UD,VectorGeometry:yi},nA=i=>Sq[i.type].create(i);function sd(i){return i!==null&&"booleanOp"in i}var od=class extends jh(_r){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ie}updateVisible(e){super.updateVisible(e),this.visible=!sd(this.parent)&&this.visible,sd(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ji.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),sd(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof od&&(e.freeBooleanPointer(),sd(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let n=super.updateTransformState(e,r);return n&&sd(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}onVariableUpdate(e=!1){super.onVariableUpdate(e),sd(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Fv=new Pt;function Bp(i,t=0,e=i.count,r,n){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h=t;h<e;h++){let d=i.getX(h),f=i.getY(h),p=i.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>u&&(u=f),p>c&&(c=p)}Fv.min.set(s,o,a),Fv.max.set(l,u,c),Fv.getCenter(r),Fv.getSize(n).multiplyScalar(.5)}var Aq=new Ae,_q=new Ho,$t=class extends od{constructor(t,e){super(Aq,_q),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Bp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Fp=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Mn=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Se.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e??this.getType(t,e);let n=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,n,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,n,s,o){return""}generate(t,e,r,n,s){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Mn&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)e=this.hashProperties[n],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var lA=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},cn=new lA;var Ye=class extends Mn{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,n,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=Se.generateUUID()),n=e.getUUID(n??this.getUUID(),!o);let a=e.getNodeData(n),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,n)):super.build(e,r,n);if(o)return a.name=a.name||super.build(e,r,n),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let u=this.getTemp(e,n);if(u)return e.format(u,l,r);{u=super.generate(e,r,n,a.output,s);let c=this.generate(e,l,n);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,n)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,s??this.getType(e),o,this.getLabel()).name}};var jt=class extends Ye{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,n,s,o,a){n=e.getUUID(n??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var wr=class extends jt{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof N?e:new N(e,r)}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,r,n,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var kn=class extends jt{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof _?e:new _(e,r,n)}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,r,n,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var gr=class extends Re{constructor(e,r,n,s){super(e,r,n);this.isColorA=!0;this.a=s}setRGBA(e,r,n,s){super.setRGB(e,r,n),this.a=s}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,r="srgb"){let n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var vi=class extends jt{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,r,n,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var Eq=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,tI=/[a-z_0-9]+/gi,ge=class extends Ye{constructor(e,r,n,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,n,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,n,s,o){let a,l=0,u=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 c=[];for(;a=tI.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&cn.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=cn.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||cn.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+m+u.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&cn.contains(m)&&e.include(cn.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,n,s){if(this.src=e||"",this.includes=r??[],this.extensions=n??{},this.keywords=s??{},this.isMethod){let o=Eq.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(tI);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var Mq=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,cA=class extends Ye{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||cA.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,n,s,o){this.src=e||"";let a,l,u="",c=Mq.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,r){if(r==="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),r)}generate(e,r,n,s,o){return e.format(this.name,this.getType(e),r)}},It=cA;It.PI="PI",It.PI2="PI2",It.RECIPROCAL_PI="RECIPROCAL_PI",It.RECIPROCAL_PI2="RECIPROCAL_PI2",It.LOG2="LOG2",It.EPSILON="EPSILON";var Tq=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3155
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+n,i)>i.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+n,i)>i.width&&(n.length===1?(r[r.length-1]+=n,n=""):(r[r.length-1]+=n.slice(0,-1),n=n[n.length-1],r.push(""))));return r[r.length-1]+=n,r}var jD,rd=new Promise(i=>{jD=i}),HD=!1;var Rv;function WD(){if(HD)return;if(Rv)return Rv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.518/build",n=import("./process.js"),[s,o]=await Promise.all([n,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});jD(l),HD=!0}return Rv=i(),Rv}function gc(i,t,e,r){let n,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let u of o){let c=s;for(let h of u)c=c[h];for(n in c){let h=c[n];$P(h)&&(c[n]=t.getVariable(h,[r.uuid,"geometry",...u,n]))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Ot.createFromState(s.shape,s.width,s.height);a.shape=u}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),a.geometry=new Eu().parse(s);else if(s.type==="SubdivGeometry"){let u=new Fr(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new td(s,t);let l;try{l=nA(a)}catch(u){console.error(u)}if(!l){let u=Ot.createFromState(mh.defaultData(),100,100);a.shape=u,l=nA(a)}return l}var pq=new ie;function Np(i,t,e,r){let n=i.position.array,s=i.normal.array,o=pq.makeScale(t,e,r).invert().elements,a,l,u;for(var c=0,h=n.length;c<h;c+=3)n[c]*=t,n[c+1]*=e,n[c+2]*=r,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Lv=new Pt,nd=new _,tt;rd.then(i=>{tt=i});var qD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),YD=new Uint32Array([0,1,2,3]),XD=new Uint8Array([4]),Fr=class extends Ae{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked,s=$s.div(r,n);this.subdividedGeometry&&Np(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Np(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(nd.fromArray(s));let a=nd.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Fr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new yn(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Lv.setFromBufferAttribute(r),Lv.getCenter(n),e.boundingSphere.radius=n.distanceTo(Lv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lv.getSize(nd);let s={width:nd.x,height:nd.y,depth:nd.z};return this.userData.parameters=s,s}static build(e,r,n,s){let o,a,l,u=e?.phongAngle??35;n===!1&&(u=-1),r&&(tt.free_bvh(r),tt.free_subdivision_surface(r));try{o=Fr.allocate(e,s)}catch(c){console.error(c,e),o=Fr.allocate({positionWASM:qD,indexWASM:YD,verticesPerFaceWASM:XD},s)}if(tt.set_destination_refinement_level(o,0),a=Fr.buildLevel(o,!0,u),e.subdivisions>0)try{tt.set_destination_refinement_level(o,e.subdivisions),l=Fr.buildLevel(o,!1,u)}catch{try{tt.set_destination_refinement_level(o,e.subdivisions-1),l=Fr.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,n){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 s=e.shape!==void 0||e.path!==void 0?r.geometry:gc(e,n,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=yc(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:u}=aA(a,c,s,h),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,r){let n,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(n=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(n=qD,s=YD,o=XD);let u=n.length,c=s.length,h=o.length,d=n.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=tt._malloc(p),v=new Float32Array(tt.HEAPF32.buffer,y,d),x=new Uint32Array(tt.HEAPU32.buffer,y+m,f);v.set(n,0),v.set(a,n.length),v.set(l,n.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(A=>A!==1)&&(w=new ie().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let S=w?tt.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,w.elements):tt.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return tt._free(y),S}static buildLevel(e,r,n,s,o){let a=o?tt.get_mesh_data2(e,r?tt.Level.CONTROL:tt.Level.REFINED,n,o.elements):tt.get_mesh_data(e,r?tt.Level.CONTROL:tt.Level.REFINED,n),l=8,u=tt.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),h=0,d=tt.HEAPU32[u[h]>>2],f=tt.HEAPF32.subarray(d>>2,(d>>2)+c[h]);h++;let p=tt.HEAPU32[u[h]>>2],m=tt.HEAPF32.subarray(p>>2,(p>>2)+c[h]);h++;let g=tt.HEAPU32[u[h]>>2],y=tt.HEAPU32.subarray(g>>2,(g>>2)+c[h]);h++;let v=tt.HEAPU32[u[h]>>2],x=tt.HEAPU32.subarray(v>>2,(v>>2)+c[h]);if(h++,s===void 0){let w=new Ae;if(w.setIndex(new Ws(x,1)),w.setAttribute("position",new be(f,3)),w.setAttribute("normal",new be(m,3)),r){w.setAttribute("faceMap",new Ws(y,1));let S=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Ge(S,4))}return tt.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,tt.free_mesh_data(a)}static freeSubdivPointer(e){tt.free_bvh(e),tt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let s=tt.get_wireframe_data_for_base_level(e),o=4,a=tt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=tt.HEAPU32[a[u]>>2],h=tt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=tt.HEAPU32[a[u]>>2],f=tt.HEAPU32.subarray(d>>2,(d>>2)+l[u]);if(r===void 0){let p=new Ae;p.setAttribute("position",new be(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=n.r,m[g++]=n.g,m[g++]=n.b;return p.setAttribute("color",new Ge(m,3)),p.setIndex(new Ws(f,1)),tt.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,tt.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,n){let s=r===0;s||tt.set_destination_refinement_level(e,r);let o=n?tt.get_topological_data2(e,s?tt.Level.CONTROL:tt.Level.REFINED,n.elements):tt.get_topological_data(e,s?tt.Level.CONTROL:tt.Level.REFINED),a=6,l=tt.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,h=tt.HEAPU32[l[c]>>2],d=new Float32Array(tt.HEAPF32.subarray(h>>2,(h>>2)+u[c]));c++;let f=tt.HEAPU32[l[c]>>2],p=new Uint32Array(tt.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=tt.HEAPU32[l[c]>>2],g=new Uint8Array(tt.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return tt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var QD=["getX","getY","getZ"];function yc(i,t){let e={},r=t?t.count:i.count,n=0,s=[],o=[],a=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,h="";for(let d=0;d<3;d++)h+=`${~~(i[QD[d]](c)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(i[QD[d]](c));e[h]=n,s.push(n),n++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Nv=new _,iA=new _,sA=new _,oA=new _;function aA(i,t,e,r){let n=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let h=0;if(c<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),n.push(h++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),n.push(h++);return s.push(h),{indices:n,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[a]*3+2]===o||i[t[a]*3+2]===0)&&l++,(i[t[a+1]*3+2]===o||i[t[a+1]*3+2]===0)&&l++,(i[t[a+2]*3+2]===o||i[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Nv.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),iA.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),sA.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),oA.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),iA.sub(Nv).normalize(),sA.sub(Nv).normalize(),oA.sub(Nv).normalize();let l=iA.cross(sA).dot(oA);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:a>=r[c]&&a<r[c+1])?(n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(n.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let h=0,d=0;h<i.length;h+=3,d++)i[h+2]===0&&(l.push(d),c++),i[h+2]===o&&u.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=u[0];u[0]=u[1],u[1]=h}l.reverse(),n.push(...l,...u),s.push(c,c)}return{indices:n,verticesPerFace:s}}var Ji={};b_(Ji,{calcBoolean:()=>yq,calcBooleanTopological:()=>gq,freeMeshSet:()=>wq,getMeshSet:()=>vq,hasOpenEdges:()=>xq,transformMeshSet:()=>bq});var KD,ZD=new Promise(i=>{KD=i});var Bv;function JD(){if(Bv)return Bv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.518/build",n=import("./boolean.js"),[s,o]=await Promise.all([n,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});KD(l)}return Bv=i(),Bv}var ft,id;ZD.then(i=>ft=i);function mq(i,t,e){let r,n;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?n=i.getClosedTorusIndicesForBooleanOrSubdiv():n=i.getIndex();let{positions:s,triIndices:o}=yc(i.getAttribute("position"),n),a;if(t&&e){let{indices:l,verticesPerFace:u}=aA(s,o,i);a=u.length,r=[];for(let c=0,h=0;c<a;c++){r.push(u[c]);for(let d=0;d<u[c];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let u=0,c=0;c<r.length;)r[c++]=3,a++,r[c++]=o[u++],r[c++]=o[u++],r[c++]=o[u++]}return{positions:s,faceIndices:r,nFaces:a}}function $D(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,n=Number.isInteger(i[0])?e:r,s=ft._malloc(n);return(Number.isInteger(i[0])?new Uint32Array(ft.HEAPU32.buffer,s,t):new Float32Array(ft.HEAPF32.buffer,s,t)).set(i,0),s}function eI(i){switch(i){case 0:return ft.OP.UNION;case 1:return ft.OP.INTERSECTION;case 2:return ft.OP.A_MINUS_B;case 3:return ft.OP.B_MINUS_A;case 4:return ft.OP.SYMMETRIC_DIFFERENCE;case 5:return ft.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function gq(i,t){id===void 0&&(id=ft.init_csg());let e=$D(i),r=ft.csg_calc_topological(id,e,i.length,eI(t));ft._free(e);let n=6,s=ft.HEAPU32.subarray(r>>2,(r>>2)+n),o=s.subarray(3,3+3),a=0,l=ft.HEAPU32[s[a]>>2],u=new Float32Array(ft.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ft.HEAPU32[s[a]>>2],h=new Uint32Array(ft.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=ft.HEAPU32[s[a]>>2],f=new Uint8Array(ft.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return ft.free_mesh_data(r),{positions:u,indices:h,verticesPerFace:f}}function yq(i,t,e,r){id===void 0&&(id=ft.init_csg());let n=$D(i),s=ft.csg_calc(id,n,i.length,r,eI(t));ft._free(n);let o=5,a=ft.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ft.HEAPU32[a[u]>>2],h=ft.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=ft.HEAPU32[a[u]>>2],f=ft.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(h,3)),e.setAttribute("normal",new be(f,3));let m=ft.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new fr),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ft.free_mesh_data(s),p}function vq(i,t,e){if(ft===void 0)return-1;let r,n,s;if(t&&i.userData.positions!==void 0){let y=i.userData;s=y.verticesPerFace.length,r=y.positions,n=Array(y.verticesPerFace.reduce((v,x)=>v+x,0)+s);for(let v=0,x=0,w=0;v<y.verticesPerFace.length;v++){n[w++]=y.verticesPerFace[v];for(let S=0;S<y.verticesPerFace[v];S++)n[w++]=y.indices[x++]}}else({positions:r,faceIndices:n,nFaces:s}=mq(i,t,e));let o=r.length,a=n.length,l=r.length,u=n.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=ft._malloc(c),p=new Float32Array(ft.HEAPF32.buffer,f,l),m=new Uint32Array(ft.HEAPU32.buffer,f+h,u);p.set(r,0),m.set(n,0);let g=ft.get_csg_mesh(f,o,f+h,a,s);return ft._free(f),g}function xq(i){return ft.has_open_edges(i)}function bq(i,t){ft.transform_csg_mesh(i,t.elements)}function wq(i){ft.free_csg_mesh(i)}var Sq={ConeGeometry:X2,CubeGeometry:Q2,CylinderGeometry:vv,DodecahedronGeometry:K2,EllipseGeometry:Jh,HelixGeometry:ED,IcosahedronGeometry:MD,LatheGeometry:TD,NonParametricGeometry:ID,PolygonGeometry:Pv,PyramidGeometry:OD,RectangleGeometry:Dv,SphereGeometry:RD,PlaneGeometry:LD,BackdropGeometry:ND,StarGeometry:Iv,TextFrameGeometry:BD,TorusGeometry:FD,TorusKnotGeometry:kD,TriangleGeometry:VD,PathGeometry:UD,VectorGeometry:yi},nA=i=>Sq[i.type].create(i);function sd(i){return i!==null&&"booleanOp"in i}var od=class extends jh(_r){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ie}updateVisible(e){super.updateVisible(e),this.visible=!sd(this.parent)&&this.visible,sd(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ji.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),sd(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof od&&(e.freeBooleanPointer(),sd(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let n=super.updateTransformState(e,r);return n&&sd(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}onVariableUpdate(e=!1){super.onVariableUpdate(e),sd(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Fv=new Pt;function Bp(i,t=0,e=i.count,r,n){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h=t;h<e;h++){let d=i.getX(h),f=i.getY(h),p=i.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>u&&(u=f),p>c&&(c=p)}Fv.min.set(s,o,a),Fv.max.set(l,u,c),Fv.getCenter(r),Fv.getSize(n).multiplyScalar(.5)}var Aq=new Ae,_q=new Ho,$t=class extends od{constructor(t,e){super(Aq,_q),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Bp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Fp=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Mn=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Se.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e??this.getType(t,e);let n=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,n,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,n,s,o){return""}generate(t,e,r,n,s){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Mn&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)e=this.hashProperties[n],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var lA=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},cn=new lA;var Ye=class extends Mn{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,n,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=Se.generateUUID()),n=e.getUUID(n??this.getUUID(),!o);let a=e.getNodeData(n),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,n)):super.build(e,r,n);if(o)return a.name=a.name||super.build(e,r,n),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let u=this.getTemp(e,n);if(u)return e.format(u,l,r);{u=super.generate(e,r,n,a.output,s);let c=this.generate(e,l,n);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,n)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,s??this.getType(e),o,this.getLabel()).name}};var jt=class extends Ye{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,n,s,o,a){n=e.getUUID(n??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var wr=class extends jt{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof N?e:new N(e,r)}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,r,n,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var kn=class extends jt{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof _?e:new _(e,r,n)}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,r,n,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var gr=class extends Re{constructor(e,r,n,s){super(e,r,n);this.isColorA=!0;this.a=s}setRGBA(e,r,n,s){super.setRGB(e,r,n),this.a=s}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,r="srgb"){let n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var vi=class extends jt{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,r,n,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var Eq=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,tI=/[a-z_0-9]+/gi,ge=class extends Ye{constructor(e,r,n,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,n,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,n,s,o){let a,l=0,u=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 c=[];for(;a=tI.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&cn.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=cn.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||cn.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+m+u.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&cn.contains(m)&&e.include(cn.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,n,s){if(this.src=e||"",this.includes=r??[],this.extensions=n??{},this.keywords=s??{},this.isMethod){let o=Eq.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(tI);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var Mq=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,cA=class extends Ye{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||cA.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,n,s,o){this.src=e||"";let a,l,u="",c=Mq.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,r){if(r==="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),r)}generate(e,r,n,s,o){return e.format(this.name,this.getType(e),r)}},It=cA;It.PI="PI",It.PI2="PI2",It.RECIPROCAL_PI="RECIPROCAL_PI",It.RECIPROCAL_PI2="RECIPROCAL_PI2",It.LOG2="LOG2",It.EPSILON="EPSILON";var Tq=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3156
3156
  )*?)}`,"gim"),Cq=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ad=class extends Ye{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,n,s,o){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=Tq.exec(e);if(r){let n=r[2],s;for(;s=Cq.exec(n);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ld=class extends Ye{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(s,this.getType(e),r)}};cn.addKeyword("uv",function(){return new ld});cn.addKeyword("uv2",function(){return new ld(1)});var vc=class extends Ye{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??vc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Di:return["Linear"];case et:return["sRGB"];default:return[]}}generate(e,r){let n=this.input.build(e,"v4"),s=this.getType(e),o=vc.Nodes[this.method],a=e.include(o);if(a===vc.LINEAR_TO_LINEAR)return e.format(n,s,r);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+n+", "+l+" )",s,r)}else return e.format(a+"( "+n+" )",s,r)}fromEncoding(e){let r=vc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=vc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},ni=vc;ni.Nodes={LinearToLinear:new ge(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3157
3157
  `)),sRGBToLinear:new ge(["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(`
3158
3158
  `)),LinearTosRGB:new ge(["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(`
@@ -5368,7 +5368,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5368
5368
  `,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),h=this.getLineInitialOffsetX(o[0],a,e.horizontalAlign,t[0],l),d=this.getLineInitialOffsetY(s,t.length,e.height,n,e.verticalAlign),f=[],p=t.map(v=>[]),m=t.map(v=>[]),g;for(let v=0;v<t.length;v++){let x=t[v],w={features:{liga:!0}},S=[];try{S=r.stringToGlyphs(x,w)}catch(E){console.warn(E)}h=this.getLineInitialOffsetX(o[v],a,e.horizontalAlign,x,l);let A=[];try{A=this.reverseLigaturesTable(r,x,S)}catch(E){console.warn(E)}c=this.computeSpaceWidthForLine(t,v,e);for(let E=0;E<S.length;E++){let b=S[E],M=b.index===0?`
5369
5369
  `:b.unicode?String.fromCharCode(b.unicode):void 0,T=A[E],C=0,P=0;E===0&&e.horizontalAlign===2&&b.leftSideBearing!==void 0&&(P=-b.leftSideBearing*n),g&&(C=r.getKerningValue(b,g)*n),h+=P+C;let D=0;if(M===`
5370
5370
  `)D=u;else if(M===" ")D=c;else{let I=this.createPath(b,n,h,d,e);I&&(D=I.offsetX-(C+P),f.push(I.path))}if(T.replacements.length===1)m[v].push([h,d]),p[v].push(D);else{let I=T.replacements.map(V=>(r.glyphs.get(V).advanceWidth??0)*n),R=I.reduce((V,G)=>V+=G,0),U=I.map(V=>V/R),F=h;for(let V=0;V<U.length;V++){let G=D*U[V];m[v].push([F,d]),p[v].push(G),F+=G}}h+=D,g=b}d-=s}let y=[];for(let v=0,x=f.length;v<x;v++)y.push(...f[v].toShapes());return{shapes:y,charWidths:p,lineWidths:o,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,n,s){return(r===3||r===2)&&n.indexOf(`
5371
- `)>=0&&(t-=s),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,s){let o=e*t,a=Math.abs(this.ascender-this.descender)*n,l=t-a,u=-this.ascender*n-l/2;return s===3?-(r-o-u):s===2?-(r*.5-o*.5-u):u}createPath(t,e,r,n,s){let o=t.getPath(r,-n,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!o){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new Jv,l=(t.advanceWidth??1)*e;if(t)for(let u of o.commands){let c=a.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":a.moveTo(u.x,-u.y);break;case"L":a.lineTo(u.x,-u.y);break;case"Q":a.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":a.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return a.subPaths.forEach(u=>{let c=g9(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+s.fontSize*s.letterSpacing,path:a}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let n=this.getCharWidth(" ",r),s=t[e];if(s){let o=this.countSpaces(s.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&o){let a=r.width,l=this.getTextWidth(s,r);return(a-(l-o*n))/o}}return n}countSpaces(t){return(t.match(/ /g)||[]).length}};function g9(i){if(i.length){let t=i[0];if(t instanceof Wn)return t.v1;if(t instanceof jn||t instanceof Ii)return t.v0}}var kA=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,r),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Xp=class extends kA{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let s=gc(e,r,this.flatShading,n);return s.computeBoundingSphere(),s}};var LI={markNeedsUpdateRendererDirty:()=>{}};var VA=class extends Wv{constructor(e){super();this.shared=e}create(e){return new Md(e,this.shared)}},Mc=class{constructor(t,e={}){this.data=t;this.geometryCache=new Xp(!0);this.geometryCache2=new Xp(!1);this.imageHolderCache=new VA(this);this.thisContext={scene:LI,shared:this};this.deletedMaterial=new Ec(Br.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new $i(_h.emptyImage,this);this.deletedVideo=new $i(ph.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,n]of Object.entries(e.images))this.addImage(r,n);if(e.videos)for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n);if(e.audios)for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.resetLib(t.lib);for(let{id:r,data:n}of t.variables)this.addVariableHolder(r,n),e&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(t.images))this.addImage(r,n);for(let[r,n]of Object.entries(t.videos))this.addVideo(r,n);for(let[r,n]of Object.entries(t.colors))this.addColor(r,n);for(let[r,n]of Object.entries(t.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(t.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(t.fonts))this.addFont(r,n)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new Ec(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new la(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new $i(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new $i(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new pl(e.r,e.g,e.b,e.a):this.colors[t]=new pl(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new gr(0,0,0,0))}else return"a"in t?new gr(t.r,t.g,t.b,t.a):new gr(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof ca)return e;{let r=new ca({src:e.data});return this.audios[t]=r,r}}deleteAudio(t){let e=this.audios[t];e&&(e instanceof ca&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new e0(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof ca&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(this.variables[t].value=e.value,!1)}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e;let r=e;for(;typeof r=="string";)r=this.variables[r].value;let n=this.entityOpContext.scene;for(let s=this.variables[t].locations.length-1;s>=0;s--){let o=this.variables[t].locations[s];if(o[0]==="material"){let a=o[1],l=r,u={scene:n,shared:this},c=o.slice(2);n.traverseMaterial(d=>{let f=d.root??d;f.uuid===a&&f.onVariableUpdate(c,l,u)});let h=this.materials[a];h&&h.onVariableUpdate(c,l,u)}else{let a=n.find(o[0]);if(a===void 0){this.variables[t].locations.splice(s,1);continue}if(o[1]!=="geometry"){for(let l=1;l<o.length-1;l++)a=a[o[l]];o[1]==="rotation"?a[o[o.length-1]]=r*Se.DEG2RAD:a[o[o.length-1]]=r}if(a=n.find(o[0]),lt.is(a)){if(o[1]==="position"||o[1]==="rotation"||o[1]==="scale")a.onVariableUpdate();else if(o[1]==="geometry"){let l=a;a.component&&(l=a.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(c=>{let h=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(h.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let n=1;n<t.length;n++)r=r[t[n]];return t[1]==="rotation"&&(r*=Se.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let n=this.variables[r],s=n.locations?.findIndex(o=>Rr.equal(o,e));s!==void 0&&s!==-1&&n.locations.splice(s,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(Lr.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0&&"value"in t.props?this.updateVariable(t.path[1],t.props.value):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(Lr.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};n.update(s),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},S_e=new Mc(fi.emptyData());var ts=class extends $t{updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),xP(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[s,o]of Object.entries(e.props)){let a=n.shared.material(o);this.material[Number(s)]=a}else if(qn(e.path,["material"])&&this.material instanceof bi)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(Lr.drop(e,1),r.material,n);else if(qn(e.path,["materials","*"])&&Array.isArray(this.material)){let s=e.path[1];if("materials"in r&&s<this.material.length){let o=r.materials[s];typeof o!="string"&&this.material[s].updateByOp(Lr.drop(e,2),o,n)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let n=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe),r.scene.markNeedsUpdateRendererDirty()),e.geometry?.type==="NonParametricGeometry"&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(s=>r.shared.material(s).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let s=0;s<this.material.length;s++)this.material[s]=this.material[s].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe)}disposeMaterial(){this.material&&hy(this.material).forEach(e=>{e instanceof bi&&(e instanceof Ec||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var NI=new _,BI=new Xe,FI=new Xe,v9=new _,kI=new ie,Qt=class extends ts{constructor(e,r,n){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new ie().fromArray(r.bindMatrix),this.bindMatrixInverse=new ie)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Ae&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Mc){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return gp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return gp.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),qn(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Lr.drop(e,1),r.geometry,n)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let s=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...s};this.localGeometry=gc(c,r,this.data.flatShading,this)}let o,a,l;s.scaleBaked?[o,a,l]=s.scaleBaked:{width:o,height:a,depth:l}=s;let u=this.localGeometry.userData;u.sxPrev!==void 0&&Np(this.localGeometry.attributes,o/u.sxPrev,a/u.syPrev,l/u.szPrev),u.sxPrev=o,u.syPrev=a,u.szPrev=l}else{let s={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=gc(s,r,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,n){let s=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Fr&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(s=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),s||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;this.is2DType?e.set(0,0,n.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Xe,n=this.geometry.attributes.skinWeight;for(let s=0,o=n.count;s<o;s++){r.fromBufferAttribute(n,s);let a=1/r.manhattanLength();a!==1/0?r.multiplyScalar(a):r.set(1,0,0,0),n.setXYZW(s,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let n=this.skeleton;if(n===void 0)return;let s=this.geometry;BI.fromBufferAttribute(s.attributes.skinIndex,e),FI.fromBufferAttribute(s.attributes.skinWeight,e),NI.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let o=0;o<4;o++){let a=FI.getComponent(o);if(a!==0){let l=BI.getComponent(o);kI.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),r.addScaledVector(v9.copy(NI).applyMatrix4(kI),a)}}return r.applyMatrix4(this.bindMatrixInverse)}};function x9(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,n=e.normal.array,s=new Float32Array(r.length);for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=new _(n[o],n[o+1],n[o+2]);t.has(a)?t.get(a)?.normals.push(l):t.set(a,{normals:[l],result:new _})}t.forEach((o,a)=>{for(let l of o.normals)o.result.add(l);o.result.divideScalar(o.normals.length)});for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=t.get(a)?.result;l&&(s[o]=l.x,s[o+1]=l.y,s[o+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new be(s,3))}function b9(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=new _;for(let s=0;s<e.length;s+=3)n.set(e[s],e[s+1],e[s+2]).normalize(),r[s]=n.x,r[s+1]=n.y,r[s+2]=n.z;i.geometry.setAttribute("extrudeNormal",new be(r,3))}function Td(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!(i.material instanceof bi)||i.material.getLayersOfType("outline").length===0)return;i instanceof Qt&&i.is2DAndNoDepth?b9(i):x9(i)}function Cd(i){if(!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=parseInt(i.uuid.replace(/\D/g,"")),s=[Se.seededRandom(n),Se.seededRandom(n+1e4),Se.seededRandom(n+2e4)];for(let o=0;o<e.length;o++)r[o]=s[o%3];i.geometry.setAttribute("randomColor",new Ge(r,3))}var w9;rd.then(i=>{w9=i});var fo=new Pt,Qp=new _;function VI(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Ds=class extends Qt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new ie;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:s,subdivPointer:o}=Fr.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=o,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Td(this),Cd(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,$t.prototype.raycast.call(this,e,r),this.localGeometry=n}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;fo.setFromBufferAttribute(r),fo.getCenter(n),e.boundingSphere.radius=n.distanceTo(fo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),fo.getSize(Qp),this.hasNonUniformScale&&Qp.divide(this.scale);let s={width:Qp.x,height:Qp.y,depth:Qp.z};return this.geometry.userData.parameters=s,s}updateBoundingSphere(e){let r=this.originalGeometry;fo.min.set(e[0],e[2],e[4]),fo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(fo.min.applyMatrix4(this.shearScaleInv),fo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new fr);let n=r.boundingSphere.center;fo.getCenter(n),r.boundingSphere.radius=n.distanceTo(fo.max)}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&this.createGeometryByControls(r)}};var zI=-1,S9=1,UI={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},GI={polygon_center:0,edge:1,vertex:2},Kp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ct=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-zI)*(e-r)/(S9-zI)+r};function HI(i){let t=[],e={};for(var r=0,n=i.length;r<n;r++){var s=JSON.stringify(i[r].pos.map(o=>Math.round(o*1e4)/1e4));e[s]||(t.push(i[r]),e[s]=!0)}return t}var A9=new _,t0=new _,_9=new _,E9=new _;function Pd(i,t){let e=_9.fromArray(i),r=E9.fromArray(t);t0.copy(r).sub(e);let n=t0.length();return t0.normalize().multiplyScalar(n*.5),A9.copy(e).add(t0).toArray()}var rs=new dr,r0=new _,n0=new _,Tc=new _;function jI(i){let t=[];for(let e=0;e<=i.index.count;e++)if(r0.fromArray(i.index.array,e*3),rs.setFromAttributeAndIndices(i.attributes.position,r0.x,r0.y,r0.z),rs.getNormal(n0),rs.getMidpoint(Tc),!(isNaN(Tc.x)||isNaN(Tc.y)||isNaN(Tc.z))){let{a:r,b:n,c:s}=rs,o=r.toArray(),a=n.toArray(),l=s.toArray(),u=r.distanceTo(n),c=n.distanceTo(s),h=s.distanceTo(r),d=Pd(o,a),f=Pd(a,l),p=Pd(l,o),m=[u,c,h],g=Math.max(...m),y=m.filter(w=>Math.round(w)===Math.round(g)).length>1,v=[],x=rs.getMidpoint(Tc).toArray();g===u&&!y&&(v=[f,p,p],x=d),g===c&&!y&&(v=[d,p,p],x=f),g===h&&!y&&(v=[d,f,f],x=p),y&&(v=[d,f,p]),t.push({vertices:[o,a,l],faceCenters:v,midpoint:x,norm:rs.getNormal(n0).toArray()})}return t}function WI(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){rs.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),rs.getNormal(n0),rs.getMidpoint(Tc);let n=rs.a.toArray(),s=rs.b.toArray(),o=rs.c.toArray();t.push({vertices:[n,s,o],faceCenters:[Pd(n,s),Pd(s,o),Pd(o,n)],midpoint:Tc.toArray(),norm:n0.toArray()})}return t}var M9=4,T9=.5,zA=i=>.5*(1-Math.cos(i*Math.PI)),UA=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let n=Math.floor(t),s=Math.floor(e),o=Math.floor(r),a=t-n,l=e-s,u=r-o,c,h,d=0,f=.5,p,m,g;for(let y=0;y<M9;y++){let v=n+(s<<4)+(o<<8);c=zA(a),h=zA(l),p=this.perlin[v&4095],p+=c*(this.perlin[v+1&4095]-p),m=this.perlin[v+16&4095],m+=c*(this.perlin[v+16+1&4095]-m),p+=h*(m-p),v+=256,m=this.perlin[v&4095],m+=c*(this.perlin[v+1&4095]-m),g=this.perlin[v+16&4095],g+=c*(this.perlin[v+16+1&4095]-g),m+=h*(g-m),p+=zA(u)*(m-p),d+=p*f,f*=T9,n<<=1,a*=2,s<<=1,l*=2,o<<=1,u*=2,a>=1&&(n++,a--),l>=1&&(s++,l--),u>=1&&(o++,u--)}return d}noiseSeed(t){let e=(()=>{let o,a;return{setSeed(l){a=o=(l??Math.random()*4294967296)>>>0},getSeed(){return o},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},qI=UA;var YI=new _,XI=new ie,QI=new gs;function GA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Dd=class extends Qt{constructor(e,r,n){super(e,r,n);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(XI.copy(n).invert(),QI.copy(e.ray).applyMatrix4(XI),QI.intersectBox(this.singleBBox,YI))){let s=YI.applyMatrix4(n),o=e.ray.origin.distanceTo(s);r.push({distance:o,point:s.clone(),object:this})}}};var oi=1e-4,po,JI,$I,eO,KI=new _,ZI=new _;rd.then(i=>{po=i,JI=[po.get_face_center,po.get_edge_midpoint,po.get_vertex_position],$I=[po.get_face_normal,po.get_edge_normal,po.get_vertex_normal],eO=[po.face_count,po.edge_count,po.vertex_count]});var C9=new ie,P9=new ie,gl=new _,Cc=new _,Zp=new _,HA=new _,D9=new _,I9=new _;var ua=new qI,Dn=class extends Gh(gt){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof mr&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof mr&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let s=0,o=this.children.length;s<o;++s)this.remove(this.children[0]);let n=this.children;if(n.length===r)return;if(n.length<r)for(let s=0,o=r-n.length;s<o;++s){let a=new mr(this.object);a.expand(),this.add(a)}else for(let s=0,o=n.length-r;s<o;++s)this.remove(n[s])}else{if(this.children.length===r)return;if(this.children.length<r)for(let n=0,s=r-this.children.length;n<s;++n){let o=new mr(this.object);o.expand(),this.add(o)}else for(let n=0,s=this.children.length-r;n<s;++n)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,n=r.start*Se.DEG2RAD,s=r.end*Se.DEG2RAD,o=n-s,a=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new _(0,0,1);break;case"y":l=new _(0,1,0);break;default:case"x":l=new _(1,0,0);break}let u=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,c=u.noiseType==="perlin";ua.noiseSeed(u.seed);let h=pv((0,Id.default)(u.seed)),d=Kp(u.strength,this.parameters.randomness);for(let[f,p]of this.children.entries()){let m=f*(u.freqScale/10)+u.movement,g=c?ua.noise(m):h(m,m),y=f+1;p.scale.x=r.scale[0]+d(y,ct(g,u.scale[0]))||oi,p.scale.y=r.scale[1]+d(y,ct(g,u.scale[1]))||oi,p.scale.z=r.scale[2]+d(y,ct(g,u.scale[2]))||oi,p.position.setScalar(0);let v=o/e.count*f-n;switch(r.axis){case"x":p.rotation.set(0,v,0);break;case"y":p.rotation.set(0,0,v);break;case"z":p.rotation.set(v,0,0);break}p.translateOnAxis(l,r.radius),p.position.x+=r.position[0]+d(y,ct(g,u.position[0])),p.position.y+=r.position[1]+d(y,ct(g,u.position[1])),p.position.z+=r.position[2]+d(y,ct(g,u.position[2]));let x=d(y,ct(g,u.rotation[0])),w=d(y,ct(g,u.rotation[1])),S=d(y,ct(g,u.rotation[2]));r.alignment===!0?(p.rotation.x+=a.x+x,p.rotation.y+=a.y+w,p.rotation.z+=a.z+S):p.rotation.set(a.x+x,a.y+w,a.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,n=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";ua.noiseSeed(s.seed);let a=pv((0,Id.default)(s.seed)),l=Kp(s.strength,this.parameters.randomness);for(let[u,c]of this.children.entries()){let h=u*(s.freqScale/10)+s.movement,d=o?ua.noise(h):a(h,h),f=u+1,p=l(f,ct(d,s.rotation[0])),m=l(f,ct(d,s.rotation[1])),g=l(f,ct(d,s.rotation[2]));c.scale.x=1+(r.scale[0]-1)*u+l(f,ct(d,s.scale[0]))||oi,c.scale.y=1+(r.scale[1]-1)*u+l(f,ct(d,s.scale[1]))||oi,c.scale.z=1+(r.scale[2]-1)*u+l(f,ct(d,s.scale[2]))||oi,c.rotation.x=n.x*u+p,c.rotation.y=n.y*u+m,c.rotation.z=n.z*u+g,c.position.x=r.position[0]*u+l(f,ct(d,s.position[0])),c.position.y=r.position[1]*u+l(f,ct(d,s.position[1])),c.position.z=r.position[2]*u+l(f,ct(d,s.position[2]))}}_updateGrid(e){let r=0,n=e.grid,s=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,o=Kp(s.strength,this.parameters.randomness),a=s.noiseType==="perlin";ua.noiseSeed(s.seed);let l=U2((0,Id.default)(s.seed));if(n.useCenter===!0){let u={x:n.count[0]%2===0?2:1,y:n.count[1]%2===0?2:1,z:n.count[2]%2===0?2:1},c=new _(n.size[0]*(n.count[0]-u.x)*.5,n.size[1]*(n.count[1]-u.y)*.5,n.size[2]*(n.count[2]-u.z)*.5);for(let h=0;h<n.count[0];h++)for(let d=0;d<n.count[1];d++)for(let f=0;f<n.count[2];f++){let p=[(h+1)*(s.freqScale/10)+s.movement,(d+1)*(s.freqScale/10)+s.movement,(f+1)*(s.freqScale/10)+s.movement],m=a?ua.noise(...p):l(...p),g=this.children[r++];g.scale.x=1+o(r,ct(m,s.scale[0]))||oi,g.scale.y=1+o(r,ct(m,s.scale[1]))||oi,g.scale.z=1+o(r,ct(m,s.scale[2]))||oi;let y=o(r,ct(m,s.rotation[0])),v=o(r,ct(m,s.rotation[1])),x=o(r,ct(m,s.rotation[2]));g.rotation.set(y,v,x),g.position.x=n.size[0]*h-c.x+o(r,ct(m,s.position[0])),g.position.y=n.size[1]*d-c.y+o(r,ct(m,s.position[1])),g.position.z=n.size[2]*f-c.z+o(r,ct(m,s.position[2]))}}else for(let u=0;u<n.count[0];u++)for(let c=0;c<n.count[1];c++)for(let h=0;h<n.count[2];h++){let d=[(u+1)*(s.freqScale/10)+s.movement,(c+1)*(s.freqScale/10)+s.movement,(h+1)*(s.freqScale/10)+s.movement],f=a?ua.noise(...d):l(...d),p=this.children[r++];p.scale.x=1+o(r,ct(f,s.scale[0]))||oi,p.scale.y=1+o(r,ct(f,s.scale[1]))||oi,p.scale.z=1+o(r,ct(f,s.scale[2]))||oi;let m=o(r,ct(f,s.rotation[0])),g=o(r,ct(f,s.rotation[1])),y=o(r,ct(f,s.rotation[2]));p.rotation.set(m,g,y),p.position.x=n.size[0]*u+o(r,ct(f,s.position[0])),p.position.y=-n.size[1]*c+o(r,ct(f,s.position[1])),p.position.z=-n.size[2]*h+o(r,ct(f,s.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,n=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";ua.noiseSeed(s.seed);let a=pv((0,Id.default)(s.seed)),l=Kp(s.strength,this.parameters.randomness);if(!r.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Dd)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),c=[],h=y=>{let v=y.length,x=y.map(A=>A[0]).reduce((A,E)=>A+E,0),w=y.map(A=>A[1]).reduce((A,E)=>A+E,0),S=y.map(A=>A[2]).reduce((A,E)=>A+E,0);return[x/v,w/v,S/v]},d=y=>Math.round(y*1e6)/1e6;u.forEach(y=>{let v=u.filter(x=>d(y.pos[0])===d(x.pos[0])&&d(y.pos[1])===d(x.pos[1])&&d(y.pos[2])===d(x.pos[2]));v.length>1?c.push({pos:y.pos,norm:h(v.map(x=>x.norm))}):c.push(y)});let f=HI(c);if(f.length>0){let y=Math.round(f.length*r.count/100);this._updateCount(y)}else{let y=this.objectForSample.geometry.getAttribute("position");if(!y||isNaN(y.count)||y.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let p=new mv(this.objectForSample).build(),m=UI[r.axis],g=this.children;p.setRandomGenerator((0,Id.default)(this.object.uuid+r.seed));for(let[y,v]of g.entries()){let x=y*(s.freqScale/10)+s.movement,w=o?ua.noise(x):a(x,x),S=y+1,A=l(S,ct(w,s.rotation[0])),E=l(S,ct(w,s.rotation[1])),b=l(S,ct(w,s.rotation[2]));r.spreadType==="random"?p.sample(Zp,HA):(f.length&&(Zp.fromArray(f[y].pos),HA.fromArray(f[y].norm)),this.objectForSample instanceof Ds&&Zp.applyMatrix4(C9.copy(this.objectForSample.matrixWorld).invert())),Zp.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Zp),gl.fromArray(m);let M=r.align==="normal"?HA:this.object.getWorldDirection(I9),T=Cc.fromArray(r.position);Cc.x+=Cc.x+l(S,ct(w,s.position[0])),Cc.y+=Cc.y+l(S,ct(w,s.position[1])),Cc.z+=Cc.z+l(S,ct(w,s.position[2]));let C=Math.acos(M.dot(gl)),P=D9.crossVectors(gl,M).normalize(),D=P9.makeRotationAxis(P,C),I=M.clone().cross(this.object.up).normalize(),R=I.clone().cross(M).normalize(),U=new ie().makeBasis(I,M,R),F=new _(gl.y,gl.z,gl.x).normalize(),V=F.clone().cross(gl).normalize(),G=new ie().makeBasis(F,gl,V).invert(),H=new ie().multiplyMatrices(U,G);v.rotation.setFromRotationMatrix(H),T.applyMatrix4(D),v.position.add(T),v.rotation.x=v.rotation.x+n.x+A,v.rotation.y=v.rotation.y+n.y+E,v.rotation.z=v.rotation.z+n.z+b,v.scale.setScalar(1),v.scale.x=v.scale.x+r.scale[0]+l(S,ct(w,s.scale[0]))||oi,v.scale.y=v.scale.y+r.scale[1]+l(S,ct(w,s.scale[1]))||oi,v.scale.z=v.scale.z+r.scale[2]+l(S,ct(w,s.scale[2]))||oi,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof Ds){let r=this.objectForSample,n=GI[e],s=eO[n],o=JI[n],a=$I[n],l=[],u=s(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let h=o(r.subdivPointerNew,c),d=a(r.subdivPointerNew,c);KI.fromArray(h).applyMatrix4(r.matrixWorld),ZI.fromArray(d),l.push({pos:KI.toArray(),norm:ZI.toArray()})}return l}else return(this.objectForSample.geometry.index?jI(this.objectForSample.geometry):WI(this.objectForSample.geometry)).map((n,s)=>e==="polygon_center"?{pos:n.midpoint,norm:n.norm}:e==="vertex"?[{pos:n.vertices[0],norm:n.norm},{pos:n.vertices[1],norm:n.norm},{pos:n.vertices[2],norm:n.norm}]:e==="edge"?[{pos:n.faceCenters[0],norm:n.norm},{pos:n.faceCenters[1],norm:n.norm},{pos:n.faceCenters[2],norm:n.norm}]:[]).flat()}updateState(e,r){if(this.parameters=Zo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let n=r.find(this.parameters.toObject.object);n instanceof $t?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new ie,this.hiddenMatrix=new ie,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var mo=i=>{var t;return t=class extends i{},t.geometryHelper=new yn(30,30,30),t};var i0=new gs,jA=new fr,tO=new ie,go=(i,t,e,r,n=!1)=>{let s=t,o=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),jA.copy(s.boundingSphere),jA.applyMatrix4(o),e.ray.intersectsSphere(jA)===!1||(tO.copy(o).invert(),i0.copy(e.ray).applyMatrix4(tO),s.boundingBox!==null&&i0.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,d=s.attributes.position,f=s.drawRange,p,m;if(n===!1){let y=Math.max(0,f.start),v=Math.min(h.count,f.start+f.count);for(p=y,m=v;p<m;p+=3)if(l=h.getX(p),u=h.getX(p+1),c=h.getX(p+2),a=g(i,e,i0,d,l,u,c),a){a.faceIndex=Math.floor(p/3),r.push(a);return}}else{let v=s.attributes.position,x=new _,w=new _,S=new _,A=new _,E=2,M=1/((i.scale.x+i.scale.y+i.scale.z)/3),T=M*M,C=Math.max(0,f.start),P=Math.min(v.count,f.start+f.count);for(let D=C,I=P-1;D<I;D+=E){if(x.fromBufferAttribute(v,D),w.fromBufferAttribute(v,D+1),i0.distanceSqToSegment(x,w,A,S)>T)continue;A.applyMatrix4(i.matrixWorld);let U=e.ray.origin.distanceTo(A);U<e.near||U>e.far||r.push({distance:U,point:S.clone().applyMatrix4(i.matrixWorld),object:i})}}function g(y,v,x,w,S,A,E){let b=new _,M=new _,T=new _,C=new _,P=new _;if(b.fromBufferAttribute(w,S),M.fromBufferAttribute(w,A),T.fromBufferAttribute(w,E),x.intersectTriangle(b,M,T,!1,C)===null)return null;P.copy(C),P.applyMatrix4(y.matrixWorld);let I=v.ray.origin.distanceTo(P);return I<v.near||I>v.far?null:{faceIndex:1,distance:I,point:P.clone(),object:y}}};var s0=new _,ns=new ys,WA=class extends Da{constructor(e){let r=new Ae,n=new Hi({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Re(15711266),u=new Re(15711266),c=new Re(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);function h(f,p,m){d(f,m),d(p,m)}function d(f,p){s.push(0,0,0),o.push(p.r,p.g,p.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}r.setAttribute("position",new be(s,3)),r.setAttribute("color",new be(o,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;ns.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=n?.8:1e-4;Is("n1",r,e,ns,-s,-o,a),Is("n2",r,e,ns,s,-o,a),Is("n3",r,e,ns,-s,o,a),Is("n4",r,e,ns,s,o,a);let l=a;Is("f1",r,e,ns,-s,-o,l),Is("f2",r,e,ns,s,-o,l),Is("f3",r,e,ns,-s,o,l),Is("f4",r,e,ns,s,o,l);let u=l,c=.5;Is("u1",r,e,ns,s*.7*c,o*1.1,u),Is("u2",r,e,ns,-s*.7*c,o*1.1,u),Is("u3",r,e,ns,0,o*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Is(i,t,e,r,n,s,o){s0.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],s0.x,s0.y,s0.z)}}var o0=class extends mo(WA){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){go(this.object,this.geometry,e,r,!0)}};var a0;(t=>t.is=e=>"objectHelper"in e)(a0||(a0={}));var yo=(i,t)=>class extends jh(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,s){this.objectHelper.raycast(n,s)}showGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof Na&&(s.visible=!0)}}updateEntityBoxSize(n,s){this.objectHelper.visible&&this.geometryHelper instanceof yn?(n.setScalar(0),s.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,s)}hideGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof Na&&(s.visible=!1)}}};var l0=790,Od=new _,qA=new _,YA=new He,XA=new _,Jp=new _,QA=new _,er=class extends yo(ys,o0){constructor(e="",r={...cc.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Qa.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new ie,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,s=this.height;this.orthoCamera=new lu(n*-.5,n*.5,s*.5,s*-.5,-5e4,1e4),this.perspCamera=new Ir(45,n/s,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,n){typeof e=="number"&&(e=new _(e,r,n)),super.lookAt(e),this.getWorldPosition(Od),this.targetOffset=Od.distanceTo(e)}getTarget(e=new _){return this.getWorldDirection(qA),this.getWorldPosition(Od),qA.multiplyScalar(this.targetOffset),e.copy(Od).add(qA),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Od),Od.distanceTo(e)}updateUp(){this.getWorldQuaternion(YA),XA.set(0,0,1).applyQuaternion(YA),Jp.copy(gt.DEFAULT_UP),this.isUpVectorFlipped&&Jp.negate(),Jp.applyQuaternion(YA),QA.copy(gt.DEFAULT_UP).projectOnPlane(XA),this.angleOffsetFromUp=QA.angleTo(Jp),this.angleOffsetFromUp*=QA.cross(Jp).dot(XA)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new _),s=e.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new _,n=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let s=e>r?this.aspect:1,o=e>r?1:this.aspect;this.left=-l0*.5*s,this.right=l0*.5*s,this.top=l0*.5*(1/o),this.bottom=-l0*.5*(1/o)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,s,o,a):this.orthoCamera.setViewOffset(e,r,n,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ih(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var Rd=new ie,R9=new ie,c0=new ie,rO=new _,nO=new _;function KA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}var is=class extends ts{constructor(e,r,n){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Ae;this.onAfterRender=(e,r,n,s,o,a)=>{super.onAfterRender(e,r,n,s,o,a),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let s=0;s<this.children.length;s++){let o=this.children[s];o instanceof is&&o.dataPatched.visible===!0&&o.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let s=0;s<this.children.length;s++){let o=this.children[s];if(o instanceof $t&&o.dataPatched.visible===!0&&o.geometry.attributes.position?.count>0&&o.geometry.drawRange.count>0){if(Rd.multiplyMatrices(o.hiddenMatrix,o.matrix),o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=Ji.getMeshSet(o.geometry,e===!0,r)),o.booleanMeshSetAddress===-1)return;Ji.transformMeshSet(o.booleanMeshSetAddress,Rd),o.booleanMatrixInvOld.copy(Rd).invert(),o.booleanWasTransformed=!1}else o instanceof is&&o.needsTransformForDownstream===!0?(Ji.transformMeshSet(o.booleanMeshSetAddress,Rd),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(Ji.transformMeshSet(o.booleanMeshSetAddress,R9.multiplyMatrices(Rd,o.booleanMatrixInvOld)),o.booleanMatrixInvOld.copy(Rd).invert(),o.booleanWasTransformed=!1);Ji.hasOpenEdges(o.booleanMeshSetAddress)===!1||s===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(o.booleanMeshSetAddress),o.geometry.userData.wasFilteredFromBoolean=!1):o.geometry.userData.wasFilteredFromBoolean=!0}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new be([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Ji.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let n=this.geometry;n.dispose(),this.geometry=new Ae,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere;try{this.booleanMeshSetAddress=Ji.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Td(this),Cd(this)}dispose(){super.dispose(),this.geometry.dispose()}get recursiveBBox(){let e=super.recursiveBBox;return this.geometry.boundingSphere?.radius===-1&&(e.getCenter(this.geometry.boundingSphere.center),c0.copy(this.matrixWorld).invert(),this.geometry.boundingSphere.center.applyMatrix4(c0),rO.copy(e.max).applyMatrix4(c0),nO.copy(e.min).applyMatrix4(c0),this.geometry.boundingSphere.radius=rO.distanceTo(nO)/2),e}};var u0;(t=>{function i(e){return lt.is(e)&&e instanceof Ra}t.is=i})(u0||(u0={}));var Ld=(i,t)=>class extends yo(i,t){updateState_Light(r,n){this.updateState_Entity(r,n),r.color!==void 0&&(this.color=n.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var Yn=i=>i instanceof $t,Xn=i=>i!==null&&i instanceof is,iO=i=>i instanceof er,sO=i=>u0.is(i),$p=i=>a0.is(i);var vo=class extends mo(Lg){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){go(this.object,vo.geometryHelper,e,r)}update(){}};var ss=class extends yo(js,vo){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var dO={RED:0,GREEN:1,BLUE:2,ALPHA:3};var em="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var L9=`#ifdef FRAMEBUFFER_PRECISION_HIGH
5371
+ `)>=0&&(t-=s),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,s){let o=e*t,a=Math.abs(this.ascender-this.descender)*n,l=t-a,u=-this.ascender*n-l/2;return s===3?-(r-o-u):s===2?-(r*.5-o*.5-u):u}createPath(t,e,r,n,s){let o=t.getPath(r,-n,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!o){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new Jv,l=(t.advanceWidth??1)*e;if(t)for(let u of o.commands){let c=a.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":a.moveTo(u.x,-u.y);break;case"L":a.lineTo(u.x,-u.y);break;case"Q":a.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":a.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return a.subPaths.forEach(u=>{let c=g9(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+s.fontSize*s.letterSpacing,path:a}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let n=this.getCharWidth(" ",r),s=t[e];if(s){let o=this.countSpaces(s.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&o){let a=r.width,l=this.getTextWidth(s,r);return(a-(l-o*n))/o}}return n}countSpaces(t){return(t.match(/ /g)||[]).length}};function g9(i){if(i.length){let t=i[0];if(t instanceof Wn)return t.v1;if(t instanceof jn||t instanceof Ii)return t.v0}}var kA=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,r),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Xp=class extends kA{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let s=gc(e,r,this.flatShading,n);return s.computeBoundingSphere(),s}};var LI={markNeedsUpdateRendererDirty:()=>{}};var VA=class extends Wv{constructor(e){super();this.shared=e}create(e){return new Md(e,this.shared)}},Mc=class{constructor(t,e={}){this.data=t;this.geometryCache=new Xp(!0);this.geometryCache2=new Xp(!1);this.imageHolderCache=new VA(this);this.thisContext={scene:LI,shared:this};this.deletedMaterial=new Ec(Br.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new $i(_h.emptyImage,this);this.deletedVideo=new $i(ph.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,n]of Object.entries(e.images))this.addImage(r,n);if(e.videos)for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n);if(e.audios)for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.resetLib(t.lib);for(let{id:r,data:n}of t.variables)this.addVariableHolder(r,n),e&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(t.images))this.addImage(r,n);for(let[r,n]of Object.entries(t.videos))this.addVideo(r,n);for(let[r,n]of Object.entries(t.colors))this.addColor(r,n);for(let[r,n]of Object.entries(t.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(t.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(t.fonts))this.addFont(r,n)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new Ec(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new la(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new $i(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new $i(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new pl(e.r,e.g,e.b,e.a):this.colors[t]=new pl(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new gr(0,0,0,0))}else return"a"in t?new gr(t.r,t.g,t.b,t.a):new gr(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof ca)return e;{let r=new ca({src:e.data});return this.audios[t]=r,r}}deleteAudio(t){let e=this.audios[t];e&&(e instanceof ca&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new e0(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof ca&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(this.variables[t].value=e.value,!1)}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e;let r=e;for(;typeof r=="string";)r=this.variables[r].value;let n=this.entityOpContext.scene;for(let s=this.variables[t].locations.length-1;s>=0;s--){let o=this.variables[t].locations[s];if(o[0]==="material"){let a=o[1],l=r,u={scene:n,shared:this},c=o.slice(2);n.traverseMaterial(d=>{let f=d.root??d;f.uuid===a&&f.onVariableUpdate(c,l,u)});let h=this.materials[a];h&&h.onVariableUpdate(c,l,u)}else{let a=n.find(o[0]);if(a===void 0){this.variables[t].locations.splice(s,1);continue}if(o[1]!=="geometry"){for(let l=1;l<o.length-1;l++)a=a[o[l]];o[1]==="rotation"?a[o[o.length-1]]=r*Se.DEG2RAD:a[o[o.length-1]]=r}if(a=n.find(o[0]),lt.is(a)){if(o[1]==="position"||o[1]==="rotation"||o[1]==="scale")a.onVariableUpdate();else if(o[1]==="geometry"){let l=a;a.component&&(l=a.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(c=>{let h=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(h.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let n=1;n<t.length;n++)r=r[t[n]];return t[1]==="rotation"&&(r*=Se.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let n=this.variables[r],s=n.locations?.findIndex(o=>Rr.equal(o,e));s!==void 0&&s!==-1&&n.locations.splice(s,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(Lr.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0&&"value"in t.props?this.updateVariable(t.path[1],t.props.value):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(Lr.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};n.update(s),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},S_e=new Mc(fi.emptyData());var ts=class extends $t{updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),xP(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[s,o]of Object.entries(e.props)){let a=n.shared.material(o);this.material[Number(s)]=a}else if(qn(e.path,["material"])&&this.material instanceof bi)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(Lr.drop(e,1),r.material,n);else if(qn(e.path,["materials","*"])&&Array.isArray(this.material)){let s=e.path[1];if("materials"in r&&s<this.material.length){let o=r.materials[s];typeof o!="string"&&this.material[s].updateByOp(Lr.drop(e,2),o,n)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let n=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe),r.scene.markNeedsUpdateRendererDirty()),e.geometry?.type==="NonParametricGeometry"&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(s=>r.shared.material(s).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let s=0;s<this.material.length;s++)this.material[s]=this.material[s].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe)}disposeMaterial(){this.material&&hy(this.material).forEach(e=>{e instanceof bi&&(e instanceof Ec||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var NI=new _,BI=new Xe,FI=new Xe,v9=new _,kI=new ie,Qt=class extends ts{constructor(e,r,n){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new ie().fromArray(r.bindMatrix),this.bindMatrixInverse=new ie)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Ae&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Mc){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return gp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return gp.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),qn(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Lr.drop(e,1),r.geometry,n)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let s=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...s};this.localGeometry=gc(c,r,this.data.flatShading,this)}let o,a,l;s.scaleBaked?[o,a,l]=s.scaleBaked:{width:o,height:a,depth:l}=s;let u=this.localGeometry.userData;u.sxPrev!==void 0&&Np(this.localGeometry.attributes,o/u.sxPrev,a/u.syPrev,l/u.szPrev),u.sxPrev=o,u.syPrev=a,u.szPrev=l}else{let s={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=gc(s,r,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,n){let s=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Fr&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(s=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),s||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;this.is2DType?e.set(0,0,n.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Xe,n=this.geometry.attributes.skinWeight;for(let s=0,o=n.count;s<o;s++){r.fromBufferAttribute(n,s);let a=1/r.manhattanLength();a!==1/0?r.multiplyScalar(a):r.set(1,0,0,0),n.setXYZW(s,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let n=this.skeleton;if(n===void 0)return;let s=this.geometry;BI.fromBufferAttribute(s.attributes.skinIndex,e),FI.fromBufferAttribute(s.attributes.skinWeight,e),NI.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let o=0;o<4;o++){let a=FI.getComponent(o);if(a!==0){let l=BI.getComponent(o);kI.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),r.addScaledVector(v9.copy(NI).applyMatrix4(kI),a)}}return r.applyMatrix4(this.bindMatrixInverse)}};function x9(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,n=e.normal.array,s=new Float32Array(r.length);for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=new _(n[o],n[o+1],n[o+2]);t.has(a)?t.get(a)?.normals.push(l):t.set(a,{normals:[l],result:new _})}t.forEach((o,a)=>{for(let l of o.normals)o.result.add(l);o.result.divideScalar(o.normals.length)});for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=t.get(a)?.result;l&&(s[o]=l.x,s[o+1]=l.y,s[o+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new be(s,3))}function b9(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=new _;for(let s=0;s<e.length;s+=3)n.set(e[s],e[s+1],e[s+2]).normalize(),r[s]=n.x,r[s+1]=n.y,r[s+2]=n.z;i.geometry.setAttribute("extrudeNormal",new be(r,3))}function Td(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!(i.material instanceof bi)||i.material.getLayersOfType("outline").length===0)return;i instanceof Qt&&i.is2DAndNoDepth?b9(i):x9(i)}function Cd(i){if(!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=parseInt(i.uuid.replace(/\D/g,"")),s=[Se.seededRandom(n),Se.seededRandom(n+1e4),Se.seededRandom(n+2e4)];for(let o=0;o<e.length;o++)r[o]=s[o%3];i.geometry.setAttribute("randomColor",new Ge(r,3))}var w9;rd.then(i=>{w9=i});var fo=new Pt,Qp=new _;function VI(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Ds=class extends Qt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new ie;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:s,subdivPointer:o}=Fr.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=o,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Td(this),Cd(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,$t.prototype.raycast.call(this,e,r),this.localGeometry=n}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;fo.setFromBufferAttribute(r),fo.getCenter(n),e.boundingSphere.radius=n.distanceTo(fo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),fo.getSize(Qp),this.hasNonUniformScale&&Qp.divide(this.scale);let s={width:Qp.x,height:Qp.y,depth:Qp.z};return this.geometry.userData.parameters=s,s}updateBoundingSphere(e){let r=this.originalGeometry;fo.min.set(e[0],e[2],e[4]),fo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(fo.min.applyMatrix4(this.shearScaleInv),fo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new fr);let n=r.boundingSphere.center;fo.getCenter(n),r.boundingSphere.radius=n.distanceTo(fo.max)}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&this.createGeometryByControls(r)}};var zI=-1,S9=1,UI={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},GI={polygon_center:0,edge:1,vertex:2},Kp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ct=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-zI)*(e-r)/(S9-zI)+r};function HI(i){let t=[],e={};for(var r=0,n=i.length;r<n;r++){var s=JSON.stringify(i[r].pos.map(o=>Math.round(o*1e4)/1e4));e[s]||(t.push(i[r]),e[s]=!0)}return t}var A9=new _,t0=new _,_9=new _,E9=new _;function Pd(i,t){let e=_9.fromArray(i),r=E9.fromArray(t);t0.copy(r).sub(e);let n=t0.length();return t0.normalize().multiplyScalar(n*.5),A9.copy(e).add(t0).toArray()}var rs=new dr,r0=new _,n0=new _,Tc=new _;function jI(i){let t=[];for(let e=0;e<=i.index.count;e++)if(r0.fromArray(i.index.array,e*3),rs.setFromAttributeAndIndices(i.attributes.position,r0.x,r0.y,r0.z),rs.getNormal(n0),rs.getMidpoint(Tc),!(isNaN(Tc.x)||isNaN(Tc.y)||isNaN(Tc.z))){let{a:r,b:n,c:s}=rs,o=r.toArray(),a=n.toArray(),l=s.toArray(),u=r.distanceTo(n),c=n.distanceTo(s),h=s.distanceTo(r),d=Pd(o,a),f=Pd(a,l),p=Pd(l,o),m=[u,c,h],g=Math.max(...m),y=m.filter(w=>Math.round(w)===Math.round(g)).length>1,v=[],x=rs.getMidpoint(Tc).toArray();g===u&&!y&&(v=[f,p,p],x=d),g===c&&!y&&(v=[d,p,p],x=f),g===h&&!y&&(v=[d,f,f],x=p),y&&(v=[d,f,p]),t.push({vertices:[o,a,l],faceCenters:v,midpoint:x,norm:rs.getNormal(n0).toArray()})}return t}function WI(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){rs.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),rs.getNormal(n0),rs.getMidpoint(Tc);let n=rs.a.toArray(),s=rs.b.toArray(),o=rs.c.toArray();t.push({vertices:[n,s,o],faceCenters:[Pd(n,s),Pd(s,o),Pd(o,n)],midpoint:Tc.toArray(),norm:n0.toArray()})}return t}var M9=4,T9=.5,zA=i=>.5*(1-Math.cos(i*Math.PI)),UA=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let n=Math.floor(t),s=Math.floor(e),o=Math.floor(r),a=t-n,l=e-s,u=r-o,c,h,d=0,f=.5,p,m,g;for(let y=0;y<M9;y++){let v=n+(s<<4)+(o<<8);c=zA(a),h=zA(l),p=this.perlin[v&4095],p+=c*(this.perlin[v+1&4095]-p),m=this.perlin[v+16&4095],m+=c*(this.perlin[v+16+1&4095]-m),p+=h*(m-p),v+=256,m=this.perlin[v&4095],m+=c*(this.perlin[v+1&4095]-m),g=this.perlin[v+16&4095],g+=c*(this.perlin[v+16+1&4095]-g),m+=h*(g-m),p+=zA(u)*(m-p),d+=p*f,f*=T9,n<<=1,a*=2,s<<=1,l*=2,o<<=1,u*=2,a>=1&&(n++,a--),l>=1&&(s++,l--),u>=1&&(o++,u--)}return d}noiseSeed(t){let e=(()=>{let o,a;return{setSeed(l){a=o=(l??Math.random()*4294967296)>>>0},getSeed(){return o},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},qI=UA;var YI=new _,XI=new ie,QI=new gs;function GA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Dd=class extends Qt{constructor(e,r,n){super(e,r,n);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(XI.copy(n).invert(),QI.copy(e.ray).applyMatrix4(XI),QI.intersectBox(this.singleBBox,YI))){let s=YI.applyMatrix4(n),o=e.ray.origin.distanceTo(s);r.push({distance:o,point:s.clone(),object:this})}}};var oi=1e-4,po,JI,$I,eO,KI=new _,ZI=new _;rd.then(i=>{po=i,JI=[po.get_face_center,po.get_edge_midpoint,po.get_vertex_position],$I=[po.get_face_normal,po.get_edge_normal,po.get_vertex_normal],eO=[po.face_count,po.edge_count,po.vertex_count]});var C9=new ie,P9=new ie,gl=new _,Cc=new _,Zp=new _,HA=new _,D9=new _,I9=new _;var ua=new qI,Dn=class extends Gh(gt){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof mr&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof mr&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let s=0,o=this.children.length;s<o;++s)this.remove(this.children[0]);let n=this.children;if(n.length===r)return;if(n.length<r)for(let s=0,o=r-n.length;s<o;++s){let a=new mr(this.object);a.expand(),this.add(a)}else for(let s=0,o=n.length-r;s<o;++s)this.remove(n[s])}else{if(this.children.length===r)return;if(this.children.length<r)for(let n=0,s=r-this.children.length;n<s;++n){let o=new mr(this.object);o.expand(),this.add(o)}else for(let n=0,s=this.children.length-r;n<s;++n)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,n=r.start*Se.DEG2RAD,s=r.end*Se.DEG2RAD,o=n-s,a=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new _(0,0,1);break;case"y":l=new _(0,1,0);break;default:case"x":l=new _(1,0,0);break}let u=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,c=u.noiseType==="perlin";ua.noiseSeed(u.seed);let h=pv((0,Id.default)(u.seed)),d=Kp(u.strength,this.parameters.randomness);for(let[f,p]of this.children.entries()){let m=f*(u.freqScale/10)+u.movement,g=c?ua.noise(m):h(m,m),y=f+1;p.scale.x=r.scale[0]+d(y,ct(g,u.scale[0]))||oi,p.scale.y=r.scale[1]+d(y,ct(g,u.scale[1]))||oi,p.scale.z=r.scale[2]+d(y,ct(g,u.scale[2]))||oi,p.position.setScalar(0);let v=o/e.count*f-n;switch(r.axis){case"x":p.rotation.set(0,v,0);break;case"y":p.rotation.set(0,0,v);break;case"z":p.rotation.set(v,0,0);break}p.translateOnAxis(l,r.radius),p.position.x+=r.position[0]+d(y,ct(g,u.position[0])),p.position.y+=r.position[1]+d(y,ct(g,u.position[1])),p.position.z+=r.position[2]+d(y,ct(g,u.position[2]));let x=d(y,ct(g,u.rotation[0])),w=d(y,ct(g,u.rotation[1])),S=d(y,ct(g,u.rotation[2]));r.alignment===!0?(p.rotation.x+=a.x+x,p.rotation.y+=a.y+w,p.rotation.z+=a.z+S):p.rotation.set(a.x+x,a.y+w,a.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,n=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";ua.noiseSeed(s.seed);let a=pv((0,Id.default)(s.seed)),l=Kp(s.strength,this.parameters.randomness);for(let[u,c]of this.children.entries()){let h=u*(s.freqScale/10)+s.movement,d=o?ua.noise(h):a(h,h),f=u+1,p=l(f,ct(d,s.rotation[0])),m=l(f,ct(d,s.rotation[1])),g=l(f,ct(d,s.rotation[2]));c.scale.x=1+(r.scale[0]-1)*u+l(f,ct(d,s.scale[0]))||oi,c.scale.y=1+(r.scale[1]-1)*u+l(f,ct(d,s.scale[1]))||oi,c.scale.z=1+(r.scale[2]-1)*u+l(f,ct(d,s.scale[2]))||oi,c.rotation.x=n.x*u+p,c.rotation.y=n.y*u+m,c.rotation.z=n.z*u+g,c.position.x=r.position[0]*u+l(f,ct(d,s.position[0])),c.position.y=r.position[1]*u+l(f,ct(d,s.position[1])),c.position.z=r.position[2]*u+l(f,ct(d,s.position[2]))}}_updateGrid(e){let r=0,n=e.grid,s=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,o=Kp(s.strength,this.parameters.randomness),a=s.noiseType==="perlin";ua.noiseSeed(s.seed);let l=U2((0,Id.default)(s.seed));if(n.useCenter===!0){let u={x:n.count[0]%2===0?2:1,y:n.count[1]%2===0?2:1,z:n.count[2]%2===0?2:1},c=new _(n.size[0]*(n.count[0]-u.x)*.5,n.size[1]*(n.count[1]-u.y)*.5,n.size[2]*(n.count[2]-u.z)*.5);for(let h=0;h<n.count[0];h++)for(let d=0;d<n.count[1];d++)for(let f=0;f<n.count[2];f++){let p=[(h+1)*(s.freqScale/10)+s.movement,(d+1)*(s.freqScale/10)+s.movement,(f+1)*(s.freqScale/10)+s.movement],m=a?ua.noise(...p):l(...p),g=this.children[r++];g.scale.x=1+o(r,ct(m,s.scale[0]))||oi,g.scale.y=1+o(r,ct(m,s.scale[1]))||oi,g.scale.z=1+o(r,ct(m,s.scale[2]))||oi;let y=o(r,ct(m,s.rotation[0])),v=o(r,ct(m,s.rotation[1])),x=o(r,ct(m,s.rotation[2]));g.rotation.set(y,v,x),g.position.x=n.size[0]*h-c.x+o(r,ct(m,s.position[0])),g.position.y=n.size[1]*d-c.y+o(r,ct(m,s.position[1])),g.position.z=n.size[2]*f-c.z+o(r,ct(m,s.position[2]))}}else for(let u=0;u<n.count[0];u++)for(let c=0;c<n.count[1];c++)for(let h=0;h<n.count[2];h++){let d=[(u+1)*(s.freqScale/10)+s.movement,(c+1)*(s.freqScale/10)+s.movement,(h+1)*(s.freqScale/10)+s.movement],f=a?ua.noise(...d):l(...d),p=this.children[r++];p.scale.x=1+o(r,ct(f,s.scale[0]))||oi,p.scale.y=1+o(r,ct(f,s.scale[1]))||oi,p.scale.z=1+o(r,ct(f,s.scale[2]))||oi;let m=o(r,ct(f,s.rotation[0])),g=o(r,ct(f,s.rotation[1])),y=o(r,ct(f,s.rotation[2]));p.rotation.set(m,g,y),p.position.x=n.size[0]*u+o(r,ct(f,s.position[0])),p.position.y=-n.size[1]*c+o(r,ct(f,s.position[1])),p.position.z=-n.size[2]*h+o(r,ct(f,s.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,n=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??eo.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";ua.noiseSeed(s.seed);let a=pv((0,Id.default)(s.seed)),l=Kp(s.strength,this.parameters.randomness);if(!r.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Dd)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),c=[],h=y=>{let v=y.length,x=y.map(A=>A[0]).reduce((A,E)=>A+E,0),w=y.map(A=>A[1]).reduce((A,E)=>A+E,0),S=y.map(A=>A[2]).reduce((A,E)=>A+E,0);return[x/v,w/v,S/v]},d=y=>Math.round(y*1e6)/1e6;u.forEach(y=>{let v=u.filter(x=>d(y.pos[0])===d(x.pos[0])&&d(y.pos[1])===d(x.pos[1])&&d(y.pos[2])===d(x.pos[2]));v.length>1?c.push({pos:y.pos,norm:h(v.map(x=>x.norm))}):c.push(y)});let f=HI(c);if(f.length>0){let y=Math.round(f.length*r.count/100);this._updateCount(y)}else{let y=this.objectForSample.geometry.getAttribute("position");if(!y||isNaN(y.count)||y.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let p=new mv(this.objectForSample).build(),m=UI[r.axis],g=this.children;p.setRandomGenerator((0,Id.default)(this.object.uuid+r.seed));for(let[y,v]of g.entries()){let x=y*(s.freqScale/10)+s.movement,w=o?ua.noise(x):a(x,x),S=y+1,A=l(S,ct(w,s.rotation[0])),E=l(S,ct(w,s.rotation[1])),b=l(S,ct(w,s.rotation[2]));r.spreadType==="random"?p.sample(Zp,HA):(f.length&&(Zp.fromArray(f[y].pos),HA.fromArray(f[y].norm)),this.objectForSample instanceof Ds&&Zp.applyMatrix4(C9.copy(this.objectForSample.matrixWorld).invert())),Zp.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Zp),gl.fromArray(m);let M=r.align==="normal"?HA:this.object.getWorldDirection(I9),T=Cc.fromArray(r.position);Cc.x+=Cc.x+l(S,ct(w,s.position[0])),Cc.y+=Cc.y+l(S,ct(w,s.position[1])),Cc.z+=Cc.z+l(S,ct(w,s.position[2]));let C=Math.acos(M.dot(gl)),P=D9.crossVectors(gl,M).normalize(),D=P9.makeRotationAxis(P,C),I=M.clone().cross(this.object.up).normalize(),R=I.clone().cross(M).normalize(),U=new ie().makeBasis(I,M,R),F=new _(gl.y,gl.z,gl.x).normalize(),V=F.clone().cross(gl).normalize(),G=new ie().makeBasis(F,gl,V).invert(),H=new ie().multiplyMatrices(U,G);v.rotation.setFromRotationMatrix(H),T.applyMatrix4(D),v.position.add(T),v.rotation.x=v.rotation.x+n.x+A,v.rotation.y=v.rotation.y+n.y+E,v.rotation.z=v.rotation.z+n.z+b,v.scale.setScalar(1),v.scale.x=v.scale.x+r.scale[0]+l(S,ct(w,s.scale[0]))||oi,v.scale.y=v.scale.y+r.scale[1]+l(S,ct(w,s.scale[1]))||oi,v.scale.z=v.scale.z+r.scale[2]+l(S,ct(w,s.scale[2]))||oi,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof Ds){let r=this.objectForSample,n=GI[e],s=eO[n],o=JI[n],a=$I[n],l=[],u=s(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let h=o(r.subdivPointerNew,c),d=a(r.subdivPointerNew,c);KI.fromArray(h).applyMatrix4(r.matrixWorld),ZI.fromArray(d),l.push({pos:KI.toArray(),norm:ZI.toArray()})}return l}else return(this.objectForSample.geometry.index?jI(this.objectForSample.geometry):WI(this.objectForSample.geometry)).map((n,s)=>e==="polygon_center"?{pos:n.midpoint,norm:n.norm}:e==="vertex"?[{pos:n.vertices[0],norm:n.norm},{pos:n.vertices[1],norm:n.norm},{pos:n.vertices[2],norm:n.norm}]:e==="edge"?[{pos:n.faceCenters[0],norm:n.norm},{pos:n.faceCenters[1],norm:n.norm},{pos:n.faceCenters[2],norm:n.norm}]:[]).flat()}updateState(e,r){if(this.parameters=Zo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let n=r.find(this.parameters.toObject.object);n instanceof $t?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new ie,this.hiddenMatrix=new ie,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var mo=i=>{var t;return t=class extends i{},t.geometryHelper=new yn(30,30,30),t};var i0=new gs,jA=new fr,tO=new ie,go=(i,t,e,r,n=!1)=>{let s=t,o=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),jA.copy(s.boundingSphere),jA.applyMatrix4(o),e.ray.intersectsSphere(jA)===!1||(tO.copy(o).invert(),i0.copy(e.ray).applyMatrix4(tO),s.boundingBox!==null&&i0.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,d=s.attributes.position,f=s.drawRange,p,m;if(n===!1){let y=Math.max(0,f.start),v=Math.min(h.count,f.start+f.count);for(p=y,m=v;p<m;p+=3)if(l=h.getX(p),u=h.getX(p+1),c=h.getX(p+2),a=g(i,e,i0,d,l,u,c),a){a.faceIndex=Math.floor(p/3),r.push(a);return}}else{let v=s.attributes.position,x=new _,w=new _,S=new _,A=new _,E=2,M=1/((i.scale.x+i.scale.y+i.scale.z)/3),T=M*M,C=Math.max(0,f.start),P=Math.min(v.count,f.start+f.count);for(let D=C,I=P-1;D<I;D+=E){if(x.fromBufferAttribute(v,D),w.fromBufferAttribute(v,D+1),i0.distanceSqToSegment(x,w,A,S)>T)continue;A.applyMatrix4(i.matrixWorld);let U=e.ray.origin.distanceTo(A);U<e.near||U>e.far||r.push({distance:U,point:S.clone().applyMatrix4(i.matrixWorld),object:i})}}function g(y,v,x,w,S,A,E){let b=new _,M=new _,T=new _,C=new _,P=new _;if(b.fromBufferAttribute(w,S),M.fromBufferAttribute(w,A),T.fromBufferAttribute(w,E),x.intersectTriangle(b,M,T,!1,C)===null)return null;P.copy(C),P.applyMatrix4(y.matrixWorld);let I=v.ray.origin.distanceTo(P);return I<v.near||I>v.far?null:{faceIndex:1,distance:I,point:P.clone(),object:y}}};var s0=new _,ns=new ys,WA=class extends Da{constructor(e){let r=new Ae,n=new Hi({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Re(15711266),u=new Re(15711266),c=new Re(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);function h(f,p,m){d(f,m),d(p,m)}function d(f,p){s.push(0,0,0),o.push(p.r,p.g,p.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}r.setAttribute("position",new be(s,3)),r.setAttribute("color",new be(o,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;ns.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=n?.8:1e-4;Is("n1",r,e,ns,-s,-o,a),Is("n2",r,e,ns,s,-o,a),Is("n3",r,e,ns,-s,o,a),Is("n4",r,e,ns,s,o,a);let l=a;Is("f1",r,e,ns,-s,-o,l),Is("f2",r,e,ns,s,-o,l),Is("f3",r,e,ns,-s,o,l),Is("f4",r,e,ns,s,o,l);let u=l,c=.5;Is("u1",r,e,ns,s*.7*c,o*1.1,u),Is("u2",r,e,ns,-s*.7*c,o*1.1,u),Is("u3",r,e,ns,0,o*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Is(i,t,e,r,n,s,o){s0.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],s0.x,s0.y,s0.z)}}var o0=class extends mo(WA){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){go(this.object,this.geometry,e,r,!0)}};var a0;(t=>t.is=e=>"objectHelper"in e)(a0||(a0={}));var yo=(i,t)=>class extends jh(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,s){this.objectHelper.raycast(n,s)}showGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof Na&&(s.visible=!0)}}updateEntityBoxSize(n,s){this.objectHelper.visible&&this.geometryHelper instanceof yn?(n.setScalar(0),s.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,s)}hideGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof Na&&(s.visible=!1)}}};var l0=790,Od=new _,qA=new _,YA=new He,XA=new _,Jp=new _,QA=new _,er=class extends yo(ys,o0){constructor(e="",r={...cc.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Qa.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new ie,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,s=this.height;this.orthoCamera=new lu(n*-.5,n*.5,s*.5,s*-.5,-5e4,1e4),this.perspCamera=new Ir(45,n/s,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,n){typeof e=="number"&&(e=new _(e,r,n)),super.lookAt(e),this.getWorldPosition(Od),this.targetOffset=Od.distanceTo(e)}getTarget(e=new _){return this.getWorldDirection(qA),this.getWorldPosition(Od),qA.multiplyScalar(this.targetOffset),e.copy(Od).add(qA),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Od),Od.distanceTo(e)}updateUp(){this.getWorldQuaternion(YA),XA.set(0,0,1).applyQuaternion(YA),Jp.copy(gt.DEFAULT_UP),this.isUpVectorFlipped&&Jp.negate(),Jp.applyQuaternion(YA),QA.copy(gt.DEFAULT_UP).projectOnPlane(XA),this.angleOffsetFromUp=QA.angleTo(Jp),this.angleOffsetFromUp*=QA.cross(Jp).dot(XA)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new _),s=e.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new _,n=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let s=e>r?this.aspect:1,o=e>r?1:this.aspect;this.left=-l0*.5*s,this.right=l0*.5*s,this.top=l0*.5*(1/o),this.bottom=-l0*.5*(1/o)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,s,o,a):this.orthoCamera.setViewOffset(e,r,n,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ih(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var Rd=new ie,R9=new ie,c0=new ie,rO=new _,nO=new _;function KA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}var is=class extends ts{constructor(e,r,n){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Ae;this.onAfterRender=(e,r,n,s,o,a)=>{super.onAfterRender(e,r,n,s,o,a),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let s=0;s<this.children.length;s++){let o=this.children[s];o instanceof is&&o.dataPatched.visible===!0&&o.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let s=0;s<this.children.length;s++){let o=this.children[s];if(o instanceof $t&&o.dataPatched.visible===!0&&o.geometry.attributes.position?.count>0&&o.geometry.drawRange.count>0&&o.booleanMeshSetAddress!==0){Rd.multiplyMatrices(o.hiddenMatrix,o.matrix);try{if(o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=Ji.getMeshSet(o.geometry,e===!0,r)),o.booleanMeshSetAddress===-1)return;Ji.transformMeshSet(o.booleanMeshSetAddress,Rd),o.booleanMatrixInvOld.copy(Rd).invert(),o.booleanWasTransformed=!1}else o instanceof is&&o.needsTransformForDownstream===!0?(Ji.transformMeshSet(o.booleanMeshSetAddress,Rd),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(Ji.transformMeshSet(o.booleanMeshSetAddress,R9.multiplyMatrices(Rd,o.booleanMatrixInvOld)),o.booleanMatrixInvOld.copy(Rd).invert(),o.booleanWasTransformed=!1)}catch(a){console.error(a),o.booleanMeshSetAddress=0,o.geometry.userData.booleanOperationDidFail=!0;continue}Ji.hasOpenEdges(o.booleanMeshSetAddress)===!1||s===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(o.booleanMeshSetAddress),o.geometry.userData.booleanOperationDidFail=!1):o.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new be([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Ji.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let n=this.geometry;n.dispose(),this.geometry=new Ae,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere;try{this.booleanMeshSetAddress=Ji.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Td(this),Cd(this)}dispose(){super.dispose(),this.geometry.dispose()}get recursiveBBox(){let e=super.recursiveBBox;return this.geometry.boundingSphere?.radius===-1&&(e.getCenter(this.geometry.boundingSphere.center),c0.copy(this.matrixWorld).invert(),this.geometry.boundingSphere.center.applyMatrix4(c0),rO.copy(e.max).applyMatrix4(c0),nO.copy(e.min).applyMatrix4(c0),this.geometry.boundingSphere.radius=rO.distanceTo(nO)/2),e}};var u0;(t=>{function i(e){return lt.is(e)&&e instanceof Ra}t.is=i})(u0||(u0={}));var Ld=(i,t)=>class extends yo(i,t){updateState_Light(r,n){this.updateState_Entity(r,n),r.color!==void 0&&(this.color=n.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var Yn=i=>i instanceof $t,Xn=i=>i!==null&&i instanceof is,iO=i=>i instanceof er,sO=i=>u0.is(i),$p=i=>a0.is(i);var vo=class extends mo(Lg){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){go(this.object,vo.geometryHelper,e,r)}update(){}};var ss=class extends yo(js,vo){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var dO={RED:0,GREEN:1,BLUE:2,ALPHA:3};var em="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var L9=`#ifdef FRAMEBUFFER_PRECISION_HIGH
5372
5372
  uniform mediump sampler2D inputBuffer;
5373
5373
  #else
5374
5374
  uniform lowp sampler2D inputBuffer;
@@ -6423,7 +6423,7 @@ end_header
6423
6423
  gVelocity = vec4(0.0); // so it is ignored by TAA
6424
6424
  }`,s={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new N},viewport:{type:"v2",value:new N},basisViewport:{type:"v2",value:new N},debugColor:{type:"v3",value:new Re},covariancesTextureSize:{type:"v2",value:new N(1024,1024)},centersColorsTextureSize:{type:"v2",value:new N(1024,1024)},orthoZoom:{type:"f",value:-1}};return new at({uniforms:s,vertexShader:r,fragmentShader:n,transparent:!0,alphaTest:1,blending:_a,depthTest:!0,depthWrite:!1,side:Ln})}static buildGeomtery(e){let r=new Ae;r.setIndex([0,1,2,0,2,3]);let n=new Float32Array(4*3),s=new Ge(n,3);r.setAttribute("position",s),s.setXYZ(0,-1,-1,0),s.setXYZ(1,-1,1,0),s.setXYZ(2,1,1,0),s.setXYZ(3,1,-1,0),s.needsUpdate=!0;let o=new qf().copy(r),a=new Uint32Array(e),l=new uu(a,1,!1);return l.setUsage(iM),o.setAttribute("splatIndex",l),o.instanceCount=e,o}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(s=>s.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,n=0;for(let s of this.splatBuffers){let o=s.nsplats;this.colors.subarray(e,e+o*4).set(s.colorsA),e+=o*4,this.centers.subarray(r,r+o*3).set(s.decoded.xyz.denormDequant().data),r+=o*3,this.covariances.subarray(n,n+o*6).set(new Float32Array(s.precomputedCovarianceBufferData)),n+=o*6}}allocateAndStoreLocalSplatDataInTextures(){let n=this.splatCount,s=new N(4096,1024);for(;s.x*s.y*2<n*6;)s.y*=2;let o=new N(4096,1024);for(;o.x*o.y*4<n*4;)o.y*=2;let a,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(s.x*s.y*2);for(let p=0;p<this.covariances.length;p++)l[p]=xM.toHalfFloat(this.covariances[p]);a=new li(l,s.x,s.y,Pu,Go)}else l=new Float32Array(s.x*s.y*2),l.set(this.covariances),a=new li(l,s.x,s.y,Pu,Xr);a.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=a,this.material.uniforms.covariancesTextureSize.value.copy(s);let u=new Uint32Array(o.x*o.y*4);for(let p=0;p<n;p++){let m=p*4,g=p*3,y=p*4;u[y]=DR(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[y+1]=L0(this.centers[g]),u[y+2]=L0(this.centers[g+1]),u[y+3]=L0(this.centers[g+2])}let c=new li(u,o.x,o.y,Xb,ps);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(o);let h=256*4,d=new Float32Array(256*16);for(let p=0;p<this.meshMatrixWorlds.length;p++)d.set(this.meshMatrixWorlds[p].elements,p*16);let f=new li(d,h,1,$n,Xr);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:a,size:s},centerColors:{data:u,texture:c,size:o},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,n,s){this.splatCount>0&&(N0.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(N0),this.material.uniforms.basisViewport.value.set(2/N0.x,2/N0.y),this.material.uniforms.focal.value.set(r,n),this.material.uniforms.orthoZoom.value=s,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var sm=class{constructor(t={}){mn(this,"updateSplatMeshUniforms",function(){let t=new N;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());mn(this,"updateView",function(){let t=new ie,e=[],r=new _(0,0,-1),n=new _(0,0,-1),s=new _,o=new _;return function(a=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!a){n.set(0,0,-1).applyQuaternion(this.camera.quaternion);let h=!1,d=!1;if(n.dot(r)<=.95&&(h=!0),o.copy(this.camera.position).sub(s).length()>=1&&(d=!0),!h&&!d&&!l&&!u)return}s.copy(this.camera.position),r.copy(n),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new _().fromArray(t.position)),t.orientation&&(t.orientation=new He().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(o=>{if(o.data.type==="Splat"){let a=o.visible;o.traverseAncestors(l=>{a&&(a=l.visible)}),a&&e.push(o)}}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(o=>o.matrixWorld),this.meshMatrixWorldsOld=e.map(o=>o.matrixWorld.clone()),this.cropsArray=e.map(o=>o.data.crops.map(a=>a.data));let r=e.map(o=>new Al(new Uint8Array(o.data.buffer).buffer)),n=0,s=[0];for(let o of r)n+=o.getSplatCount(),s.push(n);return this.setupSplatMesh(r,n,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(n),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((n,s)=>{this.cropsArray[r][s]===void 0?(t=!0,this.cropsArray[r][s]=n.data):Object.entries(n.data).forEach(([o,a])=>{Array.isArray(a)&&a.some((l,u)=>l!==this.cropsArray[r][s][o][u])?(t=!0,this.cropsArray[r][s][o]=a):a!==this.cropsArray[r][s]?.[o]&&(t=!0,this.cropsArray[r][s][o]=a)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new _,n=new He,s=!1,o=1,a,l){this.splatMesh=_l.buildMesh(t,e,s,o,a,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(n),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=PR(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var _0=new Ho;_0.wireframe=!0;var IR=new _,xl=class extends Nn{constructor(e,r){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.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new I0;this.errorPage=new Si("fdasfa",{...ea.defaultData,name:""});this.invisibleObjects=new ss("jflkdsafjasdifjaslk",{...Jy.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=JO(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=ZO(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),n=this.entityIdentityToEntity[r];n&&(e.uuid=n.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Si&&(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 r=this.find(e);if(r===void 0)return;let n=[],s=r;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);n.splice(0,0,a)}return{entity:r,sortKey:n}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push(s)}return r.sort((n,s)=>JC(n.sortKey,s.sortKey)),r.map(n=>n.entity)}nonExistOrDescendantOf(e,r){let n=this.find(e);if(n===void 0)return!0;for(;n;){if(n.uuid===r)return!0;n=n.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===Qi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.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(r=>{this.toExpandCloner.add(r)})}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,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let n=e.parent===null?this:this.find(e.parent);if(n===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,n,e.localIndex,r);s.updateVisible(),s.resetBBoxNeedsUpdate(),Yn(s)&&Xn(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markToExpandCloner(n),n.resetBBoxNeedsUpdate(),this.unregisterObject(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(n),this.markPenumbraSizeDirty(),n.parent.remove(n),Xn(n.parent)&&(n.parent.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Yn(n)&&(n.freeBooleanPointer(),s instanceof is&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n instanceof bl&&n.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),this.pathConstraints.removeDependencies(n.uuid),n.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),n.cloner?.resetOnMove(),this.markToExpandCloner(n);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(n),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(n),n.invalidateClonerTransform(n),n.updateVisible(),n.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Yn(n)&&(n.invalidateUpstreamBooleanData(),Xn(n.parent)?n.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof is&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n.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 r of this.children)r instanceof Si&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,n,s){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:a}=r.props;r={...r,props:a},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let o=this.find(e);if(o)try{XO(o,r,n,{scene:this,shared:s}),o instanceof Qt&&o.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,r){let n=Object.entries(r.data.lib.components).map((s,o)=>({data:s[1].asset.data,children:s[1].asset.children,id:s[0],fi:o}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(n,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(s=>{Xn(s)&&s.recomputeBoolean(),s instanceof er&&s.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){lt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{lt.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,n,s,o,a,l){if(e){let u=s.find(e);u&&u!==s&&o.forInstancesRec(c=>{c.data=Ha(c.data,h=>{let d=h.events.data(l.id),f=c.goUp(a);if(f){let p=[...hy(f.identity),e].join("-"),m=this.entityIdentityToEntity[p];if(m){let g=m.uuid,y=Rr.zoom(d,r);y[n]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,n,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Rs&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,n)=>{r.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(r.forInstancesRec(a=>{a.data=Ha(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of Eh.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,r,n,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,r,n,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,r,n,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,r,n,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,n,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,n,s)),this.rewriteActions(s.data.inActions,["inActions"],e,r,n,s),this.rewriteActions(s.data.outActions,["outActions"],e,r,n,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,r,n,s)})}),!0})}expandInstances(e,r,n){let s=new Set;this.traverseEntity(o=>{if(o instanceof Rs&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),r||o.resetBBoxNeedsUpdate(),n&&o.traverseEntity(a=>{n.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),C0(o)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof Rs&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let n=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[n]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[n]),r.dispose()})}clearScene(){for(let e of this.children)lt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let n=[],s=o=>{for(let a of o.children){let l=a.cloner;if(lt.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(r===!0&&a.isInstanceRoot){let u=[];if(e.intersectObject(a,!0,u),u.length){let c=u[0];c.object=a,c.point.applyMatrix4(c.object.matrixWorld);let h=a.matrixWorld.clone().invert();c.point.applyMatrix4(h),n.push(c)}}else(Yn(a)||$p(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,n),im(a,e,n)),s(a)}};return s(this),n}raycastWithClones(e){let r=[],n=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Yn(o)||$p(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),im(o,e,r,!0)),n(o))}};return n(this),r}forEachEntity(e){for(let r of this.children)lt.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)lt.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)lt.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(n=>{if(n instanceof Qt&&n.data.type==="Mesh"&&n.data.geometry.type==="TextGeometry"&&n.data.geometry.font===e){let s=n.geometry,o=n.data.geometry;s.updateFont(e,r).then(()=>{s.update(o);let a=n.invalidateDownstreamBooleanData();Xn(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Uh.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)lt.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,n){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,r,s,n),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,n,s,o,a){let l={scene:this,shared:a},u=D0(e,r,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),n.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(n,u,a)),u.updateState(r,l),u instanceof Qt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let h=c.dataPatched;if(c instanceof Qt&&h.bones&&h.boneInverses){let d=h.bones.map(m=>this.find(m)),f=h.boneInverses.map(m=>new ie().fromArray(m)),p=new Pa(d,f);c.bind(p,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let n=new Pt;return n.setFromPoints(r),n.getCenter(IR),IR}copyMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e);n?r.copy(n.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e)?.parent;n?r.copy(n.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof $t)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)r.material[n]instanceof bi&&e(r.material[n]);else r.material instanceof bi&&e(r.material)})}updateViewPlaneSize(e,r,n=!1){this.traverseConcreteEntity(s=>{s instanceof er&&s.setViewplaneSize(e,r,n)})}initializeSplatViewer(e){this.splatViewer=new sm({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};var om=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},OR=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return W7(Math.atan2(r,e))},RR=(i,t,e)=>{let r={x:0,y:0};return e=B0(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},B0=i=>i*(Math.PI/180),W7=i=>i*(180/Math.PI),LR=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,p1=new Map,m1=i=>{p1.has(i)&&clearTimeout(p1.get(i)),p1.set(i,setTimeout(i,100))},$d=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let s=0;s<r.length;s+=1)n=r[s],i.addEventListener?i.addEventListener(n,e,!1):i.attachEvent&&i.attachEvent(n,e)},g1=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let s=0;s<r.length;s+=1)n=r[s],i.removeEventListener?i.removeEventListener(n,e):i.detachEvent&&i.detachEvent(n,e)};var F0=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),y1=()=>{if(typeof window>"u")return;let i=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:i,y:t}},k0=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},V0=(i,t,e)=>{let r=BR(i);for(let n in r)if(r.hasOwnProperty(n))if(typeof t=="string")r[n]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";r[n]=s.slice(0,-2)}return r},NR=(i,t)=>{let e=BR(i);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},BR=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},z0=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},FR=(i,t)=>{let e={};for(let r in i)i.hasOwnProperty(r)&&t.hasOwnProperty(r)?e[r]=t[r]:i.hasOwnProperty(r)&&(e[r]=i[r]);return e},am=(i,t)=>{if(i.length)for(let e=0,r=i.length;e<r;e+=1)t(i[e]);else t(i)},kR=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(VR="ontouchstart"in window,zR=!!window.PointerEvent,UR=!!window.MSPointerEvent);var VR,zR,UR,lm={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"}},ef,cm={};zR?ef=lm.pointer:UR?ef=lm.MSPointer:VR?(ef=lm.touch,cm=lm.mouse):ef=lm.mouse;function Nc(){}Nc.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)n=r[s],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};Nc.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};Nc.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)n=r[s],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(o){o.call(e,{type:n,target:e},t)})};Nc.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=FR(t.options,i))};Nc.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},$d(i,ef[t],e._domHandlers_[t]),cm[t]&&$d(i,cm[t],e._domHandlers_[t]),e};Nc.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},g1(i,ef[t],e._domHandlers_[t]),cm[t]&&g1(i,cm[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var tf=Nc;function un(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,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=un.id,un.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}un.prototype=new tf;un.constructor=un;un.id=0;un.prototype.buildEl=function(i){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)};un.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=NR("borderRadius","50%"),e=V0("transition","opacity",i),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)"},z0(r.el,e),this.options.shape==="circle"&&z0(r.back,t),z0(r.front,t),this.applyStyles(r),this};un.prototype.applyStyles=function(i){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};un.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};un.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};un.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};un.prototype.show=function(i){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 i=="function"&&i.call(this)},t.options.fadeTime)),t};un.prototype.hide=function(i){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 e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,r)}return t};un.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",n={};n.front=V0("transition",["top","left"],r);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(n),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};un.prototype.restCallback=function(){var i=this,t={};t.front=V0("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};un.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};un.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,r=Math.PI/2,n,s,o;if(t>e&&t<e*3&&!i.lockX?n="up":t>-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t<r?s="left":s="right"),i.lockX||(t>0?o="up":o="down"),i.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:n},i.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return i;(!u.x||!u.y)&&this.trigger("plain",i),u.x||this.trigger("plain:"+s,i),u.y||this.trigger("plain:"+o,i),u.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var GR=un;function Vr(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Vr.id,Vr.id+=1,e.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},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Vr.prototype=new tf;Vr.constructor=Vr;Vr.id=0;Vr.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===e)return t[r];return!1}};Vr.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Vr.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Vr.prototype.createNipple=function(i,t){var e=this,r=e.manager.scroll,n={},s=e.options,o={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(i.x&&i.y)n={x:i.x-o.x,y:i.y-o.y};else if(i.top||i.right||i.bottom||i.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=i.top,a.style.right=i.right,a.style.bottom=i.bottom,a.style.left=i.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),n=i,i={x:l.left+r.x,y:l.top+r.y}}var u=new GR(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:i,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(k0(u.ui.el,n),k0(u.ui.front,u.frontPosition)),e.nipples.push(u),e.trigger("added "+u.identifier+":added",u),e.manager.trigger("added "+u.identifier+":added",u),e.bindNipple(u),u};Vr.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Vr.prototype.bindNipple=function(i){var t=this,e,r=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Vr.prototype.pressureFn=function(i,t,e){var r=this,n=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var s=i.force||i.pressure||i.webkitForce||0;s!==n&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),n=s)}.bind(r),100)};Vr.prototype.onstart=function(i){var t=this,e=t.options,r=i;i=F0(i),t.updateBox();var n=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(r.touches).findIndex(function(l){return l.identifier===o})<0){var a=[i[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return am(i,n),t.manager.bindDocument(),!1};Vr.prototype.processOnStart=function(i){var t=this,e=t.options,r,n=t.manager.getIdentifier(i),s=i.force||i.pressure||i.webkitForce||0,o={x:i.pageX,y:i.pageY},a=t.getOrCreate(n,o);a.identifier!==n&&t.manager.removeIdentifier(a.identifier),a.identifier=n;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(i,c,c.identifier),t.processOnMove(i)};if((r=t.idles.indexOf(a))>=0&&t.idles.splice(r,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var u=om(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(i);return}}return a};Vr.prototype.getOrCreate=function(i,t){var e=this,r=e.options,n;return/(semi|static)/.test(r.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):r.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,i),n)};Vr.prototype.processOnMove=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),s=t.manager.scroll;if(!LR(i)){this.processOnEnd(i);return}if(!n){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var o=n.el.getBoundingClientRect();n.position={x:s.x+o.left,y:s.y+o.top}}n.identifier=r;var a=n.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=n.position.y),e.lockY&&(l.x=n.position.x);var u=om(l,n.position),c=OR(l,n.position),h=B0(c),d=u/a,f={distance:u,position:l},p,m;if(n.options.shape==="circle"?(p=Math.min(u,a),m=RR(n.position,p,c)):(m=kR(l,n.position,a),p=om(m,n.position)),e.follow){if(u>a){let x=l.x-m.x,w=l.y-m.y;n.position.x+=x,n.position.y+=w,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",u=om(l,n.position)}}else l=m,u=p;var g=l.x-n.position.x,y=l.y-n.position.y;n.frontPosition={x:g,y},e.dataOnly||k0(n.ui.front,n.frontPosition);var v={identifier:n.identifier,position:l,force:d,pressure:i.force||i.pressure||i.webkitForce||0,distance:u,angle:{radian:h,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:n,lockX:e.lockX,lockY:e.lockY};v=n.computeDirection(v),v.angle={radian:B0(180-c),degree:180-c},n.trigger("move",v),t.trigger("move "+n.id+":move",v)};Vr.prototype.processOnEnd=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),s=t.manager.removeIdentifier(n.identifier);!n||(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};Vr.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Vr.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)i.pressureIntervals.hasOwnProperty(t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off()};var HR=Vr;function In(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=y1(),t.config(i),t.prepareCollections();var e=function(){var n;t.collections.forEach(function(s){s.forEach(function(o){n=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+n.left,y:t.scroll.y+n.top}})})};if(typeof window>"u")return t.collections;$d(window,"resize",function(){m1(e)});var r=function(){t.scroll=y1()};return $d(window,"scroll",function(){m1(r)}),t.collections}In.prototype=new tf;In.constructor=In;In.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(r){return e=r.get(t),!e}),e}};In.prototype.create=function(i){return this.createCollection(i)};In.prototype.createCollection=function(i){var t=this,e=new HR(t,i);return t.bindCollection(e),t.collections.push(e),e};In.prototype.bindCollection=function(i){var t=this,e,r=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};In.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};In.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};In.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.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]};In.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};In.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};In.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};In.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};In.prototype.onAny=function(i,t){var e=this,r,n="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=F0(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[n](a),a._found_=!0)},o=function(a){r=e.getIdentifier(a),am(e.collections,s.bind(null,a,r)),a._found_||e.removeIdentifier(r)};return am(t,o),!1};In.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.off()};In.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var jR=In;var WR=new jR,qR={create:function(i){return WR.create(i)},factory:WR};var YR=new Map,um=new Map,Ao=class{constructor(t,e,r,n){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let u=typeof s=="string"?n.getAudio(s).src:s.data;this.audioPlayer=new ca({src:u,volume:o,delay:a,loop:l}),um.has(r.uuid)?um.get(r.uuid).push(this):um.set(r.uuid,[this]),YR.set(t,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()}},rf=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=YR.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=um.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...um.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},hm=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new Ao(t,e,r,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new rf(e);else throw new Error("Missing property")}dispatchBasic(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ao?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ao?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ao&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var q7="text/plain",Y7="us-ascii",XR=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),X7=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:r,data:n,hash:s}=e.groups,o=r.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(h=>{let[d,f=""]=h.split("=").map(p=>p.trim());return d==="charset"&&(f=f.toLowerCase(),f===Y7)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==q7)&&c.unshift(l),`data:${c.join(";")},${a?n.trim():n}${s?`#${s}`:""}`};function v1(i,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},i=i.trim(),/^data:/i.test(i))return X7(i,t);if(/^view-source:/i.test(i))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=i.startsWith("//");!e&&/^\.*\//.test(i)||(i=i.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let n=new URL(i);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&n.protocol==="https:"&&(n.protocol="http:"),t.forceHttps&&n.protocol==="http:"&&(n.protocol="https:"),t.stripAuthentication&&(n.username="",n.password=""),t.stripHash?n.hash="":t.stripTextFragment&&(n.hash=n.hash.replace(/#?:~:text.*?$/i,"")),n.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(n.pathname);if(!c)break;let h=c[0],d=c.index,f=n.pathname.slice(a,d);l+=f.replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}let u=n.pathname.slice(a,n.pathname.length);l+=u.replace(/\/{2,}/g,"/"),n.pathname=l}if(n.pathname)try{n.pathname=decodeURI(n.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=n.pathname.split("/"),a=o[o.length-1];XR(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),n.pathname=o.slice(1).join("/")+"/")}if(n.hostname&&(n.hostname=n.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(n.hostname)&&(n.hostname=n.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...n.searchParams.keys()])XR(o,t.removeQueryParameters)&&n.searchParams.delete(o);if(t.removeQueryParameters===!0&&(n.search=""),t.sortQueryParameters){n.searchParams.sort();try{n.search=decodeURIComponent(n.search)}catch{}}t.removeTrailingSlash&&(n.pathname=n.pathname.replace(/\/$/,""));let s=i;return i=n.toString(),!t.removeSingleSlash&&n.pathname==="/"&&!s.endsWith("/")&&n.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||n.pathname==="/")&&n.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var G0=class{constructor({url:t,context:e},r,n,s){this.controlsManager=r;this.shared=n;this.condition=s;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:v1(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){if(Bt(this.shared,this.condition)===!1)return!1;sh?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(qe[0]),eP())}};var dm=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,n=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)n?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(n||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(Bt(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(Bt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var fm=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.shared=r;this.eventManager=n;this.condition=s;this.shared=r}dispatch(){if(Bt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),nf(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}};var eL={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},S1={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},Q7=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],j0={CSS:{},springs:{}};function Ns(i,t,e){return Math.min(Math.max(i,t),e)}function pm(i,t){return i.indexOf(t)>-1}function x1(i,t){return i.apply(null,t)}var it={arr:function(i){return Array.isArray(i)},obj:function(i){return pm(Object.prototype.toString.call(i),"Object")},pth:function(i){return it.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||it.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i>"u"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return it.hex(i)||it.rgb(i)||it.hsl(i)},key:function(i){return!eL.hasOwnProperty(i)&&!S1.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function tL(i){var t=/\(([^)]+)\)/.exec(i);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function rL(i,t){var e=tL(i),r=Ns(it.und(e[0])?1:e[0],.1,100),n=Ns(it.und(e[1])?100:e[1],.1,100),s=Ns(it.und(e[2])?10:e[2],.1,100),o=Ns(it.und(e[3])?0:e[3],.1,100),a=Math.sqrt(n/r),l=s/(2*Math.sqrt(n*r)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,h=l<1?(l*a+-o)/u:-o+a;function d(p){var m=t?t*p/1e3:p;return l<1?m=Math.exp(-m*l*a)*(c*Math.cos(u*m)+h*Math.sin(u*m)):m=(c+h*m)*Math.exp(-m*a),p===0||p===1?p:1-m}function f(){var p=j0.springs[i];if(p)return p;for(var m=1/6,g=0,y=0;;)if(g+=m,d(g)===1){if(y++,y>=16)break}else y=0;var v=g*m*1e3;return j0.springs[i]=v,v}return t?d:f}function K7(i){return i===void 0&&(i=10),function(t){return Math.ceil(Ns(t,1e-6,1)*i)*(1/i)}}var Z7=function(){var i=11,t=1/(i-1);function e(c,h){return 1-3*h+3*c}function r(c,h){return 3*h-6*c}function n(c){return 3*c}function s(c,h,d){return((e(h,d)*c+r(h,d))*c+n(h))*c}function o(c,h,d){return 3*e(h,d)*c*c+2*r(h,d)*c+n(h)}function a(c,h,d,f,p){var m,g,y=0;do g=h+(d-h)/2,m=s(g,f,p)-c,m>0?d=g:h=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(c,h,d,f){for(var p=0;p<4;++p){var m=o(h,d,f);if(m===0)return h;var g=s(h,d,f)-c;h-=g/m}return h}function u(c,h,d,f){if(!(0<=c&&c<=1&&0<=d&&d<=1))return;var p=new Float32Array(i);if(c!==h||d!==f)for(var m=0;m<i;++m)p[m]=s(m*t,c,d);function g(y){for(var v=0,x=1,w=i-1;x!==w&&p[x]<=y;++x)v+=t;--x;var S=(y-p[x])/(p[x+1]-p[x]),A=v+S*t,E=o(A,c,d);return E>=.001?l(y,A,c,d):E===0?A:a(y,v,v+t,c,d)}return function(y){return c===h&&d===f||y===0||y===1?y:s(g(y),h,f)}}return u}(),nL=function(){var i={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 n,s=4;r<((n=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((n*3-2)/22-r,2)}},Elastic:function(r,n){r===void 0&&(r=1),n===void 0&&(n=.5);var s=Ns(r,1,10),o=Ns(n,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(r,n){t[r]=function(){return function(s){return Math.pow(s,n+2)}}}),Object.keys(t).forEach(function(r){var n=t[r];i["easeIn"+r]=n,i["easeOut"+r]=function(s,o){return function(a){return 1-n(s,o)(1-a)}},i["easeInOut"+r]=function(s,o){return function(a){return a<.5?n(s,o)(a*2)/2:1-n(s,o)(a*-2+2)/2}}}),i}();function A1(i,t){if(it.fnc(i))return i;var e=i.split("(")[0],r=nL[e],n=tL(i);switch(e){case"spring":return rL(i,t);case"cubicBezier":return x1(Z7,n);case"steps":return x1(K7,n);default:return x1(r,n)}}function iL(i){try{var t=document.querySelectorAll(i);return t}catch{return}}function W0(i,t){for(var e=i.length,r=arguments.length>=2?arguments[1]:void 0,n=[],s=0;s<e;s++)if(s in i){var o=i[s];t.call(r,o,s,i)&&n.push(o)}return n}function q0(i){return i.reduce(function(t,e){return t.concat(it.arr(e)?q0(e):e)},[])}function QR(i){return it.arr(i)?i:(it.str(i)&&(i=iL(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function _1(i,t){return i.some(function(e){return e===t})}function E1(i){var t={};for(var e in i)t[e]=i[e];return t}function b1(i,t){var e=E1(i);for(var r in i)e[r]=t.hasOwnProperty(r)?t[r]:i[r];return e}function Y0(i,t){var e=E1(i);for(var r in t)e[r]=it.und(i[r])?t[r]:i[r];return e}function J7(i){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return t?"rgba("+t[1]+",1)":i}function $7(i){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=i.replace(t,function(a,l,u,c){return l+l+u+u+c+c}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),n=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+n+","+s+","+o+",1)"}function eX(i){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),e=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,n=parseInt(t[3],10)/100,s=t[4]||1;function o(d,f,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?d+(f-d)*6*p:p<1/2?f:p<2/3?d+(f-d)*(2/3-p)*6:d}var a,l,u;if(r==0)a=l=u=n;else{var c=n<.5?n*(1+r):n+r-n*r,h=2*n-c;a=o(h,c,e+1/3),l=o(h,c,e),u=o(h,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function tX(i){if(it.rgb(i))return J7(i);if(it.hex(i))return $7(i);if(it.hsl(i))return eX(i)}function fa(i){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(i);if(t)return t[1]}function rX(i){if(pm(i,"translate")||i==="perspective")return"px";if(pm(i,"rotate")||pm(i,"skew"))return"deg"}function w1(i,t){return it.fnc(i)?i(t.target,t.id,t.total):i}function _o(i,t){return i.getAttribute(t)}function M1(i,t,e){var r=fa(t);if(_1([e,"deg","rad","turn"],r))return t;var n=j0.CSS[t+e];if(!it.und(n))return n;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return j0.CSS[t+e]=u,u}function sL(i,t,e){if(t in i.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=i.style[t]||getComputedStyle(i).getPropertyValue(r)||"0";return e?M1(i,n,e):n}}function T1(i,t){if(it.dom(i)&&!it.inp(i)&&(_o(i,t)||it.svg(i)&&i[t]))return"attribute";if(it.dom(i)&&_1(Q7,t))return"transform";if(it.dom(i)&&t!=="transform"&&sL(i,t))return"css";if(i[t]!=null)return"object"}function oL(i){if(!!it.dom(i)){for(var t=i.style.transform||"",e=/(\w+)\(([^)]*)\)/g,r=new Map,n;n=e.exec(t);)r.set(n[1],n[2]);return r}}function nX(i,t,e,r){var n=pm(t,"scale")?1:0+rX(t),s=oL(i).get(t)||n;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),r?M1(i,s,r):s}function C1(i,t,e,r){switch(T1(i,t)){case"transform":return nX(i,t,r,e);case"css":return sL(i,t,e);case"attribute":return _o(i,t);default:return i[t]||0}}function P1(i,t){var e=/^(\*=|\+=|-=)/.exec(i);if(!e)return i;var r=fa(i)||0,n=parseFloat(t),s=parseFloat(i.replace(e[0],""));switch(e[0][0]){case"+":return n+s+r;case"-":return n-s+r;case"*":return n*s+r}}function aL(i,t){if(it.col(i))return tX(i);if(/\s/g.test(i))return i;var e=fa(i),r=e?i.substr(0,i.length-e.length):i;return t?r+t:r}function D1(i,t){return Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))}function iX(i){return Math.PI*2*_o(i,"r")}function sX(i){return _o(i,"width")*2+_o(i,"height")*2}function oX(i){return D1({x:_o(i,"x1"),y:_o(i,"y1")},{x:_o(i,"x2"),y:_o(i,"y2")})}function lL(i){for(var t=i.points,e=0,r,n=0;n<t.numberOfItems;n++){var s=t.getItem(n);n>0&&(e+=D1(r,s)),r=s}return e}function aX(i){var t=i.points;return lL(i)+D1(t.getItem(t.numberOfItems-1),t.getItem(0))}function cL(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return iX(i);case"rect":return sX(i);case"line":return oX(i);case"polyline":return lL(i);case"polygon":return aX(i)}}function lX(i){var t=cL(i);return i.setAttribute("stroke-dasharray",t),t}function cX(i){for(var t=i.parentNode;it.svg(t)&&it.svg(t.parentNode);)t=t.parentNode;return t}function uL(i,t){var e=t||{},r=e.el||cX(i),n=r.getBoundingClientRect(),s=_o(r,"viewBox"),o=n.width,a=n.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function uX(i,t){var e=it.str(i)?iL(i)[0]:i,r=t||100;return function(n){return{property:n,el:e,svg:uL(e),totalLength:cL(e)*(r/100)}}}function hX(i,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return i.el.getPointAtLength(l)}var r=uL(i.el,i.svg),n=e(),s=e(-1),o=e(1);switch(i.property){case"x":return(n.x-r.x)*r.w;case"y":return(n.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function KR(i,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=aL(it.pth(i)?i.totalLength:i,t)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:it.str(i)||t?r.split(e):[]}}function hL(i){var t=i?q0(it.arr(i)?i.map(QR):QR(i)):[];return W0(t,function(e,r,n){return n.indexOf(e)===r})}function dL(i){var t=hL(i);return t.map(function(e,r){return{target:e,id:r,total:t.length,transforms:{list:oL(e)}}})}function dX(i,t){var e=E1(t);if(/^spring/.test(e.easing)&&(e.duration=rL(e.easing)),it.arr(i)){var r=i.length,n=r===2&&!it.obj(i[0]);n?i={value:i}:it.fnc(t.duration)||(e.duration=t.duration/r)}var s=it.arr(i)?i:[i];return s.map(function(o,a){var l=it.obj(o)&&!it.pth(o)?o:{value:o};return it.und(l.delay)&&(l.delay=a?0:t.delay),it.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return Y0(o,e)})}function fX(i){for(var t=W0(q0(i.map(function(s){return Object.keys(s)})),function(s){return it.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},r=function(s){var o=t[s];e[o]=i.map(function(a){var l={};for(var u in a)it.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},n=0;n<t.length;n++)r(n);return e}function pX(i,t){var e=[],r=t.keyframes;r&&(t=Y0(fX(r),t));for(var n in t)it.key(n)&&e.push({name:n,tweens:dX(t[n],i)});return e}function mX(i,t){var e={};for(var r in i){var n=w1(i[r],t);it.arr(n)&&(n=n.map(function(s){return w1(s,t)}),n.length===1&&(n=n[0])),e[r]=n}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function gX(i,t){var e;return i.tweens.map(function(r){var n=mX(r,t),s=n.value,o=it.arr(s)?s[1]:s,a=fa(o),l=C1(t.target,i.name,a,t),u=e?e.to.original:l,c=it.arr(s)?s[0]:u,h=fa(c)||fa(l),d=a||h;return it.und(o)&&(o=u),n.from=KR(c,d),n.to=KR(P1(o,c),d),n.start=e?e.end:0,n.end=n.start+n.delay+n.duration+n.endDelay,n.easing=A1(n.easing,n.duration),n.isPath=it.pth(s),n.isColor=it.col(n.from.original),n.isColor&&(n.round=1),e=n,n})}var fL={css:function(i,t,e){return i.style[t]=e},attribute:function(i,t,e){return i.setAttribute(t,e)},object:function(i,t,e){return i[t]=e},transform:function(i,t,e,r,n){if(r.list.set(t,e),t===r.last||n){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function pL(i,t){var e=dL(i);e.forEach(function(r){for(var n in t){var s=w1(t[n],r),o=r.target,a=fa(s),l=C1(o,n,a,r),u=a||fa(l),c=P1(aL(s,u),l),h=T1(o,n);fL[h](o,n,c,r.transforms,!0)}})}function yX(i,t){var e=T1(i.target,t.name);if(e){var r=gX(t,i),n=r[r.length-1];return{type:e,property:t.name,animatable:i,tweens:r,duration:n.end,delay:r[0].delay,endDelay:n.endDelay}}}function vX(i,t){return W0(q0(i.map(function(e){return t.map(function(r){return yX(e,r)})})),function(e){return!it.und(e)})}function mL(i,t){var e=i.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},n={};return n.duration=e?Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,n.delay=e?Math.min.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return r(s)+o+a+s.delay})):t.delay,n.endDelay=e?n.duration-Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,n}var ZR=0;function xX(i){var t=b1(eL,i),e=b1(S1,i),r=pX(e,i),n=dL(i.targets),s=vX(n,r),o=mL(s,e),a=ZR;return ZR++,Y0(t,{id:a,children:[],animatables:n,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var ls=[],JR=[],H0,bX=function(){function i(){H0=requestAnimationFrame(t)}function t(e){var r=ls.length;if(r){for(var n=0;n<r;){var s=ls[n];s.paused?(ls.splice(n,1),r-=1):(s.tick(e),n++)}i()}else H0=cancelAnimationFrame(H0)}return i}();function wX(i){document.hidden?(ls.forEach(function(t){return t.pause(i.timeStamp)}),JR=ls.slice(0),zr.running=ls=[]):JR.forEach(function(t){return t.play(i.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",wX);function zr(i){i===void 0&&(i={});var t=0,e=0,r=0,n,s,o=0,a=null;function l(E){var b=window.Promise&&new Promise(function(M){return a=M});return E.finished=b,b}var u=xX(i),c=l(u);function h(){var E=u.direction;E!=="alternate"&&(u.direction=E!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=u.reversed)})}function d(){u.direction="normal",u.reversed=!1,s.forEach(function(E){return E.reversed=!1})}function f(E){return u.reversed?u.duration-E:E}function p(){t=0,e=f(u.currentTime)*(1/zr.speed)}function m(E,b,M=!1){b&&(u.reversed?b.seek(b.duration*b.loop-(E-b.timelineOffset-b.pingPongDelayCorrection),M):b.seek(E-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection,M))}function g(E,b=!1){if(u.reversed)for(var T=o;T--;)m(E,s[T],b);else for(var M=0;M<o;M++)m(E,s[M],b)}function y(E){var b=0,M=u.animations,T=M.length;for(u.direction!=="alternate"&&u.parent?.direction==="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1&&(u.parent?.reversed&&u.direction==="alternate"?E=u.duration-u.delay+u.endDelay-E:E=u.duration+u.delay-u.endDelay-E):S(!1,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)&&(u.parent?.reversed&&u.direction==="alternate"?E=u.duration-u.delay+u.endDelay-E:E=u.duration+u.delay-u.endDelay-E);b<T;){var C=M[b],P=C.animatable,D=C.tweens,I=D.length-1,R=D[I];I&&(R=W0(D,function(W){return E<W.end})[0]||R);let K;u.parent?.reversed&&u.direction==="alternate"?K=Ns(E-R.start-R.endDelay,0,R.duration)/R.duration:K=Ns(E-R.start-R.delay,0,R.duration)/R.duration;for(var U=isNaN(K)?1:R.easing(K),F=R.to.strings,V=R.round,G=[],H=R.to.numbers.length,Y=void 0,k=0;k<H;k++){var j=void 0;let W,ye;u.direction!=="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1?(W=R.to.numbers[k],ye=R.from.numbers[k]||0):(ye=R.to.numbers[k],W=R.from.numbers[k]||0):S(!0,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)?(W=R.to.numbers[k],ye=R.from.numbers[k]||0):(ye=R.to.numbers[k],W=R.from.numbers[k]||0),R.isPath?j=hX(R.value,U*ye):j=W+U*(ye-W),V&&(R.isColor&&k>2||(j=Math.round(j*V)/V)),G.push(j)}var X=F.length;if(!X)Y=G[0];else{Y=F[0];for(var q=0;q<X;q++){var z=F[q],J=F[q+1],Z=G[q];isNaN(Z)||(J?Y+=Z+J:Y+=Z+" ")}}fL[C.type](P.target,C.property,Y,P.transforms),C.currentValue=Y,b++}}function v(E){u[E]&&!u.passThrough&&u[E](u)}function x(){u.remaining&&u.remaining!==!0&&u.remaining--}let w={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function S(E,b,M,T,C){return w[E<<4|b<<3|M<<2|T<<1|C]}function A(E,b=!1){var M=u.duration;let T=u.delay,C=M-u.endDelay;u.parent?.reversed&&u.direction==="alternate"&&(T=u.endDelay,C=M-u.delay);var P=f(E);if(u.progress=Ns(P/M*100,0,100),b||(u.reversePlayback=P<u.currentTime),o&&g(P,b),!u.began&&u.currentTime>=0&&(u.began=!0,v("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,v("loopBegin")),(u.reversed||P>=0)&&P<=T&&u.currentTime!==0&&(y(0),v("change")),(P>=C&&u.currentTime!==M+u.pingPongDelayCorrection||!M)&&(y(M),v("change")),P>T&&P<C?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,v("changeBegin")),y(P),v("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):u.began&&P>C&&v("changeComplete"),u.currentTime=Ns(P,0,M+u.pingPongDelayCorrection),u.began&&v("update"),E>=M)if(x(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,v("loopComplete"),v("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/zr.speed:t+=u.duration;for(let D of s)D.setStartTime(0),D.remaining=D.loop;v("loopComplete"),u.loopBegan=!1,u.direction==="alternate"?h():o&&d()}}return u.reset=function(){var E=u.direction;u.passThrough=!1,u.currentTime=0,u.progress=0,u.paused=!0,u.began=!1,u.loopBegan=!1,u.changeBegan=!1,u.completed=!1,u.changeCompleted=!1,u.reversePlayback=!1,u.reversed=E==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var b=o;b--;)u.children[b].reset();y(u.reversed?u.duration:0)},u.setStartTime=function(E){t=E},u.set=function(E,b){return pL(E,b),u},u.tick=function(E){r=E,t||(t=r),A((r+(e-t))*zr.speed)},u.seek=function(E,b=!1){A(E-t,b)},u.pause=function(E){u.paused=!0,o&&(n=E??performance.now())},u.play=function(E){!u.paused||(u.completed&&u.reset(),u.paused=!1,ls.push(u),o&&n!==void 0&&(t+=(E??performance.now())-n),H0||bX())},u.reverse=function(){h(),u.completed=!u.reversed,p()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function $R(i,t){for(var e=t.length;e--;)_1(i,t[e].animatable.target)&&t.splice(e,1)}function SX(i){for(var t=hL(i),e=ls.length;e--;){var r=ls[e],n=r.animations,s=r.children;$R(t,n);for(var o=s.length;o--;){var a=s[o],l=a.animations;$R(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!n.length&&!s.length&&r.pause()}}function AX(i,t){t===void 0&&(t={});var e=t.direction||"normal",r=t.easing?A1(t.easing):null,n=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=it.arr(i),h=parseFloat(c?i[0]:i),d=c?parseFloat(i[1]):0,f=fa(c?i[1]:i)||0,p=t.start||0+(c?h:0),m=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!m.length){for(var w=0;w<x;w++){if(!n)m.push(Math.abs(o-w));else{var S=l?(n[0]-1)/2:o%n[0],A=l?(n[1]-1)/2:Math.floor(o/n[0]),E=w%n[0],b=Math.floor(w/n[0]),M=S-E,T=A-b,C=Math.sqrt(M*M+T*T);s==="x"&&(C=-M),s==="y"&&(C=-T),m.push(C)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(D){return r(D/g)*g})),e==="reverse"&&(m=m.map(function(D){return s?D<0?D*-1:-D:Math.abs(g-D)}))}var P=c?(d-h)/g:h;return p+P*(Math.round(m[v]*100)/100)+f}}function _X(i){i===void 0&&(i={});var t=zr(i);return t.duration=0,t.add=function(e,r){var n=ls.indexOf(t),s=t.children;n>-1&&ls.splice(n,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Y0(e,b1(S1,i));l.targets=l.targets||i.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=it.und(r)?u:P1(r,u),o(t);var c=zr(l);o(c),s.push(c),c.parent=t;var h=mL(s,i);return t.delay=h.delay,t.endDelay=h.endDelay,t.duration=h.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}zr.version="3.2.0";zr.speed=1;zr.running=ls;zr.remove=SX;zr.get=C1;zr.set=pL;zr.convertPx=M1;zr.path=uX;zr.setDashoffset=lX;zr.stagger=AX;zr.timeline=_X;zr.easing=A1;zr.penner=nL;zr.random=function(i,t){return Math.floor(Math.random()*(t-i+1))+i};var X0=zr;var gL=new _,yL=new _,vL=new He;function xL(i,t,e,r){if(r===0)return e.copy(i);if(r===1)return e.copy(t);let n=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(n>=1)return e.copy(i);let s=1-n*n;if(s<=Number.EPSILON){let c=1-r;return e.w=c*i.w+r*t.w,e.x=c*i.x+r*t.x,e.y=c*i.y+r*t.y,e.z=c*i.z+r*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,n),l=Math.sin((1-r)*a)/o,u=Math.sin(r*a)/o;return e.w=i.w*l+t.w*u,e.x=i.x*l+t.x*u,e.y=i.y*l+t.y*u,e.z=i.z*l+t.z*u,e}function Bs(i,t,e,r,n,s){let o=e[i]?e[i]:void 0,a=r[i];if(a==null)return;let l=o!=null?typeof o=="string"?Number(n.getVariable(o)??0):o:t[i],u=typeof a=="string"?Number(n.getVariable(a)??0):a;if(l!==u)return{update:c=>{let h=Se.lerp(l,u,c);s?t[i]=Math.trunc(h):t[i]=h},start:()=>{t[i]=l},end:()=>{t[i]=u}}}function I1(i,t,e,r,n,s){let o=e[i]?e[i]:void 0,a=r[i];if(!a)return;let l=t[i],u=[...o??l].map(h=>typeof h=="string"?Number(n.getVariable(h)??0):h),c=[...a].map(h=>typeof h=="string"?Number(n.getVariable(h)??0):h);if(!(u.length!==c.length||ip(u,c)))return{update:h=>{u.forEach((d,f)=>{let p=Se.lerp(d,c[f],h);t[i][f]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[i],u)},end:()=>{Object.assign(t[i],c)}}}function mm(i,t,e){return t.forEach((r,n)=>{i.setComponent(n,typeof r=="string"?Number(e.getVariable(r)??0):r)}),i}function O1(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=s?mm(new _,s,n):a.clone(),u=mm(new _,o,n);if(!l.equals(u))return{update:c=>{a.lerpVectors(l,u,c)},start:()=>{a.copy(l)},end:()=>{a.copy(u)}}}function bL(i,t,e,r){let n=e[i]?e[i]:void 0,s=r[i];if(!s)return;let o=t[i],a=n?new ie().fromArray(n):o.clone(),l=new _,u=new He,c=new _;a.decompose(l,u,c);let h=new ie().fromArray(s),d=new _,f=new He,p=new _;if(h.decompose(d,f,p),!a.equals(h))return{update:m=>{vL.slerpQuaternions(u,f,m),gL.lerpVectors(l,d,m),yL.lerpVectors(c,p,m),o.compose(gL,vL,yL)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(d,f,p)}}}function wL(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=s?typeof s=="string"?n.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?n.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[i]=c,{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Eo(i,t,e,r,n){if(typeof t[i]=="number")return Bs(i,t,e??{},r,n);if(Array.isArray(t[i]))return I1(i,t,e??{},r,n)}function SL(i,t,e,r){let n=[],s=i.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,o=i.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(o!==void 0){let a=s??i.zoom,l=o;a!==l&&n.push({update:u=>{i.zoom=Se.lerp(a,l,u),i.updateProjectionMatrix()},start:()=>{i.zoom=a,i.updateProjectionMatrix()},end:()=>{i.zoom=l,i.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let a=Bs("targetOffset",i,t,e,r);a&&n.push(a)}return n}function EX(i,t,e,r){if(e.scaleBaked===void 0)return;let n=(t.scaleBaked??i.data.geometry.scaleBaked).map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a),s=e.scaleBaked.map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a);if($s.isEqual(n,s))return;let o=[];return o.push({update:a=>{i.updateGeometryInteractions({scaleBaked:[Se.lerp(n[0],s[0],a),Se.lerp(n[1],s[1],a),Se.lerp(n[2],s[2],a)]},r),i.invalidateDownstreamBooleanData()},start:()=>{i.updateGeometryInteractions({scaleBaked:n},r),i.invalidateDownstreamBooleanData()},end:()=>{i.updateGeometryInteractions({scaleBaked:s},r),i.invalidateDownstreamBooleanData()}}),o}function MX(i,t,e,r){if(!e.extrusion)return;let n=i.extrusion,s=t.extrusion??{},o=e.extrusion,a=[];return Jw.forEach(l=>{let u=Eo(l,n,s,o,r);u&&a.push(u)}),a}function AL(i,t,e,r){let n=[];if(!("geometry"in e))return n;let s=i.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(i instanceof Ds){let l=EX(i,o,a,r);l&&n.push(...l)}else{let l={};if(Object.assign(l,Ni(s,$w)),$w.forEach(u=>{let c=Eo(u,l,o,a,r);c&&n.push(c)}),i instanceof bl){Object.assign(l,{extrusion:{...s.extrusion}});let u=MX(l,o,a,r);u&&n.push(...u)}n.length&&n.push({update:u=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()},start:u=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()},end:u=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()}})}return n}function _L(i,t,e,r){let n=[];if(e.intensity!==void 0){let s=Bs("intensity",i,t,e,r);s&&n.push(s)}if(e.color!==void 0){let s=wL("color",i,t,e,r);s&&n.push(s)}return n}function ML(i,t,e,r){let n=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return n;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;i.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||n.push(...EL(a,u,c,r))})}else{if(!("material"in e&&e.material))return n;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return n;n.push(...EL(i.material,s,o,r))}return n}function EL(i,t,e,r){let n=[],s=_c(e,r)||!!t.layers&&_c(t,r);n.push(NX(i,s));for(let o of i.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||o.type!=="light"&&(!(o.visible??!0)||!(l.visible??!0)))continue;let u=o.getNames().filter(c=>!qy.some(h=>c.includes(h)));for(let c of u)try{let h=o.getValue(c),d;if(c==="colors")d=RX(o,a,l,c);else if(Array.isArray(h))c==="steps"&&(d=OX(o,a,l,c));else if(typeof h=="number")d=TX(o,a,l,c,r);else{if(typeof h=="boolean")continue;h instanceof N?d=CX(o,a,l,c):h instanceof _?d=PX(o,a,l,c,r):h instanceof gr?d=IX(o,a,l,c,r):h instanceof Re?d=DX(o,a,l,c,r):"isTexture"in h&&(d=LX(o,a,l,c))}d&&(Array.isArray(d)?n.push(...d):n.push(d))}catch(h){console.error(`lerpMaterial: unexpected material layer for ${c}`,h)}}return n}function TX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:i.getValue(r),o=e[r],a=typeof s=="string"?Number(n.getVariable(s)??0):s,l=typeof o=="string"?Number(n.getVariable(o)??0):o;if(a!==l)return{update:u=>{i.setValue(r,Se.lerp(a,l,u))},start:()=>{i.setValue(r,a)},end:()=>{i.setValue(r,l)}}}function CX(i,t,e,r){if(!i.hasValue(r)||!(r in e))return;let n=i.getValue(r),s=t?new N().fromArray(t[r]):n.clone(),o=new N().fromArray(e[r]);if(!s.equals(o))return{update:a=>{n.lerpVectors(s,o,a)},start:()=>{n.copy(s)},end:()=>{n.copy(o)}}}function PX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=i.getValue(r),o=t?t[r]:void 0,a=e[r],l=o?mm(new _,o,n):s.clone(),u=mm(new _,a,n);if(!l.equals(u))return{update:c=>{s.lerpVectors(l,u,c)},start:()=>{s.copy(l)},end:()=>{s.copy(u)}}}function DX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=i.getValue(r),l=s?typeof s=="string"?n.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?n.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return{update:h=>{i.getValue(r)!==c&&i.setValue(r,c),c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function IX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=i.getValue(r),l=s?typeof s=="string"?n.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?n.getColor(o).clone():new gr(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return{update:h=>{i.getValue(r)!==c&&i.setValue(r,c),c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function OX(i,t,e,r="steps"){if(!i.hasValue(r)||!(r in e))return;let n=[],s=i.getValue(r),o=t?t[r]:s,a=e[r];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&n.push({update:h=>{s[l]=Se.lerp(u,c,h)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return n.length?n:void 0}function RX(i,t,e,r="colors"){if(!i.hasValue(r)||!(r in e))return;let n=[],s=i.getValue(r),o=t?t[r]:s.map(l=>l.toArray()),a=e[r];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];mp.isEqual(u,c)||n.push({update:h=>{s[l].fromArray(mp.lerp(u,c,h))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return n.length?n:void 0}function LX(i,t,e,r="texture"){if(!i.hasValue(r)||!(r in e))return;let n=i.getNode("mat");if(!n)return;let s=t?t[r]:n,o=e[r],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!ac.isEqual(a,u)||!ac.isEqual(l,c))return{update:h=>{n.repeat=ac.lerp(a,u,h),n.offset=ac.lerp(l,c,h),n.updateMatrix()},start:()=>{n.repeat=[...a],n.offset=[...l],n.updateMatrix()},end:()=>{n.repeat=[...u],n.offset=[...c],n.updateMatrix()}}}function NX(i,t){return{update:()=>{i.transparent=t}}}var R1=new _,TL=new Zt;function CL(i,t,e,r,n){let s=[],o,a,l,u,c,h,d={slide:t.pathSnapping?.slide??i.updatedPathSnapping?.slide??i.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??i.updatedPathSnapping?.offset??i.dataPatched.pathSnapping?.offset??0};if(c=Bs("slide",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),c&&s.push(c),h=Bs("offset",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),h&&s.push(h),!c&&!h&&(o=O1("position",i,t,e,n),o&&s.push(o),a=O1("scale",i,t,e,n),a&&s.push(a),l=BX(i,t,e,r,n),l&&s.push(l),u=bL("hiddenMatrix",i,t,e),u&&s.push(u)),o||a||l||u||c||h){let f=()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),Yn(i)&&Xn(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,d))};s.push({update:f,start:f,end:f})}return s}function BX(i,t,e,r,n){let s=t?.rotation?t.rotation.map(c=>(typeof c=="string"?Number(n.getVariable(c)??0):c)*Se.DEG2RAD):void 0,o=e.rotation?.map(c=>(typeof c=="string"?Number(n.getVariable(c)??0):c)*Se.DEG2RAD);if(!o)return;let a=s?new _().fromArray(s):new _().setFromEuler(i.rotation),l=new _().fromArray(o);if(a.equals(l))return;let u=R1.subVectors(l,a);if(r&&u.toArray().every(c=>Math.abs(c)<2*Math.PI)){let c=new He().setFromEuler(TL.setFromVector3(a)),h=new He().setFromEuler(TL.setFromVector3(l));return{update:d=>{xL(c,h,i.quaternion,d)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}else return{update:c=>{R1.lerpVectors(a,l,c),i.rotation.setFromVector3(R1)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}function PL(i,t,e,r){let n=[];if(!("cloner"in e)||!i.cloner)return n;let s=i.cloner,o="cloner"in t?t.cloner:{},a=e.cloner;Hw.forEach(f=>{let p;f==="count"?p=Bs("count",s.parameters,o,a,r,!0):p=Eo(f,s.parameters,o??{},a,r),p&&n.push(p)});let l=FX(s,o,a,r);l?.length&&n.push(...l);let u=kX(s,o,a,r);u?.length&&n.push(...u);let c=VX(s,o,a,r);c?.length&&n.push(...c);let h=zX(s,o,a,r);h?.length&&n.push(...h);let d=UX(s,o,a,r);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{s.update()}}),n}function FX(i,t,e,r){if(i.parameters.type!=="radial")return;let n=t.radial,s=e.radial;if(!s)return;let o=i.parameters.radial,a=[];return jw.forEach(l=>{let u=Eo(l,o,n??{},s,r);u&&a.push(u)}),a}function kX(i,t,e,r){if(i.parameters.type!=="linear")return;let n=t.linear,s=e.linear;if(!s)return;let o=[],a=i.parameters.linear;return Ww.forEach(l=>{let u=Eo(l,a,n??{},s,r);u&&o.push(u)}),o}function VX(i,t,e,r){if(i.parameters.type!=="grid")return;let n=t.grid,s=e.grid;if(!s)return;let o=[],a=i.parameters.grid;return qw.forEach(l=>{let u;l==="count"?u=I1(l,a,n??{},s,r,!0):u=Eo(l,a,n??{},s,r),u&&o.push(u)}),o}function zX(i,t,e,r){if(i.parameters.type!=="toObject")return;let n=t.toObject,s=e.toObject;if(!s)return;let o=[],a=i.parameters.toObject;return Yw.forEach(l=>{let u;l==="count"?u=Bs(l,a,n??{},s,r,!0):u=Eo(l,a,n??{},s,r),u&&o.push(u)}),o}function UX(i,t,e,r){if(!i.parameters.randomness)return;let n=t.randomnessObject,s=e.randomnessObject;if(!s)return;let o=[],a=i.parameters.randomnessObject;return Xw.forEach(l=>{let u=Eo(l,a,n??{},s,r);u&&o.push(u)}),o}function L1(i,t,e,r,n){let s=[];return i.data.visible&&s.push(...CL(i,t,e,n,r)),i.data.visible&&s.push(...PL(i,t,e,r)),Yn(i)?(i instanceof Qt&&i.data.visible&&s.push(...AL(i,t,e,r)),i.data.visible&&s.push(...ML(i,t,e,r))):sO(i)?i.data.visible&&s.push(..._L(i,t,e,r)):iO(i)&&s.push(...SL(i,t,e,r)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var DL=new _;function nf(i,t,e=!1){let r=[];i.traverseChildren(n=>{if(e&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(DL,!0),n.rigidBody?.setAngvel(DL,!0)),!lt.is(n))return;let s=n.uuid,o=n.data;if(delete n.states,n.uuid===Qi)return;let a=!1;r.some(l=>i.scene.find(s)?.isDescendantOf(l))?a=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&r.push(s),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let l of o.states){let u={...l.data};i.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||a)&&(l.data.position!==void 0&&delete u.position,l.data.rotation!==void 0&&delete u.rotation,l.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),n.states||(n.states={}),n.states[l.id]=ta.patch(o,u)}HX(i.scene,n,null,t,o.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),GX(i)})}function GX(i){i.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let n of Object.values(e.data.gameActions))r.push(...n);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let n of r)if(n.data.type==="Create"&&n.data.hideBase==="Yes"){let s=i.scene.find(n.data.object);s&&(s.visible=!1)}}})}function HX(i,t,e,r,n=!1){if(t instanceof Qt&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:i,shared:r},n),t instanceof Qt&&t.updateGeometryGroupsIfNeeded(),t instanceof er&&t.updateCameraState(t.dataPatched,{scene:i,shared:r}),t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}function B1(i){let t;if(i.easing===5){let{control1:e,control2:r}=i;t=`cubicBezier(
6425
6425
  ${e[0]}, ${e[1]}, ${r[0]}, ${r[1]}
6426
- )`}else if(i.easing===6){let{mass:e,stiffness:r,damping:n,velocity:s}=i;t=`spring( ${e}, ${r}, ${n}, ${s} )`}else{let e;switch(i.easing){case 0:e=$o.linear;break;case 1:e=$o.ease;break;case 2:e=$o.easeIn;break;case 3:e=$o.easeOut;break;case 4:e=$o.easeInOut;break;default:e=$o.linear}let[r,n,s,o]=e;t=`cubicBezier( ${r}, ${n}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function N1(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.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,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var jX={type:"beginState"},WX={type:"completeState",isfromEntity:!1},K0=class{constructor(t,e,r,n,s,o){this.object=t;this.data=n;this.sharedAssets=s;this.allowSlerp=o;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 t=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=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof er&&e.dispatchEvent(jX)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=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=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof er&&e.dispatchEvent(WX)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=L1(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=Q0(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=Q0(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=Q0(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...N1(n),...B1(n),change:this.onChange},this.callback=L1(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},gm=class extends Yt{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;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())};if(!e.object)throw new Error("Missing property");let o=this.page.scene.find(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,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=Q0(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:n=!1}={}){try{let s=N1(this.data.tweens[0].data);n&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=X0.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof er&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new K0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof er&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new K0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Bt(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=N1(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.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(Bt(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 Q0(i,t){let e,r;if(typeof t=="string"?(e=t,r=i.states?.[e]):t===null&&(e=null,r=i.data),!(e===void 0||r===void 0))return{id:e,data:r}}var qX={type:"beginState"},IL={type:"completeState",isfromEntity:!1},OL={type:"requestRender"},ym=class extends Yt{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new _;this.posEnd=new _;this.qStart=new He;this.qEnd=new He;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 r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");let n={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=X0({targets:n,t:1,...B1(this.data),update:()=>{n.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(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(qX));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,n.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(OL),n.t===1&&s.dispatchEvent(IL)}})}switchCamera(e){let r=this.page.scene.find(e);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(r),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:r})}play(){if(Bt(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(Bt(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(IL),this.page.activeCamera.dispatchEvent(OL))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var vm=class extends Yt{constructor(e,r,n,s,o){super();this.page=r;this.animationControls=n;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let u=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=u?.getClip()?.duration??1;let c=u?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/c*this.duration,this.rightFrameTime=this.data.crop[1]/c*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Bt(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 r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([n,s])=>{let o=n.split("/")[1];this.threeAnimAction!==s&&o===r&&s.isRunning()&&(e?s.fadeOut(.2):s.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=Se.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(Bt(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 n=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===n&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&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()}};var xm=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.eventManager=r;this.shared=n;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Bt(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(r=>r.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 t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),nf(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var bm=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Bt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=Ov(this.data.expression,this.shared,En.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var wm=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.timeoutId=null}dispatchInner(){if(Bt(this.shared,this.condition)===!1)return!1;let t=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,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="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"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="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 e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function Bt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=Ov(t.expression,i,"boolean");return t.negate?!e:!!e}function nr(i,t,e,r,n,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},a=l=>({id:u,data:c})=>{try{c.type==="Audio"?di[i.type].includes("Audio")&&o.Audio.push(new hm(u,c,s,r,l)):c.type==="Video"?di[i.type].includes("Video")&&o.Video.push(new Sm(u,c,s,r,l)):c.type==="Link"?di[i.type].includes("Link")&&o.Link.push(new G0(c,n.controlsManager,r,l)):c.type==="Create"?di[i.type].includes("Create")&&o.Create.push(new Am(c,e,n.controlsManager,r,l)):c.type==="Destroy"?di[i.type].includes("Destroy")&&o.Destroy.push(new dm(c,e,n.controlsManager,r,l)):c.type==="Reset"?di[i.type].includes("Reset")&&o.Reset.push(new fm(c,e,r,n,l)):c.type==="Transition"?di[i.type].includes("Transition")&&o.Transition.push(new gm(c,e,r,l)):c.type==="SwitchCamera"?di[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new ym(c,e,r,l)):c.type==="SceneTransition"?di[i.type].includes("SceneTransition")&&o.SceneTransition.push(new xm(c,e,n,r,l)):c.type==="Animation"?di[i.type].includes("Animation")&&o.Animation.push(new vm(c,e,n.animationControls,r,l)):c.type==="SetVariable"?di[i.type].includes("SetVariable")&&o.SetVariable.push(new bm(c,e,r,l)):c.type==="DynamicVariablePlay"?di[i.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new wm(c,e,r,l)):c.type==="Conditional"&&di[i.type].includes("Conditional")&&(c.ifActions.forEach(a({expression:c.condition,negate:!1})),c.elseActions.forEach(a({expression:c.condition,negate:!0})))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function qt(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof hm||e instanceof Sm||e instanceof vm||e instanceof gm||e instanceof Am||e instanceof dm||e instanceof ym||e instanceof xm||e instanceof fm||e instanceof bm||e instanceof wm)&&e.dispose()})})}function RL(i,t){let e;if("material"in i){let r=i.material;Array.isArray(r)?e=i.material[0].layers.find(n=>n.uuid===t):e=i.material.layers.find(n=>n.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var LL=new Map,_m=new Map,pa=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:n,loop:s,volume:o,delay:a}=e;if(this.object=r,n===void 0)throw new Error("Missing property");let l=RL(r,n);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,sh&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),_m.has(r.uuid)?_m.get(r.uuid).push(this):_m.set(r.uuid,[this]),LL.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(n=>{}).catch(n=>{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)}},sf=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=LL.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=_m.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[..._m.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Sm=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new pa(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new sf(e);else throw new Error("Missing property")}dispatchBasic(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof pa?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof pa?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var NL=(()=>{let i,t,e,r;function n(a){!i&&!BL()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,d=0;for(;d<h;){let f=u[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,r())}i=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){BL()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):n()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),n})();function BL(){return!!document&&document.hidden}var FL=new He,YX=new _,XX=new _,Am=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Se.generateUUID();this.dispatch=()=>{if(Bt(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(Bt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=ww(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 t=new mr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,n=this.page.scene.find(r);n&&(n.updateMatrixWorldSVD(),t.hiddenMatrix.copy(n.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),NL(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Dn)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof mr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Dn)return;t instanceof mr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new _().fromArray(this.data.velocity),n=e.dataPatched;if(!(n.physics.enabled==="visibility"?!n.visible:!n.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(YX,FL,XX),r.applyQuaternion(FL),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");NL(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var z1=200,F1=.02,k1=.3,QX=65,mFe=new _,kL=new _,VL=new _,KX=new _,ai=new _,_i=new _,El=new _,V1=new ie,zL=new ie,ZX=new ie,gFe=new ie,Fs=new He,ma=new He,Mo=new Zt(0,0,0,"YXZ"),JX=new _(1,0,0),ks=new _(0,1,0),$X=new _(0,0,1),UL=new _(1,1,1),yFe=new fr,eQ=1,tQ=.025,rQ=16e-6,GL=12,nQ=20,On=new nn,cs=new Pt,iQ={type:"requestRender"},sQ={type:"updateMatrix"},HL=Math.PI/6,Z0=class extends Yt{constructor(e,r,n,s,o,a,l,u,c){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new ie;this.target0=new _;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=z1;this.euler0=new Zt(0,0,0,"YXZ");this.position0Cam=new _;this.quat0Cam=new He;this.scale0Cam=new _;this.hiddenMatrix0Cam=new ie;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new nn(new _(0,-40,0),new _(0,40,0)),matrix:new ie,position:new _,rotation:new He};this.euler=new Zt(0,0,0,"YXZ");this.eulerDelta=new _;this.lastPosition=new _;this.lastCameraQuaternion=new He;this.lastCameraPosition=new _;this.PI_2=Math.PI/2;this.prevMouse=new N;this.velocityTarget=new _;this.velocity=new _;this.directionXZ=new _;this.rotVelocityStick=new _;this.rotVelocityTarget=new _;this.rotVelocity=new _;this.rotDirection=new _;this.nonColliderRotOffset=new ie;this.nonColliderPosOffset=new ie;this.firstPointerId=-1;this.rot=new _;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 ie;this.objectToTarget=new _;this.objectToTarget0=new _;this.objectToCamXZ=new _;this.objectToCamXZ0=new _;this.targetToCamera=new _;this.targetToCamera0=new _;this.cameraPolarAxis0=new _;this.targetPos=new _;this.targetQuat=new He;this.lerpFactorPos=new _().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new He;this.objXZQuatInv=new He;this.objXZRotMat=new ie;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new _;this.pushedVelocity=new _;this.groundYRotation=0;this.objectRealQuat=new He;this.colliderWorldQuat=new He;this.groundNormal=new _;this.groundTilt=new He;this.groundTiltInv=new He;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new _;this.quaternion=new He;this.scale=new _;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!on&&(!Sw||Aw>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Sw&&Aw<15.5&&!on?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Z0.isLocked=!0:Z0.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let s=e.axes[n];r===0?n===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(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 g=new _(0,0,-1).applyQuaternion(this.camera.quaternion),y=new _().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let w=new Zt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-w.x,w.x=0,w.z=0,w.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(w)}if(this.object instanceof er&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*eQ,this.speedOrbit=(n.speedRotate??100)*tQ,this.mouseOrbitSensitivity=(n.speedRotate??100)*rQ,this.keyAssignments=n.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),n.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Ja.defaultData.gravity)*GL,this.usePhysics=this.gloabalPhysics.usePhysics??Ja.defaultData.usePhysics,this.jumpPower=n.jumpPower*nQ,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??Mh.defaultDataThirdPerson.orientWith,this.slopeThresh=QX*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*F1/this.pixelsPerMeter,this.stepThresh=n.collider.height*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*F1/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*F1/this.pixelsPerMeter,this.stepThresh=n.collider.height*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let f=new _().fromArray(n.collider.position),p=new He().setFromEuler(new Zt().fromArray([...n.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,UL),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.runMultiplier=n.runMultiplier??2;let m=n.navmesh.destinationHelperRadius*2;if(m>0){let g=new Le;g.push({fi:0,data:{..._n.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{..._n.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let y=new la({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new _r(vv.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=n.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 r=new Zt().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof er?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Eh.list.forEach(n=>{this.actions[n]=nr({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,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"),qt(this.actions.idle),qt(this.actions.move),qt(this.actions.run),qt(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return ai.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,n){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 s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let u=_i.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*GL),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(c){this.onObject=!0,this.groundNormal.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),c.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=c.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(ai,ma,_i),this.groundVelocity.subVectors(ai,d.prevT),this.object.getWorldPosition(_i).add(this.collider.position).sub(ai),this.groundYRotation=Mo.setFromQuaternion(ma).y-d.prevR.y,El.copy(_i).applyAxisAngle(ks,this.groundYRotation),this.groundVelocity.add(El.sub(_i)).divideScalar(s);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*o),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 u=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 c=ai.subVectors(this.path[1],this.position),h=_i.subVectors(this.path[1],this.path[0]);c.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),u.opacity=u.userData.opacity0}else u.opacity-=.05*u.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)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):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 l=KX.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=_i.copy(l);u.y=0,l.set(0,l.y,u.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let u=ai;this.camera.getWorldDirection(u);let c=El.copy(ks).multiplyScalar(u.dot(ks));u.sub(c);let h=_i.copy(this.directionXZ);h.x*=-1,this.rot.y=u.angleTo(h)*(u.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(Mo.setFromVector3(this.rot),this.moveMode==="walk"&&(Mo.x=0),l.applyEuler(Mo),a&&(ma.setFromUnitVectors(ks,this.groundNormal),l.applyQuaternion(ma)),n){let u=Mo.set(0,this.vrEulerYOffset*HL,0);n.applyEuler(u),l.x+=n.x,l.z+=n.z,this.nonColliderPosOffset.elements[13]+=n.y*s}if(this.usePhysics===!0){let u=_i;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=El.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=c.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),ai.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=lt.is(c)?c:c.object;if(d!==null&&this.lastHitObj!==f){let p;c instanceof mr&&(p=c);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(J0));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),u.copy(d.normal1).applyQuaternion(c.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let c=u.dot(l);c<0&&l.addScaledVector(u,-c),l.add(this.pushedVelocity)}else l.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(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ks,this.euler.y-this.euler0.y);let u=_i.copy(this.objectToCamXZ).normalize(),c=El.copy(l).multiplyScalar(s);c.y=0;let h=c.sub(ai.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+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=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Se.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(Mo.copy(r),Mo.y=0):(Mo.copy(this.euler),Mo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Mo)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*HL),Fs.setFromAxisAngle(JX,this.rot.x),ma.setFromAxisAngle(ks,this.rot.y),ma.multiply(Fs),Fs.setFromAxisAngle($X,this.rot.z),ma.multiply(Fs),this.quaternion.copy(ma),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 u=_i.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let h=new _;for(let d=0;d<5;d++){let f=u.length(),p=El.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),c!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(c.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let w of x)if(w.data.target==="character"){let S=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,A;if(m.cloner){for(let E of m.cloner.children)if(E.rigidBody===S){A=E;break}}w.dispatch(A),m.dispatchEvent(J0)}}}let g=kL.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=VL.copy(p).multiplyScalar(c.toi).dot(g),v=c.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=c.toi*(y-this.offset)/y,h.addScaledVector(p,v)),u.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),w=El.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);w.y=0;let S=x.add(w);S.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(S,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);A!==null&&A.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(u);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(ai.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Fs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let h=0;h<u;h++)this.position.add(c),this.collisionAdjustment(s/u)}else this.position.addScaledVector(l,s);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 u=this.objectToTarget.add(this.position),c=this.targetToCamera.add(u);V1.lookAt(c,u,ks).setPosition(c),V1.decompose(this.targetPos,this.targetQuat,ai),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Se.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Se.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(sQ),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(iQ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Fs.setFromAxisAngle(ks,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Se.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 r;this.cameraXAxis==="Limit"?r=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=ai.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let s=ma.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){ks.angleTo(e)*180/Math.PI<15||ks.angleTo(e)*180/Math.PI>85?Fs.identity():Fs.setFromUnitVectors(ks,e),this.groundTilt.slerp(Fs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=VL.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=V1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(ai,Fs,_i).compose(ai,Fs,UL);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;cs.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=zL.copy(a).invert(),u=ZX.copy(zL).multiply(n);On.copy(this.collider.segment),On.start.applyMatrix4(u),On.end.applyMatrix4(u);let c=kL.copy(this.position).applyMatrix4(l);cs.expandByPoint(On.start),cs.expandByPoint(On.end),cs.min.addScalar(-this.collider.radius),cs.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(On.end)},intersectsBounds:h=>h.intersectsBox(cs),intersectsTriangle:h=>{let d=ai,f=_i,p=h.closestPointToSegment(On,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=El.copy(c);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);r.add(v),On.start.addScaledVector(g,m),On.end.addScaledVector(g,m)}}})}),cs.makeEmpty(),On.copy(this.collider.segment),On.start.applyMatrix4(n),On.end.applyMatrix4(n),cs.expandByPoint(On.start),cs.expandByPoint(On.end),cs.min.addScalar(-this.collider.radius),cs.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(On.end)},intersectsBounds:o=>o.intersectsBox(cs),intersectsTriangle:o=>{let a=ai,l=_i,u=o.closestPointToSegment(On,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,c),On.start.addScaledVector(h,c),On.end.addScaledVector(h,c)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}},Em=Z0;Em.isLocked=!1;var jL=pn(SS());function Vs(i,t){let e=new Ae;if(!i.getAttribute("position"))return e.setAttribute("position",new be([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=yc(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new be(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var oQ=new ie,aQ=new ie,To=[[0,0,0],[0,0,0],[0,0,0]];function U1(i){let t=i.elements;To[0][0]=t[0],To[0][1]=t[4],To[0][2]=t[8],To[1][0]=t[1],To[1][1]=t[5],To[1][2]=t[9],To[2][0]=t[2],To[2][1]=t[6],To[2][2]=t[10];let{u:e,v:r}=(0,jL.SVD)(To),n=oQ.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=aQ.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 n.multiply(s.transpose())}var $0=class extends Mu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(n=>{n.visible&&this.intersectObject(n,e,r)}),r}createRaycastLineHelper(){let t=new Hi({color:65280,linewidth:10}),e=new _(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new _(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),n=this.camera.far-this.camera.near,s=new _().addVectors(e,r.multiplyScalar(n)),o=new Ae;return o.setFromPoints([e,s]),new jl(o,t)}};var WL=i=>i instanceof ss||i instanceof Rs;function lQ(i,t){return i.distance-t.distance}function qL(i,t,e){if(!(!oo(t)||!t.visible)){Yn(t)&&t.raycast(i,e);for(let r of t.children)qL(i,r,e)}}function of(i,t,e,r=!1){if(!r&&!e.some(s=>af(i,s)!==void 0))return[];let n=[];return t.children.forEach(s=>qL(i,s,n)),n.sort(lQ),n}function Mm(i){let t=[];if(i.length){let e=i[0].object;oo(e)&&t.push(e);let r=e.parent;for(;r;)WL(r)&&t.push(r),r=r.parent}return t}function af(i,t){if(Yn(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(WL(t))return YL(i,t)}function YL(i,t){if(!(!oo(t)||!t.visible)){if(Yn(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let r=YL(i,e);if(r)return r}}}function cQ(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var ex=class{constructor(t,e,r,n,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=n;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new $0;this._useWindowEvents=!1;this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}updateRaycaster(t){let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.raycaster.setFromCamera(cQ(e,r,this._domRect),this.getCamera())}};var yr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var G1=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],XL=i=>G1.find(([t,e])=>e===i)?.[0],Co=i=>G1.find(([t])=>t===i)?.[1],uQ=(i,t)=>{let e=XL(i);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},tx=class extends yr{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[XL(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:n}=this.eventContext;n.dispatchEvent(r)};let{page:r}=this.eventContext;r.traverseEntity(n=>{if(!!n.data?.events.length){for(let[s,o]of G1)if(n.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(n):this.objectsPerEvents.set(s,[n]);let a={id:n.uuid,name:n.name},l=uQ(o,a),u=this.splineEvents[s];u?u[n.uuid]=l:this.splineEvents[s]={[n.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var H1=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.runMode==="Toggle",(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(n=>n.playing)||this.actions.Transition.forEach(n=>{this.alreadyPlayedNonTogglingActions.has(n)===!1&&n.play()}),this.actions.SwitchCamera.some(n=>n.playing)||this.actions.SwitchCamera.forEach(n=>{n.play()}),this.actions.Animation.forEach(n=>{n.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},rx=class extends yr{constructor(e,r,n){super(e);this.useForRaycastProperty=n;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=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=of(r,n,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(n)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:h})=>h.type===u&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new H1(h,d,a,s,o,r);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch(f){!1&&console.log(f)}}),c[a.uuid]?.length&&this.objectsPerTypes[u].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(([r,n])=>{n.forEach(s=>{s.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(r=>{Object.values(r).forEach(n=>{n.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,n])=>{n.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:n,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!(!o.length&&!this.useForRaycastProperty)){if(r||this.useForRaycastProperty){let a;this.sceneInterects===null?a=of(n,s,o,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]}),r&&Mm(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}r||o.forEach(a=>{af(n,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let r="MousePress",n=this.objectsPerTypes[r],s=[];if(!!n.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=of(a,l,n);s=Mm(u)}else n.forEach(u=>{af(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,r)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,r)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatchRelease()})}handleKeyEvent(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(n?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(n)})})}};var hQ=new _,dQ=new _;var nx=class{constructor(t,e,r,n,s){this.actionsIn=nr(t,t.inActions,r,n,s,e),this.actionsOut=nr(t,t.outActions,r,n,s,e)}disconnect(){qt(this.actionsIn),qt(this.actionsOut)}};var j1=class extends nx{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=hQ.setFromMatrixPosition(this.objects[0].matrixWorld),r=dQ.setFromMatrixPosition(this.objects[1].matrixWorld),n=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==n){this.stage=n;let s=n==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch())}};let{distance:l,fromObject:u,toObject:c}=r.condition;this.distance=l;for(let h of[u,c]){if(!h)throw new Error("Missing property");let d=s.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)})}},W1=class extends nx{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(n=>n.dispatchConditional()),this.actionsOut.Video.forEach(n=>n.dispatchConditional()),this.actionsOut.Link.forEach(n=>n.dispatch()),this.actionsOut.Create.forEach(n=>n.dispatch()),this.actionsOut.Destroy.forEach(n=>n.dispatch()),this.actionsOut.Reset.forEach(n=>n.dispatch()),this.actionsIn.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(n=>n.play()),this.actionsOut.Animation.forEach(n=>n.play()),this.actionsIn.SwitchCamera.forEach(n=>n.pause()),this.actionsOut.SwitchCamera.forEach(n=>n.play()),this.actionsOut.SceneTransition.forEach(n=>n.dispatch()),this.actionsOut.SetVariable.forEach(n=>n.checkConditions()),this.actionsOut.SetVariable.forEach(n=>n.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(n=>n.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(n=>n.dispatchConditional()),this.actionsIn.Video.forEach(n=>n.dispatchConditional()),this.actionsIn.Link.forEach(n=>n.dispatch()),this.actionsIn.Create.forEach(n=>n.dispatch()),this.actionsIn.Destroy.forEach(n=>n.dispatch()),this.actionsIn.Reset.forEach(n=>n.dispatch()),this.actionsOut.Transition.forEach(n=>n.pause()),this.actionsOut.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(n=>n.play()),this.actionsIn.Animation.forEach(n=>n.play()),this.actionsOut.SwitchCamera.forEach(n=>n.pause()),this.actionsIn.SwitchCamera.forEach(n=>n.play()),this.actionsIn.SceneTransition.forEach(n=>n.dispatch()),this.actionsIn.SetVariable.forEach(n=>n.checkConditions()),this.actionsIn.SetVariable.forEach(n=>n.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(n=>n.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){qi(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),qi(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),qi(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),qi(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},ix=class extends yr{constructor(e,r){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new j1(a,l,o,n,s,r):l.condition.type==="State"&&(u=new W1(a,l,o,n,s,r))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var Tm=new _,Ml=new _,Fc=new _,QL=new Or,fQ=.01,Ut=new _,hn=new _,KL=new _,kc=new He,q1=new Zt,pQ=new ie,Y1=new Gt,lf=new _,Po=new _,cf=.2;function X1(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var mQ=function(){let i=new ie;return(t,e,r)=>{let n=t.obj;i.copy(n.hiddenMatrix),n.parent!==null&&i.premultiply(n.parent.matrixWorld),i.invert(),n.position.copy(e),t.reference==="global"&&X1(n.position,t.limits),n.position.applyMatrix4(i),t.reference==="parent"?X1(n.position,t.limits):t.reference==="local"&&(kc.copy(t.quat0).invert(),n.position.sub(t.position0),n.position.applyQuaternion(kc),X1(n.position,t.limits),kc.invert(),n.position.applyQuaternion(kc),n.position.add(t.position0)),i.multiply(r??n.matrixWorld).decompose(Ut,n.quaternion,hn),n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n instanceof $t&&Xn(n.parent)&&n.invalidateDownstreamBooleanData(!0)}}(),Q1=class{constructor(t,e,r,n,s,o){this.object=t;this.data=e;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=nr(e,e.dragDropActions.drag,r,n,s,this.object),this.actionsDrop=nr(e,e.dragDropActions.drop,r,n,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=r.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=r.find(c);!h||h.data.visible!==!1&&a.push(h)}))}),this.data.dropDestinations.forEach(l=>{let u=r.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=r.find(c);!h||h.data.visible!==!1&&this.dropDestIds.push(h.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new _().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new _().setFromMatrixPosition(l.matrixWorld),pointStart:new _,pointEnd:new _,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new _().copy(l.position),quat0:new He().copy(l.quaternion),snapped:!1,orientationMatrix:new ie,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){qt(this.actionsDrag),qt(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},sx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(qe.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||lt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,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 h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(Ut,kc,hn),q1.setFromQuaternion(kc),h.prevR===void 0?(h.prevR=q1.clone(),h.prevT=Ut.clone()):(h.prevR.copy(q1),h.prevT.copy(Ut)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&l.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}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(qe.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(qe.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||lt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.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 a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof ss)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||n.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=KL.copy(a.face.normal).applyMatrix3(Y1.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ut.copy(l).applyMatrix3(Y1.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Ut.x>cf?hn.x=-u.recursiveBBox.min.x:Ut.x<-cf&&(hn.x=-u.recursiveBBox.max.x),Ut.y>cf?hn.y=-u.recursiveBBox.min.y:Ut.y<-cf&&(hn.y=-u.recursiveBBox.max.y),Ut.z>cf?hn.z=-u.recursiveBBox.min.z:Ut.z<-cf&&(hn.z=-u.recursiveBBox.max.z),hn.applyMatrix3(Y1.invert())}else hn.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(hn)}this.activeEvent.data.autoOrient&&(Ut.set(0,1,0).cross(l),Ut.length()<1e-4&&Ut.set(-1,0,0).cross(l),hn.crossVectors(KL,Ut),o.orientationMatrix.makeBasis(Ut,hn,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=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||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(n=>n.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let n={};e.page.traverseEntity(s=>{s.component&&(n[s.component.uuid]?n[s.component.uuid].push(s.uuid):n[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new Q1(s,o.data,e.page,e.sharedAssets,r,n))})})}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(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,n,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(Ml),Ml.negate();let l=kc.identity();switch(s==="parent"?pQ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ut,l,hn):s==="local"&&e.matrixWorld.decompose(Ut,l,hn),n){case"x":Ut.set(1,0,0).applyQuaternion(l),lf.copy(Ml).cross(Ut),Po.copy(Ut).cross(lf);break;case"y":Ut.set(0,1,0).applyQuaternion(l),lf.copy(Ml).cross(Ut),Po.copy(Ut).cross(lf);break;case"z":Ut.set(0,0,1).applyQuaternion(l),lf.copy(Ml).cross(Ut),Po.copy(Ut).cross(lf);break;case"xy":Po.set(0,0,1).applyQuaternion(l);break;case"yz":Po.set(1,0,0).applyQuaternion(l);break;case"xz":Po.set(0,1,0).applyQuaternion(l);break;case"adaptive":Ml.angleTo(hn.set(0,1,0))>Math.PI/6?(Ut.crossVectors(hn.set(0,1,0),Ml),Po.crossVectors(Ut,hn)):Po.set(0,1,0);break;default:Po.copy(Ml);break}Fc.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:Fc;if(QL.setFromNormalAndCoplanarPoint(Po,u),!!a.ray.intersectPlane(QL,r)&&(n==="x"||n==="y"||n==="z")){let c=hn.subVectors(r,u).dot(Ut);r.copy(u).addScaledVector(Ut,c)}}updateDragItem(e,r=!1){Fc.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Tm.subVectors(e.fromPosition,Fc).divideScalar(e.currentDampingFactor):e.reset==="original"?(Tm.subVectors(e.obj.userData.worldPosition0,Fc).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Tm.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Fc).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Tm.length()<fQ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&mQ(e,Tm.add(Fc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var uf=new _,K1=new _,ga=new _,ya=new _,ZL=new Or,gQ=.01,yQ={type:"requestRender"},vQ=function(){let i=new _,t=new _;return(e,r,n)=>n>0?(i.subVectors(e,r),i.length()<=n?e:t.copy(r).add(i.normalize().multiplyScalar(n))):r}(),JL=function(){let i=new ie;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof $t&&Xn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Z1=class{constructor(t,e,r,n,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new _;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Fy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=nr(t,t.actions,r,n,s,e)}},ox=class extends yr{constructor(e,r){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(qe.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!n.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Z1(o.data,s,n,e.sharedAssets,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events)if(n.target!==void 0){let s=n.target,o=this.onTargetChange(n);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let n of this.events)n.paused=!0,n.isReset=!1,qt(n.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:n,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(ga),e.isReset)ya.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ya);else{let{getCamera:l,raycaster:u}=this.eventContext;if(n==="custom"?(l().getWorldDirection(K1),K1.negate(),uf.copy(K1)):n==="xy"?uf.set(0,0,1):n==="xz"?uf.set(0,1,0):n==="yz"&&uf.set(1,0,0),ZL.setFromNormalAndCoplanarPoint(uf,ga),!u.ray.intersectPlane(ZL,ya))return}if(!e.isReset){if(ya.distanceTo(e.worldPosition0)>s&&o&&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)ya.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&&(ya.x=ga.x),e.data.enabledTranslation[1]===!1&&(ya.y=ga.y),e.data.enabledTranslation[2]===!1&&(ya.z=ga.z);let a=vQ(ga,ya,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=uf.subVectors(a,ga).divideScalar(e.currentDampingFactor);ga.add(l),r&&JL(e.object,ga),e.paused=l.length()<gQ}else JL(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(yQ)}};var Cm=new _,ax=new _,Pm=new ie,hf=new He,Tl=new He,Dm=new _,Im=new _,Vc=new _,va=new _,J1=new Or,xQ=1e-6,bQ={type:"requestRender"},wQ={type:"changeRotation"},$L=function(){let i=new ie;return function(e,r){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),r.premultiply(U1(i).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof $t&&Xn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),$1=class{constructor(t,e,r){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new He;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...ky.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},lx=class extends yr{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(qe.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{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=e=>{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=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:n})=>{if(!r||!n)return;let s=Co(r);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(n=>{let s=n.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!r.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new $1(s.data,n,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?r.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events){if(n.target!==void 0){let a=this.onTargetChange(n),l=n.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(n),o=n.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let[n,s]of this.pairOfUserEventListeners)n.removeEventListener("userEvent",s);for(let n of this.events)n.paused=!0,n.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:r,axis:n,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(Dm),!e.isReset)if(e.target)e.target.getWorldPosition(Im);else{if(o==="custom"?(c().getWorldDirection(ax),ax.negate(),J1.setFromNormalAndCoplanarPoint(ax,Dm)):(o==="xy"?Cm.set(0,0,1):o==="xz"?Cm.set(0,1,0):o==="yz"&&Cm.set(1,0,0),J1.setFromNormalAndCoplanarPoint(Cm,Dm)),!h.ray.intersectPlane(J1,Im))return;s>0&&(o==="custom"||o===void 0)&&Im.addScaledVector(ax,s)}if(e.isReset||(f?r==="target"?Vc.copy(f.up).applyMatrix4(Pm.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(n==="x"?(va.set(0,0,1),l[2]===!1&&va.set(0,1,0)):n==="y"?(va.set(1,0,0),l[0]===!1&&va.set(0,0,1)):(va.set(0,1,0),l[1]===!1&&va.set(1,0,0)),Vc.copy(va).applyQuaternion(e.worldQuaternion0).normalize()):Vc.set(0,1,0):o==="custom"?Vc.set(0,1,0):Vc.copy(Cm)),e.isReset)Tl.copy(e.worldQuaternion0);else if(Dm.distanceTo(Im)>a&&u&&f)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)Tl.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;SQ(Pm,Im,Dm,Vc,n,va),Tl.setFromRotationMatrix(Pm),hf.setFromUnitVectors(va.applyQuaternion(Tl),Vc),l.some(p=>p===!1)&&r!=="target"&&Tl.premultiply(hf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),hf.setFromRotationMatrix(U1(d.matrixWorld)),hf.slerp(Tl,1/e.currentDampingFactor),$L(d,Pm.makeRotationFromQuaternion(hf)),e.paused=8*(1-hf.dot(Tl))<xQ):($L(d,Pm.makeRotationFromQuaternion(Tl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(bQ),d.dispatchEvent(wQ)}},us=new _,dn=new _,Ur=new _;function SQ(i,t,e,r,n,s){let o=i.elements;Ur.subVectors(t,e),Ur.lengthSq()===0&&(Ur.z=1),Ur.normalize(),dn.crossVectors(r,Ur),dn.lengthSq()===0&&(Math.abs(r.z)===1?Ur.x+=1e-4:Ur.z+=1e-4,Ur.normalize(),dn.crossVectors(r,Ur)),dn.normalize(),us.crossVectors(Ur,dn),n==="x"?s.z===1?[dn,us,Ur]=[Ur,dn,us]:(dn.negate(),[dn,Ur]=[Ur,dn]):n==="y"?s.x===1?[dn,us,Ur]=[us,Ur,dn]:(dn.negate(),[us,Ur]=[Ur,us]):s.x===1&&(dn.negate(),[dn,us]=[us,dn]),o[0]=dn.x,o[4]=us.x,o[8]=Ur.x,o[1]=dn.y,o[5]=us.y,o[9]=Ur.y,o[2]=dn.z,o[6]=us.z,o[10]=Ur.z}var e_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),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()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),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())}},cx=class extends yr{constructor(e,r){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{qe.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new e_(a,l,o,n,s,r);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),on&&(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(r=>{r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),on&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(n=>{n.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:n,raycaster:s,page:o}=this.eventContext;if(n){let a=of(s,o,this.objects);r=Mm(a)}else this.objects.forEach(a=>{af(s,a)&&r.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(n=>{r.includes(n)||(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(n=>{n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var t_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=nr(e,e.actions,n,s,o,r)}connect(){this.scrollCounter=0}disconnect(){qt(this.actions)}dispatch(t){this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this&&(n.object.currentTransitionEvent=this,n.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(n=>n.seek(r)),this.actions.Animation.forEach(n=>n.seek(e)),this.actions.Create.forEach(n=>n.dispatchThrottled()),this.actions.SetVariable.forEach(n=>n.checkConditions()),this.actions.SetVariable.forEach(n=>n.dispatch()),this.actions.DynamicVariablePlay.forEach(n=>n.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},r_=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=nr(e,e.actions,n,s,a,r)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,r=document.documentElement,n=window.pageYOffset||r.scrollTop||e.scrollTop,s=r.clientTop||e.clientTop||0,o=Math.round(t.top+n-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=t,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){qt(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:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,n=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(n)),this.actions.Animation.forEach(s=>s.seek(n)),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(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},ux=class extends yr{constructor(e,r){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,n])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),n.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{page:n,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;n.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let h=new t_(u,c,l,n,s,r);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(h):this.wheelEventsPerObject.set(l,[h])}else{let h=new r_(u,c,l,n,s,o,r);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(h):this.scrollEventsPerObject.set(l,[h])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.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,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var n_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Reset.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.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof Ao?e.interaction.audioPlayer.play():e.interaction instanceof rf&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof pa?e.interaction.play(r==="autoplay"):e.interaction instanceof sf&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.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.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof Ao?e.interaction.audioPlayer.play():e.interaction instanceof rf&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof pa?e.interaction.play():e.interaction instanceof sf&&e.interaction.dispatch()})}},hx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext;(r?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.actions.Audio.forEach(s=>{s.interaction instanceof Ao&&s.interaction.audioPlayer.play()}),n.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof pa&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&s==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext;if(r.traverseEntity(n=>{if(!!n.data?.events.length)for(let{id:s,data:o}of n.data.events){if(o.disabled||o.type!=="Start")continue;let a=new n_(s,o,n,r,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.Reset.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(n)?this.eventsPerObject.get(n)?.push(a):this.eventsPerObject.set(n,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(n)?this.eventsAfterPerObject.get(n)?.push(a):this.eventsAfterPerObject.set(n,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(n)?this.eventsAfterPerObject.get(n)?.push(a):this.eventsAfterPerObject.set(n,[a]))}}),[...this.eventsAfterPerObject.values()].some(n=>n.length)){if(this.eventManager.activateCount===0){let{domElement:n,isExport:s}=this.eventContext,o=s?document:n;o.addEventListener("pointerdown",this.onMouseDown,{once:!0}),o.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),o.addEventListener("pointerdown",this.onAny),o.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,l])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,n=r?document:e;n.removeEventListener("pointerdown",this.onMouseDown),n.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),n.removeEventListener("pointerdown",this.onAny),n.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(n=>n.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var dx=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=nr(e,e.actions,n,s,o,r),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){qt(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{this.alreadyPlayedNonTogglingActions.has(e)===!1&&e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var fx=class extends yr{constructor(e,r,n,s,o){super(e);this.sharedVariables=r;this.eventManager=n;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.events=[];this.onFrame=e=>{this.rafId=window.requestAnimationFrame(this.onFrame);let r=new Date,n=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:u,property:c,prevValue:h}=this.propertiesToWatch[l],d=this.eventContext.scene.find(u),f=zy.propertyPaths[c];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")d=d.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)d=d[f[p]];h===null?this.propertiesToWatch[l].prevValue=d instanceof _?d.clone():d:(d instanceof _?!d.equals(h):h!==d)&&(s.push({objId:u,property:c}),d instanceof _?this.propertiesToWatch[l].prevValue.copy(d):this.propertiesToWatch[l].prevValue=d)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:u,prevValue:c}=this.variablesToWatch[l],h=this.shared.getVariable(u);h!==c&&(n.push(u),this.variablesToWatch[l].prevValue=h)}for(let l=0;l<this.dynamicVars.length;l++){let{id:u,expectedTime:c,last:h,data:d,timerSeconds:f,startValue:p}=this.dynamicVars[l],m=1e3;if((d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&d.format==="number3decimal"?m=1:d.dynamicVariableType==="counter"?m=d.updateInterval:d.dynamicVariableType==="random"&&(m=d.isStatic?1/0:d.updateInterval),c===-1){this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m;continue}if(!((this.shared.getDynamicVariablePlayState(u)==="Stopped"||this.shared.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m,d.dynamicVariableType==="counter"&&this.shared.getVariable(u)!==p&&(this.shared.updateVariable(u,p),this.eventManager.requestRender()),(d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&this.dynamicVars[l].timerSeconds!==p&&(this.dynamicVars[l].timerSeconds=p,this.shared.updateVariable(u,fi.getFormattedTimerTime(p,d)),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[l].deltaToExpectedTime===void 0&&(this.dynamicVars[l].deltaToExpectedTime=Math.max(this.dynamicVars[l].expectedTime-e,0)),this.dynamicVars[l].last=e-(m-this.dynamicVars[l].deltaToExpectedTime),this.dynamicVars[l].expectedTime=e+this.dynamicVars[l].deltaToExpectedTime;continue}else this.dynamicVars[l].deltaToExpectedTime=void 0;if(e>=c)if(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime+=m,d.dynamicVariableType==="random"){let g=d.min+Math.random()*(d.max-d.min),y=d.decimals;g=Math.round(g*Math.pow(10,y))/Math.pow(10,y),this.shared.updateVariable(u,g),n.push(u),this.eventManager.requestRender()}else if(d.dynamicVariableType==="counter"){if(d.increment===0)continue;let g=this.shared.getVariable(u),y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=this.shared.getVariable(u)+d.increment*(y?1:-1);d.hasEnd&&(v=d.increment>0?Se.clamp(v,p,d.endValue):Se.clamp(v,d.endValue,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),d.repeat?v===d.endValue&&(v=p):(v===p||v===d.endValue)&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==g&&(n.push(u),this.shared.updateVariable(u,v),this.eventManager.requestRender())}else if(d.dynamicVariableType==="time")this.shared.updateVariable(u,IA(r,d)),n.push(u),this.eventManager.requestRender();else{let g=En.isTextValue(d.endValue)?e3(d.endValue.textValue):d.endValue,y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=f+(e-h)/1e3*(d.dynamicVariableType==="timer"?-1:1)*(y?1:-1);v=Math.max(v,0),d.hasEnd&&(v=d.dynamicVariableType==="stopwatch"?Se.clamp(v,p,g):Se.clamp(v,g,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),d.repeat?Math.abs(v-g)<(d.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(d.format==="number3decimal"?1e-4:.1)||Math.abs(v-g)<(d.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==f&&(n.push(u),this.dynamicVars[l].timerSeconds=v,this.shared.updateVariable(u,fi.getFormattedTimerTime(v,d)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(l=>{l.data.variableId==="mouseProperty"&&(l.dispatch(),this.eventManager.requestRender())}));let o=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,o=!0);let a=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,a=!0),this.events.forEach(l=>{(n.includes(l.data.variableId)||s.find(u=>u.objId===l.data.objectId&&u.property===l.data.property)||l.data.variableId==="mouseProperty"&&o||l.data.variableId==="raycastProperty"&&a)&&(l.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()};e.page.traverseEntity(a=>{a.data?.events.filter(l=>l.data.type==="VariableChange"&&!l.data.disabled).forEach(l=>{this.events.push(new i_(a.uuid,l.data,a,e.page,e.sharedAssets,n))})}),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:l})=>{if(!("dynamicVariableType"in l)){this.events.find(c=>c.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let u;if(l.dynamicVariableType==="timer"||l.dynamicVariableType==="stopwatch"){let c;if(En.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let h=l.value.textValue;h.length===3?c=h[2]+h[1]*60+h[0]*3600:c=h[1]+h[0]*60}else c=l.value;u=c,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,timerSeconds:c,startValue:u})}else l.dynamicVariableType==="time"&&this.shared.updateVariable(a,IA(new Date,l)),l.dynamicVariableType==="counter"&&(u=En.isTextValue(l.value)?e3(l.value.textValue):l.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,startValue:u})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].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())}},i_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=nr(e,e.actions,n,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch())}dispose(){qt(this.actions)}};function e3(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var r3=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.517/build/",AQ=!1?r3:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.517/build/",_Q=`
6426
+ )`}else if(i.easing===6){let{mass:e,stiffness:r,damping:n,velocity:s}=i;t=`spring( ${e}, ${r}, ${n}, ${s} )`}else{let e;switch(i.easing){case 0:e=$o.linear;break;case 1:e=$o.ease;break;case 2:e=$o.easeIn;break;case 3:e=$o.easeOut;break;case 4:e=$o.easeInOut;break;default:e=$o.linear}let[r,n,s,o]=e;t=`cubicBezier( ${r}, ${n}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function N1(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.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,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var jX={type:"beginState"},WX={type:"completeState",isfromEntity:!1},K0=class{constructor(t,e,r,n,s,o){this.object=t;this.data=n;this.sharedAssets=s;this.allowSlerp=o;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 t=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=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof er&&e.dispatchEvent(jX)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=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=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof er&&e.dispatchEvent(WX)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=L1(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=Q0(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=Q0(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=Q0(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...N1(n),...B1(n),change:this.onChange},this.callback=L1(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},gm=class extends Yt{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;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())};if(!e.object)throw new Error("Missing property");let o=this.page.scene.find(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,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=Q0(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:n=!1}={}){try{let s=N1(this.data.tweens[0].data);n&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=X0.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof er&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new K0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof er&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new K0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Bt(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=N1(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.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(Bt(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 Q0(i,t){let e,r;if(typeof t=="string"?(e=t,r=i.states?.[e]):t===null&&(e=null,r=i.data),!(e===void 0||r===void 0))return{id:e,data:r}}var qX={type:"beginState"},IL={type:"completeState",isfromEntity:!1},OL={type:"requestRender"},ym=class extends Yt{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new _;this.posEnd=new _;this.qStart=new He;this.qEnd=new He;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 r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");let n={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=X0({targets:n,t:1,...B1(this.data),update:()=>{n.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(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(qX));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,n.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(OL),n.t===1&&s.dispatchEvent(IL)}})}switchCamera(e){let r=this.page.scene.find(e);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(r),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:r})}play(){if(Bt(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(Bt(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(IL),this.page.activeCamera.dispatchEvent(OL))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var vm=class extends Yt{constructor(e,r,n,s,o){super();this.page=r;this.animationControls=n;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let u=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=u?.getClip()?.duration??1;let c=u?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/c*this.duration,this.rightFrameTime=this.data.crop[1]/c*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Bt(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 r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([n,s])=>{let o=n.split("/")[1];this.threeAnimAction!==s&&o===r&&s.isRunning()&&(e?s.fadeOut(.2):s.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=Se.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(Bt(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 n=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===n&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&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()}};var xm=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.eventManager=r;this.shared=n;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Bt(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(r=>r.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 t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),nf(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var bm=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Bt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=Ov(this.data.expression,this.shared,En.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var wm=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.timeoutId=null}dispatchInner(){if(Bt(this.shared,this.condition)===!1)return!1;let t=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,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="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"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="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 e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function Bt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=Ov(t.expression,i,"boolean");return t.negate?!e:!!e}function nr(i,t,e,r,n,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},a=l=>({id:u,data:c})=>{try{c.type==="Audio"?di[i.type].includes("Audio")&&o.Audio.push(new hm(u,c,s,r,l)):c.type==="Video"?di[i.type].includes("Video")&&o.Video.push(new Sm(u,c,s,r,l)):c.type==="Link"?di[i.type].includes("Link")&&o.Link.push(new G0(c,n.controlsManager,r,l)):c.type==="Create"?di[i.type].includes("Create")&&o.Create.push(new Am(c,e,n.controlsManager,r,l)):c.type==="Destroy"?di[i.type].includes("Destroy")&&o.Destroy.push(new dm(c,e,n.controlsManager,r,l)):c.type==="Reset"?di[i.type].includes("Reset")&&o.Reset.push(new fm(c,e,r,n,l)):c.type==="Transition"?di[i.type].includes("Transition")&&o.Transition.push(new gm(c,e,r,l)):c.type==="SwitchCamera"?di[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new ym(c,e,r,l)):c.type==="SceneTransition"?di[i.type].includes("SceneTransition")&&o.SceneTransition.push(new xm(c,e,n,r,l)):c.type==="Animation"?di[i.type].includes("Animation")&&o.Animation.push(new vm(c,e,n.animationControls,r,l)):c.type==="SetVariable"?di[i.type].includes("SetVariable")&&o.SetVariable.push(new bm(c,e,r,l)):c.type==="DynamicVariablePlay"?di[i.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new wm(c,e,r,l)):c.type==="Conditional"&&di[i.type].includes("Conditional")&&(c.ifActions.forEach(a({expression:c.condition,negate:!1})),c.elseActions.forEach(a({expression:c.condition,negate:!0})))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function qt(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof hm||e instanceof Sm||e instanceof vm||e instanceof gm||e instanceof Am||e instanceof dm||e instanceof ym||e instanceof xm||e instanceof fm||e instanceof bm||e instanceof wm)&&e.dispose()})})}function RL(i,t){let e;if("material"in i){let r=i.material;Array.isArray(r)?e=i.material[0].layers.find(n=>n.uuid===t):e=i.material.layers.find(n=>n.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var LL=new Map,_m=new Map,pa=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:n,loop:s,volume:o,delay:a}=e;if(this.object=r,n===void 0)throw new Error("Missing property");let l=RL(r,n);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,sh&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),_m.has(r.uuid)?_m.get(r.uuid).push(this):_m.set(r.uuid,[this]),LL.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(n=>{}).catch(n=>{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)}},sf=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=LL.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=_m.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[..._m.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Sm=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new pa(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new sf(e);else throw new Error("Missing property")}dispatchBasic(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof pa?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof pa?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var NL=(()=>{let i,t,e,r;function n(a){!i&&!BL()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,d=0;for(;d<h;){let f=u[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,r())}i=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){BL()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):n()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),n})();function BL(){return!!document&&document.hidden}var FL=new He,YX=new _,XX=new _,Am=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Se.generateUUID();this.dispatch=()=>{if(Bt(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(Bt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=ww(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 t=new mr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,n=this.page.scene.find(r);n&&(n.updateMatrixWorldSVD(),t.hiddenMatrix.copy(n.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),NL(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Dn)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof mr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Dn)return;t instanceof mr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new _().fromArray(this.data.velocity),n=e.dataPatched;if(!(n.physics.enabled==="visibility"?!n.visible:!n.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(YX,FL,XX),r.applyQuaternion(FL),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");NL(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var z1=200,F1=.02,k1=.3,QX=65,mFe=new _,kL=new _,VL=new _,KX=new _,ai=new _,_i=new _,El=new _,V1=new ie,zL=new ie,ZX=new ie,gFe=new ie,Fs=new He,ma=new He,Mo=new Zt(0,0,0,"YXZ"),JX=new _(1,0,0),ks=new _(0,1,0),$X=new _(0,0,1),UL=new _(1,1,1),yFe=new fr,eQ=1,tQ=.025,rQ=16e-6,GL=12,nQ=20,On=new nn,cs=new Pt,iQ={type:"requestRender"},sQ={type:"updateMatrix"},HL=Math.PI/6,Z0=class extends Yt{constructor(e,r,n,s,o,a,l,u,c){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new ie;this.target0=new _;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=z1;this.euler0=new Zt(0,0,0,"YXZ");this.position0Cam=new _;this.quat0Cam=new He;this.scale0Cam=new _;this.hiddenMatrix0Cam=new ie;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new nn(new _(0,-40,0),new _(0,40,0)),matrix:new ie,position:new _,rotation:new He};this.euler=new Zt(0,0,0,"YXZ");this.eulerDelta=new _;this.lastPosition=new _;this.lastCameraQuaternion=new He;this.lastCameraPosition=new _;this.PI_2=Math.PI/2;this.prevMouse=new N;this.velocityTarget=new _;this.velocity=new _;this.directionXZ=new _;this.rotVelocityStick=new _;this.rotVelocityTarget=new _;this.rotVelocity=new _;this.rotDirection=new _;this.nonColliderRotOffset=new ie;this.nonColliderPosOffset=new ie;this.firstPointerId=-1;this.rot=new _;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 ie;this.objectToTarget=new _;this.objectToTarget0=new _;this.objectToCamXZ=new _;this.objectToCamXZ0=new _;this.targetToCamera=new _;this.targetToCamera0=new _;this.cameraPolarAxis0=new _;this.targetPos=new _;this.targetQuat=new He;this.lerpFactorPos=new _().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new He;this.objXZQuatInv=new He;this.objXZRotMat=new ie;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new _;this.pushedVelocity=new _;this.groundYRotation=0;this.objectRealQuat=new He;this.colliderWorldQuat=new He;this.groundNormal=new _;this.groundTilt=new He;this.groundTiltInv=new He;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new _;this.quaternion=new He;this.scale=new _;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!on&&(!Sw||Aw>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Sw&&Aw<15.5&&!on?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Z0.isLocked=!0:Z0.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let s=e.axes[n];r===0?n===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(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 g=new _(0,0,-1).applyQuaternion(this.camera.quaternion),y=new _().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let w=new Zt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-w.x,w.x=0,w.z=0,w.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(w)}if(this.object instanceof er&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*eQ,this.speedOrbit=(n.speedRotate??100)*tQ,this.mouseOrbitSensitivity=(n.speedRotate??100)*rQ,this.keyAssignments=n.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),n.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Ja.defaultData.gravity)*GL,this.usePhysics=this.gloabalPhysics.usePhysics??Ja.defaultData.usePhysics,this.jumpPower=n.jumpPower*nQ,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??Mh.defaultDataThirdPerson.orientWith,this.slopeThresh=QX*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*F1/this.pixelsPerMeter,this.stepThresh=n.collider.height*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*F1/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*F1/this.pixelsPerMeter,this.stepThresh=n.collider.height*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let f=new _().fromArray(n.collider.position),p=new He().setFromEuler(new Zt().fromArray([...n.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,UL),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.runMultiplier=n.runMultiplier??2;let m=n.navmesh.destinationHelperRadius*2;if(m>0){let g=new Le;g.push({fi:0,data:{..._n.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{..._n.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let y=new la({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new _r(vv.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=n.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 r=new Zt().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof er?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Eh.list.forEach(n=>{this.actions[n]=nr({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,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"),qt(this.actions.idle),qt(this.actions.move),qt(this.actions.run),qt(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return ai.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,n){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 s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let u=_i.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*GL),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(c){this.onObject=!0,this.groundNormal.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),c.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=c.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(ai,ma,_i),this.groundVelocity.subVectors(ai,d.prevT),this.object.getWorldPosition(_i).add(this.collider.position).sub(ai),this.groundYRotation=Mo.setFromQuaternion(ma).y-d.prevR.y,El.copy(_i).applyAxisAngle(ks,this.groundYRotation),this.groundVelocity.add(El.sub(_i)).divideScalar(s);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*o),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 u=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 c=ai.subVectors(this.path[1],this.position),h=_i.subVectors(this.path[1],this.path[0]);c.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),u.opacity=u.userData.opacity0}else u.opacity-=.05*u.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)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):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 l=KX.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=_i.copy(l);u.y=0,l.set(0,l.y,u.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let u=ai;this.camera.getWorldDirection(u);let c=El.copy(ks).multiplyScalar(u.dot(ks));u.sub(c);let h=_i.copy(this.directionXZ);h.x*=-1,this.rot.y=u.angleTo(h)*(u.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(Mo.setFromVector3(this.rot),this.moveMode==="walk"&&(Mo.x=0),l.applyEuler(Mo),a&&(ma.setFromUnitVectors(ks,this.groundNormal),l.applyQuaternion(ma)),n){let u=Mo.set(0,this.vrEulerYOffset*HL,0);n.applyEuler(u),l.x+=n.x,l.z+=n.z,this.nonColliderPosOffset.elements[13]+=n.y*s}if(this.usePhysics===!0){let u=_i;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=El.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=c.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),ai.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=lt.is(c)?c:c.object;if(d!==null&&this.lastHitObj!==f){let p;c instanceof mr&&(p=c);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(J0));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),u.copy(d.normal1).applyQuaternion(c.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let c=u.dot(l);c<0&&l.addScaledVector(u,-c),l.add(this.pushedVelocity)}else l.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(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ks,this.euler.y-this.euler0.y);let u=_i.copy(this.objectToCamXZ).normalize(),c=El.copy(l).multiplyScalar(s);c.y=0;let h=c.sub(ai.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+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=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Se.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(Mo.copy(r),Mo.y=0):(Mo.copy(this.euler),Mo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Mo)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*HL),Fs.setFromAxisAngle(JX,this.rot.x),ma.setFromAxisAngle(ks,this.rot.y),ma.multiply(Fs),Fs.setFromAxisAngle($X,this.rot.z),ma.multiply(Fs),this.quaternion.copy(ma),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 u=_i.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let h=new _;for(let d=0;d<5;d++){let f=u.length(),p=El.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),c!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(c.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let w of x)if(w.data.target==="character"){let S=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,A;if(m.cloner){for(let E of m.cloner.children)if(E.rigidBody===S){A=E;break}}w.dispatch(A),m.dispatchEvent(J0)}}}let g=kL.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=VL.copy(p).multiplyScalar(c.toi).dot(g),v=c.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=c.toi*(y-this.offset)/y,h.addScaledVector(p,v)),u.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),w=El.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);w.y=0;let S=x.add(w);S.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(S,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);A!==null&&A.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(u);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(ai.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Fs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let h=0;h<u;h++)this.position.add(c),this.collisionAdjustment(s/u)}else this.position.addScaledVector(l,s);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 u=this.objectToTarget.add(this.position),c=this.targetToCamera.add(u);V1.lookAt(c,u,ks).setPosition(c),V1.decompose(this.targetPos,this.targetQuat,ai),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Se.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Se.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(sQ),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(iQ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Fs.setFromAxisAngle(ks,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Se.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 r;this.cameraXAxis==="Limit"?r=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=ai.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let s=ma.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){ks.angleTo(e)*180/Math.PI<15||ks.angleTo(e)*180/Math.PI>85?Fs.identity():Fs.setFromUnitVectors(ks,e),this.groundTilt.slerp(Fs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=VL.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=V1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(ai,Fs,_i).compose(ai,Fs,UL);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;cs.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=zL.copy(a).invert(),u=ZX.copy(zL).multiply(n);On.copy(this.collider.segment),On.start.applyMatrix4(u),On.end.applyMatrix4(u);let c=kL.copy(this.position).applyMatrix4(l);cs.expandByPoint(On.start),cs.expandByPoint(On.end),cs.min.addScalar(-this.collider.radius),cs.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(On.end)},intersectsBounds:h=>h.intersectsBox(cs),intersectsTriangle:h=>{let d=ai,f=_i,p=h.closestPointToSegment(On,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=El.copy(c);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);r.add(v),On.start.addScaledVector(g,m),On.end.addScaledVector(g,m)}}})}),cs.makeEmpty(),On.copy(this.collider.segment),On.start.applyMatrix4(n),On.end.applyMatrix4(n),cs.expandByPoint(On.start),cs.expandByPoint(On.end),cs.min.addScalar(-this.collider.radius),cs.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(On.end)},intersectsBounds:o=>o.intersectsBox(cs),intersectsTriangle:o=>{let a=ai,l=_i,u=o.closestPointToSegment(On,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,c),On.start.addScaledVector(h,c),On.end.addScaledVector(h,c)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}},Em=Z0;Em.isLocked=!1;var jL=pn(SS());function Vs(i,t){let e=new Ae;if(!i.getAttribute("position"))return e.setAttribute("position",new be([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=yc(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new be(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var oQ=new ie,aQ=new ie,To=[[0,0,0],[0,0,0],[0,0,0]];function U1(i){let t=i.elements;To[0][0]=t[0],To[0][1]=t[4],To[0][2]=t[8],To[1][0]=t[1],To[1][1]=t[5],To[1][2]=t[9],To[2][0]=t[2],To[2][1]=t[6],To[2][2]=t[10];let{u:e,v:r}=(0,jL.SVD)(To),n=oQ.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=aQ.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 n.multiply(s.transpose())}var $0=class extends Mu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(n=>{n.visible&&this.intersectObject(n,e,r)}),r}createRaycastLineHelper(){let t=new Hi({color:65280,linewidth:10}),e=new _(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new _(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),n=this.camera.far-this.camera.near,s=new _().addVectors(e,r.multiplyScalar(n)),o=new Ae;return o.setFromPoints([e,s]),new jl(o,t)}};var WL=i=>i instanceof ss||i instanceof Rs;function lQ(i,t){return i.distance-t.distance}function qL(i,t,e){if(!(!oo(t)||!t.visible)){Yn(t)&&t.raycast(i,e);for(let r of t.children)qL(i,r,e)}}function of(i,t,e,r=!1){if(!r&&!e.some(s=>af(i,s)!==void 0))return[];let n=[];return t.children.forEach(s=>qL(i,s,n)),n.sort(lQ),n}function Mm(i){let t=[];if(i.length){let e=i[0].object;oo(e)&&t.push(e);let r=e.parent;for(;r;)WL(r)&&t.push(r),r=r.parent}return t}function af(i,t){if(Yn(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(WL(t))return YL(i,t)}function YL(i,t){if(!(!oo(t)||!t.visible)){if(Yn(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let r=YL(i,e);if(r)return r}}}function cQ(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var ex=class{constructor(t,e,r,n,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=n;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new $0;this._useWindowEvents=!1;this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}updateRaycaster(t){let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.raycaster.setFromCamera(cQ(e,r,this._domRect),this.getCamera())}};var yr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var G1=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],XL=i=>G1.find(([t,e])=>e===i)?.[0],Co=i=>G1.find(([t])=>t===i)?.[1],uQ=(i,t)=>{let e=XL(i);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},tx=class extends yr{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[XL(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:n}=this.eventContext;n.dispatchEvent(r)};let{page:r}=this.eventContext;r.traverseEntity(n=>{if(!!n.data?.events.length){for(let[s,o]of G1)if(n.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(n):this.objectsPerEvents.set(s,[n]);let a={id:n.uuid,name:n.name},l=uQ(o,a),u=this.splineEvents[s];u?u[n.uuid]=l:this.splineEvents[s]={[n.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var H1=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.runMode==="Toggle",(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(n=>n.playing)||this.actions.Transition.forEach(n=>{this.alreadyPlayedNonTogglingActions.has(n)===!1&&n.play()}),this.actions.SwitchCamera.some(n=>n.playing)||this.actions.SwitchCamera.forEach(n=>{n.play()}),this.actions.Animation.forEach(n=>{n.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},rx=class extends yr{constructor(e,r,n){super(e);this.useForRaycastProperty=n;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=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=of(r,n,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(n)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:h})=>h.type===u&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new H1(h,d,a,s,o,r);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch(f){!1&&console.log(f)}}),c[a.uuid]?.length&&this.objectsPerTypes[u].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(([r,n])=>{n.forEach(s=>{s.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(r=>{Object.values(r).forEach(n=>{n.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,n])=>{n.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:n,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!(!o.length&&!this.useForRaycastProperty)){if(r||this.useForRaycastProperty){let a;this.sceneInterects===null?a=of(n,s,o,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]}),r&&Mm(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}r||o.forEach(a=>{af(n,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let r="MousePress",n=this.objectsPerTypes[r],s=[];if(!!n.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=of(a,l,n);s=Mm(u)}else n.forEach(u=>{af(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,r)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,r)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatchRelease()})}handleKeyEvent(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(n?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(n)})})}};var hQ=new _,dQ=new _;var nx=class{constructor(t,e,r,n,s){this.actionsIn=nr(t,t.inActions,r,n,s,e),this.actionsOut=nr(t,t.outActions,r,n,s,e)}disconnect(){qt(this.actionsIn),qt(this.actionsOut)}};var j1=class extends nx{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=hQ.setFromMatrixPosition(this.objects[0].matrixWorld),r=dQ.setFromMatrixPosition(this.objects[1].matrixWorld),n=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==n){this.stage=n;let s=n==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch())}};let{distance:l,fromObject:u,toObject:c}=r.condition;this.distance=l;for(let h of[u,c]){if(!h)throw new Error("Missing property");let d=s.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)})}},W1=class extends nx{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(n=>n.dispatchConditional()),this.actionsOut.Video.forEach(n=>n.dispatchConditional()),this.actionsOut.Link.forEach(n=>n.dispatch()),this.actionsOut.Create.forEach(n=>n.dispatch()),this.actionsOut.Destroy.forEach(n=>n.dispatch()),this.actionsOut.Reset.forEach(n=>n.dispatch()),this.actionsIn.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(n=>n.play()),this.actionsOut.Animation.forEach(n=>n.play()),this.actionsIn.SwitchCamera.forEach(n=>n.pause()),this.actionsOut.SwitchCamera.forEach(n=>n.play()),this.actionsOut.SceneTransition.forEach(n=>n.dispatch()),this.actionsOut.SetVariable.forEach(n=>n.checkConditions()),this.actionsOut.SetVariable.forEach(n=>n.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(n=>n.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(n=>n.dispatchConditional()),this.actionsIn.Video.forEach(n=>n.dispatchConditional()),this.actionsIn.Link.forEach(n=>n.dispatch()),this.actionsIn.Create.forEach(n=>n.dispatch()),this.actionsIn.Destroy.forEach(n=>n.dispatch()),this.actionsIn.Reset.forEach(n=>n.dispatch()),this.actionsOut.Transition.forEach(n=>n.pause()),this.actionsOut.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(n=>n.play()),this.actionsIn.Animation.forEach(n=>n.play()),this.actionsOut.SwitchCamera.forEach(n=>n.pause()),this.actionsIn.SwitchCamera.forEach(n=>n.play()),this.actionsIn.SceneTransition.forEach(n=>n.dispatch()),this.actionsIn.SetVariable.forEach(n=>n.checkConditions()),this.actionsIn.SetVariable.forEach(n=>n.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(n=>n.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){qi(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),qi(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),qi(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),qi(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},ix=class extends yr{constructor(e,r){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new j1(a,l,o,n,s,r):l.condition.type==="State"&&(u=new W1(a,l,o,n,s,r))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var Tm=new _,Ml=new _,Fc=new _,QL=new Or,fQ=.01,Ut=new _,hn=new _,KL=new _,kc=new He,q1=new Zt,pQ=new ie,Y1=new Gt,lf=new _,Po=new _,cf=.2;function X1(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var mQ=function(){let i=new ie;return(t,e,r)=>{let n=t.obj;i.copy(n.hiddenMatrix),n.parent!==null&&i.premultiply(n.parent.matrixWorld),i.invert(),n.position.copy(e),t.reference==="global"&&X1(n.position,t.limits),n.position.applyMatrix4(i),t.reference==="parent"?X1(n.position,t.limits):t.reference==="local"&&(kc.copy(t.quat0).invert(),n.position.sub(t.position0),n.position.applyQuaternion(kc),X1(n.position,t.limits),kc.invert(),n.position.applyQuaternion(kc),n.position.add(t.position0)),i.multiply(r??n.matrixWorld).decompose(Ut,n.quaternion,hn),n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n instanceof $t&&Xn(n.parent)&&n.invalidateDownstreamBooleanData(!0)}}(),Q1=class{constructor(t,e,r,n,s,o){this.object=t;this.data=e;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=nr(e,e.dragDropActions.drag,r,n,s,this.object),this.actionsDrop=nr(e,e.dragDropActions.drop,r,n,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=r.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=r.find(c);!h||h.data.visible!==!1&&a.push(h)}))}),this.data.dropDestinations.forEach(l=>{let u=r.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=r.find(c);!h||h.data.visible!==!1&&this.dropDestIds.push(h.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new _().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new _().setFromMatrixPosition(l.matrixWorld),pointStart:new _,pointEnd:new _,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new _().copy(l.position),quat0:new He().copy(l.quaternion),snapped:!1,orientationMatrix:new ie,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){qt(this.actionsDrag),qt(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},sx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(qe.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||lt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,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 h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(Ut,kc,hn),q1.setFromQuaternion(kc),h.prevR===void 0?(h.prevR=q1.clone(),h.prevT=Ut.clone()):(h.prevR.copy(q1),h.prevT.copy(Ut)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&l.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}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(qe.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(qe.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||lt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.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 a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof ss)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||n.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=KL.copy(a.face.normal).applyMatrix3(Y1.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ut.copy(l).applyMatrix3(Y1.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Ut.x>cf?hn.x=-u.recursiveBBox.min.x:Ut.x<-cf&&(hn.x=-u.recursiveBBox.max.x),Ut.y>cf?hn.y=-u.recursiveBBox.min.y:Ut.y<-cf&&(hn.y=-u.recursiveBBox.max.y),Ut.z>cf?hn.z=-u.recursiveBBox.min.z:Ut.z<-cf&&(hn.z=-u.recursiveBBox.max.z),hn.applyMatrix3(Y1.invert())}else hn.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(hn)}this.activeEvent.data.autoOrient&&(Ut.set(0,1,0).cross(l),Ut.length()<1e-4&&Ut.set(-1,0,0).cross(l),hn.crossVectors(KL,Ut),o.orientationMatrix.makeBasis(Ut,hn,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=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||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(n=>n.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let n={};e.page.traverseEntity(s=>{s.component&&(n[s.component.uuid]?n[s.component.uuid].push(s.uuid):n[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new Q1(s,o.data,e.page,e.sharedAssets,r,n))})})}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(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,n,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(Ml),Ml.negate();let l=kc.identity();switch(s==="parent"?pQ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ut,l,hn):s==="local"&&e.matrixWorld.decompose(Ut,l,hn),n){case"x":Ut.set(1,0,0).applyQuaternion(l),lf.copy(Ml).cross(Ut),Po.copy(Ut).cross(lf);break;case"y":Ut.set(0,1,0).applyQuaternion(l),lf.copy(Ml).cross(Ut),Po.copy(Ut).cross(lf);break;case"z":Ut.set(0,0,1).applyQuaternion(l),lf.copy(Ml).cross(Ut),Po.copy(Ut).cross(lf);break;case"xy":Po.set(0,0,1).applyQuaternion(l);break;case"yz":Po.set(1,0,0).applyQuaternion(l);break;case"xz":Po.set(0,1,0).applyQuaternion(l);break;case"adaptive":Ml.angleTo(hn.set(0,1,0))>Math.PI/6?(Ut.crossVectors(hn.set(0,1,0),Ml),Po.crossVectors(Ut,hn)):Po.set(0,1,0);break;default:Po.copy(Ml);break}Fc.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:Fc;if(QL.setFromNormalAndCoplanarPoint(Po,u),!!a.ray.intersectPlane(QL,r)&&(n==="x"||n==="y"||n==="z")){let c=hn.subVectors(r,u).dot(Ut);r.copy(u).addScaledVector(Ut,c)}}updateDragItem(e,r=!1){Fc.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Tm.subVectors(e.fromPosition,Fc).divideScalar(e.currentDampingFactor):e.reset==="original"?(Tm.subVectors(e.obj.userData.worldPosition0,Fc).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Tm.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Fc).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Tm.length()<fQ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&mQ(e,Tm.add(Fc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var uf=new _,K1=new _,ga=new _,ya=new _,ZL=new Or,gQ=.01,yQ={type:"requestRender"},vQ=function(){let i=new _,t=new _;return(e,r,n)=>n>0?(i.subVectors(e,r),i.length()<=n?e:t.copy(r).add(i.normalize().multiplyScalar(n))):r}(),JL=function(){let i=new ie;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof $t&&Xn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Z1=class{constructor(t,e,r,n,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new _;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Fy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=nr(t,t.actions,r,n,s,e)}},ox=class extends yr{constructor(e,r){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(qe.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!n.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Z1(o.data,s,n,e.sharedAssets,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events)if(n.target!==void 0){let s=n.target,o=this.onTargetChange(n);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let n of this.events)n.paused=!0,n.isReset=!1,qt(n.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:n,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(ga),e.isReset)ya.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ya);else{let{getCamera:l,raycaster:u}=this.eventContext;if(n==="custom"?(l().getWorldDirection(K1),K1.negate(),uf.copy(K1)):n==="xy"?uf.set(0,0,1):n==="xz"?uf.set(0,1,0):n==="yz"&&uf.set(1,0,0),ZL.setFromNormalAndCoplanarPoint(uf,ga),!u.ray.intersectPlane(ZL,ya))return}if(!e.isReset){if(ya.distanceTo(e.worldPosition0)>s&&o&&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)ya.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&&(ya.x=ga.x),e.data.enabledTranslation[1]===!1&&(ya.y=ga.y),e.data.enabledTranslation[2]===!1&&(ya.z=ga.z);let a=vQ(ga,ya,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=uf.subVectors(a,ga).divideScalar(e.currentDampingFactor);ga.add(l),r&&JL(e.object,ga),e.paused=l.length()<gQ}else JL(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(yQ)}};var Cm=new _,ax=new _,Pm=new ie,hf=new He,Tl=new He,Dm=new _,Im=new _,Vc=new _,va=new _,J1=new Or,xQ=1e-6,bQ={type:"requestRender"},wQ={type:"changeRotation"},$L=function(){let i=new ie;return function(e,r){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),r.premultiply(U1(i).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof $t&&Xn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),$1=class{constructor(t,e,r){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new He;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...ky.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},lx=class extends yr{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(qe.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{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=e=>{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=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:n})=>{if(!r||!n)return;let s=Co(r);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(n=>{let s=n.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!r.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new $1(s.data,n,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?r.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events){if(n.target!==void 0){let a=this.onTargetChange(n),l=n.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(n),o=n.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let[n,s]of this.pairOfUserEventListeners)n.removeEventListener("userEvent",s);for(let n of this.events)n.paused=!0,n.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:r,axis:n,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(Dm),!e.isReset)if(e.target)e.target.getWorldPosition(Im);else{if(o==="custom"?(c().getWorldDirection(ax),ax.negate(),J1.setFromNormalAndCoplanarPoint(ax,Dm)):(o==="xy"?Cm.set(0,0,1):o==="xz"?Cm.set(0,1,0):o==="yz"&&Cm.set(1,0,0),J1.setFromNormalAndCoplanarPoint(Cm,Dm)),!h.ray.intersectPlane(J1,Im))return;s>0&&(o==="custom"||o===void 0)&&Im.addScaledVector(ax,s)}if(e.isReset||(f?r==="target"?Vc.copy(f.up).applyMatrix4(Pm.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(n==="x"?(va.set(0,0,1),l[2]===!1&&va.set(0,1,0)):n==="y"?(va.set(1,0,0),l[0]===!1&&va.set(0,0,1)):(va.set(0,1,0),l[1]===!1&&va.set(1,0,0)),Vc.copy(va).applyQuaternion(e.worldQuaternion0).normalize()):Vc.set(0,1,0):o==="custom"?Vc.set(0,1,0):Vc.copy(Cm)),e.isReset)Tl.copy(e.worldQuaternion0);else if(Dm.distanceTo(Im)>a&&u&&f)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)Tl.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;SQ(Pm,Im,Dm,Vc,n,va),Tl.setFromRotationMatrix(Pm),hf.setFromUnitVectors(va.applyQuaternion(Tl),Vc),l.some(p=>p===!1)&&r!=="target"&&Tl.premultiply(hf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),hf.setFromRotationMatrix(U1(d.matrixWorld)),hf.slerp(Tl,1/e.currentDampingFactor),$L(d,Pm.makeRotationFromQuaternion(hf)),e.paused=8*(1-hf.dot(Tl))<xQ):($L(d,Pm.makeRotationFromQuaternion(Tl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(bQ),d.dispatchEvent(wQ)}},us=new _,dn=new _,Ur=new _;function SQ(i,t,e,r,n,s){let o=i.elements;Ur.subVectors(t,e),Ur.lengthSq()===0&&(Ur.z=1),Ur.normalize(),dn.crossVectors(r,Ur),dn.lengthSq()===0&&(Math.abs(r.z)===1?Ur.x+=1e-4:Ur.z+=1e-4,Ur.normalize(),dn.crossVectors(r,Ur)),dn.normalize(),us.crossVectors(Ur,dn),n==="x"?s.z===1?[dn,us,Ur]=[Ur,dn,us]:(dn.negate(),[dn,Ur]=[Ur,dn]):n==="y"?s.x===1?[dn,us,Ur]=[us,Ur,dn]:(dn.negate(),[us,Ur]=[Ur,us]):s.x===1&&(dn.negate(),[dn,us]=[us,dn]),o[0]=dn.x,o[4]=us.x,o[8]=Ur.x,o[1]=dn.y,o[5]=us.y,o[9]=Ur.y,o[2]=dn.z,o[6]=us.z,o[10]=Ur.z}var e_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),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()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),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())}},cx=class extends yr{constructor(e,r){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{qe.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new e_(a,l,o,n,s,r);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),on&&(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(r=>{r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),on&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(n=>{n.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:n,raycaster:s,page:o}=this.eventContext;if(n){let a=of(s,o,this.objects);r=Mm(a)}else this.objects.forEach(a=>{af(s,a)&&r.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(n=>{r.includes(n)||(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(n=>{n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var t_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=nr(e,e.actions,n,s,o,r)}connect(){this.scrollCounter=0}disconnect(){qt(this.actions)}dispatch(t){this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this&&(n.object.currentTransitionEvent=this,n.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(n=>n.seek(r)),this.actions.Animation.forEach(n=>n.seek(e)),this.actions.Create.forEach(n=>n.dispatchThrottled()),this.actions.SetVariable.forEach(n=>n.checkConditions()),this.actions.SetVariable.forEach(n=>n.dispatch()),this.actions.DynamicVariablePlay.forEach(n=>n.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},r_=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=nr(e,e.actions,n,s,a,r)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,r=document.documentElement,n=window.pageYOffset||r.scrollTop||e.scrollTop,s=r.clientTop||e.clientTop||0,o=Math.round(t.top+n-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=t,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){qt(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:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,n=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(n)),this.actions.Animation.forEach(s=>s.seek(n)),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(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},ux=class extends yr{constructor(e,r){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,n])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),n.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{page:n,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;n.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let h=new t_(u,c,l,n,s,r);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(h):this.wheelEventsPerObject.set(l,[h])}else{let h=new r_(u,c,l,n,s,o,r);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(h):this.scrollEventsPerObject.set(l,[h])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.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,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var n_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Reset.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.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof Ao?e.interaction.audioPlayer.play():e.interaction instanceof rf&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof pa?e.interaction.play(r==="autoplay"):e.interaction instanceof sf&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.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.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof Ao?e.interaction.audioPlayer.play():e.interaction instanceof rf&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof pa?e.interaction.play():e.interaction instanceof sf&&e.interaction.dispatch()})}},hx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext;(r?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.actions.Audio.forEach(s=>{s.interaction instanceof Ao&&s.interaction.audioPlayer.play()}),n.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof pa&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Co(e);s&&s==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext;if(r.traverseEntity(n=>{if(!!n.data?.events.length)for(let{id:s,data:o}of n.data.events){if(o.disabled||o.type!=="Start")continue;let a=new n_(s,o,n,r,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.Reset.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(n)?this.eventsPerObject.get(n)?.push(a):this.eventsPerObject.set(n,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(n)?this.eventsAfterPerObject.get(n)?.push(a):this.eventsAfterPerObject.set(n,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(n)?this.eventsAfterPerObject.get(n)?.push(a):this.eventsAfterPerObject.set(n,[a]))}}),[...this.eventsAfterPerObject.values()].some(n=>n.length)){if(this.eventManager.activateCount===0){let{domElement:n,isExport:s}=this.eventContext,o=s?document:n;o.addEventListener("pointerdown",this.onMouseDown,{once:!0}),o.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),o.addEventListener("pointerdown",this.onAny),o.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,l])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,n=r?document:e;n.removeEventListener("pointerdown",this.onMouseDown),n.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),n.removeEventListener("pointerdown",this.onAny),n.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(n=>n.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var dx=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=nr(e,e.actions,n,s,o,r),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){qt(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{this.alreadyPlayedNonTogglingActions.has(e)===!1&&e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var fx=class extends yr{constructor(e,r,n,s,o){super(e);this.sharedVariables=r;this.eventManager=n;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.events=[];this.onFrame=e=>{this.rafId=window.requestAnimationFrame(this.onFrame);let r=new Date,n=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:u,property:c,prevValue:h}=this.propertiesToWatch[l],d=this.eventContext.scene.find(u),f=zy.propertyPaths[c];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")d=d.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)d=d[f[p]];h===null?this.propertiesToWatch[l].prevValue=d instanceof _?d.clone():d:(d instanceof _?!d.equals(h):h!==d)&&(s.push({objId:u,property:c}),d instanceof _?this.propertiesToWatch[l].prevValue.copy(d):this.propertiesToWatch[l].prevValue=d)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:u,prevValue:c}=this.variablesToWatch[l],h=this.shared.getVariable(u);h!==c&&(n.push(u),this.variablesToWatch[l].prevValue=h)}for(let l=0;l<this.dynamicVars.length;l++){let{id:u,expectedTime:c,last:h,data:d,timerSeconds:f,startValue:p}=this.dynamicVars[l],m=1e3;if((d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&d.format==="number3decimal"?m=1:d.dynamicVariableType==="counter"?m=d.updateInterval:d.dynamicVariableType==="random"&&(m=d.isStatic?1/0:d.updateInterval),c===-1){this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m;continue}if(!((this.shared.getDynamicVariablePlayState(u)==="Stopped"||this.shared.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m,d.dynamicVariableType==="counter"&&this.shared.getVariable(u)!==p&&(this.shared.updateVariable(u,p),this.eventManager.requestRender()),(d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&this.dynamicVars[l].timerSeconds!==p&&(this.dynamicVars[l].timerSeconds=p,this.shared.updateVariable(u,fi.getFormattedTimerTime(p,d)),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[l].deltaToExpectedTime===void 0&&(this.dynamicVars[l].deltaToExpectedTime=Math.max(this.dynamicVars[l].expectedTime-e,0)),this.dynamicVars[l].last=e-(m-this.dynamicVars[l].deltaToExpectedTime),this.dynamicVars[l].expectedTime=e+this.dynamicVars[l].deltaToExpectedTime;continue}else this.dynamicVars[l].deltaToExpectedTime=void 0;if(e>=c)if(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime+=m,d.dynamicVariableType==="random"){let g=d.min+Math.random()*(d.max-d.min),y=d.decimals;g=Math.round(g*Math.pow(10,y))/Math.pow(10,y),this.shared.updateVariable(u,g),n.push(u),this.eventManager.requestRender()}else if(d.dynamicVariableType==="counter"){if(d.increment===0)continue;let g=this.shared.getVariable(u),y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=this.shared.getVariable(u)+d.increment*(y?1:-1);d.hasEnd&&(v=d.increment>0?Se.clamp(v,p,d.endValue):Se.clamp(v,d.endValue,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),d.repeat?v===d.endValue&&(v=p):(v===p||v===d.endValue)&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==g&&(n.push(u),this.shared.updateVariable(u,v),this.eventManager.requestRender())}else if(d.dynamicVariableType==="time")this.shared.updateVariable(u,IA(r,d)),n.push(u),this.eventManager.requestRender();else{let g=En.isTextValue(d.endValue)?e3(d.endValue.textValue):d.endValue,y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=f+(e-h)/1e3*(d.dynamicVariableType==="timer"?-1:1)*(y?1:-1);v=Math.max(v,0),d.hasEnd&&(v=d.dynamicVariableType==="stopwatch"?Se.clamp(v,p,g):Se.clamp(v,g,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),d.repeat?Math.abs(v-g)<(d.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(d.format==="number3decimal"?1e-4:.1)||Math.abs(v-g)<(d.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==f&&(n.push(u),this.dynamicVars[l].timerSeconds=v,this.shared.updateVariable(u,fi.getFormattedTimerTime(v,d)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(l=>{l.data.variableId==="mouseProperty"&&(l.dispatch(),this.eventManager.requestRender())}));let o=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,o=!0);let a=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,a=!0),this.events.forEach(l=>{(n.includes(l.data.variableId)||s.find(u=>u.objId===l.data.objectId&&u.property===l.data.property)||l.data.variableId==="mouseProperty"&&o||l.data.variableId==="raycastProperty"&&a)&&(l.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()};e.page.traverseEntity(a=>{a.data?.events.filter(l=>l.data.type==="VariableChange"&&!l.data.disabled).forEach(l=>{this.events.push(new i_(a.uuid,l.data,a,e.page,e.sharedAssets,n))})}),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:l})=>{if(!("dynamicVariableType"in l)){this.events.find(c=>c.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let u;if(l.dynamicVariableType==="timer"||l.dynamicVariableType==="stopwatch"){let c;if(En.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let h=l.value.textValue;h.length===3?c=h[2]+h[1]*60+h[0]*3600:c=h[1]+h[0]*60}else c=l.value;u=c,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,timerSeconds:c,startValue:u})}else l.dynamicVariableType==="time"&&this.shared.updateVariable(a,IA(new Date,l)),l.dynamicVariableType==="counter"&&(u=En.isTextValue(l.value)?e3(l.value.textValue):l.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,startValue:u})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].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())}},i_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=nr(e,e.actions,n,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch())}dispose(){qt(this.actions)}};function e3(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var r3=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.518/build/",AQ=!1?r3:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.518/build/",_Q=`
6427
6427
  (async function() {
6428
6428
  const [wasmImport, wasmBinary] = await Promise.all([
6429
6429
  import('${r3}' + 'navmesh.js'),
@@ -6489,4 +6489,4 @@ onmessage = function(messageEvent) {
6489
6489
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6490
6490
  </svg>
6491
6491
  `),M.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),M.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,m];return}let E={zone:m,mode:"static",position:w,size:g};v==="hide"&&(E.restOpacity=0);let b=qR.create(E);b.on("move",(M,T)=>{let C=this.gameControl;f==="pos"?T.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-T.angle.radian),C.movementState.movePosX=Math.cos(-T.angle.radian),T.force>1.2?C.movementState.run=1:C.movementState.run=0,T.force<.3?C.moveForce=(T.force-.2)/.1:C.moveForce=1):f==="rot"&&(T.force<.2?C.rotForce=0:(C.movementState.rotPosX=T.vector.y,C.movementState.rotPosY=-T.vector.x,T.force<.3?C.rotForce=(T.force-.2)/.1:C.rotForce=1)),this.requestRender()}),b.on("end",(M,T)=>{let C=this.gameControl;f==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):f==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[b,m]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(f=>f.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new At.World(new At.Vector3(0,this.gravity,0)),this.events=new At.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof Dn)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;l=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof mr)l=a.object;else if(l=a,l.dataPatched.cloner?.disabled===!1&&l.dataPatched.cloner?.hideBase&&l.dataPatched.physics?.fusedBody!==!0)return!0;let u=l.dataPatched,c;for(let y of u.events)y.data.disabled!==!0&&y.data.type==="GameControl"&&(c=y.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldSVD();let h=Om(u),d=!1,f=l.userData.hasDestroy,p=l.userData.hasDrag,m=!1;for(let y of u.events)if(y.data.disabled!==!0){if(y.data.type==="Collision"){d=!0;let v=new dx(y.id,y.data,l,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(x=>x.id!==y.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[v]}else if(y.data.type==="Follow"){m=!0;let v=y.data.target;a.traverseVisible(x=>{x.userData.isFollowingObj=v})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(c!==void 0){let y=At.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose($r,zs,Cl),a.position0=$r.clone().divideScalar(this.pixelsPerMeter),a.rotation0=zs.clone(),$r.divideScalar(this.pixelsPerMeter),y.setTranslation($r.x,$r.y,$r.z).setRotation(zs);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=v;let x;c.collider.type==="sphere"?x=At.ColliderDesc.ball(c.collider.radius/this.pixelsPerMeter):c.collider.type==="capsule"?x=At.ColliderDesc.capsule((c.collider.height/2-c.collider.radius)/this.pixelsPerMeter,c.collider.radius/this.pixelsPerMeter):x=At.ColliderDesc.cuboid(c.collider.width/this.pixelsPerMeter/2,c.collider.height/this.pixelsPerMeter/2,c.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(At.CoefficientCombineRule.Average).setRestitutionCombineRule(At.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(u.physics.restitution);let w=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(w.handle,l),$r.fromArray(c.collider.position).multiply(Cl.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),w.setTranslationWrtParent($r);let S=new He().setFromEuler(new Zt().setFromVector3(new _().fromArray(c.collider.rotation)));w.setRotationWrtParent(S),w.setActiveEvents(At.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else u.physics.rigidBody==="dynamic"||h||m||f||p||d?(this.addRigidBody(a,l,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(l,u.physics.fusedBody)):(g&&t.push(Vs(g,a.matrixWorld)),u.physics.fusedBody&&a.traverseObject((y,v)=>{if(v===0)return;let x;if(y instanceof Dn)if(y.objectForSample){if(y.objectForSample.dataPatched.physics.fusedBody)return;x=y.object}else return y.object.dataPatched.physics.fusedBody===!0&&y.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(y instanceof mr)x=y.object;else if(x=y,x.dataPatched.cloner?.hideBase)return!0;let w=x.dataPatched;if(w.physics.enabled==="visibility"?!w.visible:!w.physics.enabled)return!0;let S=y.geometry;S?.getAttribute("position")!==void 0&&t.push(Vs(S,y.matrixWorld))}),this.generateSensorColliderDescs(l,u.physics.fusedBody,e));if(u.physics?.fusedBody===!0||c)return!0}),t.length===0)return;let r=ws(t);r.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let n=At.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n),o=At.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array).setFrictionCombineRule(At.CoefficientCombineRule.Multiply).setRestitutionCombineRule(At.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);for(let[a,l]of e){let u=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[u.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let r=new Rm(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),n=new ie().compose(Us.fromArray(e.data.position),mf.setFromEuler(l3.fromArray(e.data.rotation)),d_);if(e.data.triggerZone==="box"){let s=new Pt;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,n,t,r])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,n,t,r])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(!!this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.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(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t,e,r){if(!this.isEnabled)return!0;let n=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(n=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,n=!1):this.initializationCounter===2&&this.gameControl&&(n=!this.gameControl.update(t,e,r)&&n),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(t===0)n=this.stepPhysics()&&n;else{let o=t/1e3;o<s&&o>s*.55&&(o=s),this.accumulator+=o;let a=performance.now(),l=0,u=6;for(;this.accumulator>=s&&l<u&&(n=this.stepPhysics()&&n,this.accumulator-=s,l++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}return n}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose($r,zs,Cl),u_.setFromQuaternion(zs);let r=e;r.prevR===void 0?(r.prevR=u_.clone(),r.prevT=$r.clone()):(r.prevR.copy(u_),r.prevT.copy($r)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation($r.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(zs))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,r){let n=(this.sharedGameControlGlobals.rapierWorld?.getCollider(r))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===n){s=o;break}}t.dispatch(s),e.dispatchEvent(J0)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,r){let n=c3.copy(t.matrixWorld).invert();t.traverseEntity((s,o)=>{if(e===!1&&o===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let l=new Rm(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),u;if(a.data.triggerZone==="box"?u=At.ColliderDesc.cuboid(...a.data.size.map(c=>c/(2*this.pixelsPerMeter))):u=At.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),u.setDensity(0).setSensor(!0).setActiveEvents(At.ActiveEvents.COLLISION_EVENTS),Us.fromArray(a.data.position),mf.setFromEuler(l3.fromArray(a.data.rotation)),yx.compose(Us,mf,d_).premultiply(s.matrixWorld),r?(yx.decompose(Us,mf,h_),u.setActiveCollisionTypes(At.ActiveCollisionTypes.KINEMATIC_FIXED|At.ActiveCollisionTypes.DYNAMIC_FIXED)):(yx.premultiply(n).decompose(Us,mf,h_),t.rigidBody.bodyType()===At.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===At.RigidBodyType.Fixed?u.setActiveCollisionTypes(At.ActiveCollisionTypes.KINEMATIC_FIXED|At.ActiveCollisionTypes.DYNAMIC_FIXED):u.setActiveCollisionTypes(At.ActiveCollisionTypes.KINEMATIC_KINEMATIC|At.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Us.divideScalar(this.pixelsPerMeter),u.setTranslation(Us.x,Us.y,Us.z),u.setRotation(mf),r)r.push([u,l]);else{let c=this.sharedGameControlGlobals.rapierWorld.createCollider(u,t.rigidBody);this.sensorToTriggerEvent[c.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[r,n,s,o]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let l=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===l||o.isValidTriggeringObject(lt.is(l)?l:l.object)===!1)continue;let u=c3.copy(s.matrixWorld).decompose(Us,u3,h_).compose(Us,u3,d_).multiply(n),c=yx.copy(l.matrixWorld).invert().multiply(u);r instanceof Pt?t=l.bvhGeometry.boundsTree.intersectsBox(r,c):(f_.radius=r,f_.center.setFromMatrixPosition(c),t=l.bvhGeometry.boundsTree.intersectsSphere(f_)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(kQ)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(h=>h!==l)}}}};function d3(i){let t=this._clip.duration,e=this._clip.start??0,r=this.loop,n=this.time+i,s=this._loopCount,o=r===Xf;if(i===0)return s===-1?n:o&&(s&1)===1?t-(n-e):n;if(r===Qb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:i<0?-1:1})}}else{if(s===-1&&(i>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<e){let a=Math.floor((n-e)/(t-e));n-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(n=i>0?t:e,this.repetitions===1&&(n=t)),this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:i>0?1:-1});else{if(l===1){let u=i<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return t-(n-e)}return n}var f3=!1,xx=class{constructor(t,e,r,n){this.scene=t;this.requestRender=e;this.updateDisplayProgress=r;this.animationInspectorState=n;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,r)=>{let n=e[0]+"/";if(Array.isArray(t.identity)?n+=t.identity[0]:n+=t.uuid,this.clipIdToAction[n])return;let s=Su.parse(JSON.parse(e[2]));t.animations[r]=s;let o=this.mixer.clipAction(s,t);f3===!1&&(Object.getPrototypeOf(o)._updateTime=d3,f3=!0),o.clampWhenFinished=!0,this.clipIdToAction[n]=o})};this.mixer=new Dg(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let r=this.scene.find(e);if(!r)return;let n=r.animations.find(o=>o.uuid===t);if(!n)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(n),delete this.clipIdToAction[t],r.animations=r.animations.filter(o=>o.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=Kb}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,r=this.clipIdToAction[e];if(!!r)return t&&(t.repeat>=0&&(r.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(r.loop=Xf)),r.play(),r.paused=!1,this.requestRender(),r}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/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(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let r=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?t/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),r&&(this.clipIdToAction[e].paused=!0)}};var p_=new WeakMap,bx=class extends Au{constructor(t){super(t),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(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,r,n){let s=new _u(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,o=>{this.decodeDracoFile(o,e).catch(n)},r,n)}decodeDracoFile(t,e,r,n){let s={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){let r=JSON.stringify(e);if(p_.has(t)){let l=p_.get(t);if(l.key===r)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(n=l,new Promise((u,c)=>{n._callbacks[s]={resolve:u,reject:c},n.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{n&&s&&this._releaseTask(n,s)}),p_.set(t,{key:r,promise:a}),a}_createGeometry(t){let e=new Ae;t.index&&e.setIndex(new Ge(t.index.array,1));for(let r=0;r<t.attributes.length;r++){let n=t.attributes[r],s=n.name,o=n.array,a=n.itemSize;e.setAttribute(s,new Ge(o,a))}return e}_loadLibrary(t,e){let r=new _u(this.manager);return r.setPath(this.decoderPath),r.setResponseType(e),r.setWithCredentials(this.withCredentials),new Promise((n,s)=>{r.load(t,n,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(r=>{let n=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let s=VQ.toString(),o=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
6492
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){let o=s.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function VQ(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(c){i.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let h=c.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(h,d,f,u),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let g in c){let y=self[h[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[c[g]]),x===-1)continue;v=a.GetAttribute(d,x)}m.attributes.push(n(o,a,d,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=r(o,a,d)),o.destroy(d),m}function r(o,a,l){let c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:f,itemSize:1}}function n(o,a,l,u,c,h){let d=h.num_components(),p=l.num_points()*d,m=p*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,g,m,y);let v=new c(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:u,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Pl;function zQ(){return Pl||(Pl=new bx,Pl.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Pl.decoderPending}async function UQ(i){if(Pl){let t={attributeIDs:Pl.defaultAttributeIDs,attributeTypes:Pl.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Pl.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function p3(i,t){let[e,r]=Pw(Ny.deserialize(new Uint8Array(i)));tv(e);let n=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&n.push(o)}),n.length&&await zQ();for(let s of n){let o=await UQ(xr(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var m_=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.dataEvent=r;this.object=n;this.stage=!1;this.actions=nr(r,e.actions,s,o,a,n)}disconnect(){qt(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),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())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},wx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(n=>{let s=Vy.deviceToSize(n.data.size),o=n.dataEvent.orientation==="horizontal"?e:r,a;switch(n.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}n.stage!==a&&(n.stage=a,n.stage?n.dispatchIn():n.dispatchOut())})};this.onResizeObserver=new ResizeObserver(e=>{for(let r of e){let{width:n,height:s}=r.contentRect;this.resize(n,s)}})}connect(){let{page:e,sharedAssets:r,domElement:n}=this.eventContext;this.onResizeObserver.observe(n),e.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length))for(let{data:o}of s.data.events)o.disabled||o.type==="Resize"&&o.breakpoints.forEach(({data:a,id:l})=>{try{let u=new m_(l,a,o,s,e,r,this.eventManager);this.breakpoints.push(u)}catch(u){!1&&console.log(u)}})})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var Sx=class{constructor(t,e,r,n,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=n;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onTouchMovePreventScroll=t=>{(t.touches.length>1||this.preventTouchScroll)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:n}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:n-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=n.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 tx(this.eventContext),DynamicVariable:new fx(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new ix(this.eventContext,this),["Start"]:new hx(this.eventContext,this),Basic:new rx(this.eventContext,this,this.needsRaycast),["MouseHover"]:new cx(this.eventContext,this),["Scroll"]:new ux(this.eventContext,this),["Follow"]:new ox(this.eventContext,this),["DragDrop"]:new sx(this.eventContext,this),["LookAt"]:new lx(this.eventContext),["Resize"]:new wx(this.eventContext,this)};let{page:t,domElement:e,eventElement:r}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(n=>n.connect()),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.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:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.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(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let n of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in n&&Array.isArray(n.id)&&(n.id[0]==="mouse"&&(this.needsMouse=!0),n.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length){for(let n of r.data.events)if(!n.data.disabled)if(n.data.type==="VariableChange"&&(n.data.variableId==="mouseProperty"&&(this.needsMouse=!0),n.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),n.data.type==="Conditional")for(let s of["inActions","outActions"])n.data[s].forEach(e);else if(n.data.type==="DragDrop")for(let s of["drag","drop"])n.data.dragDropActions[s].forEach(e);else if(n.data.type==="GameControl")for(let s of["idle","move","jump","run"])n.data.gameActions[s].forEach(e);else if(n.data.type==="Resize")for(let s of n.data.breakpoints)s.data.actions.forEach(e);else n.data.type==="LookAt"||n.data.actions.forEach(e)}})}};var Ax=class{constructor(t,e,r,n,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new N().copy(r),this._editorSize=new N().copy(n),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,n=this._fov;if(t&&e>r){let s=GQ(e,1080,2160,1,15)/100;n*=e/r,n*=1-s}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function GQ(i,t,e,r,n){return(i-t)/(e-t)*(n-r)+r}var _x=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Mc(t.shared,e),this.scene=new xl(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof Si&&t.personalCamera.updateState(t.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(t=>{t instanceof Qt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Ex=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(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=`${t}px`,this.element.style.top=`${e}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 HQ(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Lm(i){return i instanceof Ds?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function jQ(i,t){let e={};return i.traverseEntity(r=>{if(!r.visible||!(r instanceof $t)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let n=r.parent;for(;n;){if(n instanceof $t&&r.states&&Object.keys(r.states).length)return;n=n.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!Br.isMergable(o))return}else{let u=t.scene.objects.get(r.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!Br.isMergable(u.material))return;s=Br.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Lm(r)];if(l){if(l.push(r),r.cloner)for(let u of r.cloner.children)l.push(u)}else if(e[s][Lm(r)]=[r],r.cloner)for(let u of r.cloner.children)e[s][Lm(r)].push(u)}),e}function WQ(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(r=>{let n=r.length;n>t&&(t=n)})}),t}function m3(i,t){let e=jQ(t,i),r=WQ(e),n=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),u=0,c=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,u=0,p.forEach(g=>{g instanceof $t&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&HQ(o[g]);let m=ws(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new _r(m,l[0].material);break}default:{g=new _r(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof $t&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Lm(x)]&&e[x.material.uuid][Lm(x)].length>1||(c[h++]=x));for(let x=0;x<h;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),n[s++]=x}}}for(let d=0;d<s;d++)n[d].removeFromParent()}var v3=pn(y3(),1);var YQ=new N;function XQ(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var g_=class{constructor(t,{renderOnDemand:e,renderMode:r="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=t=>{if(this.time=t,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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,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=YQ.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 t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}};this._debouncedResize=rc(this._resize,10);this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Ex({x:10,y:10})),nP(t)}async load(t,e,r){XQ(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let n=await p3(t);this._data=n,n.version&&(0,v3.default)(n.version,"0.9.517")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([KA(n)&&JD(),VI(n)&&WD(),el.physicsEnabled(n.scene.objects)&&uP(),GA(n)&&RI(),o_(n)&&aP()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new _x(n);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let l=performance.now();m3(n,s.scene);let u=performance.now();console.log("Merged geometries in ",u-l," ms")}KA(n)&&this._scene.traverse(l=>{Xn(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Dn&&l.pendingMediaLoad&&l.update()})});let o=Object.keys(n.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);Promise.all(o).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),GA(n)&&h3(n)&&await Promise.all(o),this._scene.rewriteEventsBeforeGoToPlayMode(),nf(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new A0({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),this._scene.initializeSplatViewer(this._renderer),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let a=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(a.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=a.size[0],this._viewportHeight=a.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 Ax(this._renderer,this._camera,new N(this._viewportWidth,this._viewportHeight),new N(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(a.allowResponsive??!1)&&a.preset==="fullscreen"),e){let l=new ex(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,a);this._scene.updateMatrixWorld(!0),this._controls=new vx(l),this._animationControls=new xx(this._scene,this._requestRenderAutoMode),this._eventManager=new Sx(n.scene.publish,this._controls,this._animationControls,l,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),r!==void 0&&this.setVariables(r),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(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,n]of e)this.setVariable(r,n)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let n=e;typeof r.data.value=="number"?n=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?n=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(n=e.toString());let s=typeof n=="string"?{textValue:n}:n;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&En.isTextValue(t)?En.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==Qi&&!this._scene.isInvisibleObjects(e)&&!(e instanceof Si)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof pf&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:r,b:n,a:s}={r:0,g:0,b:0,a:1},o=new gr(e,r,n,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{pw.unsubscribe(t)}),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(),iP(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(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof Si&&(e=s.name)});let r={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof Si||t instanceof xl?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},n=pw(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};
6492
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){let o=s.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function VQ(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(c){i.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let h=c.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(h,d,f,u),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let g in c){let y=self[h[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[c[g]]),x===-1)continue;v=a.GetAttribute(d,x)}m.attributes.push(n(o,a,d,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=r(o,a,d)),o.destroy(d),m}function r(o,a,l){let c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:f,itemSize:1}}function n(o,a,l,u,c,h){let d=h.num_components(),p=l.num_points()*d,m=p*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,g,m,y);let v=new c(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:u,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Pl;function zQ(){return Pl||(Pl=new bx,Pl.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Pl.decoderPending}async function UQ(i){if(Pl){let t={attributeIDs:Pl.defaultAttributeIDs,attributeTypes:Pl.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Pl.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function p3(i,t){let[e,r]=Pw(Ny.deserialize(new Uint8Array(i)));tv(e);let n=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&n.push(o)}),n.length&&await zQ();for(let s of n){let o=await UQ(xr(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var m_=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.dataEvent=r;this.object=n;this.stage=!1;this.actions=nr(r,e.actions,s,o,a,n)}disconnect(){qt(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),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())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},wx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(n=>{let s=Vy.deviceToSize(n.data.size),o=n.dataEvent.orientation==="horizontal"?e:r,a;switch(n.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}n.stage!==a&&(n.stage=a,n.stage?n.dispatchIn():n.dispatchOut())})};this.onResizeObserver=new ResizeObserver(e=>{for(let r of e){let{width:n,height:s}=r.contentRect;this.resize(n,s)}})}connect(){let{page:e,sharedAssets:r,domElement:n}=this.eventContext;this.onResizeObserver.observe(n),e.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length))for(let{data:o}of s.data.events)o.disabled||o.type==="Resize"&&o.breakpoints.forEach(({data:a,id:l})=>{try{let u=new m_(l,a,o,s,e,r,this.eventManager);this.breakpoints.push(u)}catch(u){!1&&console.log(u)}})})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var Sx=class{constructor(t,e,r,n,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=n;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onTouchMovePreventScroll=t=>{(t.touches.length>1||this.preventTouchScroll)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:n}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:n-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=n.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 tx(this.eventContext),DynamicVariable:new fx(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new ix(this.eventContext,this),["Start"]:new hx(this.eventContext,this),Basic:new rx(this.eventContext,this,this.needsRaycast),["MouseHover"]:new cx(this.eventContext,this),["Scroll"]:new ux(this.eventContext,this),["Follow"]:new ox(this.eventContext,this),["DragDrop"]:new sx(this.eventContext,this),["LookAt"]:new lx(this.eventContext),["Resize"]:new wx(this.eventContext,this)};let{page:t,domElement:e,eventElement:r}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(n=>n.connect()),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.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:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.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(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let n of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in n&&Array.isArray(n.id)&&(n.id[0]==="mouse"&&(this.needsMouse=!0),n.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length){for(let n of r.data.events)if(!n.data.disabled)if(n.data.type==="VariableChange"&&(n.data.variableId==="mouseProperty"&&(this.needsMouse=!0),n.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),n.data.type==="Conditional")for(let s of["inActions","outActions"])n.data[s].forEach(e);else if(n.data.type==="DragDrop")for(let s of["drag","drop"])n.data.dragDropActions[s].forEach(e);else if(n.data.type==="GameControl")for(let s of["idle","move","jump","run"])n.data.gameActions[s].forEach(e);else if(n.data.type==="Resize")for(let s of n.data.breakpoints)s.data.actions.forEach(e);else n.data.type==="LookAt"||n.data.actions.forEach(e)}})}};var Ax=class{constructor(t,e,r,n,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new N().copy(r),this._editorSize=new N().copy(n),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,n=this._fov;if(t&&e>r){let s=GQ(e,1080,2160,1,15)/100;n*=e/r,n*=1-s}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function GQ(i,t,e,r,n){return(i-t)/(e-t)*(n-r)+r}var _x=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Mc(t.shared,e),this.scene=new xl(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof Si&&t.personalCamera.updateState(t.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(t=>{t instanceof Qt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Ex=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(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=`${t}px`,this.element.style.top=`${e}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 HQ(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Lm(i){return i instanceof Ds?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function jQ(i,t){let e={};return i.traverseEntity(r=>{if(!r.visible||!(r instanceof $t)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let n=r.parent;for(;n;){if(n instanceof $t&&r.states&&Object.keys(r.states).length)return;n=n.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!Br.isMergable(o))return}else{let u=t.scene.objects.get(r.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!Br.isMergable(u.material))return;s=Br.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Lm(r)];if(l){if(l.push(r),r.cloner)for(let u of r.cloner.children)l.push(u)}else if(e[s][Lm(r)]=[r],r.cloner)for(let u of r.cloner.children)e[s][Lm(r)].push(u)}),e}function WQ(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(r=>{let n=r.length;n>t&&(t=n)})}),t}function m3(i,t){let e=jQ(t,i),r=WQ(e),n=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),u=0,c=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,u=0,p.forEach(g=>{g instanceof $t&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&HQ(o[g]);let m=ws(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new _r(m,l[0].material);break}default:{g=new _r(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof $t&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Lm(x)]&&e[x.material.uuid][Lm(x)].length>1||(c[h++]=x));for(let x=0;x<h;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),n[s++]=x}}}for(let d=0;d<s;d++)n[d].removeFromParent()}var v3=pn(y3(),1);var YQ=new N;function XQ(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var g_=class{constructor(t,{renderOnDemand:e,renderMode:r="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=t=>{if(this.time=t,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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,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=YQ.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 t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}};this._debouncedResize=rc(this._resize,10);this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Ex({x:10,y:10})),nP(t)}async load(t,e,r){XQ(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let n=await p3(t);this._data=n,n.version&&(0,v3.default)(n.version,"0.9.518")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([KA(n)&&JD(),VI(n)&&WD(),el.physicsEnabled(n.scene.objects)&&uP(),GA(n)&&RI(),o_(n)&&aP()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new _x(n);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let l=performance.now();m3(n,s.scene);let u=performance.now();console.log("Merged geometries in ",u-l," ms")}KA(n)&&this._scene.traverse(l=>{Xn(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Dn&&l.pendingMediaLoad&&l.update()})});let o=Object.keys(n.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);Promise.all(o).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),GA(n)&&h3(n)&&await Promise.all(o),this._scene.rewriteEventsBeforeGoToPlayMode(),nf(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new A0({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),this._scene.initializeSplatViewer(this._renderer),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let a=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(a.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=a.size[0],this._viewportHeight=a.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 Ax(this._renderer,this._camera,new N(this._viewportWidth,this._viewportHeight),new N(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(a.allowResponsive??!1)&&a.preset==="fullscreen"),e){let l=new ex(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,a);this._scene.updateMatrixWorld(!0),this._controls=new vx(l),this._animationControls=new xx(this._scene,this._requestRenderAutoMode),this._eventManager=new Sx(n.scene.publish,this._controls,this._animationControls,l,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),r!==void 0&&this.setVariables(r),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(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,n]of e)this.setVariable(r,n)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let n=e;typeof r.data.value=="number"?n=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?n=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(n=e.toString());let s=typeof n=="string"?{textValue:n}:n;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&En.isTextValue(t)?En.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==Qi&&!this._scene.isInvisibleObjects(e)&&!(e instanceof Si)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof pf&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:r,b:n,a:s}={r:0,g:0,b:0,a:1},o=new gr(e,r,n,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{pw.unsubscribe(t)}),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(),iP(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(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof Si&&(e=s.name)});let r={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof Si||t instanceof xl?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},n=pw(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};