@splinetool/runtime 0.9.494 → 0.9.495

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
@@ -3135,10 +3135,10 @@ void main() {
3135
3135
  squared_mean = squared_mean / samples;
3136
3136
  float std_dev = sqrt( squared_mean - mean * mean );
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
- }`;function QV(i,t,e){let n=new of,r=new B,s=new B,o=new Xe,a=new af({depthPacking:bb}),l=new Kx,u={},c=e.maxTextureSize,d={[mi]:Un,[Un]:mi,[Ur]:Ur},h=new ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:XV,fragmentShader:KV}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ee;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new kn(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=sg,this.render=function(b,w,E){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=i.getRenderTarget(),S=i.getActiveCubeFace(),T=i.getActiveMipmapLevel(),M=i.state;M.setBlending(Bt),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let C=0,D=b.length;C<D;C++){let P=b[C],I=P.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;r.copy(I.mapSize);let L=I.getFrameExtents();if(r.multiply(L),s.copy(I.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/L.x),r.x=s.x*L.x,I.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/L.y),r.y=s.y*L.y,I.mapSize.y=s.y)),I.map===null){let k=this.type!==Kh?{minFilter:Nt,magFilter:Nt}:{};I.map=new ut(r.x,r.y,k),I.map.texture.name=P.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let H=I.getViewportCount();for(let k=0;k<H;k++){let G=I.getViewport(k);o.set(s.x*G.x,s.y*G.y,s.x*G.z,s.y*G.w),M.viewport(o),I.updateMatrices(P,k),n=I.getFrustum(),x(w,E,I.camera,P,this.type)}I.isPointLightShadow!==!0&&this.type===Kh&&y(I,E),I.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(_,S,T)};function y(b,w){let E=t.update(m);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new ut(r.x,r.y)),h.uniforms.shadow_pass.value=b.map.texture,h.uniforms.resolution.value=b.mapSize,h.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(w,null,E,h,m,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(w,null,E,f,m,null)}function v(b,w,E,_,S,T){let M=null,C=E.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)M=C;else if(M=E.isPointLight===!0?l:a,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let D=M.uuid,P=w.uuid,I=u[D];I===void 0&&(I={},u[D]=I);let L=I[P];L===void 0&&(L=M.clone(),I[P]=L),M=L}return M.visible=w.visible,M.wireframe=w.wireframe,T===Kh?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:d[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,E.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(E.matrixWorld),M.nearDistance=_,M.farDistance=S),M}function x(b,w,E,_,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===Kh)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,b.matrixWorld);let C=t.update(b),D=b.material;if(Array.isArray(D)){let P=C.groups;for(let I=0,L=P.length;I<L;I++){let H=P[I],k=D[H.materialIndex];if(k&&k.visible){let G=v(b,k,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,G,b,H)}}}else if(D.visible){let P=v(b,D,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,P,b,null)}}let M=b.children;for(let C=0,D=M.length;C<D;C++)x(M[C],w,E,_,S)}}function ZV(i,t,e){let n=e.isWebGL2;function r(){let Y=!1,ce=new Xe,ve=null,ke=new Xe(0,0,0,0);return{setMask:function(Be){ve!==Be&&!Y&&(i.colorMask(Be,Be,Be,Be),ve=Be)},setLocked:function(Be){Y=Be},setClear:function(Be,wt,Nn,Sn,ol){ol===!0&&(Be*=Sn,wt*=Sn,Nn*=Sn),ce.set(Be,wt,Nn,Sn),ke.equals(ce)===!1&&(i.clearColor(Be,wt,Nn,Sn),ke.copy(ce))},reset:function(){Y=!1,ve=null,ke.set(-1,0,0,0)}}}function s(){let Y=!1,ce=null,ve=null,ke=null;return{setTest:function(Be){Be?Z(2929):Q(2929)},setMask:function(Be){ce!==Be&&!Y&&(i.depthMask(Be),ce=Be)},setFunc:function(Be){if(ve!==Be){switch(Be){case ML:i.depthFunc(512);break;case CL:i.depthFunc(519);break;case PL:i.depthFunc(513);break;case Lx:i.depthFunc(515);break;case DL:i.depthFunc(514);break;case IL:i.depthFunc(518);break;case OL:i.depthFunc(516);break;case RL:i.depthFunc(517);break;default:i.depthFunc(515)}ve=Be}},setLocked:function(Be){Y=Be},setClear:function(Be){ke!==Be&&(i.clearDepth(Be),ke=Be)},reset:function(){Y=!1,ce=null,ve=null,ke=null}}}function o(){let Y=!1,ce=null,ve=null,ke=null,Be=null,wt=null,Nn=null,Sn=null,ol=null;return{setTest:function(on){Y||(on?Z(2960):Q(2960))},setMask:function(on){ce!==on&&!Y&&(i.stencilMask(on),ce=on)},setFunc:function(on,uo,_i){(ve!==on||ke!==uo||Be!==_i)&&(i.stencilFunc(on,uo,_i),ve=on,ke=uo,Be=_i)},setOp:function(on,uo,_i){(wt!==on||Nn!==uo||Sn!==_i)&&(i.stencilOp(on,uo,_i),wt=on,Nn=uo,Sn=_i)},setLocked:function(on){Y=on},setClear:function(on){ol!==on&&(i.clearStencil(on),ol=on)},reset:function(){Y=!1,ce=null,ve=null,ke=null,Be=null,wt=null,Nn=null,Sn=null,ol=null}}}let a=new r,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=null,I=null,L=i.getParameter(35661),H=!1,k=0,G=i.getParameter(7938);G.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(G)[1]),H=k>=1):G.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=k>=2);let z=null,U={},$=i.getParameter(3088),F=i.getParameter(2978),j=new Xe().fromArray($),X=new Xe().fromArray(F);function q(Y,ce,ve){let ke=new Uint8Array(4),Be=i.createTexture();i.bindTexture(Y,Be),i.texParameteri(Y,10241,9728),i.texParameteri(Y,10240,9728);for(let wt=0;wt<ve;wt++)i.texImage2D(ce+wt,0,6408,1,1,0,6408,5121,ke);return Be}let V={};V[3553]=q(3553,3553,1),V[34067]=q(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),Z(2929),l.setFunc(Lx),Oe(!1),Ie(VA),Z(2884),Ae(Bt);function Z(Y){h[Y]!==!0&&(i.enable(Y),h[Y]=!0)}function Q(Y){h[Y]!==!1&&(i.disable(Y),h[Y]=!1)}function K(Y,ce){return f[Y]!==ce?(i.bindFramebuffer(Y,ce),f[Y]=ce,n&&(Y===36009&&(f[36160]=ce),Y===36160&&(f[36009]=ce)),!0):!1}function W(Y,ce){let ve=m,ke=!1;if(Y)if(ve=p.get(ce),ve===void 0&&(ve=[],p.set(ce,ve)),Y.isWebGLMultipleRenderTargets){let Be=Y.texture;if(ve.length!==Be.length||ve[0]!==36064){for(let wt=0,Nn=Be.length;wt<Nn;wt++)ve[wt]=36064+wt;ve.length=Be.length,ke=!0}}else ve[0]!==36064&&(ve[0]=36064,ke=!0);else ve[0]!==1029&&(ve[0]=1029,ke=!0);ke&&(e.isWebGL2?i.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ye(Y){return g!==Y?(i.useProgram(Y),g=Y,!0):!1}let fe={[Cc]:32774,[gL]:32778,[yL]:32779};if(n)fe[GA]=32775,fe[HA]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(fe[GA]=Y.MIN_EXT,fe[HA]=Y.MAX_EXT)}let ie={[vL]:0,[xL]:1,[bL]:768,[m_]:770,[TL]:776,[EL]:774,[wL]:772,[SL]:769,[g_]:771,[_L]:775,[AL]:773};function Ae(Y,ce,ve,ke,Be,wt,Nn,Sn){if(Y===Bt){y===!0&&(Q(3042),y=!1);return}if(y===!1&&(Z(3042),y=!0),Y!==mL){if(Y!==v||Sn!==T){if((x!==Cc||E!==Cc)&&(i.blendEquation(32774),x=Cc,E=Cc),Sn)switch(Y){case Rc:i.blendFuncSeparate(1,771,1,771);break;case kA:i.blendFunc(1,1);break;case UA:i.blendFuncSeparate(0,769,0,1);break;case zA:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Rc:i.blendFuncSeparate(770,771,1,771);break;case kA:i.blendFunc(770,1);break;case UA:i.blendFuncSeparate(0,769,0,1);break;case zA:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,_=null,S=null,v=Y,T=Sn}return}Be=Be||ce,wt=wt||ve,Nn=Nn||ke,(ce!==x||Be!==E)&&(i.blendEquationSeparate(fe[ce],fe[Be]),x=ce,E=Be),(ve!==b||ke!==w||wt!==_||Nn!==S)&&(i.blendFuncSeparate(ie[ve],ie[ke],ie[wt],ie[Nn]),b=ve,w=ke,_=wt,S=Nn),v=Y,T=!1}function xe(Y,ce){Y.side===Ur?Q(2884):Z(2884);let ve=Y.side===Un;ce&&(ve=!ve),Oe(ve),Y.blending===Rc&&Y.transparent===!1?Ae(Bt):Ae(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),a.setMask(Y.colorWrite);let ke=Y.stencilWrite;u.setTest(ke),ke&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),Te(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?Z(32926):Q(32926)}function Oe(Y){M!==Y&&(Y?i.frontFace(2304):i.frontFace(2305),M=Y)}function Ie(Y){Y!==hL?(Z(2884),Y!==C&&(Y===VA?i.cullFace(1029):Y===fL?i.cullFace(1028):i.cullFace(1032))):Q(2884),C=Y}function Pe(Y){Y!==D&&(H&&i.lineWidth(Y),D=Y)}function Te(Y,ce,ve){Y?(Z(32823),(P!==ce||I!==ve)&&(i.polygonOffset(ce,ve),P=ce,I=ve)):Q(32823)}function Ue(Y){Y?Z(3089):Q(3089)}function ze(Y){Y===void 0&&(Y=33984+L-1),z!==Y&&(i.activeTexture(Y),z=Y)}function R(Y,ce,ve){ve===void 0&&(z===null?ve=33984+L-1:ve=z);let ke=U[ve];ke===void 0&&(ke={type:void 0,texture:void 0},U[ve]=ke),(ke.type!==Y||ke.texture!==ce)&&(z!==ve&&(i.activeTexture(ve),z=ve),i.bindTexture(Y,ce||V[Y]),ke.type=Y,ke.texture=ce)}function O(){let Y=U[z];Y!==void 0&&Y.type!==void 0&&(i.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ne(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{i.texSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{i.texSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Me(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function _e(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function le(){try{i.texStorage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ke(){try{i.texStorage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ve(){try{i.texImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{i.texImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(Y){j.equals(Y)===!1&&(i.scissor(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function Je(Y){X.equals(Y)===!1&&(i.viewport(Y.x,Y.y,Y.z,Y.w),X.copy(Y))}function St(Y,ce){let ve=d.get(ce);ve===void 0&&(ve=new WeakMap,d.set(ce,ve));let ke=ve.get(Y);ke===void 0&&(ke=i.getUniformBlockIndex(ce,Y.name),ve.set(Y,ke))}function Zt(Y,ce){let ke=d.get(ce).get(Y);c.get(ce)!==ke&&(i.uniformBlockBinding(ce,ke,Y.__bindingPointIndex),c.set(ce,ke))}function Ln(){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),n===!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),h={},z=null,U={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=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:Z,disable:Q,bindFramebuffer:K,drawBuffers:W,useProgram:ye,setBlending:Ae,setMaterial:xe,setFlipSided:Oe,setCullFace:Ie,setLineWidth:Pe,setPolygonOffset:Te,setScissorTest:Ue,activeTexture:ze,bindTexture:R,unbindTexture:O,compressedTexImage2D:ne,compressedTexImage3D:ue,texImage2D:Ve,texImage3D:Le,updateUBOMapping:St,uniformBlockBinding:Zt,texStorage2D:le,texStorage3D:Ke,texSubImage2D:me,texSubImage3D:De,compressedTexSubImage2D:Me,compressedTexSubImage3D:_e,scissor:je,viewport:Je,reset:Ln}}function JV(i,t,e,n,r,s,o){let a=r.isWebGL2,l=r.maxTextures,u=r.maxCubemapSize,c=r.maxTextureSize,d=r.maxSamples,h=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(R,O){return y?new OffscreenCanvas(R,O):Bm("canvas")}function x(R,O,ne,ue){let me=1;if((R.width>ue||R.height>ue)&&(me=ue/Math.max(R.width,R.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let De=O?Nm:Math.floor,Me=De(me*R.width),_e=De(me*R.height);m===void 0&&(m=v(Me,_e));let le=ne?v(Me,_e):m;return le.width=Me,le.height=_e,le.getContext("2d").drawImage(R,0,0,Me,_e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Me+"x"+_e+")."),le}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Ux(R.width)&&Ux(R.height)}function w(R){return a?!1:R.wrapS!==Jt||R.wrapT!==Jt||R.minFilter!==Nt&&R.minFilter!==Ze}function E(R,O){return R.generateMipmaps&&O&&R.minFilter!==Nt&&R.minFilter!==Ze}function _(R){i.generateMipmap(R)}function S(R,O,ne,ue,me=!1){if(a===!1)return O;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let De=O;return O===6403&&(ne===5126&&(De=33326),ne===5131&&(De=33325),ne===5121&&(De=33321)),O===33319&&(ne===5126&&(De=33328),ne===5131&&(De=33327),ne===5121&&(De=33323)),O===6408&&(ne===5126&&(De=34836),ne===5131&&(De=34842),ne===5121&&(De=ue===$e&&me===!1?35907:32856),ne===32819&&(De=32854),ne===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function T(R,O,ne){return E(R,ne)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Ze?Math.log2(Math.max(O.width,O.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?O.mipmaps.length:1}function M(R){return R===Nt||R===jA||R===Z0?9728:9729}function C(R){let O=R.target;O.removeEventListener("dispose",C),P(O),O.isVideoTexture&&p.delete(O)}function D(R){let O=R.target;O.removeEventListener("dispose",D),L(O)}function P(R){let O=n.get(R);if(O.__webglInit===void 0)return;let ne=R.source,ue=g.get(ne);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(R),Object.keys(ue).length===0&&g.delete(ne)}n.remove(R)}function I(R){let O=n.get(R);i.deleteTexture(O.__webglTexture);let ne=R.source,ue=g.get(ne);delete ue[O.__cacheKey],o.memory.textures--}function L(R){let O=R.texture,ne=n.get(R),ue=n.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(ne.__webglFramebuffer[me]),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(ne.__webglFramebuffer),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&i.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let me=0;me<ne.__webglColorRenderbuffer.length;me++)ne.__webglColorRenderbuffer[me]&&i.deleteRenderbuffer(ne.__webglColorRenderbuffer[me]);ne.__webglDepthRenderbuffer&&i.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let me=0,De=O.length;me<De;me++){let Me=n.get(O[me]);Me.__webglTexture&&(i.deleteTexture(Me.__webglTexture),o.memory.textures--),n.remove(O[me])}n.remove(O),n.remove(R)}let H=0;function k(){H=0}function G(){let R=H;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),H+=1,R}function z(R){let O=[];return O.push(R.wrapS),O.push(R.wrapT),O.push(R.wrapR||0),O.push(R.magFilter),O.push(R.minFilter),O.push(R.anisotropy),O.push(R.internalFormat),O.push(R.format),O.push(R.type),O.push(R.generateMipmaps),O.push(R.premultiplyAlpha),O.push(R.flipY),O.push(R.unpackAlignment),O.push(R.encoding),O.join()}function U(R,O){let ne=n.get(R);if(R.isVideoTexture&&Ue(R),R.isRenderTargetTexture===!1&&R.version>0&&ne.__version!==R.version){let ue=R.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{Q(ne,R,O);return}}e.bindTexture(3553,ne.__webglTexture,33984+O)}function $(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(35866,ne.__webglTexture,33984+O)}function F(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(32879,ne.__webglTexture,33984+O)}function j(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){K(ne,R,O);return}e.bindTexture(34067,ne.__webglTexture,33984+O)}let X={[Zi]:10497,[Jt]:33071,[Fx]:33648},q={[Nt]:9728,[jA]:9984,[Z0]:9986,[Ze]:9729,[zL]:9985,[yl]:9987};function V(R,O,ne){if(ne?(i.texParameteri(R,10242,X[O.wrapS]),i.texParameteri(R,10243,X[O.wrapT]),(R===32879||R===35866)&&i.texParameteri(R,32882,X[O.wrapR]),i.texParameteri(R,10240,q[O.magFilter]),i.texParameteri(R,10241,q[O.minFilter])):(i.texParameteri(R,10242,33071),i.texParameteri(R,10243,33071),(R===32879||R===35866)&&i.texParameteri(R,32882,33071),(O.wrapS!==Jt||O.wrapT!==Jt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,10240,M(O.magFilter)),i.texParameteri(R,10241,M(O.minFilter)),O.minFilter!==Nt&&O.minFilter!==Ze&&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===Nt||O.minFilter!==Z0&&O.minFilter!==yl||O.type===wr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===vl&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(i.texParameterf(R,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,r.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy)}}function Z(R,O){let ne=!1;R.__webglInit===void 0&&(R.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=z(O);if(De!==R.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),me[De].usedTimes++;let Me=me[R.__cacheKey];Me!==void 0&&(me[R.__cacheKey].usedTimes--,Me.usedTimes===0&&I(O)),R.__cacheKey=De,R.__webglTexture=me[De].texture}return ne}function Q(R,O,ne){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=Z(R,O),De=O.source;e.bindTexture(ue,R.__webglTexture,33984+ne);let Me=n.get(De);if(De.version!==Me.__version||me===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let _e=w(O)&&b(O.image)===!1,le=x(O.image,_e,!1,c);le=ze(O,le);let Ke=b(le)||a,Ve=s.convert(O.format,O.encoding),Le=s.convert(O.type),je=S(O.internalFormat,Ve,Le,O.encoding,O.isVideoTexture);V(ue,O,Ke);let Je,St=O.mipmaps,Zt=a&&O.isVideoTexture!==!0,Ln=Me.__version===void 0||me===!0,Y=T(O,le,Ke);if(O.isDepthTexture)je=6402,a?O.type===wr?je=36012:O.type===xo?je=33190:O.type===sa?je=35056:je=33189:O.type===wr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===ml&&je===6402&&O.type!==x_&&O.type!==xo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=xo,Le=s.convert(O.type)),O.format===la&&je===6402&&(je=34041,O.type!==sa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=sa,Le=s.convert(O.type))),Ln&&(Zt?e.texStorage2D(3553,1,je,le.width,le.height):e.texImage2D(3553,0,je,le.width,le.height,0,Ve,Le,null));else if(O.isDataTexture)if(St.length>0&&Ke){Zt&&Ln&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,Ve,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,Ve,Le,Je.data);O.generateMipmaps=!1}else Zt?(Ln&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,le.width,le.height,Ve,Le,le.data)):e.texImage2D(3553,0,je,le.width,le.height,0,Ve,Le,le.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Zt&&Ln&&e.texStorage3D(35866,Y,je,St[0].width,St[0].height,le.depth);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==pi?Ve!==null?Zt?e.compressedTexSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,Ve,Je.data,0,0):e.compressedTexImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,Je.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,Ve,Le,Je.data):e.texImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,Ve,Le,Je.data)}else{Zt&&Ln&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==pi?Ve!==null?Zt?e.compressedTexSubImage2D(3553,ce,0,0,Je.width,Je.height,Ve,Je.data):e.compressedTexImage2D(3553,ce,je,Je.width,Je.height,0,Je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,Ve,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,Ve,Le,Je.data)}else if(O.isDataArrayTexture)Zt?(Ln&&e.texStorage3D(35866,Y,je,le.width,le.height,le.depth),e.texSubImage3D(35866,0,0,0,0,le.width,le.height,le.depth,Ve,Le,le.data)):e.texImage3D(35866,0,je,le.width,le.height,le.depth,0,Ve,Le,le.data);else if(O.isData3DTexture)Zt?(Ln&&e.texStorage3D(32879,Y,je,le.width,le.height,le.depth),e.texSubImage3D(32879,0,0,0,0,le.width,le.height,le.depth,Ve,Le,le.data)):e.texImage3D(32879,0,je,le.width,le.height,le.depth,0,Ve,Le,le.data);else if(O.isFramebufferTexture){if(Ln)if(Zt)e.texStorage2D(3553,Y,je,le.width,le.height);else{let ce=le.width,ve=le.height;for(let ke=0;ke<Y;ke++)e.texImage2D(3553,ke,je,ce,ve,0,Ve,Le,null),ce>>=1,ve>>=1}}else if(St.length>0&&Ke){Zt&&Ln&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,Ve,Le,Je):e.texImage2D(3553,ce,je,Ve,Le,Je);O.generateMipmaps=!1}else Zt?(Ln&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,Ve,Le,le)):e.texImage2D(3553,0,je,Ve,Le,le);E(O,Ke)&&_(ue),Me.__version=De.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function K(R,O,ne){if(O.image.length!==6)return;let ue=Z(R,O),me=O.source;e.bindTexture(34067,R.__webglTexture,33984+ne);let De=n.get(me);if(me.version!==De.__version||ue===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Me=O.isCompressedTexture||O.image[0].isCompressedTexture,_e=O.image[0]&&O.image[0].isDataTexture,le=[];for(let ce=0;ce<6;ce++)!Me&&!_e?le[ce]=x(O.image[ce],!1,!0,u):le[ce]=_e?O.image[ce].image:O.image[ce],le[ce]=ze(O,le[ce]);let Ke=le[0],Ve=b(Ke)||a,Le=s.convert(O.format,O.encoding),je=s.convert(O.type),Je=S(O.internalFormat,Le,je,O.encoding),St=a&&O.isVideoTexture!==!0,Zt=De.__version===void 0||ue===!0,Ln=T(O,Ke,Ve);V(34067,O,Ve);let Y;if(Me){St&&Zt&&e.texStorage2D(34067,Ln,Je,Ke.width,Ke.height);for(let ce=0;ce<6;ce++){Y=le[ce].mipmaps;for(let ve=0;ve<Y.length;ve++){let ke=Y[ve];O.format!==pi?Le!==null?St?e.compressedTexSubImage2D(34069+ce,ve,0,0,ke.width,ke.height,Le,ke.data):e.compressedTexImage2D(34069+ce,ve,Je,ke.width,ke.height,0,ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):St?e.texSubImage2D(34069+ce,ve,0,0,ke.width,ke.height,Le,je,ke.data):e.texImage2D(34069+ce,ve,Je,ke.width,ke.height,0,Le,je,ke.data)}}}else{Y=O.mipmaps,St&&Zt&&(Y.length>0&&Ln++,e.texStorage2D(34067,Ln,Je,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(_e){St?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Le,je,le[ce].data):e.texImage2D(34069+ce,0,Je,le[ce].width,le[ce].height,0,Le,je,le[ce].data);for(let ve=0;ve<Y.length;ve++){let Be=Y[ve].image[ce].image;St?e.texSubImage2D(34069+ce,ve+1,0,0,Be.width,Be.height,Le,je,Be.data):e.texImage2D(34069+ce,ve+1,Je,Be.width,Be.height,0,Le,je,Be.data)}}else{St?e.texSubImage2D(34069+ce,0,0,0,Le,je,le[ce]):e.texImage2D(34069+ce,0,Je,Le,je,le[ce]);for(let ve=0;ve<Y.length;ve++){let ke=Y[ve];St?e.texSubImage2D(34069+ce,ve+1,0,0,Le,je,ke.image[ce]):e.texImage2D(34069+ce,ve+1,Je,Le,je,ke.image[ce])}}}E(O,Ve)&&_(34067),De.__version=me.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function W(R,O,ne,ue,me){let De=s.convert(ne.format,ne.encoding),Me=s.convert(ne.type),_e=S(ne.internalFormat,De,Me,ne.encoding);n.get(O).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,_e,O.width,O.height,O.depth,0,De,Me,null):e.texImage2D(me,0,_e,O.width,O.height,0,De,Me,null)),e.bindFramebuffer(36160,R),Te(O)?h.framebufferTexture2DMultisampleEXT(36160,ue,me,n.get(ne).__webglTexture,0,Pe(O)):(me===3553||me>=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,n.get(ne).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(R,O,ne){if(i.bindRenderbuffer(36161,R),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(ne||Te(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===wr?ue=36012:me.type===xo&&(ue=33190));let De=Pe(O);Te(O)?h.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,R)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);ne&&Te(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):Te(O)?h.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,R)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<ue.length;me++){let De=ue[me],Me=s.convert(De.format,De.encoding),_e=s.convert(De.type),le=S(De.internalFormat,Me,_e,De.encoding),Ke=Pe(O);ne&&Te(O)===!1?i.renderbufferStorageMultisample(36161,Ke,le,O.width,O.height):Te(O)?h.renderbufferStorageMultisampleEXT(36161,Ke,le,O.width,O.height):i.renderbufferStorage(36161,le,O.width,O.height)}}i.bindRenderbuffer(36161,null)}function fe(R,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.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),U(O.depthTexture,0);let ue=n.get(O.depthTexture).__webglTexture,me=Pe(O);if(O.depthTexture.format===ml)Te(O)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,me):i.framebufferTexture2D(36160,36096,3553,ue,0);else if(O.depthTexture.format===la)Te(O)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,me):i.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ie(R){let O=n.get(R),ne=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!O.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");fe(O.__webglFramebuffer,R)}else if(ne){O.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)e.bindFramebuffer(36160,O.__webglFramebuffer[ue]),O.__webglDepthbuffer[ue]=i.createRenderbuffer(),ye(O.__webglDepthbuffer[ue],R,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=i.createRenderbuffer(),ye(O.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function Ae(R,O,ne){let ue=n.get(R);O!==void 0&&W(ue.__webglFramebuffer,R,R.texture,36064,3553),ne!==void 0&&ie(R)}function xe(R){let O=R.texture,ne=n.get(R),ue=n.get(O);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=O.version,o.memory.textures++);let me=R.isWebGLCubeRenderTarget===!0,De=R.isWebGLMultipleRenderTargets===!0,Me=b(R)||a;if(me){ne.__webglFramebuffer=[];for(let _e=0;_e<6;_e++)ne.__webglFramebuffer[_e]=i.createFramebuffer()}else{if(ne.__webglFramebuffer=i.createFramebuffer(),De)if(r.drawBuffers){let _e=R.texture;for(let le=0,Ke=_e.length;le<Ke;le++){let Ve=n.get(_e[le]);Ve.__webglTexture===void 0&&(Ve.__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&&R.samples>0&&Te(R)===!1){let _e=De?O:[O];ne.__webglMultisampledFramebuffer=i.createFramebuffer(),ne.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer);for(let le=0;le<_e.length;le++){let Ke=_e[le];ne.__webglColorRenderbuffer[le]=i.createRenderbuffer(),i.bindRenderbuffer(36161,ne.__webglColorRenderbuffer[le]);let Ve=s.convert(Ke.format,Ke.encoding),Le=s.convert(Ke.type),je=S(Ke.internalFormat,Ve,Le,Ke.encoding,R.isXRRenderTarget===!0),Je=Pe(R);i.renderbufferStorageMultisample(36161,Je,je,R.width,R.height),i.framebufferRenderbuffer(36160,36064+le,36161,ne.__webglColorRenderbuffer[le])}i.bindRenderbuffer(36161,null),R.depthBuffer&&(ne.__webglDepthRenderbuffer=i.createRenderbuffer(),ye(ne.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ue.__webglTexture),V(34067,O,Me);for(let _e=0;_e<6;_e++)W(ne.__webglFramebuffer[_e],R,O,36064,34069+_e);E(O,Me)&&_(34067),e.unbindTexture()}else if(De){let _e=R.texture;for(let le=0,Ke=_e.length;le<Ke;le++){let Ve=_e[le],Le=n.get(Ve);e.bindTexture(3553,Le.__webglTexture),V(3553,Ve,Me),W(ne.__webglFramebuffer,R,Ve,36064+le,3553),E(Ve,Me)&&_(3553)}e.unbindTexture()}else{let _e=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?_e=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(_e,ue.__webglTexture),V(_e,O,Me),W(ne.__webglFramebuffer,R,O,36064,_e),E(O,Me)&&_(_e),e.unbindTexture()}R.depthBuffer&&ie(R)}function Oe(R){let O=b(R)||a,ne=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ue=0,me=ne.length;ue<me;ue++){let De=ne[ue];if(E(De,O)){let Me=R.isWebGLCubeRenderTarget?34067:3553,_e=n.get(De).__webglTexture;e.bindTexture(Me,_e),_(Me),e.unbindTexture()}}}function Ie(R){if(a&&R.samples>0&&Te(R)===!1){let O=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ne=R.width,ue=R.height,me=16384,De=[],Me=R.stencilBuffer?33306:36096,_e=n.get(R),le=R.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke<O.length;Ke++)e.bindFramebuffer(36160,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,null),e.bindFramebuffer(36160,_e.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,null,0);e.bindFramebuffer(36008,_e.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,_e.__webglFramebuffer);for(let Ke=0;Ke<O.length;Ke++){De.push(36064+Ke),R.depthBuffer&&De.push(Me);let Ve=_e.__ignoreDepthValues!==void 0?_e.__ignoreDepthValues:!1;if(Ve===!1&&(R.depthBuffer&&(me|=256),R.stencilBuffer&&(me|=1024)),le&&i.framebufferRenderbuffer(36008,36064,36161,_e.__webglColorRenderbuffer[Ke]),Ve===!0&&(i.invalidateFramebuffer(36008,[Me]),i.invalidateFramebuffer(36009,[Me])),le){let Le=n.get(O[Ke]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Le,0)}i.blitFramebuffer(0,0,ne,ue,0,0,ne,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,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,_e.__webglColorRenderbuffer[Ke]);let Ve=n.get(O[Ke]).__webglTexture;e.bindFramebuffer(36160,_e.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,Ve,0)}e.bindFramebuffer(36009,_e.__webglMultisampledFramebuffer)}}function Pe(R){return Math.min(d,R.samples)}function Te(R){let O=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ue(R){let O=o.render.frame;p.get(R)!==O&&(p.set(R,O),R.update())}function ze(R,O){let ne=R.encoding,ue=R.format,me=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===kx||ne!==gi&&(ne===$e?a===!1?t.has("EXT_sRGB")===!0&&ue===pi?(R.format=kx,R.minFilter=Ze,R.generateMipmaps=!1):O=Fm.sRGBToLinear(O):(ue!==pi||me!==nn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ne)),O}this.allocateTextureUnit=G,this.resetTextureUnits=k,this.setTexture2D=U,this.setTexture2DArray=$,this.setTexture3D=F,this.setTextureCube=j,this.rebindTextures=Ae,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ie,this.setupFrameBufferTexture=W,this.useMultisampledRTT=Te}function $V(i,t,e){let n=e.isWebGL2;function r(s,o=null){let a;if(s===nn)return 5121;if(s===WL)return 32819;if(s===qL)return 32820;if(s===GL)return 5120;if(s===HL)return 5122;if(s===x_)return 5123;if(s===jL)return 5124;if(s===xo)return 5125;if(s===wr)return 5126;if(s===vl)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===YL)return 6406;if(s===pi)return 6408;if(s===XL)return 6409;if(s===KL)return 6410;if(s===ml)return 6402;if(s===la)return 34041;if(s===kx)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===QL)return 6403;if(s===ZL)return 36244;if(s===gb)return 33319;if(s===JL)return 33320;if(s===$L)return 36249;if(s===J0||s===$0||s===ex||s===tx)if(o===$e)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===J0)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===$0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===ex)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===tx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===J0)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===$0)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===ex)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===tx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===WA||s===qA||s===YA||s===XA)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===WA)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===qA)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===YA)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===XA)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===e3)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===KA||s===QA)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===KA)return o===$e?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===QA)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===ZA||s===JA||s===$A||s===eE||s===tE||s===nE||s===rE||s===iE||s===sE||s===oE||s===aE||s===lE||s===cE||s===uE)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===ZA)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===JA)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===$A)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===eE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===tE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===nE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===rE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===iE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===sE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===oE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===aE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===lE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===cE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===uE)return o===$e?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===$e?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===t3||s===dE||s===hE||s===fE)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===nx)return a.COMPRESSED_RED_RGTC1_EXT;if(s===dE)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===hE)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===fE)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===sa?n?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:r}}var Qx=class extends An{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Ts=class extends mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},ek={type:"move"},$h=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ts,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 Ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),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 n of t.hand.values())this._getHandJoint(e,n)}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,n){let r=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,n),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"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,p=.005;u.inputState.pinching&&h>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=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,n),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&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(ek)))}return a!==null&&(a.visible=r!==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 n=new Ts;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Ci=class extends en{constructor(t,e,n,r,s,o,a,l,u,c){if(c=c!==void 0?c:ml,c!==ml&&c!==la)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===ml&&(n=xo),n===void 0&&c===la&&(n=sa),super(null,r,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Nt,this.minFilter=l!==void 0?l:Nt,this.flipY=!1,this.generateMipmaps=!1}},Zx=class extends Ht{constructor(t,e){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],b=new Set,w=new Map,E=new An;E.layers.enable(1),E.viewport=new Xe;let _=new An;_.layers.enable(2),_.viewport=new Xe;let S=[E,_],T=new Qx;T.layers.enable(1),T.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let j=v[F];return j===void 0&&(j=new $h,v[F]=j),j.getTargetRaySpace()},this.getControllerGrip=function(F){let j=v[F];return j===void 0&&(j=new $h,v[F]=j),j.getGripSpace()},this.getHand=function(F){let j=v[F];return j===void 0&&(j=new $h,v[F]=j),j.getHandSpace()};function D(F){let j=x.indexOf(F.inputSource);if(j===-1)return;let X=v[j];X!==void 0&&X.dispatchEvent({type:F.type,data:F.inputSource})}function P(){r.removeEventListener("select",D),r.removeEventListener("selectstart",D),r.removeEventListener("selectend",D),r.removeEventListener("squeeze",D),r.removeEventListener("squeezestart",D),r.removeEventListener("squeezeend",D),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",I);for(let F=0;F<v.length;F++){let j=x[F];j!==null&&(x[F]=null,v[F].disconnect(j))}M=null,C=null,t.setRenderTarget(g),f=null,h=null,d=null,r=null,y=null,$.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(F){u=F},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(F){if(r=F,r!==null){if(g=t.getRenderTarget(),r.addEventListener("select",D),r.addEventListener("selectstart",D),r.addEventListener("selectend",D),r.addEventListener("squeeze",D),r.addEventListener("squeezestart",D),r.addEventListener("squeezeend",D),r.addEventListener("end",P),r.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),r.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let j={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,e,j),r.updateRenderState({baseLayer:f}),y=new ut(f.framebufferWidth,f.framebufferHeight,{format:pi,type:nn,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let j=null,X=null,q=null;m.depth&&(q=m.stencil?35056:33190,j=m.stencil?la:ml,X=m.stencil?sa:xo);let V={colorFormat:32856,depthFormat:q,scaleFactor:s};d=new XRWebGLBinding(r,e),h=d.createProjectionLayer(V),r.updateRenderState({layers:[h]}),y=new ut(h.textureWidth,h.textureHeight,{format:pi,type:nn,depthTexture:new Ci(h.textureWidth,h.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 Z=t.properties.get(y);Z.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await r.requestReferenceSpace(a),$.setContext(r),$.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function I(F){for(let j=0;j<F.removed.length;j++){let X=F.removed[j],q=x.indexOf(X);q>=0&&(x[q]=null,v[q].disconnect(X))}for(let j=0;j<F.added.length;j++){let X=F.added[j],q=x.indexOf(X);if(q===-1){for(let Z=0;Z<v.length;Z++)if(Z>=x.length){x.push(X),q=Z;break}else if(x[Z]===null){x[Z]=X,q=Z;break}if(q===-1)break}let V=v[q];V&&V.connect(X)}}let L=new A,H=new A;function k(F,j,X){L.setFromMatrixPosition(j.matrixWorld),H.setFromMatrixPosition(X.matrixWorld);let q=L.distanceTo(H),V=j.projectionMatrix.elements,Z=X.projectionMatrix.elements,Q=V[14]/(V[10]-1),K=V[14]/(V[10]+1),W=(V[9]+1)/V[5],ye=(V[9]-1)/V[5],fe=(V[8]-1)/V[0],ie=(Z[8]+1)/Z[0],Ae=Q*fe,xe=Q*ie,Oe=q/(-fe+ie),Ie=Oe*-fe;j.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(Ie),F.translateZ(Oe),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let Pe=Q+Oe,Te=K+Oe,Ue=Ae-Ie,ze=xe+(q-Ie),R=W*K/Te*Pe,O=ye*K/Te*Pe;F.projectionMatrix.makePerspective(Ue,ze,R,O,Pe,Te)}function G(F,j){j===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(j.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(r===null)return;T.near=_.near=E.near=F.near,T.far=_.far=E.far=F.far,(M!==T.near||C!==T.far)&&(r.updateRenderState({depthNear:T.near,depthFar:T.far}),M=T.near,C=T.far);let j=F.parent,X=T.cameras;G(T,j);for(let V=0;V<X.length;V++)G(X[V],j);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),F.matrix.copy(T.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);let q=F.children;for(let V=0,Z=q.length;V<Z;V++)q[V].updateMatrixWorld(!0);X.length===2?k(T,E,_):T.projectionMatrix.copy(E.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(F){l=F,h!==null&&(h.fixedFoveation=F),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=F)},this.getPlanes=function(){return b};let z=null;function U(F,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!==T.cameras.length&&(T.cameras.length=0,q=!0);for(let V=0;V<X.length;V++){let Z=X[V],Q=null;if(f!==null)Q=f.getViewport(Z);else{let W=d.getViewSubImage(h,Z);Q=W.viewport,V===0&&(t.setRenderTargetTextures(y,W.colorTexture,h.ignoreDepthValues?void 0:W.depthStencilTexture),t.setRenderTarget(y))}let K=S[V];K===void 0&&(K=new An,K.layers.enable(V),K.viewport=new Xe,S[V]=K),K.matrix.fromArray(Z.transform.matrix),K.projectionMatrix.fromArray(Z.projectionMatrix),K.viewport.set(Q.x,Q.y,Q.width,Q.height),V===0&&T.matrix.copy(K.matrix),q===!0&&T.cameras.push(K)}}for(let X=0;X<v.length;X++){let q=x[X],V=v[X];q!==null&&V!==void 0&&V.update(q,j,u||o)}if(z&&z(F,j),j.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:j.detectedPlanes});let X=null;for(let q of b)j.detectedPlanes.has(q)||(X===null&&(X=[]),X.push(q));if(X!==null)for(let q of X)b.delete(q),w.delete(q),n.dispatchEvent({type:"planeremoved",data:q});for(let q of j.detectedPlanes)if(!b.has(q))b.add(q),w.set(q,j.lastChangedTime),n.dispatchEvent({type:"planeadded",data:q});else{let V=w.get(q);q.lastChangedTime>V&&(w.set(q,q.lastChangedTime),n.dispatchEvent({type:"planechanged",data:q}))}}p=null}let $=new E_;$.setAnimationLoop(U),this.setAnimationLoop=function(F){z=F},this.dispose=function(){}}};function tk(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,A_(i)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),c(m,g)):g.isMeshPhongMaterial?(r(m,g),u(m,g)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&h(m,g,x)):g.isMeshMatcapMaterial?(r(m,g),f(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),p(m,g)):g.isMeshNormalMaterial?r(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 r(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===Un&&(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===Un&&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 b=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}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 d(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 h(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===Un&&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:n}}function nk(i,t,e,n){let r={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let b=x.program;n.uniformBlockBinding(v,b)}function u(v,x){let b=r[v.id];b===void 0&&(p(v),b=c(v),r[v.id]=b,v.addEventListener("dispose",g));let w=x.program;n.updateUBOMapping(v,w);let E=t.render.frame;s[v.id]!==E&&(h(v),s[v.id]=E)}function c(v){let x=d();v.__bindingPointIndex=x;let b=i.createBuffer(),w=v.__size,E=v.usage;return i.bindBuffer(35345,b),i.bufferData(35345,w,E),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,b),b}function d(){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 h(v){let x=r[v.id],b=v.uniforms,w=v.__cache;i.bindBuffer(35345,x);for(let E=0,_=b.length;E<_;E++){let S=b[E];if(f(S,E,w)===!0){let T=S.__offset,M=Array.isArray(S.value)?S.value:[S.value],C=0;for(let D=0;D<M.length;D++){let P=M[D],I=m(P);typeof P=="number"?(S.__data[0]=P,i.bufferSubData(35345,T+C,S.__data)):P.isMatrix3?(S.__data[0]=P.elements[0],S.__data[1]=P.elements[1],S.__data[2]=P.elements[2],S.__data[3]=P.elements[0],S.__data[4]=P.elements[3],S.__data[5]=P.elements[4],S.__data[6]=P.elements[5],S.__data[7]=P.elements[0],S.__data[8]=P.elements[6],S.__data[9]=P.elements[7],S.__data[10]=P.elements[8],S.__data[11]=P.elements[0]):(P.toArray(S.__data,C),C+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,T,S.__data)}}i.bindBuffer(35345,null)}function f(v,x,b){let w=v.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let E=Array.isArray(w)?w:[w],_=[];for(let S=0;S<E.length;S++)_.push(E[S].clone());b[x]=_}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let E=Array.isArray(b[x])?b[x]:[b[x]],_=Array.isArray(w)?w:[w];for(let S=0;S<E.length;S++){let T=E[S];if(T.equals(_[S])===!1)return T.copy(_[S]),!0}}return!1}function p(v){let x=v.uniforms,b=0,w=16,E=0;for(let _=0,S=x.length;_<S;_++){let T=x[_],M={boundary:0,storage:0},C=Array.isArray(T.value)?T.value:[T.value];for(let D=0,P=C.length;D<P;D++){let I=C[D],L=m(I);M.boundary+=L.boundary,M.storage+=L.storage}if(T.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=b,_>0){E=b%w;let D=w-E;E!==0&&D-M.boundary<0&&(b+=w-E,T.__offset=b)}b+=M.storage}return E=b%w,E>0&&(b+=w-E),v.__size=b,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 b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function y(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:u,dispose:y}}function rk(){let i=Bm("canvas");return i.style.display="block",i}function Ab(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:rk(),e=i.context!==void 0?i.context:null,n=i.depth!==void 0?i.depth:!0,r=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 d=null,h=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=gi,this.physicallyCorrectLights=!1,this.toneMapping=So,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,b=-1,w=null,E=new Xe,_=new Xe,S=null,T=t.width,M=t.height,C=1,D=null,P=null,I=new Xe(0,0,T,M),L=new Xe(0,0,T,M),H=!1,k=new of,G=!1,z=!1,U=null,$=new se,F=new B,j=new A,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let V=e;function Z(N,te){for(let de=0;de<N.length;de++){let ee=N[de],pe=t.getContext(ee,te);if(pe!==null)return pe}return null}try{let N={alpha:!0,depth:n,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${To}`),t.addEventListener("webglcontextlost",je,!1),t.addEventListener("webglcontextrestored",Je,!1),t.addEventListener("webglcontextcreationerror",St,!1),V===null){let te=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&te.shift(),V=Z(te,N),V===null)throw Z(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let Q,K,W,ye,fe,ie,Ae,xe,Oe,Ie,Pe,Te,Ue,ze,R,O,ne,ue,me,De,Me,_e,le,Ke;function Ve(){Q=new EF(V),K=new vF(V,Q,i),Q.init(K),_e=new $V(V,Q,K),W=new ZV(V,Q,K),ye=new MF,fe=new kV,ie=new JV(V,Q,W,fe,K,_e,ye),Ae=new bF(m),xe=new AF(m),Oe=new B3(V,K),le=new gF(V,Q,Oe,K),Ie=new _F(V,Oe,ye,le),Pe=new IF(V,Ie,Oe,ye),me=new DF(V,K,ie),O=new xF(fe),Te=new VV(m,Ae,xe,Q,K,le,O),Ue=new tk(m,fe),ze=new zV,R=new YV(Q,K),ue=new mF(m,Ae,xe,W,Pe,c,o),ne=new QV(m,Pe,K),Ke=new nk(V,ye,K,W),De=new yF(V,Q,ye,K),Me=new TF(V,Q,ye,K),ye.programs=Te.programs,m.capabilities=K,m.extensions=Q,m.properties=fe,m.renderLists=ze,m.shadowMap=ne,m.state=W,m.info=ye}Ve();let Le=new Zx(m,V);this.xr=Le,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let N=Q.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=Q.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(N){N!==void 0&&(C=N,this.setSize(T,M,!1))},this.getSize=function(N){return N.set(T,M)},this.setSize=function(N,te,de){if(Le.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=N,M=te,t.width=Math.floor(N*C),t.height=Math.floor(te*C),de!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(T*C,M*C).floor()},this.setDrawingBufferSize=function(N,te,de){T=N,M=te,C=de,t.width=Math.floor(N*de),t.height=Math.floor(te*de),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(E)},this.getViewport=function(N){return N.copy(I)},this.setViewport=function(N,te,de,ee){N.isVector4?I.set(N.x,N.y,N.z,N.w):I.set(N,te,de,ee),W.viewport(E.copy(I).multiplyScalar(C).floor())},this.getScissor=function(N){return N.copy(L)},this.setScissor=function(N,te,de,ee){N.isVector4?L.set(N.x,N.y,N.z,N.w):L.set(N,te,de,ee),W.scissor(_.copy(L).multiplyScalar(C).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(N){W.setScissorTest(H=N)},this.setOpaqueSort=function(N){D=N},this.setTransparentSort=function(N){P=N},this.getClearColor=function(N){return N.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(N=!0,te=!0,de=!0){let ee=0;N&&(ee|=16384),te&&(ee|=256),de&&(ee|=1024),V.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",je,!1),t.removeEventListener("webglcontextrestored",Je,!1),t.removeEventListener("webglcontextcreationerror",St,!1),ze.dispose(),R.dispose(),fe.dispose(),Ae.dispose(),xe.dispose(),Pe.dispose(),le.dispose(),Ke.dispose(),Te.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",ke),Le.removeEventListener("sessionend",Be),U&&(U.dispose(),U=null),wt.stop()};function je(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Je(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=ye.autoReset,te=ne.enabled,de=ne.autoUpdate,ee=ne.needsUpdate,pe=ne.type;Ve(),ye.autoReset=N,ne.enabled=te,ne.autoUpdate=de,ne.needsUpdate=ee,ne.type=pe}function St(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function Zt(N){let te=N.target;te.removeEventListener("dispose",Zt),Ln(te)}function Ln(N){Y(N),fe.remove(N)}function Y(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(de){Te.releaseProgram(de)}),N.isShaderMaterial&&Te.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,de,ee,pe,it){te===null&&(te=X);let dt=pe.isMesh&&pe.matrixWorld.determinant()<0,pt=nL(N,te,de,ee,pe);W.setMaterial(ee,dt);let vt=de.index,It=1;ee.wireframe===!0&&(vt=Ie.getWireframeAttribute(de),It=2);let At=de.drawRange,Et=de.attributes.position,Bn=At.start*It,ui=(At.start+At.count)*It;it!==null&&(Bn=Math.max(Bn,it.start*It),ui=Math.min(ui,(it.start+it.count)*It)),vt!==null?(Bn=Math.max(Bn,0),ui=Math.min(ui,vt.count)):Et!=null&&(Bn=Math.max(Bn,0),ui=Math.min(ui,Et.count));let ho=ui-Bn;if(ho<0||ho===1/0)return;le.setup(pe,ee,pt,de,vt);let al,Fn=De;if(vt!==null&&(al=Oe.get(vt),Fn=Me,Fn.setIndex(al)),pe.isMesh)ee.wireframe===!0?(W.setLineWidth(ee.wireframeLinewidth*q()),Fn.setMode(1)):Fn.setMode(4);else if(pe.isLine){let _t=ee.linewidth;_t===void 0&&(_t=1),W.setLineWidth(_t*q()),pe.isLineSegments?Fn.setMode(1):pe.isLineLoop?Fn.setMode(2):Fn.setMode(3)}else pe.isPoints?Fn.setMode(0):pe.isSprite&&Fn.setMode(4);if(pe.isInstancedMesh)Fn.renderInstances(Bn,ho,pe.count);else if(de.isInstancedBufferGeometry){let _t=de._maxInstanceCount!==void 0?de._maxInstanceCount:1/0,Y0=Math.min(de.instanceCount,_t);Fn.renderInstances(Bn,ho,Y0)}else Fn.render(Bn,ho)},this.compile=function(N,te){function de(ee,pe,it){ee.transparent===!0&&ee.side===Ur&&ee.forceSinglePass===!1?(ee.side=Un,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=mi,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=Ur):_i(ee,pe,it)}h=R.get(N),h.init(),p.push(h),N.traverseVisible(function(ee){ee.isLight&&ee.layers.test(te.layers)&&(h.pushLight(ee),ee.castShadow&&h.pushShadow(ee))}),h.setupLights(m.physicallyCorrectLights),N.traverse(function(ee){let pe=ee.material;if(pe)if(Array.isArray(pe))for(let it=0;it<pe.length;it++){let dt=pe[it];de(dt,N,ee)}else de(pe,N,ee)}),p.pop(),h=null};let ce=null;function ve(N){ce&&ce(N)}function ke(){wt.stop()}function Be(){wt.start()}let wt=new E_;wt.setAnimationLoop(ve),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(N){ce=N,Le.setAnimationLoop(N),N===null?wt.stop():wt.start()},Le.addEventListener("sessionstart",ke),Le.addEventListener("sessionend",Be),this.render=function(N,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;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Le.enabled===!0&&Le.isPresenting===!0&&(Le.cameraAutoUpdate===!0&&Le.updateCamera(te),te=Le.getCamera()),N.isScene===!0&&N.onBeforeRender(m,N,te,x),h=R.get(N,p.length),h.init(),p.push(h),$.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),k.setFromProjectionMatrix($),z=this.localClippingEnabled,G=O.init(this.clippingPlanes,z),d=ze.get(N,f.length),d.init(),f.push(d),Nn(N,te,0,m.sortObjects),d.finish(),m.sortObjects===!0&&d.sort(D,P),G===!0&&O.beginShadows();let de=h.state.shadowsArray;if(ne.render(de,N,te),G===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(d,N),h.setupLights(m.physicallyCorrectLights),te.isArrayCamera){let ee=te.cameras;for(let pe=0,it=ee.length;pe<it;pe++){let dt=ee[pe];Sn(d,N,dt,dt.viewport)}}else Sn(d,N,te);x!==null&&(ie.updateMultisampleRenderTarget(x),ie.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(m,N,te),le.resetDefaultState(),b=-1,w=null,p.pop(),p.length>0?h=p[p.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function Nn(N,te,de,ee){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)de=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||k.intersectsSprite(N)){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let dt=Pe.update(N),pt=N.material;pt.visible&&d.push(N,dt,pt,de,j.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==ye.render.frame&&(N.skeleton.update(),N.skeleton.frame=ye.render.frame),!N.frustumCulled||k.intersectsObject(N))){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let dt=Pe.update(N),pt=N.material;if(Array.isArray(pt)){let vt=dt.groups;for(let It=0,At=vt.length;It<At;It++){let Et=vt[It],Bn=pt[Et.materialIndex];Bn&&Bn.visible&&d.push(N,dt,Bn,de,j.z,Et)}}else pt.visible&&d.push(N,dt,pt,de,j.z,null)}}let it=N.children;for(let dt=0,pt=it.length;dt<pt;dt++)Nn(it[dt],te,de,ee)}function Sn(N,te,de,ee){let pe=N.opaque,it=N.transmissive,dt=N.transparent;h.setupLightsView(de),G===!0&&O.setGlobalState(m.clippingPlanes,de),it.length>0&&ol(pe,te,de),ee&&W.viewport(E.copy(ee)),pe.length>0&&on(pe,te,de),it.length>0&&on(it,te,de),dt.length>0&&on(dt,te,de),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function ol(N,te,de){let ee=K.isWebGL2;U===null&&(U=new ut(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?vl:nn,minFilter:yl,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(F),ee?U.setSize(F.x,F.y):U.setSize(Nm(F.x),Nm(F.y));let pe=m.getRenderTarget();m.setRenderTarget(U),m.clear();let it=m.toneMapping;m.toneMapping=So,on(N,te,de),m.toneMapping=it,ie.updateMultisampleRenderTarget(U),ie.updateRenderTargetMipmap(U),m.setRenderTarget(pe)}function on(N,te,de){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,it=N.length;pe<it;pe++){let dt=N[pe],pt=dt.object,vt=dt.geometry,It=ee===null?dt.material:ee,At=dt.group;pt.layers.test(de.layers)&&uo(pt,te,de,vt,It,At)}}function uo(N,te,de,ee,pe,it){N.onBeforeRender(m,te,de,ee,pe,it),N.modelViewMatrix.multiplyMatrices(de.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),pe.onBeforeRender(m,te,de,ee,N,it),pe.transparent===!0&&pe.side===Ur&&pe.forceSinglePass===!1?(pe.side=Un,pe.needsUpdate=!0,m.renderBufferDirect(de,te,ee,pe,N,it),pe.side=mi,pe.needsUpdate=!0,m.renderBufferDirect(de,te,ee,pe,N,it),pe.side=Ur):m.renderBufferDirect(de,te,ee,pe,N,it),N.onAfterRender(m,te,de,ee,pe,it)}function _i(N,te,de){te.isScene!==!0&&(te=X);let ee=fe.get(N),pe=h.state.lights,it=h.state.shadowsArray,dt=pe.state.version,pt=Te.getParameters(N,pe.state,it,te,de),vt=Te.getProgramCacheKey(pt),It=ee.programs;ee.environment=N.isMeshStandardMaterial?te.environment:null,ee.fog=te.fog,ee.envMap=(N.isMeshStandardMaterial?xe:Ae).get(N.envMap||ee.environment),It===void 0&&(N.addEventListener("dispose",Zt),It=new Map,ee.programs=It);let At=It.get(vt);if(At!==void 0){if(ee.currentProgram===At&&ee.lightsStateVersion===dt)return RA(N,pt),At}else pt.uniforms=Te.getUniforms(N),N.onBuild(de,pt,m),N.onBeforeCompile(pt,m),At=Te.acquireProgram(pt,vt),It.set(vt,At),ee.uniforms=pt.uniforms;let Et=ee.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(Et.clippingPlanes=O.uniform),RA(N,pt),ee.needsLights=iL(N),ee.lightsStateVersion=dt,ee.needsLights&&(Et.ambientLightColor.value=pe.state.ambient,Et.lightProbe.value=pe.state.probe,Et.directionalLights.value=pe.state.directional,Et.directionalLightShadows.value=pe.state.directionalShadow,Et.spotLights.value=pe.state.spot,Et.spotLightShadows.value=pe.state.spotShadow,Et.rectAreaLights.value=pe.state.rectArea,Et.ltc_1.value=pe.state.rectAreaLTC1,Et.ltc_2.value=pe.state.rectAreaLTC2,Et.pointLights.value=pe.state.point,Et.pointLightShadows.value=pe.state.pointShadow,Et.hemisphereLights.value=pe.state.hemi,Et.directionalShadowMap.value=pe.state.directionalShadowMap,Et.directionalShadowMatrix.value=pe.state.directionalShadowMatrix,Et.spotShadowMap.value=pe.state.spotShadowMap,Et.spotLightMatrix.value=pe.state.spotLightMatrix,Et.spotLightMap.value=pe.state.spotLightMap,Et.pointShadowMap.value=pe.state.pointShadowMap,Et.pointShadowMatrix.value=pe.state.pointShadowMatrix);let Bn=At.getUniforms(),ui=Lc.seqWithValue(Bn.seq,Et);return ee.currentProgram=At,ee.uniformsList=ui,At}function RA(N,te){let de=fe.get(N);de.outputEncoding=te.outputEncoding,de.instancing=te.instancing,de.skinning=te.skinning,de.morphTargets=te.morphTargets,de.morphNormals=te.morphNormals,de.morphColors=te.morphColors,de.morphTargetsCount=te.morphTargetsCount,de.numClippingPlanes=te.numClippingPlanes,de.numIntersection=te.numClipIntersection,de.vertexAlphas=te.vertexAlphas,de.vertexTangents=te.vertexTangents,de.toneMapping=te.toneMapping}function nL(N,te,de,ee,pe){te.isScene!==!0&&(te=X),ie.resetTextureUnits();let it=te.fog,dt=ee.isMeshStandardMaterial?te.environment:null,pt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:gi,vt=(ee.isMeshStandardMaterial?xe:Ae).get(ee.envMap||dt),It=ee.vertexColors===!0&&!!de.attributes.color&&de.attributes.color.itemSize===4,At=!!ee.normalMap&&!!de.attributes.tangent,Et=!!de.morphAttributes.position,Bn=!!de.morphAttributes.normal,ui=!!de.morphAttributes.color,ho=ee.toneMapped?m.toneMapping:So,al=de.morphAttributes.position||de.morphAttributes.normal||de.morphAttributes.color,Fn=al!==void 0?al.length:0,_t=fe.get(ee),Y0=h.state.lights;if(G===!0&&(z===!0||N!==w)){let di=N===w&&ee.id===b;O.setState(ee,N,di)}let rr=!1;ee.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==Y0.state.version||_t.outputEncoding!==pt||pe.isInstancedMesh&&_t.instancing===!1||!pe.isInstancedMesh&&_t.instancing===!0||pe.isSkinnedMesh&&_t.skinning===!1||!pe.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==vt||ee.fog===!0&&_t.fog!==it||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==O.numPlanes||_t.numIntersection!==O.numIntersection)||_t.vertexAlphas!==It||_t.vertexTangents!==At||_t.morphTargets!==Et||_t.morphNormals!==Bn||_t.morphColors!==ui||_t.toneMapping!==ho||K.isWebGL2===!0&&_t.morphTargetsCount!==Fn)&&(rr=!0):(rr=!0,_t.__version=ee.version);let ll=_t.currentProgram;rr===!0&&(ll=_i(ee,te,pe));let LA=!1,Uh=!1,X0=!1,Sr=ll.getUniforms(),cl=_t.uniforms;if(W.useProgram(ll.program)&&(LA=!0,Uh=!0,X0=!0),ee.id!==b&&(b=ee.id,Uh=!0),LA||w!==N){if(Sr.setValue(V,"projectionMatrix",N.projectionMatrix),K.logarithmicDepthBuffer&&Sr.setValue(V,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),w!==N&&(w=N,Uh=!0,X0=!0),ee.isShaderMaterial||ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshStandardMaterial||ee.envMap){let di=Sr.map.cameraPosition;di!==void 0&&di.setValue(V,j.setFromMatrixPosition(N.matrixWorld))}(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&Sr.setValue(V,"isOrthographic",N.isOrthographicCamera===!0),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial||ee.isShadowMaterial||pe.isSkinnedMesh)&&Sr.setValue(V,"viewMatrix",N.matrixWorldInverse)}if(pe.isSkinnedMesh){Sr.setOptional(V,pe,"bindMatrix"),Sr.setOptional(V,pe,"bindMatrixInverse");let di=pe.skeleton;di&&(K.floatVertexTextures?(di.boneTexture===null&&di.computeBoneTexture(),Sr.setValue(V,"boneTexture",di.boneTexture,ie),Sr.setValue(V,"boneTextureSize",di.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 K0=de.morphAttributes;if((K0.position!==void 0||K0.normal!==void 0||K0.color!==void 0&&K.isWebGL2===!0)&&me.update(pe,de,ee,ll),(Uh||_t.receiveShadow!==pe.receiveShadow)&&(_t.receiveShadow=pe.receiveShadow,Sr.setValue(V,"receiveShadow",pe.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(cl.envMap.value=vt,cl.flipEnvMap.value=vt.isCubeTexture&&vt.isRenderTargetTexture===!1?-1:1),Uh&&(Sr.setValue(V,"toneMappingExposure",m.toneMappingExposure),_t.needsLights&&rL(cl,X0),it&&ee.fog===!0&&Ue.refreshFogUniforms(cl,it),Ue.refreshMaterialUniforms(cl,ee,C,M,U),Lc.upload(V,_t.uniformsList,cl,ie)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(Lc.upload(V,_t.uniformsList,cl,ie),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&Sr.setValue(V,"center",pe.center),Sr.setValue(V,"modelViewMatrix",pe.modelViewMatrix),Sr.setValue(V,"normalMatrix",pe.normalMatrix),Sr.setValue(V,"modelMatrix",pe.matrixWorld),pe.previousModelViewMatrix&&Sr.setValue(V,"previousModelViewMatrix",pe.previousModelViewMatrix),N.previousProjectionMatrix&&Sr.setValue(V,"previousProjectionMatrix",N.previousProjectionMatrix),ee.isShaderMaterial||ee.isRawShaderMaterial){let di=ee.uniformsGroups;for(let Q0=0,sL=di.length;Q0<sL;Q0++)if(K.isWebGL2){let NA=di[Q0];Ke.update(NA,ll),Ke.bind(NA,ll)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ll}function rL(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function iL(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,de){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=de;let ee=fe.get(N);ee.__hasExternalTextures=!0,ee.__hasExternalTextures&&(ee.__autoAllocateDepthBuffer=de===void 0,ee.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ee.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let de=fe.get(N);de.__webglFramebuffer=te,de.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,de=0){x=N,y=te,v=de;let ee=!0,pe=null,it=!1,dt=!1;if(N){let vt=fe.get(N);vt.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(36160,null),ee=!1):vt.__webglFramebuffer===void 0?ie.setupRenderTarget(N):vt.__hasExternalTextures&&ie.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let It=N.texture;(It.isData3DTexture||It.isDataArrayTexture||It.isCompressedArrayTexture)&&(dt=!0);let At=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(pe=At[te],it=!0):K.isWebGL2&&N.samples>0&&ie.useMultisampledRTT(N)===!1?pe=fe.get(N).__webglMultisampledFramebuffer:pe=At,E.copy(N.viewport),_.copy(N.scissor),S=N.scissorTest}else E.copy(I).multiplyScalar(C).floor(),_.copy(L).multiplyScalar(C).floor(),S=H;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(N,pe),W.viewport(E),W.scissor(_),W.setScissorTest(S),it){let vt=fe.get(N.texture);V.framebufferTexture2D(36160,36064,34069+te,vt.__webglTexture,de)}else if(dt){let vt=fe.get(N.texture),It=te||0;V.framebufferTextureLayer(36160,36064,vt.__webglTexture,de||0,It)}b=-1},this.readRenderTargetPixels=function(N,te,de,ee,pe,it,dt){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&dt!==void 0&&(pt=pt[dt]),pt){W.bindFramebuffer(36160,pt);try{let vt=N.texture,It=vt.format,At=vt.type;if(It!==pi&&_e.convert(It)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Et=At===vl&&(Q.has("EXT_color_buffer_half_float")||K.isWebGL2&&Q.has("EXT_color_buffer_float"));if(At!==nn&&_e.convert(At)!==V.getParameter(35738)&&!(At===wr&&(K.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!Et){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-ee&&de>=0&&de<=N.height-pe&&V.readPixels(te,de,ee,pe,_e.convert(It),_e.convert(At),it)}finally{let vt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,vt)}}},this.copyFramebufferToTexture=function(N,te,de=0){let ee=Math.pow(2,-de),pe=Math.floor(te.image.width*ee),it=Math.floor(te.image.height*ee);ie.setTexture2D(te,0),V.copyTexSubImage2D(3553,de,0,0,N.x,N.y,pe,it),W.unbindTexture()},this.copyTextureToTexture=function(N,te,de,ee=0){let pe=te.image.width,it=te.image.height,dt=_e.convert(de.format),pt=_e.convert(de.type);ie.setTexture2D(de,0),V.pixelStorei(37440,de.flipY),V.pixelStorei(37441,de.premultiplyAlpha),V.pixelStorei(3317,de.unpackAlignment),te.isDataTexture?V.texSubImage2D(3553,ee,N.x,N.y,pe,it,dt,pt,te.image.data):te.isCompressedTexture?V.compressedTexSubImage2D(3553,ee,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,dt,te.mipmaps[0].data):V.texSubImage2D(3553,ee,N.x,N.y,dt,pt,te.image),ee===0&&de.generateMipmaps&&V.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(N,te,de,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let it=N.max.x-N.min.x+1,dt=N.max.y-N.min.y+1,pt=N.max.z-N.min.z+1,vt=_e.convert(ee.format),It=_e.convert(ee.type),At;if(ee.isData3DTexture)ie.setTexture3D(ee,0),At=32879;else if(ee.isDataArrayTexture)ie.setTexture2DArray(ee,0),At=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(37440,ee.flipY),V.pixelStorei(37441,ee.premultiplyAlpha),V.pixelStorei(3317,ee.unpackAlignment);let Et=V.getParameter(3314),Bn=V.getParameter(32878),ui=V.getParameter(3316),ho=V.getParameter(3315),al=V.getParameter(32877),Fn=de.isCompressedTexture?de.mipmaps[0]:de.image;V.pixelStorei(3314,Fn.width),V.pixelStorei(32878,Fn.height),V.pixelStorei(3316,N.min.x),V.pixelStorei(3315,N.min.y),V.pixelStorei(32877,N.min.z),de.isDataTexture||de.isData3DTexture?V.texSubImage3D(At,pe,te.x,te.y,te.z,it,dt,pt,vt,It,Fn.data):de.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(At,pe,te.x,te.y,te.z,it,dt,pt,vt,Fn.data)):V.texSubImage3D(At,pe,te.x,te.y,te.z,it,dt,pt,vt,It,Fn),V.pixelStorei(3314,Et),V.pixelStorei(32878,Bn),V.pixelStorei(3316,ui),V.pixelStorei(3315,ho),V.pixelStorei(32877,al),pe===0&&ee.generateMipmaps&&V.generateMipmap(At),W.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ie.setTextureCube(N,0):N.isData3DTexture?ie.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ie.setTexture2DArray(N,0):ie.setTexture2D(N,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 Jx=class extends Ab{};Jx.prototype.isWebGL1Renderer=!0;var Vc=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Fe(t),this.near=e,this.far=n}clone(){return new Vc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Ar=class extends mt{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}},jm=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Vx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Mi()}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,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];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=Mi()),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]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}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=Mi()),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}}},Vr=new A,bl=class{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}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,n=this.data.count;e<n;e++)Vr.fromBufferAttribute(this,e),Vr.applyMatrix4(t),this.setXYZ(e,Vr.x,Vr.y,Vr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Vr.fromBufferAttribute(this,e),Vr.applyNormalMatrix(t),this.setXYZ(e,Vr.x,Vr.y,Vr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Vr.fromBufferAttribute(this,e),Vr.transformDirection(t),this.setXYZ(e,Vr.x,Vr.y,Vr.z);return this}setX(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Wt(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=bo(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=bo(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=bo(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=bo(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array),s=Wt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,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 n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+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 bl(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 n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+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 lf=class extends mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Eo=class extends en{constructor(t=null,e=1,n=1,r,s,o,a,l,u=Nt,c=Nt,d,h){super(null,o,a,l,u,c,r,s,d,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},YE=new se,ik=new se,ca=class{constructor(t=[],e=[]){this.uuid=Mi(),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 n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new se)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new se;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:ik;YE.multiplyMatrices(a,e[s]),YE.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ca(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=b_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new Eo(e,t,t,pi,wr);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){let s=t.bones[n],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new lf),this.bones.push(o),this.boneInverses.push(new se().fromArray(t.boneInverses[n]))}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,n=this.boneInverses;for(let r=0,s=e.length;r<s;r++){let o=e[r];t.bones.push(o.uuid);let a=n[r];t.boneInverses.push(a.toArray())}return t}},Wm=class extends Ge{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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 Pi=class extends xl{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Fe(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}},XE=new A,KE=new A,QE=new se,Cx=new Ji,Am=new ln,Sl=class extends mt{constructor(t=new Ee,e=new Pi){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,n=[0];for(let r=1,s=e.count;r<s;r++)XE.fromBufferAttribute(e,r-1),KE.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=XE.distanceTo(KE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,r=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Am.copy(n.boundingSphere),Am.applyMatrix4(r),Am.radius+=s,t.ray.intersectsSphere(Am)===!1)return;QE.copy(r).invert(),Cx.copy(t.ray).applyMatrix4(QE);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,f=this.isLineSegments?2:1,p=n.index,g=n.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,b=v-1;x<b;x+=f){let w=p.getX(x),E=p.getX(x+1);if(u.fromBufferAttribute(g,w),c.fromBufferAttribute(g,E),Cx.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(h);S<t.near||S>t.far||e.push({distance:S,point:d.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,b=v-1;x<b;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),Cx.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let E=t.ray.origin.distanceTo(h);E<t.near||E>t.far||e.push({distance:E,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},ZE=new A,JE=new A,ua=class extends Sl{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,n=[];for(let r=0,s=e.count;r<s;r+=2)ZE.fromBufferAttribute(e,r),JE.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+ZE.distanceTo(JE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var qm=class extends en{constructor(t,e,n,r,s,o,a,l,u){super(t,e,n,r,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ze,this.magFilter=s!==void 0?s:Ze,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}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 Di=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/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=[],n,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),r=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),u=n[r]-o,u<0)a=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===o)return r/(s-1);let c=n[r],h=n[r+1]-c,f=(o-c)/h;return(r+f)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),l=e||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,r=[],s=[],o=[],a=new A,l=new se;for(let f=0;f<=t;f++){let p=f/t;r[f]=this.getTangentAt(p,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[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(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Wn(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(e===!0){let f=Math.acos(Wn(s[0].dot(s[t]),-1,1));f/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,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 Di{constructor(t=0,e=0,n=1,r=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=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new B,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);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),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.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}},$x=class extends wl{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Eb(){let i=0,t=0,e=0,n=0;function r(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){r(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+n*a}}}var Em=new A,Px=new Eb,Dx=new Eb,Ix=new Eb,eb=class extends Di{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new A){let n=e,r=this.points,s=r.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=r[(a-1)%s]:(Em.subVectors(r[0],r[1]).add(r[0]),u=Em);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?c=r[(a+2)%s]:(Em.subVectors(r[s-1],r[s-2]).add(r[s-1]),c=Em),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(u.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),Px.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,p,m,g),Dx.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,p,m,g),Ix.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(Px.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),Dx.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),Ix.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(Px.calc(l),Dx.calc(l),Ix.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.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,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.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,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new A().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function $E(i,t,e,n,r){let s=(n-t)*.5,o=(r-e)*.5,a=i*i,l=i*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*i+e}function sk(i,t){let e=1-i;return e*e*t}function ok(i,t){return 2*(1-i)*i*t}function ak(i,t){return i*i*t}function ef(i,t,e,n){return sk(i,t)+ok(i,e)+ak(i,n)}function lk(i,t){let e=1-i;return e*e*e*t}function ck(i,t){let e=1-i;return 3*e*e*i*t}function uk(i,t){return 3*(1-i)*i*i*t}function dk(i,t){return i*i*i*t}function tf(i,t,e,n,r){return lk(i,t)+ck(i,e)+uk(i,n)+dk(i,r)}var Ir=class extends Di{constructor(t=new B,e=new B,n=new B,r=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(tf(t,r.x,s.x,o.x,a.x),tf(t,r.y,s.y,o.y,a.y)),n}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}},Al=class extends Di{constructor(t=new A,e=new A,n=new A,r=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(tf(t,r.x,s.x,o.x,a.x),tf(t,r.y,s.y,o.y,a.y),tf(t,r.z,s.z,o.z,a.z)),n}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}},Or=class extends Di{constructor(t=new B,e=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new B){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}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}},cf=class extends Di{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}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}},yi=class extends Di{constructor(t=new B,e=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(ef(t,r.x,s.x,o.x),ef(t,r.y,s.y,o.y)),n}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}},tb=class extends Di{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(ef(t,r.x,s.x,o.x),ef(t,r.y,s.y,o.y),ef(t,r.z,s.z,o.z)),n}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}},kc=class extends Di{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new B){let n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],u=r[o],c=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return n.set($E(a,l.x,u.x,c.x,d.x),$E(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new B().fromArray(r))}return this}},hk=Object.freeze({__proto__:null,ArcCurve:$x,CatmullRomCurve3:eb,CubicBezierCurve:Ir,CubicBezierCurve3:Al,EllipseCurve:wl,LineCurve:Or,LineCurve3:cf,QuadraticBezierCurve:yi,QuadraticBezierCurve3:tb,SplineCurve:kc}),uf=class extends Di{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 Or(e,t))}getPoint(t,e){let n=t*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,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 n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],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];n&&n.equals(c)||(e.push(c),n=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,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new hk[r.type]().fromJSON(r))}return this}},El=class extends uf{constructor(t){super(),this.type="Path",this.currentPoint=new B,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;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 n=new Or(this.currentPoint.clone(),new B(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){let s=new yi(this.currentPoint.clone(),new B(t,e),new B(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){let a=new Ir(this.currentPoint.clone(),new B(t,e),new B(n,r),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new kc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,r,s,o,a,l),this}absellipse(t,e,n,r,s,o,a,l){let u=new wl(t,e,n,r,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.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}},Uc=class extends Ee{constructor(t=[new B(0,-.5),new B(.5,0),new B(0,.5)],e=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:r},e=Math.floor(e),r=Wn(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new B,f=new A,p=new A,m=new A,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=n+v*c*r,b=Math.sin(x),w=Math.cos(x);for(let E=0;E<=t.length-1;E++){d.x=t[E].x*b,d.y=t[E].y,d.z=t[E].x*w,o.push(d.x,d.y,d.z),h.x=v/e,h.y=E/(t.length-1),a.push(h.x,h.y);let _=l[3*E+0]*b,S=l[3*E+1],T=l[3*E+0]*w;u.push(_,S,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,w=b,E=b+t.length,_=b+t.length+1,S=b+1;s.push(w,E,S),s.push(_,S,E)}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 Uc(t.points,t.segments,t.phiStart,t.phiLength)}};var _l=class extends Ee{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;r=Math.floor(r),s=Math.floor(s);let c=[],d=[],h=[],f=[],p=0,m=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(d,3)),this.setAttribute("normal",new be(h,3)),this.setAttribute("uv",new be(f,2));function v(){let b=new A,w=new A,E=0,_=(e-t)/n;for(let S=0;S<=s;S++){let T=[],M=S/s,C=M*(e-t)+t;for(let D=0;D<=r;D++){let P=D/r,I=P*l+a,L=Math.sin(I),H=Math.cos(I);w.x=C*L,w.y=-M*n+g,w.z=C*H,d.push(w.x,w.y,w.z),b.set(L,_,H).normalize(),h.push(b.x,b.y,b.z),f.push(P,1-M),T.push(p++)}m.push(T)}for(let S=0;S<r;S++)for(let T=0;T<s;T++){let M=m[T][S],C=m[T+1][S],D=m[T+1][S+1],P=m[T][S+1];c.push(M,C,P),c.push(C,D,P),E+=6}u.addGroup(y,E,0),y+=E}function x(b){let w=p,E=new B,_=new A,S=0,T=b===!0?t:e,M=b===!0?1:-1;for(let D=1;D<=r;D++)d.push(0,g*M,0),h.push(0,M,0),f.push(.5,.5),p++;let C=p;for(let D=0;D<=r;D++){let I=D/r*l+a,L=Math.cos(I),H=Math.sin(I);_.x=T*H,_.y=g*M,_.z=T*L,d.push(_.x,_.y,_.z),h.push(0,M,0),E.x=L*.5+.5,E.y=H*.5*M+.5,f.push(E.x,E.y),p++}for(let D=0;D<r;D++){let P=w+D,I=C+D;b===!0?c.push(I,I+1,P):c.push(I+1,I,P),S+=3}u.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new _l(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},zc=class extends _l{constructor(t=1,e=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new zc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Gc=class extends Ee{constructor(t=[],e=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};let s=[],o=[];a(r),u(n),c(),this.setAttribute("position",new be(s,3)),this.setAttribute("normal",new be(s.slice(),3)),this.setAttribute("uv",new be(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,b=new A,w=new A;for(let E=0;E<e.length;E+=3)f(e[E+0],x),f(e[E+1],b),f(e[E+2],w),l(x,b,w,v)}function l(v,x,b,w){let E=w+1,_=[];for(let S=0;S<=E;S++){_[S]=[];let T=v.clone().lerp(b,S/E),M=x.clone().lerp(b,S/E),C=E-S;for(let D=0;D<=C;D++)D===0&&S===E?_[S][D]=T:_[S][D]=T.clone().lerp(M,D/C)}for(let S=0;S<E;S++)for(let T=0;T<2*(E-S)-1;T++){let M=Math.floor(T/2);T%2===0?(h(_[S][M+1]),h(_[S+1][M]),h(_[S][M])):(h(_[S][M+1]),h(_[S+1][M+1]),h(_[S+1][M]))}}function u(v){let x=new A;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(v),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function c(){let v=new A;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 b=g(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(b,1-w)}p(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],w=o[v+4],E=Math.max(x,b,w),_=Math.min(x,b,w);E>.9&&_<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let b=v*3;x.x=t[b+0],x.y=t[b+1],x.z=t[b+2]}function p(){let v=new A,x=new A,b=new A,w=new A,E=new B,_=new B,S=new B;for(let T=0,M=0;T<s.length;T+=9,M+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),E.set(o[M+0],o[M+1]),_.set(o[M+2],o[M+3]),S.set(o[M+4],o[M+5]),w.copy(v).add(x).add(b).divideScalar(3);let C=g(w);m(E,M+0,v,C),m(_,M+2,x,C),m(S,M+4,b,C)}}function m(v,x,b,w){w<0&&v.x===1&&(o[x]=v.x-1),b.x===0&&b.z===0&&(o[x]=w/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 Gc(t.vertices,t.indices,t.radius,t.details)}},Hc=class extends Gc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],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 Hc(t.radius,t.detail)}};var _o=class extends El{constructor(t){super(t),this.uuid=Mi(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].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,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new El().fromJSON(r))}return this}},fk={triangulate:function(i,t,e=2){let n=t&&t.length,r=n?t[0]*e:i.length,s=P_(i,0,r,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=vk(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let p=e;p<r;p+=e)d=i[p],h=i[p+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return df(s,o,e,a,l,f,0),o}};function P_(i,t,e,n,r){let s,o;if(r===Pk(i,t,e,n)>0)for(s=t;s<e;s+=n)o=e_(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=e_(s,i[s],i[s+1],o);return o&&ag(o,o.next)&&(ff(o),o=o.next),o}function Tl(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(ag(e,e.next)||fn(e.prev,e,e.next)===0)){if(ff(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function df(i,t,e,n,r,s,o){if(!i)return;!o&&s&&Ak(i,n,r,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?mk(i,n,r,s):pk(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),ff(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=gk(Tl(i),t,e),df(i,t,e,n,r,s,2)):o===2&&yk(i,t,e,n,r,s):df(Tl(i),t,e,n,r,s,1);break}}}function pk(i){let t=i.prev,e=i,n=i.next;if(fn(t,e,n)>=0)return!1;let r=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=r<s?r<o?r:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=r>s?r>o?r:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=n.next;for(;p!==t;){if(p.x>=c&&p.x<=h&&p.y>=d&&p.y<=f&&Oc(r,a,s,l,o,u,p.x,p.y)&&fn(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function mk(i,t,e,n){let r=i.prev,s=i,o=i.next;if(fn(r,s,o)>=0)return!1;let a=r.x,l=s.x,u=o.x,c=r.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,p=c<d?c<h?c:h:d<h?d:h,m=a>l?a>u?a:u:l>u?l:u,g=c>d?c>h?c:h:d>h?d:h,y=nb(f,p,t,e,n),v=nb(m,g,t,e,n),x=i.prevZ,b=i.nextZ;for(;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Oc(a,c,l,d,u,h,x.x,x.y)&&fn(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Oc(a,c,l,d,u,h,b.x,b.y)&&fn(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Oc(a,c,l,d,u,h,x.x,x.y)&&fn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Oc(a,c,l,d,u,h,b.x,b.y)&&fn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function gk(i,t,e){let n=i;do{let r=n.prev,s=n.next.next;!ag(r,s)&&D_(r,n,n.next,s)&&hf(r,s)&&hf(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),ff(n),ff(n.next),n=i=s),n=n.next}while(n!==i);return Tl(n)}function yk(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Tk(o,a)){let l=I_(o,a);o=Tl(o,o.next),l=Tl(l,l.next),df(o,t,e,n,r,s,0),df(l,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function vk(i,t,e,n){let r=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:i.length,u=P_(i,a,l,n,!1),u===u.next&&(u.steiner=!0),r.push(_k(u));for(r.sort(xk),s=0;s<r.length;s++)e=bk(r[s],e);return e}function xk(i,t){return i.x-t.x}function bk(i,t){let e=Sk(i,t);if(!e)return t;let n=I_(e,i);return Tl(n,n.next),Tl(e,e.next)}function Sk(i,t){let e=t,n=-1/0,r,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,r=e.x<e.next.x?e:e.next,h===s))return r}e=e.next}while(e!==t);if(!r)return null;let a=r,l=r.x,u=r.y,c=1/0,d;e=r;do s>=e.x&&e.x>=l&&s!==e.x&&Oc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),hf(e,i)&&(d<c||d===c&&(e.x>r.x||e.x===r.x&&wk(r,e)))&&(r=e,c=d)),e=e.next;while(e!==a);return r}function wk(i,t){return fn(i.prev,i,t.prev)<0&&fn(t.next,i,i.next)<0}function Ak(i,t,e,n){let r=i;do r.z===0&&(r.z=nb(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Ek(r)}function Ek(i){let t,e,n,r,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,u*=2}while(o>1);return i}function nb(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|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 _k(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 Oc(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function Tk(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Mk(i,t)&&(hf(i,t)&&hf(t,i)&&Ck(i,t)&&(fn(i.prev,i,t.prev)||fn(i,t.prev,t))||ag(i,t)&&fn(i.prev,i,i.next)>0&&fn(t.prev,t,t.next)>0)}function fn(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ag(i,t){return i.x===t.x&&i.y===t.y}function D_(i,t,e,n){let r=Tm(fn(i,t,e)),s=Tm(fn(i,t,n)),o=Tm(fn(e,n,i)),a=Tm(fn(e,n,t));return!!(r!==s&&o!==a||r===0&&_m(i,e,t)||s===0&&_m(i,n,t)||o===0&&_m(e,i,n)||a===0&&_m(e,t,n))}function _m(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 Tm(i){return i>0?1:i<0?-1:0}function Mk(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&&D_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function hf(i,t){return fn(i.prev,i,i.next)<0?fn(i,t,i.next)>=0&&fn(i,i.prev,t)>=0:fn(i,t,i.prev)<0||fn(i,i.next,t)<0}function Ck(i,t){let e=i,n=!1,r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function I_(i,t){let e=new rb(i.i,i.x,i.y),n=new rb(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function e_(i,t,e,n){let r=new rb(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ff(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 rb(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 Pk(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var jc=class{static area(t){let e=t.length,n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return jc.area(t)<0}static triangulateShape(t,e){let n=[],r=[],s=[];t_(t),n_(n,t);let o=t.length;e.forEach(t_);for(let l=0;l<e.length;l++)r.push(o),o+=e[l].length,n_(n,e[l]);let a=fk.triangulate(n,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function t_(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function n_(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var Wc=class extends Gc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=[-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],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Wc(t.radius,t.detail)}};var Ml=class extends Ee{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],d=new A,h=new A,f=[],p=[],m=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,b=0;y==0&&o==0?b=.5/e:y==n&&l==Math.PI&&(b=-.5/e);for(let w=0;w<=e;w++){let E=w/e;d.x=-t*Math.cos(r+E*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(r+E*s)*Math.sin(o+x*a),p.push(d.x,d.y,d.z),h.copy(d).normalize(),m.push(h.x,h.y,h.z),g.push(E+b,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],b=c[y][v],w=c[y+1][v],E=c[y+1][v+1];(y!==0||o>0)&&f.push(x,b,E),(y!==n-1||l<Math.PI)&&f.push(b,w,E)}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 Ml(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var qc=class extends Ee{constructor(t=1,e=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],l=[],u=[],c=[],d=new A,h=new A,f=new A,p=new A,m=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let b=x/n*s*Math.PI*2;v(b,s,o,t,f),v(b+.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 w=0;w<=r;++w){let E=w/r*Math.PI*2,_=-e*Math.cos(E),S=e*Math.sin(E);d.x=f.x+(_*y.x+S*m.x),d.y=f.y+(_*y.y+S*m.y),d.z=f.z+(_*y.z+S*m.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(w/r)}}for(let x=1;x<=n;x++)for(let b=1;b<=r;b++){let w=(r+1)*(x-1)+(b-1),E=(r+1)*x+(b-1),_=(r+1)*x+b,S=(r+1)*(x-1)+b;a.push(w,E,S),a.push(E,_,S)}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,b,w,E,_){let S=Math.cos(x),T=Math.sin(x),M=w/b*x,C=Math.cos(M);_.x=E*(2+C)*.5*S,_.y=E*(2+C)*T*.5,_.z=E*Math.sin(M)*.5}}static fromJSON(t){return new qc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function ia(i,t,e){return O_(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Mm(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 O_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Dk(i){function t(r,s){return i[r]-i[s]}let e=i.length,n=new Array(e);for(let r=0;r!==e;++r)n[r]=r;return n.sort(t),n}function r_(i,t,e){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=e[s]*t;for(let l=0;l!==t;++l)r[o++]=i[a+l]}return r}function R_(i,t,e,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=i[r++];while(s!==void 0)}var Yc=class{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],s=e[n-1];e:{t:{let o;n:{r:if(!(t<r)){for(let a=n+2;;){if(r===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=e[++n],t<r)break t}o=e.length;break n}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=e[--n-1],t>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(r=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r;for(let o=0;o!==r;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},ib=class extends Yc{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Pc,endingEnd:Pc}}intervalChanged_(t,e,n){let r=this.parameterPositions,s=t-2,o=t+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Dc:s=t,a=2*e-n;break;case Lm:s=r.length-2,a=e+r[s]-r[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Dc:o=t,l=2*n-e;break;case Lm:o=1,l=n+r[1]-r[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,p=(n-e)/(r-e),m=p*p,g=m*p,y=-h*g+2*h*m-h*p,v=(1+h)*g+(-1.5-2*h)*m+(-.5+h)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,b=f*g-f*m;for(let w=0;w!==a;++w)s[w]=y*o[c+w]+v*o[u+w]+x*o[l+w]+b*o[d+w];return s}},Ym=class extends Yc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(r-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},sb=class extends Yc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}},Ii=class{constructor(t,e,n,r){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=Mm(e,this.TimeBufferType),this.values=Mm(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Mm(t.times,Array),values:Mm(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new sb(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ym(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ib(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Om:e=this.InterpolantFactoryMethodDiscrete;break;case Rm:e=this.InterpolantFactoryMethodLinear;break;case rx:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="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(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Om;case this.InterpolantFactoryMethodLinear:return Rm;case this.InterpolantFactoryMethodSmooth:return rx}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=ia(n,s,o),this.values=ia(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 n=this.times,r=this.values,s=n.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=n[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(r!==void 0&&O_(r))for(let a=0,l=r.length;a!==l;++a){let u=r[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=ia(this.times),e=ia(this.values),n=this.getValueSize(),r=this.getInterpolation()===rx,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(r)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let p=0;p!==n;++p){let m=e[d+p];if(m!==e[h+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=ia(t,0,o),this.values=ia(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=ia(this.times,0),e=ia(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}};Ii.prototype.TimeBufferType=Float32Array;Ii.prototype.ValueBufferType=Float32Array;Ii.prototype.DefaultInterpolation=Rm;var da=class extends Ii{};da.prototype.ValueTypeName="bool";da.prototype.ValueBufferType=Array;da.prototype.DefaultInterpolation=Om;da.prototype.InterpolantFactoryMethodLinear=void 0;da.prototype.InterpolantFactoryMethodSmooth=void 0;var Xm=class extends Ii{};Xm.prototype.ValueTypeName="color";var Xc=class extends Ii{};Xc.prototype.ValueTypeName="number";var ob=class extends Yc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(r-e),u=t*a;for(let c=u+a;u!==c;u+=4)Ye.slerpFlat(s,0,o,u-a,o,u,l);return s}},Cl=class extends Ii{InterpolantFactoryMethodLinear(t){return new ob(this.times,this.values,this.getValueSize(),t)}};Cl.prototype.ValueTypeName="quaternion";Cl.prototype.DefaultInterpolation=Rm;Cl.prototype.InterpolantFactoryMethodSmooth=void 0;var ha=class extends Ii{};ha.prototype.ValueTypeName="string";ha.prototype.ValueBufferType=Array;ha.prototype.DefaultInterpolation=Om;ha.prototype.InterpolantFactoryMethodLinear=void 0;ha.prototype.InterpolantFactoryMethodSmooth=void 0;var Kc=class extends Ii{};Kc.prototype.ValueTypeName="vector";var Qc=class{constructor(t,e=-1,n,r=xb){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=Mi(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(Ok(n[o]).scale(r));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=n.length;s!==o;++s)e.push(Ii.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(t,e,n,r){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=Dk(l);l=r_(l,1,c),u=r_(u,1,c),!r&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new Xc(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let r={},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 d=c[1],h=r[d];h||(r[d]=h=[]),h.push(u)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(d,h,f,p,m){if(f.length!==0){let g=[],y=[];R_(f,g,y,p),g.length!==0&&m.push(new d(h,g,y))}},r=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let d=0;d<u.length;d++){let h=u[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)f[h[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==h[p].morphTargets.length;++v){let x=h[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}r.push(new Xc(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[d].name+"]";n(Kc,f+".position",h,"pos",r),n(Cl,f+".quaternion",h,"rot",r),n(Kc,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let s=this.tracks[n];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 Ik(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Xc;case"vector":case"vector2":case"vector3":case"vector4":return Kc;case"color":return Xm;case"quaternion":return Cl;case"bool":case"boolean":return da;case"string":return ha}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Ok(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Ik(i.type);if(i.times===void 0){let e=[],n=[];R_(i.keys,e,n,"value"),i.times=e,i.values=n}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var i_={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={}}},pf=class{constructor(t,e,n){let r=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&r.onStart!==void 0&&r.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,r.onProgress!==void 0&&r.onProgress(c,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],p=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}},Rk=new pf,Zc=class{constructor(t){this.manager=t!==void 0?t:Rk,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(r,s){n.load(t,r,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}},vo={},ab=class extends Error{constructor(t,e){super(t),this.response=e}},Jc=class extends Zc{constructor(t){super(t)}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=i_.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(vo[t]!==void 0){vo[t].push({onLoad:e,onProgress:n,onError:r});return}vo[t]=[],vo[t].push({onLoad:e,onProgress:n,onError:r});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=vo[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:b})=>{if(x)y.close();else{m+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let E=0,_=c.length;E<_;E++){let S=c[E];S.onProgress&&S.onProgress(w)}y.enqueue(b),v()}})}}});return new Response(g)}else throw new ab(`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 d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{i_.add(t,u);let c=vo[t];delete vo[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=vo[t];if(c===void 0)throw this.manager.itemError(t),u;delete vo[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];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 fa=class extends mt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Fe(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}},Km=class extends fa{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Fe(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},Ox=new se,s_=new A,o_=new A,mf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new se,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new of,this._frameExtents=new B(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,n=this.matrix;s_.setFromMatrixPosition(t.matrixWorld),e.position.copy(s_),o_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(o_),e.updateMatrixWorld(),Ox.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ox),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ox)}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}},lb=class extends mf{constructor(){super(new An(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=rf*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||r!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=r,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Qm=class extends fa{constructor(t,e,n=0,r=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new lb}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}},a_=new se,Xh=new A,Rx=new A,cb=class extends mf{constructor(){super(new An(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(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 A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Xh.setFromMatrixPosition(t.matrixWorld),n.position.copy(Xh),Rx.copy(n.position),Rx.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Rx),n.updateMatrixWorld(),r.makeTranslation(-Xh.x,-Xh.y,-Xh.z),a_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(a_)}},Zm=class extends fa{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new cb}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}},ub=class extends mf{constructor(){super(new Fc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Jm=class extends fa{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.shadow=new ub}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var db=class extends Ee{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}},$c=class extends Zc{constructor(t){super(t)}load(t,e,n,r){let s=this,o=new Jc(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){r?r(l):console.error(l),s.manager.itemError(t)}},n,r)}parse(t){let e={},n={};function r(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=im(g.type,y),x=new jm(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(n[p]!==void 0)return n[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return n[p]=y,y}let o=t.isInstancedBufferGeometry?new db:new Ee,a=t.data.index;if(a!==void 0){let f=im(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=r(t.data,p.data);m=new bl(g,p.itemSize,p.offset,p.normalized)}else{let g=im(p.type,p.array),y=p.isInstancedBufferAttribute?Wm: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 b=r(t.data,v.data);x=new bl(b,v.itemSize,v.offset,v.normalized)}else{let b=im(v.type,v.array);x=new Ge(b,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 d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,p=d.length;f!==p;++f){let m=d[f];o.addGroup(m.start,m.count,m.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new ln(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var $m=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=l_(),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=l_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function l_(){return(typeof performance>"u"?Date:performance).now()}var hb=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let r,s,o;switch(e){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,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 n=this.buffer,r=this.valueSize,s=t*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,r=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(n,r,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){a.setValue(n,r);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let s=n,o=r;s!==o;++s)e[s]=e[r+s%n];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 n=t;n<e;n++)this.buffer[n]=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 n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,r){Ye.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,s){let o=this._workIndex*s;Ye.multiplyQuaternionsFlat(t,o,t,e,t,n),Ye.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[n+o]*r}}},_b="\\[\\]\\.:\\/",Lk=new RegExp("["+_b+"]","g"),Tb="[^"+_b+"]",Nk="[^"+_b.replace("\\.","")+"]",Bk=/((?:WC+[\/:])*)/.source.replace("WC",Tb),Fk=/(WCOD+)?/.source.replace("WCOD",Nk),Vk=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Tb),kk=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Tb),Uk=new RegExp("^"+Bk+Fk+Vk+kk+"$"),zk=["material","materials","bones","map"],fb=class{constructor(t,e,n){let r=n||Lt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Lt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Lt.parseTrackName(e),this.node=Lt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Lt.Composite(t,e,n):new Lt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Lk,"")}static parseTrackName(t){let e=Uk.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);zk.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=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=n(a.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)t[e++]=n[r]}_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 n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=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,n=e.objectName,r=e.propertyName,s=e.propertyIndex;if(t||(t=Lt.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(n){let u=e.objectIndex;switch(n){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[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}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[r];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" 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(r==="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=r;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}};Lt.Composite=fb;Lt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Lt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Lt.prototype.GetterByBindingType=[Lt.prototype._getValue_direct,Lt.prototype._getValue_array,Lt.prototype._getValue_arrayElement,Lt.prototype._getValue_toArray];Lt.prototype.SetterByBindingTypeAndVersioning=[[Lt.prototype._setValue_direct,Lt.prototype._setValue_direct_setNeedsUpdate,Lt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_array,Lt.prototype._setValue_array_setNeedsUpdate,Lt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_arrayElement,Lt.prototype._setValue_arrayElement_setNeedsUpdate,Lt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_fromArray,Lt.prototype._setValue_fromArray_setNeedsUpdate,Lt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var pb=class{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Pc,endingEnd:Pc};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=vb,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,n){if(t.fadeOut(e),this.fadeIn(e),n){let r=this._clip.duration,s=t._clip.duration,o=s/r,a=r/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}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,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+n,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,n,r){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*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 n3:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case xb:default:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulate(r,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,r=this.time+t,s=this._loopCount,o=n===yf;if(t===0)return s===-1?r:o&&(s&1)===1?e-r:r;if(n===yb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=e)r=e;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction: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)),r>=e||r<0){let a=Math.floor(r/e);r-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,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=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return e-r}return r}_setEndings(t,e,n){let r=this._interpolantSettings;n?(r.endingStart=Dc,r.endingEnd=Dc):(t?r.endingStart=this.zeroSlopeAtStart?Dc:Pc:r.endingStart=Lm,e?r.endingEnd=this.zeroSlopeAtEnd?Dc:Pc:r.endingEnd=Lm)}_scheduleFading(t,e,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}},Gk=new Float32Array(1),eg=class extends Ht{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,s=r.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let d=0;d!==s;++d){let h=r[d],f=h.name,p=c[f];if(p!==void 0)++p.referenceCount,o[d]=p;else{if(p=o[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[d].binding.parsedPath;p=new hb(Lt.create(n,f,m),h.ValueTypeName,h.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,s=this._actionsByClip[r];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--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,n){let r=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=r.length,r.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,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 d=a.actionByRoot,h=(t._localRoot||this._root).uuid;delete d[h],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[e];o===void 0&&(o={},r[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],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[r]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new Ym(new Float32Array(2),new Float32Array(2),1,Gk),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,s=e[r];t.__cacheIndex=r,e[r]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){let r=e||this._root,s=r.uuid,o=typeof t=="string"?Qc.findByName(r,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(n===void 0&&(o!==null?n=o.blendMode:n=xb),l!==void 0){let d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===n)return d;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new pb(this,o,e,n);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let n=e||this._root,r=n.uuid,s=typeof t=="string"?Qc.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,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,n=t.uuid,r=this._actionsByClip,s=r[n];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,d=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,d._cacheIndex=c,e[c]=d,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},oe=class{constructor(t){this.value=t}clone(){return new oe(this.value.clone===void 0?this.value:this.value.clone())}};var eu=class{constructor(t,e,n=0,r=1/0){this.ray=new Ji(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new sf,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,n=[]){return mb(t,this,n,e),n.sort(c_),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)mb(t[r],this,n,e);return n.sort(c_),n}};function c_(i,t){return i.distance-t.distance}function mb(i,t,e,n){if(i.layers.test(t.layers)&&i.raycast(t,e),n===!0){let r=i.children;for(let s=0,o=r.length;s<o;s++)mb(r[s],t,e,!0)}}var gf=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,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,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Wn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var u_=new B,tu=class{constructor(t=new B(1/0,1/0),e=new B(-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,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=u_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),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 u_.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)}},d_=new A,Cm=new A,Xn=class{constructor(t=new A,e=new A){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){d_.subVectors(t,this.start),Cm.subVectors(this.end,this.start);let n=Cm.dot(Cm),s=Cm.dot(d_)/n;return e&&(s=Wn(s,0,1)),s}closestPointToPoint(t,e,n){let r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).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)}},h_=new A,tg=class extends mt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Ee,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;r.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new be(r,3));let s=new Pi({fog:!1,toneMapped:!1});this.cone=new ua(n,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),h_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(h_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var ng=class extends kn{constructor(t,e,n){let r=new Ml(e,4,2),s=new wo({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=t,this.color=n,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 f_=new A,Pm=new A,p_=new A,rg=class extends mt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let r=new Ee;r.setAttribute("position",new be([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Pi({fog:!1,toneMapped:!1});this.lightPlane=new Sl(r,s),this.add(this.lightPlane),r=new Ee,r.setAttribute("position",new be([0,0,0,0,0,1],3)),this.targetLine=new Sl(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),f_.setFromMatrixPosition(this.light.matrixWorld),Pm.setFromMatrixPosition(this.light.target.matrixWorld),p_.subVectors(Pm,f_),this.lightPlane.lookAt(Pm),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(Pm),this.targetLine.scale.z=p_.length()}},Dm=new A,yn=new $i,pa=class extends ua{constructor(t){let e=new Ee,n=new Pi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],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){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}e.setAttribute("position",new be(r,3)),e.setAttribute("color",new be(s,3)),super(e,n),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 Fe(16755200),c=new Fe(16711680),d=new Fe(43775),h=new Fe(16777215),f=new Fe(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,r,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,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,r=1;yn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),wn("c",e,t,yn,0,0,-1),wn("t",e,t,yn,0,0,1),wn("n1",e,t,yn,-n,-r,-1),wn("n2",e,t,yn,n,-r,-1),wn("n3",e,t,yn,-n,r,-1),wn("n4",e,t,yn,n,r,-1),wn("f1",e,t,yn,-n,-r,1),wn("f2",e,t,yn,n,-r,1),wn("f3",e,t,yn,-n,r,1),wn("f4",e,t,yn,n,r,1),wn("u1",e,t,yn,n*.7,r*1.1,-1),wn("u2",e,t,yn,-n*.7,r*1.1,-1),wn("u3",e,t,yn,0,r*2,-1),wn("cf1",e,t,yn,-n,0,1),wn("cf2",e,t,yn,n,0,1),wn("cf3",e,t,yn,0,-r,1),wn("cf4",e,t,yn,0,r,1),wn("cn1",e,t,yn,-n,0,-1),wn("cn2",e,t,yn,n,0,-1),wn("cn3",e,t,yn,0,-r,-1),wn("cn4",e,t,yn,0,r,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function wn(i,t,e,n,r,s,o){Dm.set(r,s,o).unproject(n);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],Dm.x,Dm.y,Dm.z)}}var ma=class extends ua{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ee;s.setIndex(new Ge(n,1)),s.setAttribute("position",new be(r,3)),super(s,new Pi({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 ig=class extends ua{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ee;r.setAttribute("position",new be(e,3)),r.setAttribute("color",new be(n,3));let s=new Pi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(t,e,n){let r=new Fe,s=this.geometry.attributes.color.array;return r.set(t),r.toArray(s,0),r.toArray(s,3),r.set(e),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:To}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=To);var iu=".",vf=Symbol("target"),Mb=Symbol("unsubscribe");function xf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function L_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var xi=Array.isArray;function Pl(i){return typeof i=="symbol"}var Hk={after:(i,t)=>xi(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>xi(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=iu),Pl(t)?i+t.toString():i+t):i,initial:i=>{if(xi(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(xi(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(xi(i))for(let e of i)t(e);else if(i!==""){let e=0,n=i.indexOf(iu);if(n===-1)t(i);else for(;e<i.length;)n===-1&&(n=i.length),t(i.slice(e,n)),e=n+1,n=i.indexOf(iu,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},zr=Hk;function Cb(i){return typeof i=="object"&&typeof i.next=="function"}function Pb(i,t,e,n,r){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=r(o.value[0],t,o.value[0],n),o.value[1]=r(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[vf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=r(a.value,t,o.next().value,n)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=r(o.value,t,o.value,n)),o};return i}function lg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Pl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var bf=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(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),r=n[e];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(t,e),n[e]=r),r}getProxy(t,e,n,r){if(this.isUnsubscribed)return t;let s=t[r],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,n):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,zr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,r,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,r):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(t);r&&(delete r[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let r=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&r!==void 0&&Object.is(t.value,r.value)&&(t.writable||!1)===(r.writable||!1)&&(t.enumerable||!1)===(r.enumerable||!1)&&(t.configurable||!1)===(r.configurable||!1)&&t.get===r.get&&t.set===r.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function su(i){return toString.call(i)==="[object Object]"}function ou(){return!0}function ga(i,t){return i.length!==t.length||i.some((e,n)=>t[n]!==e)}var cg=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var jk=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Db={push:ou,pop:ou,shift:ou,unshift:ou,copyWithin:ga,reverse:ga,sort:ga,splice:ga,flat:ga,fill:ga},N_=new Set([...cg,...jk,...Object.keys(Db)]);function au(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var Ib=["keys","values","entries"],Ob=new Set(["has","toString"]),Rb={add:au,clear:au,delete:au,forEach:au},B_=new Set([...Ob,...Object.keys(Rb),...Ib]);function lu(i,t){if(i.size!==t.size)return!0;let e;for(let[n,r]of i)if(e=t.get(n),e!==r||e===void 0&&!t.has(n))return!0;return!1}var Wk=new Set([...Ob,"get"]),Lb={set:lu,clear:lu,delete:lu,forEach:lu},F_=new Set([...Wk,...Object.keys(Lb),...Ib]);var ar=class{constructor(t,e,n,r){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return cg.has(t)}_shallowClone(t){let e=t;if(su(t))e={...t};else if(xi(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,r]of t.entries())e.set(n,this._shallowClone(r))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,r){return t?(xi(r)?this._onIsChanged=Db[e]:r instanceof Set?this._onIsChanged=Rb[e]:r instanceof Map&&(this._onIsChanged=Lb[e]),r):n}update(t,e,n){let r=zr.after(t,this._path);if(e!=="length"){let s=this.clone;zr.walk(r,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:r,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],zr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var cu=class extends ar{static isHandledMethod(t){return N_.has(t)}};var Sf=class extends ar{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var uu=class extends ar{static isHandledMethod(t){return B_.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 du=class extends ar{static isHandledMethod(t){return F_.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var wf=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._arg1=n[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 Af=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._weakKey=n[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 ts=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return su(t)||xi(t)||xf(t)}static isHandledMethod(t,e){return su(t)?ar.isHandledMethod(e):xi(t)?cu.isHandledMethod(e):t instanceof Set?uu.isHandledMethod(e):t instanceof Map?du.isHandledMethod(e):xf(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let r=ar;xi(t)?r=cu:t instanceof Date?r=Sf:t instanceof Set?r=uu:t instanceof Map?r=du:t instanceof WeakSet?r=wf:t instanceof WeakMap&&(r=Af),this._stack.push(new r(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:r}=t,s=ts.isHandledMethod(n,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var qk={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Nb=(i,t,e={})=>{e={...qk,...e};let n=Symbol("ProxyTarget"),{equals:r,isShallow:s,ignoreDetached:o,details:a}=e,l=new bf(r),u=typeof e.onValidate=="function",c=new ts(u),d=(v,x,b,w,E)=>!u||c.isCloning||e.onValidate(zr.concat(l.getPath(v),x),b,w,E)===!0,h=(v,x,b,w)=>{!lg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,b,w)},f=(v,x,b,w,E)=>{c.isCloning?c.update(v,x,w):t(zr.concat(v,x),b,w,E)},p=v=>v&&(v[n]||v),m=(v,x,b,w)=>L_(v)||b==="constructor"||s&&!ts.isHandledMethod(x,b)||lg(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,zr.concat(w,b),g,n)),g={get(v,x,b){if(Pl(x)){if(x===n||x===vf)return v;if(x===Mb&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=xf(v)?Reflect.get(v,x):Reflect.get(v,x,b);return m(w,v,x)},set(v,x,b,w){b=p(b);let E=v[n]||v,_=E[x];if(r(_,b)&&x in v)return!0;let S=d(v,x,b,_);return S&&l.setProperty(E,x,b,w,_)?(h(v,x,v[x],_),!0):!S},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let w=v[x];d(v,x,b.value,w)&&l.defineProperty(v,x,b,w)&&h(v,x,b.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),w=d(v,x,void 0,b);return w&&l.deleteProperty(v,x,b)?(h(v,x,void 0,b),!0):!w},apply(v,x,b){let w=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,b);if((a===!1||a!==!0&&!a.includes(v.name))&&ts.isHandledType(w)){let E=zr.initial(l.getPath(v)),_=ts.isHandledMethod(w,v.name);c.start(w,E,b);let S=Reflect.apply(v,c.preferredThisArg(v,x,w),_?b.map(C=>p(C)):b),T=c.isChanged(w,r),M=c.stop();if(ts.isHandledType(S)&&_&&(x instanceof Map&&v.name==="get"&&(E=zr.concat(E,b[0])),S=l.getProxy(S,E,g)),T){let C={name:v.name,args:b,result:S},D=c.isCloning?zr.initial(E):E,P=c.isCloning?zr.last(E):"";d(zr.get(i,D),P,w,M,C)?f(D,P,w,M,C):c.undo(w)}return(x instanceof Map||x instanceof Set)&&Cb(S)?Pb(S,v,x,E,m):S}return Reflect.apply(v,x,b)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};Nb.target=i=>i&&i[vf]||i;Nb.unsubscribe=i=>i[Mb]||i;var Bb=Nb;var Yk=typeof global=="object"&&global&&global.Object===Object&&global,ug=Yk;var Xk=typeof self=="object"&&self&&self.Object===Object&&self,Kk=ug||Xk||Function("return this")(),vn=Kk;var Qk=vn.Symbol,lr=Qk;var V_=Object.prototype,Zk=V_.hasOwnProperty,Jk=V_.toString,Ef=lr?lr.toStringTag:void 0;function $k(i){var t=Zk.call(i,Ef),e=i[Ef];try{i[Ef]=void 0;var n=!0}catch{}var r=Jk.call(i);return n&&(t?i[Ef]=e:delete i[Ef]),r}var k_=$k;var eU=Object.prototype,tU=eU.toString;function nU(i){return tU.call(i)}var U_=nU;var rU="[object Null]",iU="[object Undefined]",z_=lr?lr.toStringTag:void 0;function sU(i){return i==null?i===void 0?iU:rU:z_&&z_ in Object(i)?k_(i):U_(i)}var bi=sU;function oU(i){return i!=null&&typeof i=="object"}var Er=oU;var aU="[object Symbol]";function lU(i){return typeof i=="symbol"||Er(i)&&bi(i)==aU}var ya=lU;function cU(i,t){for(var e=-1,n=i==null?0:i.length,r=Array(n);++e<n;)r[e]=t(i[e],e,i);return r}var dg=cU;var uU=Array.isArray,Kn=uU;var dU=1/0,G_=lr?lr.prototype:void 0,H_=G_?G_.toString:void 0;function j_(i){if(typeof i=="string")return i;if(Kn(i))return dg(i,j_)+"";if(ya(i))return H_?H_.call(i):"";var t=i+"";return t=="0"&&1/i==-dU?"-0":t}var W_=j_;var hU=/\s/;function fU(i){for(var t=i.length;t--&&hU.test(i.charAt(t)););return t}var q_=fU;var pU=/^\s+/;function mU(i){return i&&i.slice(0,q_(i)+1).replace(pU,"")}var Y_=mU;function gU(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var zn=gU;var X_=0/0,yU=/^[-+]0x[0-9a-f]+$/i,vU=/^0b[01]+$/i,xU=/^0o[0-7]+$/i,bU=parseInt;function SU(i){if(typeof i=="number")return i;if(ya(i))return X_;if(zn(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=zn(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Y_(i);var e=vU.test(i);return e||xU.test(i)?bU(i.slice(2),e?2:8):yU.test(i)?X_:+i}var Fb=SU;function wU(i){return i}var K_=wU;var AU="[object AsyncFunction]",EU="[object Function]",_U="[object GeneratorFunction]",TU="[object Proxy]";function MU(i){if(!zn(i))return!1;var t=bi(i);return t==EU||t==_U||t==AU||t==TU}var hg=MU;var CU=vn["__core-js_shared__"],fg=CU;var Q_=function(){var i=/[^.]+$/.exec(fg&&fg.keys&&fg.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function PU(i){return!!Q_&&Q_ in i}var Z_=PU;var DU=Function.prototype,IU=DU.toString;function OU(i){if(i!=null){try{return IU.call(i)}catch{}try{return i+""}catch{}}return""}var Mo=OU;var RU=/[\\^$.*+?()[\]{}|]/g,LU=/^\[object .+?Constructor\]$/,NU=Function.prototype,BU=Object.prototype,FU=NU.toString,VU=BU.hasOwnProperty,kU=RegExp("^"+FU.call(VU).replace(RU,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function UU(i){if(!zn(i)||Z_(i))return!1;var t=hg(i)?kU:LU;return t.test(Mo(i))}var J_=UU;function zU(i,t){return i?.[t]}var $_=zU;function GU(i,t){var e=$_(i,t);return J_(e)?e:void 0}var Kr=GU;var HU=Kr(vn,"WeakMap"),pg=HU;var eT=Object.create,jU=function(){function i(){}return function(t){if(!zn(t))return{};if(eT)return eT(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),tT=jU;function WU(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 nT=WU;function qU(i,t){var e=-1,n=i.length;for(t||(t=Array(n));++e<n;)t[e]=i[e];return t}var rT=qU;var YU=800,XU=16,KU=Date.now;function QU(i){var t=0,e=0;return function(){var n=KU(),r=XU-(n-e);if(e=n,r>0){if(++t>=YU)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var iT=QU;function ZU(i){return function(){return i}}var sT=ZU;var JU=function(){try{var i=Kr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),hu=JU;var $U=hu?function(i,t){return hu(i,"toString",{configurable:!0,enumerable:!1,value:sT(t),writable:!0})}:K_,oT=$U;var ez=iT(oT),aT=ez;function tz(i,t){for(var e=-1,n=i==null?0:i.length;++e<n&&t(i[e],e,i)!==!1;);return i}var lT=tz;var nz=9007199254740991,rz=/^(?:0|[1-9]\d*)$/;function iz(i,t){var e=typeof i;return t=t??nz,!!t&&(e=="number"||e!="symbol"&&rz.test(i))&&i>-1&&i%1==0&&i<t}var fu=iz;function sz(i,t,e){t=="__proto__"&&hu?hu(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var mg=sz;function oz(i,t){return i===t||i!==i&&t!==t}var pu=oz;var az=Object.prototype,lz=az.hasOwnProperty;function cz(i,t,e){var n=i[t];(!(lz.call(i,t)&&pu(n,e))||e===void 0&&!(t in i))&&mg(i,t,e)}var mu=cz;function uz(i,t,e,n){var r=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),r?mg(e,a,l):mu(e,a,l)}return e}var Cs=uz;var cT=Math.max;function dz(i,t,e){return t=cT(t===void 0?i.length-1:t,0),function(){for(var n=arguments,r=-1,s=cT(n.length-t,0),o=Array(s);++r<s;)o[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=e(o),nT(i,this,a)}}var uT=dz;var hz=9007199254740991;function fz(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=hz}var gu=fz;function pz(i){return i!=null&&gu(i.length)&&!hg(i)}var gg=pz;var mz=Object.prototype;function gz(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||mz;return i===e}var yu=gz;function yz(i,t){for(var e=-1,n=Array(i);++e<i;)n[e]=t(e);return n}var dT=yz;var vz="[object Arguments]";function xz(i){return Er(i)&&bi(i)==vz}var Vb=xz;var hT=Object.prototype,bz=hT.hasOwnProperty,Sz=hT.propertyIsEnumerable,wz=Vb(function(){return arguments}())?Vb:function(i){return Er(i)&&bz.call(i,"callee")&&!Sz.call(i,"callee")},vu=wz;function Az(){return!1}var fT=Az;var gT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pT=gT&&typeof module=="object"&&module&&!module.nodeType&&module,Ez=pT&&pT.exports===gT,mT=Ez?vn.Buffer:void 0,_z=mT?mT.isBuffer:void 0,Tz=_z||fT,Dl=Tz;var Mz="[object Arguments]",Cz="[object Array]",Pz="[object Boolean]",Dz="[object Date]",Iz="[object Error]",Oz="[object Function]",Rz="[object Map]",Lz="[object Number]",Nz="[object Object]",Bz="[object RegExp]",Fz="[object Set]",Vz="[object String]",kz="[object WeakMap]",Uz="[object ArrayBuffer]",zz="[object DataView]",Gz="[object Float32Array]",Hz="[object Float64Array]",jz="[object Int8Array]",Wz="[object Int16Array]",qz="[object Int32Array]",Yz="[object Uint8Array]",Xz="[object Uint8ClampedArray]",Kz="[object Uint16Array]",Qz="[object Uint32Array]",rn={};rn[Gz]=rn[Hz]=rn[jz]=rn[Wz]=rn[qz]=rn[Yz]=rn[Xz]=rn[Kz]=rn[Qz]=!0;rn[Mz]=rn[Cz]=rn[Uz]=rn[Pz]=rn[zz]=rn[Dz]=rn[Iz]=rn[Oz]=rn[Rz]=rn[Lz]=rn[Nz]=rn[Bz]=rn[Fz]=rn[Vz]=rn[kz]=!1;function Zz(i){return Er(i)&&gu(i.length)&&!!rn[bi(i)]}var yT=Zz;function Jz(i){return function(t){return i(t)}}var xu=Jz;var vT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_f=vT&&typeof module=="object"&&module&&!module.nodeType&&module,$z=_f&&_f.exports===vT,kb=$z&&ug.process,eG=function(){try{var i=_f&&_f.require&&_f.require("util").types;return i||kb&&kb.binding&&kb.binding("util")}catch{}}(),Co=eG;var xT=Co&&Co.isTypedArray,tG=xT?xu(xT):yT,yg=tG;var nG=Object.prototype,rG=nG.hasOwnProperty;function iG(i,t){var e=Kn(i),n=!e&&vu(i),r=!e&&!n&&Dl(i),s=!e&&!n&&!r&&yg(i),o=e||n||r||s,a=o?dT(i.length,String):[],l=a.length;for(var u in i)(t||rG.call(i,u))&&!(o&&(u=="length"||r&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||fu(u,l)))&&a.push(u);return a}var vg=iG;function sG(i,t){return function(e){return i(t(e))}}var xg=sG;var oG=xg(Object.keys,Object),bT=oG;var aG=Object.prototype,lG=aG.hasOwnProperty;function cG(i){if(!yu(i))return bT(i);var t=[];for(var e in Object(i))lG.call(i,e)&&e!="constructor"&&t.push(e);return t}var ST=cG;function uG(i){return gg(i)?vg(i):ST(i)}var bu=uG;function dG(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var wT=dG;var hG=Object.prototype,fG=hG.hasOwnProperty;function pG(i){if(!zn(i))return wT(i);var t=yu(i),e=[];for(var n in i)n=="constructor"&&(t||!fG.call(i,n))||e.push(n);return e}var AT=pG;function mG(i){return gg(i)?vg(i,!0):AT(i)}var Su=mG;var gG=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yG=/^\w*$/;function vG(i,t){if(Kn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ya(i)?!0:yG.test(i)||!gG.test(i)||t!=null&&i in Object(t)}var ET=vG;var xG=Kr(Object,"create"),Po=xG;function bG(){this.__data__=Po?Po(null):{},this.size=0}var _T=bG;function SG(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var TT=SG;var wG="__lodash_hash_undefined__",AG=Object.prototype,EG=AG.hasOwnProperty;function _G(i){var t=this.__data__;if(Po){var e=t[i];return e===wG?void 0:e}return EG.call(t,i)?t[i]:void 0}var MT=_G;var TG=Object.prototype,MG=TG.hasOwnProperty;function CG(i){var t=this.__data__;return Po?t[i]!==void 0:MG.call(t,i)}var CT=CG;var PG="__lodash_hash_undefined__";function DG(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Po&&t===void 0?PG:t,this}var PT=DG;function wu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}wu.prototype.clear=_T;wu.prototype.delete=TT;wu.prototype.get=MT;wu.prototype.has=CT;wu.prototype.set=PT;var Ub=wu;function IG(){this.__data__=[],this.size=0}var DT=IG;function OG(i,t){for(var e=i.length;e--;)if(pu(i[e][0],t))return e;return-1}var va=OG;var RG=Array.prototype,LG=RG.splice;function NG(i){var t=this.__data__,e=va(t,i);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():LG.call(t,e,1),--this.size,!0}var IT=NG;function BG(i){var t=this.__data__,e=va(t,i);return e<0?void 0:t[e][1]}var OT=BG;function FG(i){return va(this.__data__,i)>-1}var RT=FG;function VG(i,t){var e=this.__data__,n=va(e,i);return n<0?(++this.size,e.push([i,t])):e[n][1]=t,this}var LT=VG;function Au(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}Au.prototype.clear=DT;Au.prototype.delete=IT;Au.prototype.get=OT;Au.prototype.has=RT;Au.prototype.set=LT;var xa=Au;var kG=Kr(vn,"Map"),ba=kG;function UG(){this.size=0,this.__data__={hash:new Ub,map:new(ba||xa),string:new Ub}}var NT=UG;function zG(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var BT=zG;function GG(i,t){var e=i.__data__;return BT(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Sa=GG;function HG(i){var t=Sa(this,i).delete(i);return this.size-=t?1:0,t}var FT=HG;function jG(i){return Sa(this,i).get(i)}var VT=jG;function WG(i){return Sa(this,i).has(i)}var kT=WG;function qG(i,t){var e=Sa(this,i),n=e.size;return e.set(i,t),this.size+=e.size==n?0:1,this}var UT=qG;function Eu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}Eu.prototype.clear=NT;Eu.prototype.delete=FT;Eu.prototype.get=VT;Eu.prototype.has=kT;Eu.prototype.set=UT;var Il=Eu;var YG="Expected a function";function zb(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(YG);var e=function(){var n=arguments,r=t?t.apply(this,n):n[0],s=e.cache;if(s.has(r))return s.get(r);var o=i.apply(this,n);return e.cache=s.set(r,o)||s,o};return e.cache=new(zb.Cache||Il),e}zb.Cache=Il;var zT=zb;var XG=500;function KG(i){var t=zT(i,function(n){return e.size===XG&&e.clear(),n}),e=t.cache;return t}var GT=KG;var QG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ZG=/\\(\\)?/g,JG=GT(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(QG,function(e,n,r,s){t.push(r?s.replace(ZG,"$1"):n||e)}),t}),HT=JG;function $G(i){return i==null?"":W_(i)}var jT=$G;function e4(i,t){return Kn(i)?i:ET(i,t)?[i]:HT(jT(i))}var Oi=e4;var t4=1/0;function n4(i){if(typeof i=="string"||ya(i))return i;var t=i+"";return t=="0"&&1/i==-t4?"-0":t}var wa=n4;function r4(i,t){t=Oi(t,i);for(var e=0,n=t.length;i!=null&&e<n;)i=i[wa(t[e++])];return e&&e==n?i:void 0}var bg=r4;function i4(i,t){for(var e=-1,n=t.length,r=i.length;++e<n;)i[r+e]=t[e];return i}var _u=i4;var WT=lr?lr.isConcatSpreadable:void 0;function s4(i){return Kn(i)||vu(i)||!!(WT&&i&&i[WT])}var qT=s4;function YT(i,t,e,n,r){var s=-1,o=i.length;for(e||(e=qT),r||(r=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?YT(a,t-1,e,n,r):_u(r,a):n||(r[r.length]=a)}return r}var XT=YT;function o4(i){var t=i==null?0:i.length;return t?XT(i,1):[]}var KT=o4;function a4(i){return aT(uT(i,void 0,KT),i+"")}var Sg=a4;var l4=xg(Object.getPrototypeOf,Object),Tu=l4;var c4="[object Object]",u4=Function.prototype,d4=Object.prototype,QT=u4.toString,h4=d4.hasOwnProperty,f4=QT.call(Object);function p4(i){if(!Er(i)||bi(i)!=c4)return!1;var t=Tu(i);if(t===null)return!0;var e=h4.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&QT.call(e)==f4}var ZT=p4;function m4(i,t,e){var n=-1,r=i.length;t<0&&(t=-t>r?0:r+t),e=e>r?r:e,e<0&&(e+=r),r=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(r);++n<r;)s[n]=i[n+t];return s}var JT=m4;function g4(){this.__data__=new xa,this.size=0}var $T=g4;function y4(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var eM=y4;function v4(i){return this.__data__.get(i)}var tM=v4;function x4(i){return this.__data__.has(i)}var nM=x4;var b4=200;function S4(i,t){var e=this.__data__;if(e instanceof xa){var n=e.__data__;if(!ba||n.length<b4-1)return n.push([i,t]),this.size=++e.size,this;e=this.__data__=new Il(n)}return e.set(i,t),this.size=e.size,this}var rM=S4;function Mu(i){var t=this.__data__=new xa(i);this.size=t.size}Mu.prototype.clear=$T;Mu.prototype.delete=eM;Mu.prototype.get=tM;Mu.prototype.has=nM;Mu.prototype.set=rM;var Cu=Mu;function w4(i,t){return i&&Cs(t,bu(t),i)}var iM=w4;function A4(i,t){return i&&Cs(t,Su(t),i)}var sM=A4;var cM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,oM=cM&&typeof module=="object"&&module&&!module.nodeType&&module,E4=oM&&oM.exports===cM,aM=E4?vn.Buffer:void 0,lM=aM?aM.allocUnsafe:void 0;function _4(i,t){if(t)return i.slice();var e=i.length,n=lM?lM(e):new i.constructor(e);return i.copy(n),n}var uM=_4;function T4(i,t){for(var e=-1,n=i==null?0:i.length,r=0,s=[];++e<n;){var o=i[e];t(o,e,i)&&(s[r++]=o)}return s}var dM=T4;function M4(){return[]}var wg=M4;var C4=Object.prototype,P4=C4.propertyIsEnumerable,hM=Object.getOwnPropertySymbols,D4=hM?function(i){return i==null?[]:(i=Object(i),dM(hM(i),function(t){return P4.call(i,t)}))}:wg,Pu=D4;function I4(i,t){return Cs(i,Pu(i),t)}var fM=I4;var O4=Object.getOwnPropertySymbols,R4=O4?function(i){for(var t=[];i;)_u(t,Pu(i)),i=Tu(i);return t}:wg,Ag=R4;function L4(i,t){return Cs(i,Ag(i),t)}var pM=L4;function N4(i,t,e){var n=t(i);return Kn(i)?n:_u(n,e(i))}var Eg=N4;function B4(i){return Eg(i,bu,Pu)}var Tf=B4;function F4(i){return Eg(i,Su,Ag)}var _g=F4;var V4=Kr(vn,"DataView"),Tg=V4;var k4=Kr(vn,"Promise"),Mg=k4;var U4=Kr(vn,"Set"),Cg=U4;var mM="[object Map]",z4="[object Object]",gM="[object Promise]",yM="[object Set]",vM="[object WeakMap]",xM="[object DataView]",G4=Mo(Tg),H4=Mo(ba),j4=Mo(Mg),W4=Mo(Cg),q4=Mo(pg),Ol=bi;(Tg&&Ol(new Tg(new ArrayBuffer(1)))!=xM||ba&&Ol(new ba)!=mM||Mg&&Ol(Mg.resolve())!=gM||Cg&&Ol(new Cg)!=yM||pg&&Ol(new pg)!=vM)&&(Ol=function(i){var t=bi(i),e=t==z4?i.constructor:void 0,n=e?Mo(e):"";if(n)switch(n){case G4:return xM;case H4:return mM;case j4:return gM;case W4:return yM;case q4:return vM}return t});var Do=Ol;var Y4=Object.prototype,X4=Y4.hasOwnProperty;function K4(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&X4.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var bM=K4;var Q4=vn.Uint8Array,Du=Q4;function Z4(i){var t=new i.constructor(i.byteLength);return new Du(t).set(new Du(i)),t}var Iu=Z4;function J4(i,t){var e=t?Iu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var SM=J4;var $4=/\w*$/;function eH(i){var t=new i.constructor(i.source,$4.exec(i));return t.lastIndex=i.lastIndex,t}var wM=eH;var AM=lr?lr.prototype:void 0,EM=AM?AM.valueOf:void 0;function tH(i){return EM?Object(EM.call(i)):{}}var _M=tH;function nH(i,t){var e=t?Iu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var TM=nH;var rH="[object Boolean]",iH="[object Date]",sH="[object Map]",oH="[object Number]",aH="[object RegExp]",lH="[object Set]",cH="[object String]",uH="[object Symbol]",dH="[object ArrayBuffer]",hH="[object DataView]",fH="[object Float32Array]",pH="[object Float64Array]",mH="[object Int8Array]",gH="[object Int16Array]",yH="[object Int32Array]",vH="[object Uint8Array]",xH="[object Uint8ClampedArray]",bH="[object Uint16Array]",SH="[object Uint32Array]";function wH(i,t,e){var n=i.constructor;switch(t){case dH:return Iu(i);case rH:case iH:return new n(+i);case hH:return SM(i,e);case fH:case pH:case mH:case gH:case yH:case vH:case xH:case bH:case SH:return TM(i,e);case sH:return new n;case oH:case cH:return new n(i);case aH:return wM(i);case lH:return new n;case uH:return _M(i)}}var MM=wH;function AH(i){return typeof i.constructor=="function"&&!yu(i)?tT(Tu(i)):{}}var CM=AH;var EH="[object Map]";function _H(i){return Er(i)&&Do(i)==EH}var PM=_H;var DM=Co&&Co.isMap,TH=DM?xu(DM):PM,IM=TH;var MH="[object Set]";function CH(i){return Er(i)&&Do(i)==MH}var OM=CH;var RM=Co&&Co.isSet,PH=RM?xu(RM):OM,LM=PH;var DH=1,IH=2,OH=4,NM="[object Arguments]",RH="[object Array]",LH="[object Boolean]",NH="[object Date]",BH="[object Error]",BM="[object Function]",FH="[object GeneratorFunction]",VH="[object Map]",kH="[object Number]",FM="[object Object]",UH="[object RegExp]",zH="[object Set]",GH="[object String]",HH="[object Symbol]",jH="[object WeakMap]",WH="[object ArrayBuffer]",qH="[object DataView]",YH="[object Float32Array]",XH="[object Float64Array]",KH="[object Int8Array]",QH="[object Int16Array]",ZH="[object Int32Array]",JH="[object Uint8Array]",$H="[object Uint8ClampedArray]",e5="[object Uint16Array]",t5="[object Uint32Array]",tn={};tn[NM]=tn[RH]=tn[WH]=tn[qH]=tn[LH]=tn[NH]=tn[YH]=tn[XH]=tn[KH]=tn[QH]=tn[ZH]=tn[VH]=tn[kH]=tn[FM]=tn[UH]=tn[zH]=tn[GH]=tn[HH]=tn[JH]=tn[$H]=tn[e5]=tn[t5]=!0;tn[BH]=tn[BM]=tn[jH]=!1;function Pg(i,t,e,n,r,s){var o,a=t&DH,l=t&IH,u=t&OH;if(e&&(o=r?e(i,n,r,s):e(i)),o!==void 0)return o;if(!zn(i))return i;var c=Kn(i);if(c){if(o=bM(i),!a)return rT(i,o)}else{var d=Do(i),h=d==BM||d==FH;if(Dl(i))return uM(i,a);if(d==FM||d==NM||h&&!r){if(o=l||h?{}:CM(i),!a)return l?pM(i,sM(o,i)):fM(i,iM(o,i))}else{if(!tn[d])return r?i:{};o=MM(i,d,a)}}s||(s=new Cu);var f=s.get(i);if(f)return f;s.set(i,o),LM(i)?i.forEach(function(g){o.add(Pg(g,t,e,g,i,s))}):IM(i)&&i.forEach(function(g,y){o.set(y,Pg(g,t,e,y,i,s))});var p=u?l?_g:Tf:l?Su:bu,m=c?void 0:p(i);return lT(m||i,function(g,y){m&&(y=g,g=i[y]),mu(o,y,Pg(g,t,e,y,i,s))}),o}var Dg=Pg;var n5=1,r5=4;function i5(i){return Dg(i,n5|r5)}var Io=i5;var s5="__lodash_hash_undefined__";function o5(i){return this.__data__.set(i,s5),this}var VM=o5;function a5(i){return this.__data__.has(i)}var kM=a5;function Ig(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Il;++t<e;)this.add(i[t])}Ig.prototype.add=Ig.prototype.push=VM;Ig.prototype.has=kM;var UM=Ig;function l5(i,t){for(var e=-1,n=i==null?0:i.length;++e<n;)if(t(i[e],e,i))return!0;return!1}var zM=l5;function c5(i,t){return i.has(t)}var GM=c5;var u5=1,d5=2;function h5(i,t,e,n,r,s){var o=e&u5,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 d=-1,h=!0,f=e&d5?new UM:void 0;for(s.set(i,t),s.set(t,i);++d<a;){var p=i[d],m=t[d];if(n)var g=o?n(m,p,d,t,i,s):n(p,m,d,i,t,s);if(g!==void 0){if(g)continue;h=!1;break}if(f){if(!zM(t,function(y,v){if(!GM(f,v)&&(p===y||r(p,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(p===m||r(p,m,e,n,s))){h=!1;break}}return s.delete(i),s.delete(t),h}var Og=h5;function f5(i){var t=-1,e=Array(i.size);return i.forEach(function(n,r){e[++t]=[r,n]}),e}var HM=f5;function p5(i){var t=-1,e=Array(i.size);return i.forEach(function(n){e[++t]=n}),e}var jM=p5;var m5=1,g5=2,y5="[object Boolean]",v5="[object Date]",x5="[object Error]",b5="[object Map]",S5="[object Number]",w5="[object RegExp]",A5="[object Set]",E5="[object String]",_5="[object Symbol]",T5="[object ArrayBuffer]",M5="[object DataView]",WM=lr?lr.prototype:void 0,Gb=WM?WM.valueOf:void 0;function C5(i,t,e,n,r,s,o){switch(e){case M5:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case T5:return!(i.byteLength!=t.byteLength||!s(new Du(i),new Du(t)));case y5:case v5:case S5:return pu(+i,+t);case x5:return i.name==t.name&&i.message==t.message;case w5:case E5:return i==t+"";case b5:var a=HM;case A5:var l=n&m5;if(a||(a=jM),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;n|=g5,o.set(i,t);var c=Og(a(i),a(t),n,r,s,o);return o.delete(i),c;case _5:if(Gb)return Gb.call(i)==Gb.call(t)}return!1}var qM=C5;var P5=1,D5=Object.prototype,I5=D5.hasOwnProperty;function O5(i,t,e,n,r,s){var o=e&P5,a=Tf(i),l=a.length,u=Tf(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:I5.call(t,h)))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;++d<l;){h=a[d];var y=i[h],v=t[h];if(n)var x=o?n(v,y,h,t,i,s):n(y,v,h,i,t,s);if(!(x===void 0?y===v||r(y,v,e,n,s):x)){m=!1;break}g||(g=h=="constructor")}if(m&&!g){var b=i.constructor,w=t.constructor;b!=w&&"constructor"in i&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return s.delete(i),s.delete(t),m}var YM=O5;var R5=1,XM="[object Arguments]",KM="[object Array]",Rg="[object Object]",L5=Object.prototype,QM=L5.hasOwnProperty;function N5(i,t,e,n,r,s){var o=Kn(i),a=Kn(t),l=o?KM:Do(i),u=a?KM:Do(t);l=l==XM?Rg:l,u=u==XM?Rg:u;var c=l==Rg,d=u==Rg,h=l==u;if(h&&Dl(i)){if(!Dl(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new Cu),o||yg(i)?Og(i,t,e,n,r,s):qM(i,t,l,e,n,r,s);if(!(e&R5)){var f=c&&QM.call(i,"__wrapped__"),p=d&&QM.call(t,"__wrapped__");if(f||p){var m=f?i.value():i,g=p?t.value():t;return s||(s=new Cu),r(m,g,e,n,s)}}return h?(s||(s=new Cu),YM(i,t,e,n,r,s)):!1}var ZM=N5;function JM(i,t,e,n,r){return i===t?!0:i==null||t==null||!Er(i)&&!Er(t)?i!==i&&t!==t:ZM(i,t,e,n,JM,r)}var $M=JM;function B5(i,t){return i!=null&&t in Object(i)}var eC=B5;function F5(i,t,e){t=Oi(t,i);for(var n=-1,r=t.length,s=!1;++n<r;){var o=wa(t[n]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++n!=r?s:(r=i==null?0:i.length,!!r&&gu(r)&&fu(o,r)&&(Kn(i)||vu(i)))}var tC=F5;function V5(i,t){return i!=null&&tC(i,t,eC)}var nC=V5;var k5=function(){return vn.Date.now()},Lg=k5;var U5="Expected a function",z5=Math.max,G5=Math.min;function H5(i,t,e){var n,r,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof i!="function")throw new TypeError(U5);t=Fb(t)||0,zn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?z5(Fb(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(E){var _=n,S=r;return n=r=void 0,u=E,o=i.apply(S,_),o}function p(E){return u=E,a=setTimeout(y,t),c?f(E):o}function m(E){var _=E-l,S=E-u,T=t-_;return d?G5(T,s-S):T}function g(E){var _=E-l,S=E-u;return l===void 0||_>=t||_<0||d&&S>=s}function y(){var E=Lg();if(g(E))return v(E);a=setTimeout(y,m(E))}function v(E){return a=void 0,h&&n?f(E):(n=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0}function b(){return a===void 0?o:v(Lg())}function w(){var E=Lg(),_=g(E);if(n=arguments,r=this,l=E,_){if(a===void 0)return p(l);if(d)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=b,w}var Rl=H5;function j5(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var rC=j5;function W5(i,t){return t.length<2?i:bg(i,JT(t,0,-1))}var iC=W5;function q5(i,t){return $M(i,t)}var Mf=q5;function Y5(i,t){return t=Oi(t,i),i=iC(i,t),i==null||delete i[wa(rC(t))]}var sC=Y5;function X5(i){return ZT(i)?void 0:i}var oC=X5;var K5=1,Q5=2,Z5=4,J5=Sg(function(i,t){var e={};if(i==null)return e;var n=!1;t=dg(t,function(s){return s=Oi(s,i),n||(n=s.length>1),s}),Cs(i,_g(i),e),n&&(e=Dg(e,K5|Q5|Z5,oC));for(var r=t.length;r--;)sC(e,t[r]);return e}),Ou=J5;function $5(i,t,e,n){if(!zn(i))return i;t=Oi(t,i);for(var r=-1,s=t.length,o=s-1,a=i;a!=null&&++r<s;){var l=wa(t[r]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(r!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=zn(c)?c:fu(t[r+1])?[]:{})}mu(a,l,u),a=a[l]}return i}var aC=$5;function ej(i,t,e){for(var n=-1,r=t.length,s={};++n<r;){var o=t[n],a=bg(i,o);e(a,o)&&aC(s,Oi(o,i),a)}return s}var lC=ej;function tj(i,t){return lC(i,t,function(e,n){return nC(i,n)})}var cC=tj;var nj=Sg(function(i,t){return i==null?{}:cC(i,t)}),Si=nj;var rj="Expected a function";function ij(i,t,e){var n=!0,r=!0;if(typeof i!="function")throw new TypeError(rj);return zn(e)&&(n="leading"in e?!!e.leading:n,r="trailing"in e?!!e.trailing:r),Rl(i,t,{leading:n,maxWait:t,trailing:r})}var Hb=ij;function uC(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Qr(i,t){return Object.setPrototypeOf(i,t),i}var sj=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),oj=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),aj=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ll&&"ontouchend"in document,lj=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,cj=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,uj=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},dj=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},hj=()=>{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"},fj=sj(),tie=fj?hj():void 0,Ll=oj(),Ng=aj(),dC=lj(),Qn=cj(),jb=uj(),Wb=Number(dj());function Bg(i){return Array.isArray(i)?i:[i]}function hC(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 Cf(i){return Ll?i.metaKey:i.ctrlKey}var We=[],Vg={},Pf={},Fg={};function fC(i){We.includes(i)||We.push(i)}function Ru(i){delete Vg[i.pointerId];for(let t=0;t<We.length;t++)if(We[t].pointerId===i.pointerId){We.splice(t,1);break}}function pC(){We.splice(0,We.length)}function kg(i){if(i.pointerType!=="touch")return;let t=Vg[i.pointerId];t===void 0&&(t={x:0,y:0},Vg[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function Ug(i){let t=i.pointerId===We[0].pointerId?We[1]:We[0];return Vg[t.pointerId]}function mC(i){Pf[i.key]=!0,Fg[i.key]=Fg[i.key]===void 0?1:Fg[i.key]+1}function gC(i){if(Ll&&Pf.Meta)for(let t in Pf)Pf[t]=!1;else Pf[i.key]=!1;Fg={}}function yC(i){i.addEventListener("pointerdown",fC,!0),i.addEventListener("pointerdown",kg,!0),i.addEventListener("pointermove",kg,!0),i.addEventListener("pointerup",Ru,!0),i.addEventListener("pointercancel",Ru,!0),i.addEventListener("pointerleave",Ru,!0),window.addEventListener("keydown",mC,!0),window.addEventListener("keyup",gC,!0)}function vC(i){i.removeEventListener("pointerdown",fC,!0),i.removeEventListener("pointerdown",kg,!0),i.removeEventListener("pointermove",kg,!0),i.removeEventListener("pointerup",Ru,!0),i.removeEventListener("pointercancel",Ru,!0),i.removeEventListener("pointerleave",Ru,!0),window.removeEventListener("keydown",mC,!0),window.removeEventListener("keyup",gC,!0)}var xC,bC=new Promise(i=>{xC=i});var zg;function SC(){if(zg)return zg;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.494/build",r=import("./navmesh.js"),[s,o]=await Promise.all([r,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});xC(l)}return zg=i(),zg}var wC,AC=new Promise(i=>{wC=i});var Gg;function EC(){if(Gg)return Gg;async function i(){let e=await import("./physics.js");await e.init(),wC(e)}return Gg=i(),Gg}var tt=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,tt.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 n=e[t.id],r;n===void 0?r={type:2,id:t.id}:r={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,tt.prototype),{data:a,actual:t,reverse:r}}else if(t.type===2){let{id:n}=t,r=e[n];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,tt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:r}}}}return null}};function Df(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let n=i[e];n&&typeof n=="object"&&Df(n)}return Object.freeze(i)}function _C(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 Lu=class extends Error{};function Hg(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ps(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 n=[],r=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*r;n.push(o)}return n}function Nu(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 TC(){return typeof process<"u"}function MC(i,t){for(let e of i)t(e.id,e.data)!==!0&&MC(e.children,t)}function CC(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)CC(e,t)}var cn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,cn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Df(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let r of e.children)this.fillCaches0(r,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,n){if(!this.has(e))return!0;for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}rootAcestor(e){for(;e;){let n=this.parent(e);if(n)e=n;else return e}return e}isDescendantOf(e,n){for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}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,n){if(e===null)this.traverse(n);else{let r=this.get(e);r&&CC(r,n)}}traverse(e){MC(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,n){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:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let r=e,s=n;for(;r!==null;){let a=s,l=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);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,cn.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:n}){if(this.get(e)!==void 0)return!0;for(let r of n)if(this.checkDuplicatedIdRec(r))return!0;return!1}addOp(e){let{parent:n,fi:r,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:r,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let r=this.parent(n);if(r===void 0)return null;let s=this.childrenArray(r),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(r,s),actual:e,reverse:{type:7,...a,parent:r}}}}moveOp(e){let{parent:n,fi:r,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Lu("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],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:r},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let r=null;for(let s of this.childrenArray(e)){if(s.id===n)return r;r=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)+1;if(s<r.length)return r[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(r[s].id):n}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push({...r,...s})}n.sort((r,s)=>_C(r.sortKey,s.sortKey));for(let r of n)delete r.sortKey;return n}getWithSortKey(e){var n=e;let r=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)r.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:r}}}insertBeforeHelper(e,n,r){return this.insertAfterHelper(e,this.previous(e,n),r)}insertAfterHelper(e,n,r){let s=this.childrenArray(e);if(n===null){if(s.length===0)return Ps(0,r,r);{let o=s[0].fi;return Ps(o-r,o,r)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==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 Ps(l,l+r,r)}else return Ps(o.fi,a.fi,r)}}};var Bu;(t=>{function i(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let r=n.props,s={},o=[...e],a=!1;if(r)for(let l of Object.keys(r)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=r[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let r=n.props,s={},o={...e},a=!1;if(r)for(let l of Object.keys(r)){s[l]=o[l];let u=r[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=i})(Bu||(Bu={}));var Re=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Re.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Df(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,n){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:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Re.prototype);let n=e;return TC()||n.fillCaches(),n}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:n,id:r,data:s}=e,o=this,a={fi:n,id:r,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:r}}}deleteOp(e){let{id:n}=e,r=this,s=r.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,r=[...r];let o=r.splice(s,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:r}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===r);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let r of this){if(r.id===e)return n;n=r.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let r=this;if(e===null){if(r.length===0)return Ps(0,n,n);{let s=r[0].fi;return Ps(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=r.find(a=>a.fi>s.fi);if(o===void 0){let a=r[r.length-1].fi;return Ps(a,a+n,n)}else return Ps(s.fi,o.fi,n)}}};function Fu(i){return i&&typeof i=="object"&&i instanceof Yt}var Yt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,r=0,s={};for(;r<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[r]],n!==void 0&&!Fu(n))return null;r+=1}n=n?Hg(n):new Yt;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;r>0;){if(Object.keys(n).length===0){let l=e[r-1];l&&(n=Hg(l),delete n[t.path[r-1]])}else{let l=e[r-1];if(l){let u=Hg(l);u[t.path[r-1]]=n,n=u}else{let u=new Yt;u[t.path[r-1]]=n,n=u}}r-=1}let o=Object.setPrototypeOf(n,Yt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Ds;(n=>{function i(r,s){return If(r,s)??r}n.apply=i;function t(r,s){return Yb(r,s)}n.merge=t;function e(r,s){let o=0,a=s.path,l=r;for(;o<a.length&&l!==void 0;){if(l=_n.zoomOnce(l,a[o]),l===void 0)return s;if(!Fu(l))return;o+=1}if(l===void 0)return s;if(!!Fu(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=qb([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(Ds||(Ds={}));function qb(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=If(r.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=r.data),r.children){let a=qb(r.children,t);return a!==void 0?e=!0:a=r.children,{...r,id:s,data:o,children:a}}else return{...r,id:s,data:o}});if(e)return n}function pj(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=If(r.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=r.data),{...r,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function If(i,t){if(!Fu(t))return t;if(i instanceof cn){let e=qb(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Re)return pj(i,t);if(Array.isArray(i)){let e=!1,n=i.map((r,s)=>{let o=If(r,t[s]);return e=e||o!==void 0,o===void 0&&(o=r),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else{if(i instanceof Yt)return Yb(i,t);if(i&&typeof i=="object"){let e={},n=!1;for(let[r,s]of Object.entries(i)){let o=If(s,t[r]);n=n||o!==void 0,o===void 0&&(o=s),e[r]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Yb(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Fu(t))return t;if(!Fu(i))return Ds.apply(i,t);let e=new Set;for(let r of Object.keys(i))e.add(r);for(let r of Object.keys(t))e.add(r);let n=new Yt;for(let r of e){let s=Yb(i===void 0?void 0:i[r],t===void 0?void 0:t[r]);n[r]=s}return n}function PC(i,t){let e={cur:[],result:[],len:0};return i=Of(i,t,e)??i,[i,e.result]}function jg(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Wg(i){i&&(i.len-=1)}function mj(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function DC(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Of(s.data,t,jg(e,o));Wg(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=DC(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return r}function gj(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Of(s.data,t,jg(e,o));return Wg(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Of(i,t,e){if(i instanceof cn){let n=DC(i,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}else{if(i instanceof Re)return gj(i,t,e);if(Array.isArray(i)){let n=!1,r=i.map((s,o)=>{let a=Of(s,t,jg(e,o));return Wg(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(i&&typeof i=="object"&&!Nu(i)){let n={},r=!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");r=!0,s=a}let l=Of(o,t,jg(e,s));Wg(e),r=r||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(typeof i=="string"){let n=t[i];return n!==void 0&&mj(e),n}else return}}var qg;(t=>{function i(e,n){let r=_n.zoom(n,e.path);if(typeof r=="object"){let s={};for(let o of Object.keys(e.props))s[o]=r[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(qg||(qg={}));var Tn;(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 d=[];;){let h;if(l instanceof Yt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof cn||l instanceof Re||l instanceof tt?h=l.runOp(u):h=Bu.runOp(l,u)),h!==void 0)if(h!==null){let m=h.data;for(let g=d.length-1;g>=0;g--){let y=c[g],v=d[g];if(v instanceof cn){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Re){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof tt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Yt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Yt.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:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],p;if(l instanceof cn){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Re){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)d.push(l),l=p;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function r(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=r;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&r(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(Tn||(Tn={}));var Rf;(l=>{function i(){return[]}l.empty=i;function t(u,c){let d=[];for(let h of u){let[f,...p]=h.path;f===c&&d.push({...h,path:p})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function r(u,c){return[...u.filter(h=>!c.some(f=>Tn.subsumed(h,f))),...c]}l.compress=r;function s(u,c){return u.every(d=>c.every(h=>Tn.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],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=_n.zoom(d,[...p.path,p.id]),y=Tn.apply(d,{...p,type:2})):(m=_n.zoom(d,[...p.path,p.id,"value"]),y=Tn.apply(d,p)),y!==null){d=y.data;let[v,x]=PC(d,{[p.id]:m});d=v;for(let b=0;b<x.length;b++){let w=x[b],E=w.pop();if(typeof E=="number"){let _=[E];for(let T=b+1;T<x.length;T++){let M=x[T],C=M[M.length-1];if(typeof C=="number"&&_n.equal(w,M.slice(0,M.length-1)))_.push(C),x.splice(T,1);else break}let S=_n.zoom(d,w);g=S.map((T,M)=>_.includes(M)?p.id:T),m=S,E=w.pop()}else{if(E==="alphaOverride"||E==="alpha"){m/=100;let _=m,S=_n.zoom(d,w.slice(0,w.length-2)),T=S.layers.map(M=>M.id===w[w.length-1]?{...M,data:{...M.data,[E]:_}}:M);Object.setPrototypeOf(T,Object.getPrototypeOf(S.layers)),S.layers=T}g=p.id}h.push({type:0,path:w,props:{[E]:m}}),f.push({type:0,path:w,props:{[E]:g}})}f.push(y.reverse),h.push(y.actual)}}else{let m=Tn.apply(d,p);m!==null&&(h.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Lu)return null;throw m}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(Rf||(Rf={}));var IC=Symbol(),yj=Symbol(),Xg=Symbol(),Nl=class{reportOp(t,e,n=[]){let r=this;if(e===null)return;r._current=e.data;let s=n;for(;!(r instanceof Yg);){let o=r._path,a=r._current;if(o!==""&&s.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[Xg];n&&n(),delete this._children[t]}}}},Kb=class extends Nl{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}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,Bu.runOp(this._current,t),t.path)}},Qb=class extends Nl{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,tt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},OC={get(i,t){if(t===Xg)return()=>{i._parent=null};if(t===IC)return i._current;if(t===yj)return i;let{_current:e,_children:n}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e[t],o=Kg(i,t,s);return o!==s?(n===void 0&&(n={},i._children=n),n[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,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},vj={...OC,set(i,t,e){let n={type:0,props:{[t]:pn(e)??e}};return i.deleteChildren(t),i.runOp(n),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},xj={...OC,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}},Vu=class extends Nl{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Xg]=()=>{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,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Kg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,r,s){this.runOp({type:7,parent:t,fi:e,id:n,data:r,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}moveBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[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)}},ku=class extends Nl{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Xg]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),r,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id;if(t(this.data(r),r))return this.get(r)}}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:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Kg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Xb(i,t,e){if(i.length>0){let n=i[i.length-1];if(n.type===0&&t.type===0&&_n.equal(n.path,e)){Object.assign(n.props,t.props);return}}i.push({...t,path:e})}var Yg=class extends Nl{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,n,r){Xb(this.ts,e,t),Xb(this.actual,n,t),Xb(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Kg(i,t,e){return e instanceof cn?new Vu(i,t,e):e instanceof Re?new ku(i,t,e):e instanceof tt?new Proxy(new Qb(i,t,e),xj):e!==null&&typeof e=="object"?Nu(e)?e:new Proxy(new Kb(i,t,e),vj):e}function Zb(i){let t=new Yg(i);return[Kg(t,"",i),t]}function Aa(i,t){let[e,n]=Zb(i);return t(e),n.result()}function pn(i){return i instanceof Vu||i instanceof ku?i._current:i!==null&&typeof i=="object"?i[IC]:i}var _n;(r=>{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}r.equal=i;function t(s,o,a){let l=n(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}r.removeOverridden=t;function e(s,o){if((s instanceof cn||s instanceof Vu)&&typeof o=="string")return s.data(o);if((s instanceof Re||s instanceof ku)&&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]}r.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}r.zoom=n})(_n||(_n={}));function RC(i,t){let e=[];if(t.length===i.length)for(var n=0;n<i.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}function Rr(i,t){let e=[];if(t.length<=i.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}var Qg=class{},Lf=class extends Qg{constructor(e){super();this.id=e}},Nf=class extends Qg{constructor(e){super();this.data=e}};var $b;try{$b=new TextDecoder}catch{}var Ne,_a,J=0;var zC=[],eS=zC,tS=0,Zr={},Ot,Ea,Ri=0,Is=0,wi,Oo,Gr=[],kt,LC={useRecords:!1,mapsAsObjects:!0},Bf=class{},rS=new Bf;rS.name="MessagePack 0xC1";var Uu=!1,Os=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(Ne)return qC(()=>(Jg(),this?this.unpack(t,e):Os.prototype.unpack.call(LC,t,e)));_a=e>-1?e:t.length,J=0,tS=0,Is=0,Ea=null,eS=zC,wi=null,Ne=t;try{kt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Ne=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Os){if(Zr=this,this.structures)return Ot=this.structures,Zg();(!Ot||Ot.length>0)&&(Ot=[])}else Zr=LC,(!Ot||Ot.length>0)&&(Ot=[]);return Zg()}unpackMultiple(t,e){let n,r=0;try{Uu=!0;let s=t.length,o=this?this.unpack(t,s):ty.unpack(t,s);if(e){for(e(o);J<s;)if(r=J,e(Zg())===!1)return}else{for(n=[o];J<s;)r=J,n.push(Zg());return n}}catch(s){throw s.lastPosition=r,s.values=n,s}finally{Uu=!1,Jg()}}_mergeStructures(t,e){t=t||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let r=t[n],s=e[n];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[n]=r),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Zg(){try{if(!Zr.trusted&&!Uu){let t=Ot.sharedLength||0;t<Ot.length&&(Ot.length=t)}let i=xn();if(J==_a)Ot.restoreStructures&&NC(),Ot=null,Ne=null,Oo&&(Oo=null);else if(J>_a){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Uu)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Ot.restoreStructures&&NC(),Jg(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function NC(){for(let i in Ot.restoreStructures)Ot[i]=Ot.restoreStructures[i];Ot.restoreStructures=null}function xn(){let i=Ne[J++];if(i<160)if(i<128){if(i<64)return i;{let t=Ot[i&63]||Zr.getStructures&&GC()[i&63];return t?(t.read||(t.read=iS(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[jC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}else if(i<192){let t=i-160;if(Is>=J)return Ea.slice(J-Ri,(J+=t)-Ri);if(Is==0&&_a<140){let e=t<16?sS(t):HC(t);if(e!=null)return e}return nS(t)}else{let t;switch(i){case 192:return null;case 193:return wi?(t=xn(),t>0?wi[1].slice(wi.position1,wi.position1+=t):wi[0].slice(wi.position0,wi.position0-=t)):rS;case 194:return!1;case 195:return!0;case 196:return Jb(Ne[J++]);case 197:return t=kt.getUint16(J),J+=2,Jb(t);case 198:return t=kt.getUint32(J),J+=4,Jb(t);case 199:return Bl(Ne[J++]);case 200:return t=kt.getUint16(J),J+=2,Bl(t);case 201:return t=kt.getUint32(J),J+=4,Bl(t);case 202:if(t=kt.getFloat32(J),Zr.useFloat32>2){let e=ey[(Ne[J]&127)<<1|Ne[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=kt.getFloat64(J),J+=8,t;case 204:return Ne[J++];case 205:return t=kt.getUint16(J),J+=2,t;case 206:return t=kt.getUint32(J),J+=4,t;case 207:return Zr.int64AsNumber?(t=kt.getUint32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigUint64(J),J+=8,t;case 208:return kt.getInt8(J++);case 209:return t=kt.getInt16(J),J+=2,t;case 210:return t=kt.getInt32(J),J+=4,t;case 211:return Zr.int64AsNumber?(t=kt.getInt32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigInt64(J),J+=8,t;case 212:if(t=Ne[J++],t==114)return UC(Ne[J++]&63);{let e=Gr[t];if(e)return e.read?(J++,e.read(xn())):e.noBuffer?(J++,e()):e(Ne.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=Ne[J],t==114?(J++,UC(Ne[J++]&63,Ne[J++])):Bl(2);case 214:return Bl(4);case 215:return Bl(8);case 216:return Bl(16);case 217:return t=Ne[J++],Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):Sj(t);case 218:return t=kt.getUint16(J),J+=2,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):wj(t);case 219:return t=kt.getUint32(J),J+=4,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):Aj(t);case 220:return t=kt.getUint16(J),J+=2,FC(t);case 221:return t=kt.getUint32(J),J+=4,FC(t);case 222:return t=kt.getUint16(J),J+=2,VC(t);case 223:return t=kt.getUint32(J),J+=4,VC(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 bj=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function iS(i,t){function e(){if(e.count++>2){let r=i.read=new Function("r","return function(){return {"+i.map(s=>bj.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(xn);return i.highByte===0&&(i.read=BC(t,i.read)),r()}let n={};for(let r=0,s=i.length;r<s;r++){let o=i[r];n[o]=xn()}return n}return e.count=0,i.highByte===0?BC(t,e):e}var BC=(i,t)=>function(){let e=Ne[J++];if(e===0)return t();let n=i<32?-(i+(e<<5)):i+(e<<5),r=Ot[n]||GC()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=iS(r,i)),r.read()};function GC(){let i=qC(()=>(Ne=null,Zr.getStructures()));return Ot=Zr._mergeStructures(i,Ot)}var nS=$g,Sj=$g,wj=$g,Aj=$g;function $g(i){let t;if(i<16&&(t=sS(i)))return t;if(i>64&&$b)return $b.decode(Ne.subarray(J,J+=i));let e=J+i,n=[];for(t="";J<e;){let r=Ne[J++];if((r&128)===0)n.push(r);else if((r&224)===192){let s=Ne[J++]&63;n.push((r&31)<<6|s)}else if((r&240)===224){let s=Ne[J++]&63,o=Ne[J++]&63;n.push((r&31)<<12|s<<6|o)}else if((r&248)===240){let s=Ne[J++]&63,o=Ne[J++]&63,a=Ne[J++]&63,l=(r&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(r);n.length>=4096&&(t+=ur.apply(String,n),n.length=0)}return n.length>0&&(t+=ur.apply(String,n)),t}function FC(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}function VC(i){if(Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[jC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}}var ur=String.fromCharCode;function HC(i){let t=J,e=new Array(i);for(let n=0;n<i;n++){let r=Ne[J++];if((r&128)>0){J=t;return}e[n]=r}return ur.apply(String,e)}function sS(i){if(i<4)if(i<2){if(i===0)return"";{let t=Ne[J++];if((t&128)>1){J-=1;return}return ur(t)}}else{let t=Ne[J++],e=Ne[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(i<3)return ur(t,e);let n=Ne[J++];if((n&128)>0){J-=3;return}return ur(t,e,n)}else{let t=Ne[J++],e=Ne[J++],n=Ne[J++],r=Ne[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(r&128)>0){J-=4;return}if(i<6){if(i===4)return ur(t,e,n,r);{let s=Ne[J++];if((s&128)>0){J-=5;return}return ur(t,e,n,r,s)}}else if(i<8){let s=Ne[J++],o=Ne[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(i<7)return ur(t,e,n,r,s,o);let a=Ne[J++];if((a&128)>0){J-=7;return}return ur(t,e,n,r,s,o,a)}else{let s=Ne[J++],o=Ne[J++],a=Ne[J++],l=Ne[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(i<10){if(i===8)return ur(t,e,n,r,s,o,a,l);{let u=Ne[J++];if((u&128)>0){J-=9;return}return ur(t,e,n,r,s,o,a,l,u)}}else if(i<12){let u=Ne[J++],c=Ne[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(i<11)return ur(t,e,n,r,s,o,a,l,u,c);let d=Ne[J++];if((d&128)>0){J-=11;return}return ur(t,e,n,r,s,o,a,l,u,c,d)}else{let u=Ne[J++],c=Ne[J++],d=Ne[J++],h=Ne[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(i<14){if(i===12)return ur(t,e,n,r,s,o,a,l,u,c,d,h);{let f=Ne[J++];if((f&128)>0){J-=13;return}return ur(t,e,n,r,s,o,a,l,u,c,d,h,f)}}else{let f=Ne[J++],p=Ne[J++];if((f&128)>0||(p&128)>0){J-=14;return}if(i<15)return ur(t,e,n,r,s,o,a,l,u,c,d,h,f,p);let m=Ne[J++];if((m&128)>0){J-=15;return}return ur(t,e,n,r,s,o,a,l,u,c,d,h,f,p,m)}}}}}function Jb(i){return Zr.copyBuffers?Uint8Array.prototype.slice.call(Ne,J,J+=i):Ne.subarray(J,J+=i)}function Bl(i){let t=Ne[J++];if(Gr[t])return Gr[t](Ne.subarray(J,J+=i));throw new Error("Unknown extension type "+t)}var kC=new Array(4096);function jC(){let i=Ne[J++];if(i>=160&&i<192){if(i=i-160,Is>=J)return Ea.slice(J-Ri,(J+=i)-Ri);if(!(Is==0&&_a<180))return nS(i)}else return J--,xn();let t=(i<<5^(i>1?kt.getUint16(J):i>0?Ne[J]:0))&4095,e=kC[t],n=J,r=J+i-3,s,o=0;if(e&&e.bytes==i){for(;n<r;){if(s=kt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(r+=3;n<r;)if(s=Ne[n++],s!=e[o++]){n=1879048192;break}if(n===r)return J=n,e.string;r-=3,n=J}for(e=[],kC[t]=e,e.bytes=i;n<r;)s=kt.getUint32(n),e.push(s),n+=4;for(r+=3;n<r;)s=Ne[n++],e.push(s);let a=i<16?sS(i):HC(i);return a!=null?e.string=a:e.string=nS(i)}var UC=(i,t)=>{var e=xn();let n=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let r=Ot[i];return r&&r.isShared&&((Ot.restoreStructures||(Ot.restoreStructures=[]))[i]=r),Ot[i]=e,e.read=iS(e,n),e.read()},WC=typeof self=="object"?self:global;Gr[0]=()=>{};Gr[0].noBuffer=!0;Gr[101]=()=>{let i=xn();return(WC[i[0]]||Error)(i[1])};Gr[105]=i=>{let t=kt.getUint32(J-4);Oo||(Oo=new Map);let e=Ne[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let r={target:n};Oo.set(t,r);let s=xn();return r.used?Object.assign(n,s):(r.target=s,s)};Gr[112]=i=>{let t=kt.getUint32(J-4),e=Oo.get(t);return e.used=!0,e.target};Gr[115]=()=>new Set(xn());var oS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Gr[116]=i=>{let t=i[0],e=oS[t];if(!e)throw new Error("Could not find typed array for code "+t);return new WC[e](Uint8Array.prototype.slice.call(i,1).buffer)};Gr[120]=()=>{let i=xn();return new RegExp(i[0],i[1])};Gr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=J;J+=t-4,wi=[xn(),xn()],wi.position0=0,wi.position1=0;let n=J;J=e;try{return xn()}finally{J=n}};Gr[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 qC(i){let t=_a,e=J,n=tS,r=Ri,s=Is,o=Ea,a=eS,l=Oo,u=wi,c=new Uint8Array(Ne.slice(0,_a)),d=Ot,h=Ot.slice(0,Ot.length),f=Zr,p=Uu,m=i();return _a=t,J=e,tS=n,Ri=r,Is=s,Ea=o,eS=a,Oo=l,wi=u,Ne=c,Uu=p,Ot=d,Ot.splice(0,Ot.length,...h),Zr=f,kt=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),m}function Jg(){Ne=null,Oo=null,Ot=null}function YC(i){i.unpack?Gr[i.type]=i.unpack:Gr[i.type]=i}var ey=new Array(147);for(let i=0;i<256;i++)ey[i]=+("1e"+Math.floor(45.15-i*.30103));var ty=new Os({useRecords:!1}),Ej=ty.unpack,_j=ty.unpackMultiple,Tj=ty.unpack,ny={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Mj=new Float32Array(1),hse=new Uint8Array(Mj.buffer,0,4);var ry;try{ry=new TextEncoder}catch{}var iy,lS,sy=typeof Buffer<"u",aS=sy?Buffer.allocUnsafeSlow:Uint8Array,ZC=sy?Buffer:Uint8Array,XC=sy?4294967296:2144337920,he,Mn,re=0,Rs,Ls=null,Cj=/[\u0080-\uFFFF]/,Ff=Symbol("record-id"),Fl=class extends Os{constructor(t){super(t),this.offset=0;let e,n,r,s,o,a,l=0,u=ZC.prototype.utf8Write?function(S,T,M){return he.utf8Write(S,T,M)}:ry&&ry.encodeInto?function(S,T){return ry.encodeInto(S,he.subarray(T)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=h?32:64),d&&!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,b=0;this.pack=this.encode=function(S,T){if(he||(he=new aS(8192),Mn=new DataView(he.buffer,0,8192),re=0),Rs=he.length-10,Rs-re<2048?(he=new aS(he.length),Mn=new DataView(he.buffer,0,he.length),Rs=he.length-10,re=0):re=re+7&2147483640,n=re,a=c.structuredClone?new Map:null,c.bundleStrings?(Ls=["",""],he[re++]=214,he[re++]=98,Ls.position=re-n,re+=4):Ls=null,r=c.structures,r){r.uninitialized&&(r=c._mergeStructures(c.getStructures()));let M=r.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let D=r[C];if(!D)continue;let P,I=r.transitions;for(let L=0,H=D.length;L<H;L++){let k=D[L];P=I[k],P||(P=I[k]=Object.create(null)),I=P}I[Ff]=C+64}l=M}d||(r.nextId=M+64)}s&&(s=!1),o=r||[];try{if(w(S),Ls){Mn.setUint32(Ls.position+n,re-Ls.position-n);let M=Ls;Ls=null,w(M[0]),w(M[1])}if(c.offset=re,a&&a.idsToInsert){re+=a.idsToInsert.length*6,re>Rs&&_(re),c.offset=re;let M=Dj(he.subarray(n,re),a.idsToInsert);return a=null,M}return T&$C?(he.start=n,he.end=re,he):he.subarray(n,re)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,C=v.length;M<C;M++)v[M][Ff]=0;v=[]}if(s&&c.saveStructures){let M=r.sharedLength||f;r.length>M&&(r=r.slice(0,M));let C=he.subarray(n,re);return c.saveStructures(r,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(S)):(l=M,C)}}T&Fj&&(re=n)}};let w=S=>{re>Rs&&(he=_(re));var T=typeof S,M;if(T==="string"){let C=S.length;if(Ls&&C>=8&&C<4096){let I=Cj.test(S);Ls[I?0:1]+=S,he[re++]=193,w(I?-C:C);return}let D;C<32?D=1:C<256?D=2:C<65536?D=3:D=5;let P=C*3;if(re+P>Rs&&(he=_(re+P)),C<64||!u){let I,L,H,k=re+D;for(I=0;I<C;I++)L=S.charCodeAt(I),L<128?he[k++]=L:L<2048?(he[k++]=L>>6|192,he[k++]=L&63|128):(L&64512)===55296&&((H=S.charCodeAt(I+1))&64512)===56320?(L=65536+((L&1023)<<10)+(H&1023),I++,he[k++]=L>>18|240,he[k++]=L>>12&63|128,he[k++]=L>>6&63|128,he[k++]=L&63|128):(he[k++]=L>>12|224,he[k++]=L>>6&63|128,he[k++]=L&63|128);M=k-re-D}else M=u(S,re+D,P);M<32?he[re++]=160|M:M<256?(D<2&&he.copyWithin(re+2,re+1,re+1+M),he[re++]=217,he[re++]=M):M<65536?(D<3&&he.copyWithin(re+3,re+2,re+2+M),he[re++]=218,he[re++]=M>>8,he[re++]=M&255):(D<5&&he.copyWithin(re+5,re+3,re+3+M),he[re++]=219,Mn.setUint32(re,M),re+=4),re+=M}else if(T==="number")if(S>>>0===S)S<64?he[re++]=S:S<256?(he[re++]=204,he[re++]=S):S<65536?(he[re++]=205,he[re++]=S>>8,he[re++]=S&255):(he[re++]=206,Mn.setUint32(re,S),re+=4);else if(S>>0===S)S>=-32?he[re++]=256+S:S>=-128?(he[re++]=208,he[re++]=S+256):S>=-32768?(he[re++]=209,Mn.setInt16(re,S),re+=2):(he[re++]=210,Mn.setInt32(re,S),re+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){he[re++]=202,Mn.setFloat32(re,S);let D;if(C<4||(D=S*ey[(he[re]&127)<<1|he[re+1]>>7])>>0===D){re+=4;return}else re--}he[re++]=203,Mn.setFloat64(re,S),re+=8}else if(T==="object")if(!S)he[re++]=192;else{if(a){let D=a.get(S);if(D){if(!D.id){let P=a.idsToInsert||(a.idsToInsert=[]);D.id=P.push(D)}he[re++]=214,he[re++]=112,Mn.setUint32(re,D.id),re+=4;return}else a.set(S,{offset:re-n})}let C=S.constructor;if(C===Object)E(S,!0);else if(C===Array){M=S.length,M<16?he[re++]=144|M:M<65536?(he[re++]=220,he[re++]=M>>8,he[re++]=M&255):(he[re++]=221,Mn.setUint32(re,M),re+=4);for(let D=0;D<M;D++)w(S[D])}else if(C===Map){M=S.size,M<16?he[re++]=128|M:M<65536?(he[re++]=222,he[re++]=M>>8,he[re++]=M&255):(he[re++]=223,Mn.setUint32(re,M),re+=4);for(let[D,P]of S)w(D),w(P)}else{for(let D=0,P=iy.length;D<P;D++){let I=lS[D];if(S instanceof I){let L=iy[D];if(L.write){L.type&&(he[re++]=212,he[re++]=L.type,he[re++]=0),w(L.write.call(this,S));return}let H=he,k=Mn,G=re;he=null;let z;try{z=L.pack.call(this,S,U=>(he=H,H=null,re+=U,re>Rs&&_(re),{target:he,targetView:Mn,position:re-U}),w)}finally{H&&(he=H,Mn=k,re=G,Rs=he.length-10)}z&&(z.length+re>Rs&&_(z.length+re),re=Pj(z,he,re,L.type));return}}E(S,!S.hasOwnProperty)}}else if(T==="boolean")he[re++]=S?195:194;else if(T==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))he[re++]=211,Mn.setBigInt64(re,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)he[re++]=207,Mn.setBigUint64(re,S);else if(this.largeBigIntToFloat)he[re++]=203,Mn.setFloat64(re,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");re+=8}else if(T==="undefined")this.encodeUndefinedAsNil?he[re++]=192:(he[re++]=212,he[re++]=0,he[re++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},E=this.useRecords===!1?this.variableMapSize?S=>{let T=Object.keys(S),M=T.length;M<16?he[re++]=128|M:M<65536?(he[re++]=222,he[re++]=M>>8,he[re++]=M&255):(he[re++]=223,Mn.setUint32(re,M),re+=4);let C;for(let D=0;D<M;D++)w(C=T[D]),w(S[C])}:(S,T)=>{he[re++]=222;let M=re-n;re+=2;let C=0;for(let D in S)(T||S.hasOwnProperty(D))&&(w(D),w(S[D]),C++);he[M+++n]=C>>8,he[M+n]=C&255}:S=>{let T=Object.keys(S),M,C=o.transitions||(o.transitions=Object.create(null)),D=0;for(let I=0,L=T.length;I<L;I++){let H=T[I];M=C[H],M||(M=C[H]=Object.create(null),D++),C=M}let P=C[Ff];if(P)P>=96&&m?(he[re++]=((P-=96)&31)+96,he[re++]=P>>5):he[re++]=P;else{P=o.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(P=o.nextOwnId,P<y||(P=g),o.nextOwnId=P+1):(P>=y&&(P=g),o.nextId=P+1);let I=T.highByte=P>=96&&m?P-96>>5:-1;C[Ff]=P,o[P-64]=T,P<g?(T.isShared=!0,o.sharedLength=P-63,s=!0,I>=0?(he[re++]=(P&31)+96,he[re++]=I):he[re++]=P):(I>=0?(he[re++]=213,he[re++]=114,he[re++]=(P&31)+96,he[re++]=I):(he[re++]=212,he[re++]=114,he[re++]=P),D&&(x+=b*D),v.length>=p&&(v.shift()[Ff]=0),v.push(C),w(T))}for(let I=0,L=T.length;I<L;I++)w(S[T[I]])},_=S=>{let T;if(S>16777216){if(S-n>XC)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(XC,Math.round(Math.max((S-n)*(S>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(S-n<<2,he.length-1)>>12)+1<<12;let M=new aS(T);return Mn=new DataView(M.buffer,0,T),he.copy?he.copy(M,0,n,S):M.set(he.slice(n,S)),re-=n,n=0,Rs=M.length-10,he=M}}useBuffer(t){he=t,Mn=new DataView(he.buffer,he.byteOffset,he.byteLength),re=0}};lS=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Bf];iy=[{pack(i,t,e){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:s,position:o}=t(6);r[o++]=214,r[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:r,targetView:s,position:o}=t(10);r[o++]=215,r[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:r,targetView:s,position:o}=t(3);r[o++]=212,r[o++]=255,r[o++]=255}else{let{target:r,targetView:s,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(i,t,e){let n=Array.from(i),{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=115,r[s++]=0),e(n)}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=101,n[r++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=120,n[r++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?KC(i,16,t):QC(sy?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==ZC&&this.structuredClone?KC(i,oS.indexOf(e.name),t):QC(i,t)}},{pack(i,t){let{target:e,position:n}=t(1);e[n]=193}}];function KC(i,t,e,n){let r=i.byteLength;if(r+1<256){var{target:s,position:o}=e(4+r);s[o++]=199,s[o++]=r+1}else if(r+1<65536){var{target:s,position:o}=e(5+r);s[o++]=200,s[o++]=r+1>>8,s[o++]=r+1&255}else{var{target:s,position:o,targetView:a}=e(7+r);s[o++]=201,a.setUint32(o,r+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function QC(i,t){let e=i.byteLength;var n,r;if(e<256){var{target:n,position:r}=t(e+2);n[r++]=196,n[r++]=e}else if(e<65536){var{target:n,position:r}=t(e+3);n[r++]=197,n[r++]=e>>8,n[r++]=e&255}else{var{target:n,position:r,targetView:s}=t(e+5);n[r++]=198,s.setUint32(r,e),r+=4}n.set(i,r)}function Pj(i,t,e,n){let r=i.length;switch(r){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:r<256?(t[e++]=199,t[e++]=r):r<65536?(t[e++]=200,t[e++]=r>>8,t[e++]=r&255):(t[e++]=201,t[e++]=r>>24,t[e++]=r>>16&255,t[e++]=r>>8&255,t[e++]=r&255)}return t[e++]=n,t.set(i,e),e+=r,e}function Dj(i,t){let e,n=t.length*6,r=i.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+n,s,r),n-=6;let a=s+n;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,r=s}return i}function Ta(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)");lS.unshift(i.Class),iy.unshift(i)}YC(i)}var JC=new Fl({useRecords:!1}),Ij=JC.pack,Oj=JC.pack;var{NEVER:Rj,ALWAYS:Lj,DECIMAL_ROUND:Nj,DECIMAL_FIT:Bj}=ny,$C=512,Fj=1024;var eP=new Fl({structuredClone:!0});Ta({Class:tt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,tt.prototype),i}});Ta({Class:Re.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Re.prototype),i}});Ta({Class:cn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,cn.prototype),i}});Ta({Class:Lf.prototype.constructor,type:4,write(i){return i.id},read(i){return new Lf(i)}});Ta({Class:Nf.prototype.constructor,type:5,write(i){return i.data},read(i){return new Nf(i)}});Ta({Class:Yt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Yt.prototype),i}});function Vj(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let n=i[e];t=(t<<5)-t+n,t=t&t}return t}function cS(i){if(Nu(i))return i;if(Array.isArray(i))return i.map(cS);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=cS(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var oy;(n=>{function i(r){return eP.pack(r)}n.serialize=i;function t(r){return eP.unpack(r)}n.deserialize=t;function e(r){return Vj(i(cS(r))).toString()}n.checksum=e})(oy||(oy={}));var tP;(e=>{function i(n){return n.type==="Conditional"?n.condition.type==="Distance"?"Distance":"StateChange":n.type}e.toEventUIType=i;function t(n){return n==="Distance"||n==="StateChange"?"Conditional":n}e.fromEventUIType=t})(tP||(tP={}));var Jr={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],["GameControl"]:["Transition","Animation","Audio","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Resize"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["VariableChange"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},nP;(e=>{function i(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=i;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,runMode:"Once",actions:new Re}:{type:n,disabled:!1,key:void 0,runMode:"Once",actions:new Re}}e.defaultData=t})(nP||(nP={}));var ay;(e=>{function i(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(ay||(ay={}));var uS;(n=>{function i(r){return{type:"Comparison",operator:"==",lOperand:ay.propertyDefaultData(r),rOperand:{...ay.valueDefaultData}}}n.comparisonDefaultData=i;function t(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}}n.distanceDefaultData=t;function e(r,s){return{type:"State",object:r??null,state:s??null}}n.stateDefaultData=e})(uS||(uS={}));var rP;(e=>{function i(n){return n.type==="Conditional"}e.is=i;function t(n){return{type:"Conditional",disabled:!1,inActions:new Re,outActions:new Re,condition:uS.distanceDefaultData(n)}}e.defaultData=t})(rP||(rP={}));var iP;(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 Re,drop:new Re}})(iP||(iP={}));var ly;(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 Re})(ly||(ly={}));var cy;(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})(cy||(cy={}));var sP;(e=>{function i(n){return n.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Re}}e.defaultData=t})(sP||(sP={}));var oP;(e=>{function i(n){return n.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 Re}}e.defaultData=t})(oP||(oP={}));var aP;(e=>{function i(n){return n.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Re}}e.defaultData=t})(aP||(aP={}));var lP;(e=>{function i(n){return n.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Re}}e.defaultData=t})(lP||(lP={}));var cP;(e=>{function i(n){return n.type==="Trigger"}e.is=i;function t(n,r){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Re,triggerZone:"box",position:r.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}e.defaultData=t})(cP||(cP={}));var uy;(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 n(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=n;function r(){let a={size:"mobile",operator:"<",actions:new Re},l={size:"tablet",operator:"<",actions:new Re},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Re},c=new Re;return c.push({id:we.generateUUID(),fi:0,data:a},{id:we.generateUUID(),fi:1,data:l},{id:we.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=r;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Re}}o.defaultBreakpointData=s})(uy||(uy={}));var dy;(n=>{n.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}n.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Re,variableId:"",objectId:null,property:"Position X"}}n.defaultData=e})(dy||(dy={}));var Li="personal camera",Ca="a218fcc3-276b-49b9-b485-49037fd14f5f",hP=2960946,Zn=5526619;var Vl;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s]}e.lerp=t})(Vl||(Vl={}));var Ns;(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 n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function r(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=r;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})(Ns||(Ns={}));var Vf;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s,n[2]+(r[2]-n[2])*s,n[3]+(r[3]-n[3])*s]}e.lerp=t})(Vf||(Vf={}));var Ma;(r=>{r.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}r.isEqual=t;function e(s){return s??r.identity}r.simplify=e;function n(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}r.applyMatrix4=n})(Ma||(Ma={}));var dr;(c=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.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 r(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=r;function s(d){return{r:d.r,g:d.g,b:d.b}}c.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=a;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}c.equals=l;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}c.lerp=u})(dr||(dr={}));var Hr;(a=>{a.white={...dr.white,a:1},a.transparent={...dr.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...dr.fromHex(l),a:u}}a.fromHexAndA=n;function r(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=r;function s(l,u){return dr.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})(Hr||(Hr={}));var hy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(hy||(hy={}));var uP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(uP||(uP={}));var dP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(dP||(dP={}));var Ro;(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]))(Ro||(Ro={}));function fP(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 ns;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(ns||(ns={}));var Pa;(r=>{r.DefaultUp=[0,1,0],r.DefaultTargetOffset=1e3,r.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:r.DefaultUp,isUpVectorFlipped:!1,targetOffset:r.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}r.getZoom=n})(Pa||(Pa={}));var Bs;(e=>{function i(n,r=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[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:[n[0]+n[0]*r,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+r)),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(n,r){let s={...n};if(dS.forEach(o=>{Object.assign(s,{[o]:r[o]??n[o]})}),s.radial={...n.radial},r.radial){let o=n.radial,a=r.radial;hS.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},r.linear){let o=n.linear,a=r.linear;fS.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},r.grid){let o=n.grid,a=r.grid;pS.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},r.toObject){let o=n.toObject,a=r.toObject;mS.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},r.randomnessObject){let o=n.randomnessObject,a=r.randomnessObject;gS.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Bs||(Bs={}));var fy;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(r,s){let o=[];r.count!==void 0&&o.push({type:0,path:s,props:{count:r.count}});for(let a of t){let l=r[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(fy||(fy={}));var dS=["count"],hS=["radius","start","end","position","scale","rotation"],fS=["position","scale","rotation"],pS=["count","size"],mS=["count","position","scale","rotation"],gS=["strength","scale","rotation","position","movement","seed","freqScale"];var py;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(py||(py={}));var my;(e=>{function i(n){return t(n)}e.defaultData=i;function t(n){if(n==="PointLight")return{type:n,color:Hr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(n==="SpotLight")return{type:n,color:Hr.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(n==="DirectionalLight")return{type:n,color:Hr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(my||(my={}));var Da;(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]})(Da||(Da={}));var yS;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,r){return n.castShadow===r.castShadow&&n.receiveShadow===r.receiveShadow}e.equals=t})(yS||(yS={}));var vS;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe}e.equals=t})(vS||(vS={}));var gy;(t=>t.defaultData={...vS.defaultData,...yS.defaultData})(gy||(gy={}));var pP;(t=>{function i(e,n){let r=[];if("material"in e){let s=typeof e.material=="string"?n.materials[e.material]??n.lib.materials[e.material]?.asset:e.material;s&&r.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?n.materials[s]??n.lib.materials[s]?.asset:s;o&&r.push(o)}return r}t.getMaterialData=i})(pP||(pP={}));var zu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(zu||(zu={}));var mP;(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})(mP||(mP={}));function yP(i){return i.type!=="displace"}var gP;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(gP||(gP={}));var yy=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],vP=["wrapping","image","video","name"],hr;(r=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}r.patch=i;function t(s,o){return s==="light"&&o?e(o):n(s)}r.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 n(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:zu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:dr.fromHex(Zn)};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:{...dr.fromHex(6710886),a:1},colorB:{...dr.fromHex(6710886),a:1},colorC:{...dr.fromHex(16777215),a:1},colorD:{...dr.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:Hr.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:Hr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Hr.fromHexAndA(0,1),contourColor:Hr.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:{...dr.fromHex(0),a:1},colorB:{...dr.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}}}})(hr||(hr={}));var Cn;(l=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${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 Re}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function r(u,c){return{...u,name:c}}l.withName=r;function s(u,c="layer1",d="layer2"){let h=new Re;return h.push({fi:0,data:hr.defaultData("light",u),id:c}),h.push({fi:1,data:hr.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=hr.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Re;return p.push({fi:0,data:f,id:d}),p.push({fi:1,data:hr.defaultData("light",c),id:h}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=hr.defaultData("video");Object.assign(f.texture,{video:u});let p=new Re;return p.push({fi:0,data:f,id:d}),p.push({fi:1,data:hr.defaultData("light",c),id:h}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Cn||(Cn={}));var Gu;(t=>{function i(){return{points:new Re,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Gu||(Gu={}));var Hu;(t=>{function i(){return{points:new Re,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Hu||(Hu={}));var xS={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var vy;(t=>{function i(e,n){let r={...e};return bS.forEach(s=>{Object.assign(r,{[s]:n[s]??e[s]})}),r}t.merge=i})(vy||(vy={}));var xy={shape:xS,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},bS=["depth","offset","angle","twist","startScale","endScale"];var kf;(e=>{function i(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=i;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(kf||(kf={}));var by;(t=>{function i(e,n){let r={...e};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...e.extrusion},Object.assign(r.extrusion,vy.merge(r.extrusion,n.extrusion))),r}t.merge=i})(by||(by={}));var Ia;(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:Hu.defaultData(),extrusion:xy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Gu.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})(Ia||(Ia={}));var SS=["width","height","depth"];var Sy;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:dr.white,near:.1,far:2e3})(Sy||(Sy={}));var ju;(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}}})(ju||(ju={}));var wS;(t=>t.defaultData={softShadowQuality:"low"})(wS||(wS={}));var AS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(AS||(AS={}));var ES;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(ES||(ES={}));var Oa;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Oa||(Oa={}));var _S;(t=>t.defaultData={playCamera:Li,gameControlObject:null})(_S||(_S={}));var wy;(t=>t.defaultData={backgroundColor:Hr.fromHexAndA(hP,1),postprocessing:ju.defaultData,fog:Sy.defaultData,globalPhysics:Oa.defaultData,ambient:AS.defaultData,ao:ES.defaultData,shadow:wS.defaultData,publish:_S.defaultData})(wy||(wy={}));var xP;(e=>{function i(n){return n==="Component"||n==="Instance"}e.isComponentRelated=i;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(xP||(xP={}));var Wu;(r=>{r.identity={...hy.identity,hiddenMatrix:Ma.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}r.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}}r.merge=e;function n(s,o){return uC({position:Ns.isEqual(s.position,o.position)?void 0:o.position,rotation:Ns.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Ns.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Ma.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}r.diff=n})(Wu||(Wu={}));var _r;(t=>t.defaultData={states:new Re,events:new Re,visible:!0,raycastLock:!1,physics:Da.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Wu.identity,cloner:null})(_r||(_r={}));var Ay;(t=>t.defaultData={type:"Empty",..._r.defaultData})(Ay||(Ay={}));var bP;(t=>t.defaultData={type:"Component",..._r.defaultData})(bP||(bP={}));var kl;(t=>t.defaultData={type:"Mesh",..._r.defaultData,...gy.defaultData})(kl||(kl={}));var Ul;(t=>t.defaultData={..._r.defaultData,...Wu.identity,position:[0,0,Pa.DefaultTargetOffset],...Pa.defaultData})(Ul||(Ul={}));var Ey;(e=>{function i(n){return{..._r.defaultData,...my.defaultData(n)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Ey||(Ey={}));var qu;(e=>{function i(n,r,s=0){for(;s<r.length;){let o=n?n[r[s]]:void 0;if(r.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(n,r,s=0){let o=i(n,r,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(qu||(qu={}));var Fs;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{..._r.defaultData,...a,component:o,overrides:new Yt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=n;function r(o){let a=Wu.fromObject(o.data);return n(o.id,a)}s.fromComponentData=r})(Fs||(Fs={}));var Lo;(t=>t.defaultData={type:"Page",..._r.defaultData,physics:{...Da.defaultData,fusedBody:!1},...wy.defaultData,camera:Ul.defaultData})(Lo||(Lo={}));var _y;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ma.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Da.defaultData,states:new Re,events:new Re,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Pa.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",..._r.defaultData,...kl.defaultData,geometry:Ia.defaultData("RectangleGeometry"),material:Cn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",..._r.defaultData,...kl.defaultData,geometry:Ia.defaultData("BooleanGeometry"),material:Cn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",..._r.defaultData,...kl.defaultData,geometry:Ia.defaultData("TextGeometry"),material:Cn.defaultTwoLayerData("phong","layer1","layer2")}))(_y||(_y={}));var No;(r=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Yt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Yt})))):ns.is(s.type)&&(a.perspective={},a.orthographic={}),a}r.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=Aa(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&hr.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Aa(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&hr.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,p]of Object.entries(h.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",f],props:g,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...fy.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,p]of Object.entries(h))c(["materials",f],p);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}r.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Wu.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})}),ns.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:by.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(py.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=dr.clone(l.color))}return a}r.patch=n})(No||(No={}));var Xu;(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})(Xu||(Xu={}));var Vs;(t=>t.defaultData={orbitControls:Xu.defaultData,playPage:Ca,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let r=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?r=30:(n===4||n===11||n===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Vs||(Vs={}));var TS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(TS||(TS={}));var MS;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(MS||(MS={}));var Ra;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...TS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:MS.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ra||(Ra={}));var La;(e=>{function i(n){return n.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(n,r,s){n.scene.objects.traverseFrom(r,(o,a)=>{if(a.type==="Instance"){let l=Ku.getComponentData(n,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(La||(La={}));var Na;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=_y.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:Ey.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 d=new cn;return d.push({fi:1,id:Ca,data:{...Lo.defaultData,name:"Scene 1"},children:u}),d}a.defaultData={objects:t(),publish:Vs.defaultData,styles:Ra.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new cn,publish:Vs.defaultData,styles:Ra.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:Vs.defaultData,styles:Ra.defaultData()}};function s(l){return{...a.defaultData,objects:Qr(l,cn.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(Na||(Na={}));var Qu;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Qu||(Qu={}));var Zu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Zu||(Zu={}));var fr;(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 n(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=n;function r(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=r})(fr||(fr={}));var CS;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(CS||(CS={}));var SP;(t=>t.all=[...CS.all,"components"])(SP||(SP={}));var wP;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(wP||(wP={}));var Ba;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(Ba||(Ba={}));var $r;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Qr(o,tt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Zu.emptyImage,name:"AI generated image"}),Qr(a,tt.prototype)}s.defaultImages=t;function e(){return{catelogs:new tt,materials:new tt,images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,variables:new Re,lib:Ba.defaultData()}}s.emptyData=e;function n(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=n;function r(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=r})($r||($r={}));var Ju;(t=>t.list=["idle","move","jump","run"])(Ju||(Ju={}));var $u;(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 Re,move:new Re,jump:new Re,run:new Re},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Hr.fromHexAndA(3728051,1)}}))($u||($u={}));function AP(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,r=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)r.push(r[1]),s.push(1);let o={...Si(pn(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:r,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={...pn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Bo(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Fo(i,t){i.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach((r,s)=>{r===void 0&&(n.materials[s]=Cn.defaultData(),r=n.materials[s]),typeof r!="string"&&t(r)}):"material"in n?typeof n.material!="string"&&(n.material===void 0&&(n.material=Cn.defaultData()),t(n.material)):n.type==="Mesh"&&(n.material===void 0&&(n.material=Cn.defaultData()),t(n.material)),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&t(r.material)})})}function Uj(i){Object.assign(i.scene.publish,{orbitControls:{...Xu.defaultData,...pn(i.scene.publish.orbitControls)}})}function zj(i){Object.assign(i.scene.publish.settings,{video:{...Vs.defaultData.settings.video,...pn(i.scene.publish.settings.video)}})}function Gj(i){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[r,s]of Object.entries(n))if((yy.includes(r)||typeof s=="boolean")&&delete n[r],r==="texture")for(let[o,a]of Object.entries(s))(vP.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,n)=>{n.states.forEach(r=>{let s=r;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function Hj(i){i.scene.publish.withBackground=!0}function jj(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Wj(i){i.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(r=>r+1),n.linear.scale=n.linear.scale.map(r=>r+1))})}function qj(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function Yj(i){i.scene.objects.traverse((t,e)=>{let n=i.scene.objects.unproxy().parent(t);if(n){let r=pn(i.scene.objects.data(n));r&&r.type==="Mesh"&&r.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=pn(e).booleanExclude!==!0)}})}function Xj(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function Kj(i){function t(n){Object.setPrototypeOf(n,Yt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Yt.prototype)}function e(n){Object.setPrototypeOf(n,Yt.prototype);for(let r in n)t(n[r])}i.scene.objects.traverse((n,r)=>{r.states.forEach(s=>{let o=s;if(o.material){let a=pn(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=pn(l).layers;e(u),l.layers=u}})})}function EP(i){i.layers===void 0&&Object.assign(i,Cn.defaultTwoLayerData("lambert"))}function PS(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 n=[...t.steps];n.push(t.steps[9]);let r={...pn(t),colors:e,steps:n};Object.assign(t,r)}})}function Qj(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function _P(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&PS(n)}):"material"in e&&typeof e.material!="string"&&PS(e.material)}),Object.values(i.shared.materials).forEach(t=>PS(t))}function Zj(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 Jj(i){i.shared.audios=Qr({},tt.prototype)}function $j(i){i.shared.videos=Qr({},tt.prototype)}function eW(i){let t=i.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let r={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]:r})}})}function tW(i){Object.entries(pn(i.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.images[n]}),Object.entries(pn(i.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.audios[n]})}function nW(i){i.scene.publish.settings.web.preload=!1}function TP(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 MP(i){i.layers&&i.layers.forEach(t=>{yP(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 rW(i){i.shared.fonts=Qr({},tt.prototype)}function iW(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 sW(i){let t=[];i.scene.objects.traverse((e,n)=>{let r=n;if(r.type==="TextFrame"){let s=Cn.defaultTwoLayerData("phong"),o=typeof r.color=="string"?i.shared.colors[r.color]:r.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=r.alpha;let a=iW(r.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:r.name,..._r.defaultData,...kl.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ia.defaultData("TextGeometry"),width:r.width,height:r.height,font:a,depth:0,horizontalAlign:r.horizontalAlign,verticalAlign:r.verticalAlign,fontSize:r.fontSize*1.40625,lineHeight:r.lineHeight/1.40625,letterSpacing:r.letterSpacing-1,text:r.text,textTransform:r.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:pn(r.states),events:pn(r.events),visible:r.visible,raycastLock:r.raycastLock,position:r.position,rotation:r.rotation,scale:r.scale,hiddenMatrix:r.hiddenMatrix},u=pn(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 oW(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,n)=>{n.events.forEach(r=>{if(!!t[Number(r.type)])if(Object.assign(r,{type:t[Number(r.type)]}),r.type==="Audio"&&"audioEvent"in r&&(Object.assign(r,{playAudio:r.audioEvent}),delete r.audioEvent),r.type==="GameControl")Object.assign(r,{gameActions:{idle:new Re,move:new Re,jump:new Re}});else{let s=new Re;Object.assign(r,{actions:s}),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp")&&"url"in r&&s.push({fi:0,id:we.generateUUID(),data:{type:"Link",url:r.url,delay:0}}),"targets"in r&&(r.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,Si(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Re({fi:0,id:we.generateUUID(),data:u},{fi:1,id:we.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete r.targets)}})})}function aW(i){i.scene.objects.traverse((t,e)=>{function n(r,s){let o=new Re,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Si(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")&&(d={...Si(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===r)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:we.generateUUID(),data:{type:r,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function CP(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=hr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function PP(i){Bo(i,CP),Fo(i,CP)}function lW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function cW(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 uW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Cn.defaultTwoLayerData("phong"))})}function dW(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 hW(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 fW(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 pW(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function mW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function gW(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function yW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=$u.defaultDataThirdPerson.navmesh)})})}function vW(i){i.scene.styles||(i.scene.styles=Ra.defaultData())}function DP(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function xW(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}),Fo(i,DP),Bo(i,DP)}function bW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&Object.assign(n.gameActions,{run:new Re})})})}function SW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.keyAssignments=[...n.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function IP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function OP(i,t){if(t<1&&(Fo(i,AP),Bo(i,AP),i.schema=1),t<2&&(Uj(i),i.schema=2),t<3&&(Gj(i),i.schema=3),t<4&&(Hj(i),i.schema=4),t<5&&(jj(i),i.schema=5),t<6&&(Wj(i),i.schema=6),t<7&&(qj(i),i.schema=7),t<8&&(i.schema=8),t<9&&(_P(i),i.schema=9),t<10&&(Qj(i),i.schema=10),t<11&&(Zj(i),i.schema=11),t<12&&(_P(i),i.schema=12),t<13&&(Jj(i),i.schema=13),t<14&&(eW(i),i.schema=14),t<15&&(tW(i),i.schema=15),t<16&&(nW(i),i.schema=16),t<17&&(Fo(i,TP),Bo(i,TP),i.schema=17),t<18&&(Fo(i,EP),Bo(i,EP),i.schema=18),t<19&&(zj(i),i.schema=19),t<20&&(rW(i),sW(i),i.schema=20),t<21&&(oW(i),aW(i),i.schema=21),t<22&&(PP(i),i.schema=22),t<23&&(lW(i),i.schema=23),t<24&&(cW(i),i.schema=24),(t<25||i.shared.videos===void 0)&&($j(i),t<25&&(i.schema=25)),t<26&&(Yj(i),i.schema=26),t<27&&(Xj(i),i.schema=27),t<28&&(PP(i),i.schema=28),t<29&&(Kj(i),i.schema=29),t<30&&(uW(i),i.schema=30),t<31&&(dW(i),i.schema=31),t<33&&(hW(i),i.schema=33),t<34&&(fW(i),i.schema=34),t<35&&(pW(i),i.schema=35),t<36&&(mW(i),i.schema=36),t<37&&(gW(i),i.schema=37),t<38&&(Fo(i,MP),Bo(i,MP),i.schema=38),t<39&&(yW(i),i.schema=39),t<40&&(vW(i),i.schema=40),t<41&&(xW(i),i.schema=41),t<42&&(bW(i),i.schema=42),t<43&&(SW(i),i.schema=43),t<99){Fo(i,IP),Bo(i,IP),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Li);let e=pn(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=Ca,n.insertBefore(null,null,[{id:Ca,data:{...Lo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Si(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Si(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Oa.defaultData,...Si(i.scene.environment,"usePhysics","gravity")},camera:pn(i.scene.ownerCamera)??Lo.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Na.TRASH_CAN_ID&&n.move(Ca,o.fi,o.id);let r=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(r,2)],r+=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,Da.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function RP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function wW(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}var ed=180/Math.PI;function LP(i){i.rotation=i.rotation.slice(0,3).map(t=>t*ed)}function NP(i){LP(i),i.type==="Page"&&LP(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(n=>n*ed))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=t.thetaLength*ed),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ed),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ed,t.extrusion.twist*=ed),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(pn(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 AW(i){i.shared.variables=Qr({},tt.prototype)}function EW(i){let t=pn(i.shared.variables);i.shared.variables=Qr(Object.entries(t??{}).map(([e,n],r)=>({fi:r,id:e,data:n})),Re.prototype)}var Vo=107;function BP(i,t){t(i.data);for(let e of i.children)BP(e,t)}function _W(i){let t=i.schema??104;t!==Vo&&t<105&&(BP(i.asset,NP),i.schema=105)}function Ty(i){let t=i.schema??0;if(t!==Vo){console.warn("updating from ",t,"to ",Vo),OP(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Vs.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Fo(i,RP),Bo(i,RP),i.schema=101),t<102&&(wW(i),i.schema=102),t<104&&(i.shared.catelogs=new tt,i.shared.lib=Ba.defaultData(),i.schema=104),t<105&&(AW(i),i.scene.objects.traverse((e,n)=>{NP(n)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))_W(e);t<106&&(EW(i),i.schema=106),t<107&&(i.shared.lib.variables=Ba.defaultData().variables,i.schema=107)}}var Ku;(a=>{a.defaultData={schema:Vo,scene:Na.defaultData,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qu.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors()}},a.emptyDataForImports=function(l){let u=Na.emptyDataWithPage(l);return{schema:Vo,scene:u,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qu.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors(),images:$r.defaultImages(l)}}},a.emptyData=function(){return{schema:Vo,scene:Na.emptyDataWithPage(),frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qu.defaultData),shared:$r.emptyData()}},a.collabHelper={...Rf,updateSchema(l){return(l.schema??0)<Vo?Aa(l,Ty):(l.schema??0)-Vo}};function r(l){let u=a.collabHelper.updateSchema(l);return typeof u=="number"?u===0?l:null:u.data}a.updateSchemaDirectly=r;function s(l){return{...l,shared:{...l.shared,lib:Ba.defaultData()}}}a.withoutLib=s;function o(l,u){let c=l.scene.objects.get(u);if(c&&c.data.type==="Component")return c;{let d=l.shared.lib.components[u];if(d)return d.asset}}a.getComponentData=o})(Ku||(Ku={}));function rs(i,t=!1){let e=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ee,u=0;for(let c=0;c<i.length;++c){let d=i[c],h=0;if(e!==(d.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 d.attributes){if(!n.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(d.attributes[f]),h++}if(h!==n.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!==d.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 d.morphAttributes){if(!r.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(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=d.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,d=[];for(let h=0;h<i.length;++h){let f=i[h].index;for(let p=0;p<f.count;++p)d.push(f.getX(p)+c);c+=i[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=FP(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][h]);let p=FP(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 FP(i){let t,e,n,r=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(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=l.array.length}let s=new t(r),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,n)}var VP=Math.pow(2,-24);var zl=class{constructor(){}};function Ni(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 DS(i){let t=-1,e=-1/0;for(let n=0;n<3;n++){let r=i[n+3]-i[n];r>e&&(e=r,t=n)}return t}function IS(i,t){t.set(i)}function OS(i,t,e){let n,r;for(let s=0;s<3;s++){let o=s+3;n=i[s],r=t[s],e[s]=n<r?n:r,n=i[o],r=t[o],e[o]=n>r?n:r}}function Uf(i,t,e){for(let n=0;n<3;n++){let r=t[i+2*n],s=t[i+2*n+1],o=r-s,a=r+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function td(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function CW(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r;e>65535?r=new Uint32Array(new n(4*e)):r=new Uint16Array(new n(2*e)),i.setIndex(new Ge(r,1));for(let s=0;s<e;s++)r[s]=s}}function PW(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let r of i.groups)e.add(r.start),e.add(r.start+r.count);let n=Array.from(e.values()).sort((r,s)=>r-s);for(let r=0;r<n.length-1;r++){let s=n[r],o=n[r+1];t.push({offset:s/3,count:(o-s)/3})}return t}function LS(i,t,e,n,r=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=r!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=i[v+0],w=i[v+1],E=b-w,_=b+w;E<s&&(s=E),_>l&&(l=_),y&&b<d&&(d=b),y&&b>p&&(p=b);let S=i[v+2],T=i[v+3],M=S-T,C=S+T;M<o&&(o=M),C>u&&(u=C),y&&S<h&&(h=S),y&&S>m&&(m=S);let D=i[v+4],P=i[v+5],I=D-P,L=D+P;I<a&&(a=I),L>c&&(c=L),y&&D<f&&(f=D),y&&D>g&&(g=D)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(r[0]=d,r[1]=h,r[2]=f,r[3]=p,r[4]=m,r[5]=g)}function DW(i,t,e,n){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=i[c+0];h<r&&(r=h),h>a&&(a=h);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)}n[0]=r,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function IW(i,t,e,n,r){let s=e,o=e+n-1,a=r.pos,l=r.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 d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var ko=32,OW=(i,t)=>i.candidate-t.candidate,Fa=new Array(ko).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),My=new Float32Array(6);function RW(i,t,e,n,r,s){let o=-1,a=0;if(s===0)o=DS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=DS(i),o!==-1&&(a=LW(e,n,r,o));else if(s===2){let l=td(i),u=1.25*r,c=n*6,d=(n+r)*6;for(let h=0;h<3;h++){let f=t[h],g=(t[h+3]-f)/ko;if(r<ko/4){let y=[...Fa];y.length=r;let v=0;for(let b=c;b<d;b+=6,v++){let w=y[v];w.candidate=e[b+2*h],w.count=0;let{bounds:E,leftCacheBounds:_,rightCacheBounds:S}=w;for(let T=0;T<3;T++)S[T]=1/0,S[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0,E[T]=1/0,E[T+3]=-1/0;Uf(b,e,E)}y.sort(OW);let x=r;for(let b=0;b<x;b++){let w=y[b];for(;b+1<x&&y[b+1].candidate===w.candidate;)y.splice(b+1,1),x--}for(let b=c;b<d;b+=6){let w=e[b+2*h];for(let E=0;E<x;E++){let _=y[E];w>=_.candidate?Uf(b,e,_.rightCacheBounds):(Uf(b,e,_.leftCacheBounds),_.count++)}}for(let b=0;b<x;b++){let w=y[b],E=w.count,_=r-w.count,S=w.leftCacheBounds,T=w.rightCacheBounds,M=0;E!==0&&(M=td(S)/l);let C=0;_!==0&&(C=td(T)/l);let D=1+1.25*(M*E+C*_);D<u&&(o=h,u=D,a=w.candidate)}}else{for(let x=0;x<ko;x++){let b=Fa[x];b.count=0,b.candidate=f+g+x*g;let w=b.bounds;for(let E=0;E<3;E++)w[E]=1/0,w[E+3]=-1/0}for(let x=c;x<d;x+=6){let E=~~((e[x+2*h]-f)/g);E>=ko&&(E=ko-1);let _=Fa[E];_.count++,Uf(x,e,_.bounds)}let y=Fa[ko-1];IS(y.bounds,y.rightCacheBounds);for(let x=ko-2;x>=0;x--){let b=Fa[x],w=Fa[x+1];OS(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<ko-1;x++){let b=Fa[x],w=b.count,E=b.bounds,S=Fa[x+1].rightCacheBounds;w!==0&&(v===0?IS(E,My):OS(E,My,My)),v+=w;let T=0,M=0;v!==0&&(T=td(My)/l);let C=r-v;C!==0&&(M=td(S)/l);let D=1+1.25*(T*v+M*C);D<u&&(o=h,u=D,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function LW(i,t,e,n){let r=0;for(let s=t,o=t+e;s<o;s++)r+=i[s*6+n*2];return r/e}function NW(i,t){let e=i.attributes.position,n=i.index.array,r=n.length/3,s=new Float32Array(r*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 d=0;d<r;d++){let h=d*3,f=d*6,p,m,g;o?(p=n[h+0],m=n[h+1],g=n[h+2]):(p=n[h+0]*u+l,m=n[h+1]*u+l,g=n[h+2]*u+l);for(let y=0;y<3;y++){let v,x,b;o?(v=e[c[y]](p),x=e[c[y]](m),b=e[c[y]](g)):(v=a[p+y],x=a[m+y],b=a[g+y]);let w=v;x<w&&(w=x),b<w&&(w=b);let E=v;x>E&&(E=x),b>E&&(E=b);let _=(E-w)/2,S=y*2;s[f+S+0]=w+_,s[f+S+1]=_+(Math.abs(w)+_)*VP,w<t[y]&&(t[y]=w),E>t[y+3]&&(t[y+3]=E)}}return s}function BW(i,t){function e(y){h&&h(y/f)}function n(y,v,x,b=null,w=0){if(!p&&w>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||w>=l)return e(v+x),y.offset=v,y.count=x,y;let E=RW(y.boundingData,b,o,v,x,d);if(E.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let _=IW(a,o,v,x,E);if(_===v||_===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=E.axis;let S=new zl,T=v,M=_-v;y.left=S,S.boundingData=new Float32Array(6),LS(o,T,M,S.boundingData,s),n(S,T,M,s,w+1);let C=new zl,D=_,P=x-M;y.right=C,C.boundingData=new Float32Array(6),LS(o,D,P,C.boundingData,s),n(C,D,P,s,w+1)}return y}CW(i,t);let r=new Float32Array(6),s=new Float32Array(6),o=NW(i,r),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=i.index.count/3,p=!1,m=[],g=PW(i);if(g.length===1){let y=g[0],v=new zl;v.boundingData=r,DW(o,y.offset,y.count,s),n(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new zl;v.boundingData=new Float32Array(6),LS(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),m.push(v)}return m}function zP(i,t){let e=BW(i,t),n,r,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),r=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,p=!!d.count,m=d.boundingData;for(let g=0;g<6;g++)n[h+g]=m[g];if(p){let g=d.offset,y=d.count;return r[h+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=d.left,y=d.right,v=d.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 r[h+6]=x/4,x=u(x,y),r[h+7]=v,x}}}var ei=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,r=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}setFromPoints(t,e){let n=1/0,r=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}};ei.prototype.setFromBox=function(){let i=new A;return function(e,n){let r=n.min,s=n.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=r.x*l+s.x*(1-l),i.y=r.y*u+s.y*(1-u),i.z=r.z*c+s.z*(1-c);let d=e.dot(i);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var fce=function(){let i=new ei;return function(e,n){let r=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let d=o[c],h=s[c];if(i.setFromPoints(h,a),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(i.setFromPoints(h,r),d.isSeparated(i))return!1}}}();var FW=function(){let i=new A,t=new A,e=new A;return function(r,s,o){let a=r.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),p=e.dot(l),g=l.dot(l)*f-h*h,y,v;g!==0?y=(d*h-p*f)/g:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),zf=function(){let i=new B,t=new A,e=new A;return function(r,s,o,a){FW(r,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){r.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=r.start:c=r.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),GP=function(){let i=new A,t=new A,e=new En,n=new Xn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(n.start=c,n.end=d,n.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 VW=1e-15;function nd(i){return Math.abs(i)<VW}var ti=class extends an{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new ei),this.points=[this.a,this.b,this.c],this.sphere=new ln,this.plane=new En,this.needsUpdate=!0}intersectsSphere(t){return GP(t,this)}update(){let t=this.a,e=this.b,n=this.c,r=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,r);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,r);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,r);let f=s[3],p=o[3];f.subVectors(n,t),p.setFromPoints(f,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};ti.prototype.closestPointToSegment=function(){let i=new A,t=new A,e=new Xn;return function(r,s=null,o=null){let{start:a,end:l}=r,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),zf(e,r,i,t),c=i.distanceToSquared(t),c<d&&(d=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(d)}}();ti.prototype.intersectsTriangle=function(){let i=new ti,t=new Array(3),e=new Array(3),n=new ei,r=new ei,s=new A,o=new A,a=new A,l=new A,u=new Xn,c=new Xn,d=new Xn;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 E=0;E<4;E++){let _=v[E],S=x[E];if(n.setFromPoints(S,e),_.isSeparated(n))return!1}let b=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let E=0;E<4;E++){let _=b[E],S=w[E];if(n.setFromPoints(S,t),_.isSeparated(n))return!1}for(let E=0;E<4;E++){let _=x[E];for(let S=0;S<4;S++){let T=w[S];if(s.crossVectors(_,T),n.setFromPoints(s,t),r.setFromPoints(s,e),n.isSeparated(r))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,b=0;for(let I=0;I<3;I++){let L=v[I],H=v[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(o);let k=x?c.start:c.end,G=nd(y.distanceToPoint(L));if(nd(y.normal.dot(o))&&G){c.copy(u),b=2;break}if((y.intersectLine(u,k)||G)&&!nd(k.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let w=f.points,E=!1,_=0;for(let I=0;I<3;I++){let L=w[I],H=w[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(a);let k=E?d.start:d.end,G=nd(g.distanceToPoint(L));if(nd(g.normal.dot(a))&&G){d.copy(u),_=2;break}if((g.intersectLine(u,k)||G)&&!nd(k.distanceTo(H))){if(_++,E)break;E=!0}}if(_===1&&this.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(_!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let I=d.start;d.start=d.end,d.end=I}let S=c.start.dot(o),T=c.end.dot(o),M=d.start.dot(o),C=d.end.dot(o),D=T<M,P=S<C;return S!==C&&M!==T&&D===P?!1:(p&&(l.subVectors(c.start,d.start),l.dot(o)>0?p.start.copy(c.start):p.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(d.end)),!0)}}}();ti.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();ti.prototype.distanceToTriangle=function(){let i=new A,t=new A,e=["a","b","c"],n=new Xn,r=new Xn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],p=o[f];this.closestPointToPoint(p,i),h=p.distanceToSquared(i),h<c&&(c=h,a&&a.copy(i),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,i),h=m.distanceToSquared(i),h<c&&(c=h,a&&a.copy(m),l&&l.copy(i))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];r.set(o[m],o[g]),zf(n,r,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var ni=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new A,this.max=new A,this.matrix=new se,this.invMatrix=new se,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new ei),this.alignedSatBounds=new Array(3).fill().map(()=>new ei),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};ni.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,r=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=r[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=r[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=r[h];c.subVectors(a,f),d.setFromPoints(c,r)}let l=this.alignedSatBounds;l[0].setFromPointsField(r,"x"),l[1].setFromPointsField(r,"y"),l[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ni.prototype.intersectsBox=function(){let i=new ei;return function(e){this.needsUpdate&&this.update();let n=e.min,r=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=n.x,i.max=r.x,a[0].isSeparated(i)||(i.min=n.y,i.max=r.y,a[1].isSeparated(i))||(i.min=n.z,i.max=r.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}}();ni.prototype.intersectsTriangle=function(){let i=new ti,t=new Array(3),e=new ei,n=new ei,r=new A;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 h=0;h<3;h++){let f=a[h],p=l[h];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],p=c[h];if(e.setFromPoints(p,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let p=0;p<4;p++){let m=c[p];if(r.crossVectors(f,m),e.setFromPoints(r,t),n.setFromPoints(r,d),e.isSeparated(n))return!1}}return!0}}();ni.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}}();ni.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();ni.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Xn),e=new Array(12).fill().map(()=>new Xn),n=new A,r=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(r),this.closestPointToPoint(r,n),o.closestPointToPoint(n,r),l&&l.copy(n),u&&u.copy(r)),0;let c=a*a,d=o.min,h=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];r.copy(y).clamp(d,h);let v=y.distanceToSquared(r);if(v<p&&(p=v,l&&l.copy(y),u&&u.copy(r),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,b=(g+2)%3,w=y<<x|v<<b,E=1<<g|y<<x|v<<b,_=f[w],S=f[E];t[m].set(_,S);let M=i[g],C=i[x],D=i[b],P=e[m],I=P.start,L=P.end;I[M]=d[M],I[C]=y?d[C]:h[C],I[D]=v?d[D]:h[C],L[M]=h[M],L[C]=y?d[C]:h[C],L[D]=v?d[D]:h[C],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){r.x=g?h.x:d.x,r.y=y?h.y:d.y,r.z=v?h.z:d.z,this.closestPointToPoint(r,n);let x=r.distanceToSquared(n);if(x<p&&(p=x,l&&l.copy(n),u&&u.copy(r),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];zf(y,x,n,r);let b=n.distanceToSquared(r);if(b<p&&(p=b,l&&l.copy(n),u&&u.copy(r),b<c))return Math.sqrt(b)}}return Math.sqrt(p)}}();var rd=new A,id=new A,sd=new A,Py=new B,Dy=new B,Iy=new B,HP=new A,jP=new A,WP=new A,Oy=new A;function kW(i,t,e,n,r,s){let o;return s===Un?o=i.intersectTriangle(n,e,t,!0,r):o=i.intersectTriangle(t,e,n,s!==Ur,r),o===null?null:{distance:i.origin.distanceTo(r),point:r.clone()}}function UW(i,t,e,n,r,s,o,a,l){rd.fromBufferAttribute(t,s),id.fromBufferAttribute(t,o),sd.fromBufferAttribute(t,a);let u=kW(i,rd,id,sd,Oy,l);if(u){n&&(Py.fromBufferAttribute(n,s),Dy.fromBufferAttribute(n,o),Iy.fromBufferAttribute(n,a),u.uv=an.getInterpolation(Oy,rd,id,sd,Py,Dy,Iy,new B)),r&&(Py.fromBufferAttribute(r,s),Dy.fromBufferAttribute(r,o),Iy.fromBufferAttribute(r,a),u.uv1=an.getInterpolation(Oy,rd,id,sd,Py,Dy,Iy,new B)),e&&(HP.fromBufferAttribute(e,s),jP.fromBufferAttribute(e,o),WP.fromBufferAttribute(e,a),u.normal=an.getInterpolation(Oy,rd,id,sd,HP,jP,WP,new A),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new A,materialIndex:0};an.getNormal(rd,id,sd,c.normal),u.face=c,u.faceIndex=s}return u}function BS(i,t,e,n,r){let s=n*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:d,uv1:h}=i.attributes,f=UW(e,u,c,d,h,o,a,l,t);return f?(f.faceIndex=n,r&&r.push(f),f):null}function qP(i,t,e,n,r,s){for(let o=n,a=n+r;o<a;o++)BS(i,t,e,o,s)}function YP(i,t,e,n,r){let s=1/0,o=null;for(let a=n,l=n+r;a<l;a++){let u=BS(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Bi(i,t,e,n){let r=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)),r.x=n.getX(a),r.y=n.getY(a),r.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function FS(i,t,e,n,r,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Bi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,r,s))return!0;return!1}var od=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 Uo(i,t){return t[i+15]===65535}function Gl(i,t){return t[i+6]}function ad(i,t){return t[i+14]}function ld(i){return i+8}function cd(i,t){return t[i+6]}function XP(i,t){return t[i+7]}var ud=new Tt,Ly=new A,GW=["x","y","z"];function Ny(i,t,e,n,r){let s=i*2,o=dd,a=Va,l=ka;if(Uo(s,a)){let c=Gl(i,l),d=ad(s,a);qP(t,e,n,c,d,r)}else{let c=ld(i);Fy(c,o,n,Ly)&&Ny(c,t,e,n,r);let d=cd(i,l);Fy(d,o,n,Ly)&&Ny(d,t,e,n,r)}}function By(i,t,e,n){let r=i*2,s=dd,o=Va,a=ka;if(Uo(r,o)){let u=Gl(i,a),c=ad(r,o);return YP(t,e,n,u,c)}else{let u=XP(i,a),c=GW[u],h=n.direction[c]>=0,f,p;h?(f=ld(i),p=cd(i,a)):(f=cd(i,a),p=ld(i));let g=Fy(f,s,n,Ly)?By(f,t,e,n):null;if(g){let x=g.point[c];if(h?x<=s[p+u]:x>=s[p+u+3])return g}let v=Fy(p,s,n,Ly)?By(p,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var KP=function(){let i,t,e=[],n=new od(()=>new Tt);return function(...o){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let a=r(...o);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function r(s,o,a,l,u=null,c=0,d=0){function h(x){let b=x*2,w=Va,E=ka;for(;!Uo(b,w);)x=ld(x),b=x*2;return Gl(x,E)}function f(x){let b=x*2,w=Va,E=ka;for(;!Uo(b,w);)x=cd(x,E),b=x*2;return Gl(x,E)+ad(b,w)}let p=s*2,m=dd,g=Va,y=ka;if(Uo(p,g)){let x=Gl(s,y),b=ad(p,g);return Ni(s,m,i),l(x,b,!1,d,c+s,i)}else{let x=ld(s),b=cd(s,y),w=x,E=b,_,S,T,M;if(u&&(T=i,M=t,Ni(w,m,T),Ni(E,m,M),_=u(T),S=u(M),S<_)){w=b,E=x;let k=_;_=S,S=k,T=M}T||(T=i,Ni(w,m,T));let C=Uo(w*2,g),D=a(T,C,_,d+1,c+w),P;if(D===2){let k=h(w),z=f(w)-k;P=l(k,z,!0,d+1,c+w,T)}else P=D&&r(w,o,a,l,u,c,d+1);if(P)return!0;M=t,Ni(E,m,M);let I=Uo(E*2,g),L=a(M,I,S,d+1,c+E),H;if(L===2){let k=h(E),z=f(E)-k;H=l(k,z,!0,d+1,c+E,M)}else H=L&&r(E,o,a,l,u,c,d+1);return!!H}}}(),QP=function(){let i=new ti,t=new ti,e=new se,n=new ni,r=new ni;return function s(o,a,l,u,c=null){let d=o*2,h=dd,f=Va,p=ka;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),Uo(d,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,b=l.attributes.position,w=Gl(o,p),E=ad(d,f);if(e.copy(u).invert(),l.boundsTree)return Ni(o,h,r),r.matrix.copy(e),r.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>r.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(u),S.b.applyMatrix4(u),S.c.applyMatrix4(u),S.needsUpdate=!0;for(let T=w*3,M=(E+w)*3;T<M;T+=3)if(Bi(t,T,y,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let _=w*3,S=E+w*3;_<S;_+=3){Bi(i,_,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let T=0,M=x.count;T<M;T+=3)if(Bi(t,T,x,b),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return Ni(g,h,ud),!!(c.intersectsBox(ud)&&s(g,a,l,u,c)||(Ni(y,h,ud),c.intersectsBox(ud)&&s(y,a,l,u,c)))}}}();function Fy(i,t,e,n){return Ni(i,t,ud),e.intersectBox(ud,n)}var VS=[],Ry,dd,Va,ka;function hd(i){Ry&&VS.push(Ry),Ry=i,dd=new Float32Array(i),Va=new Uint16Array(i),ka=new Uint32Array(i)}function Gf(){Ry=null,dd=null,Va=null,ka=null,VS.length&&hd(VS.pop())}var kS=Symbol("skip tree generation"),US=new Tt,zS=new Tt,fd=new se,Hl=new ni,Hf=new ni,jf=new A,Vy=new A,HW=new A,jW=new A,WW=new A,ZP=new Tt,ks=new od(()=>new ti),Us=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."),Us.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,r=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:r.map(a=>a.slice()),index:s.array.slice()}:o={roots:r,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Us.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:r,roots:s}=t,o=new Us(e,{...n,[kS]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==r&&(a.array.set(r),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,[kS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[kS]||(this._roots=zP(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Tt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,r=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let h=0,f=c.length;h<f;h++)s=c[h],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,u),u+=s.byteLength;function d(h,f,p=!1){let m=h*2;if(a[m+15]===65535){let y=o[h+6],v=a[m+14],x=1/0,b=1/0,w=1/0,E=-1/0,_=-1/0,S=-1/0;for(let T=3*y,M=3*(y+v);T<M;T++){let C=n[T],D=r.getX(C),P=r.getY(C),I=r.getZ(C);D<x&&(x=D),D>E&&(E=D),P<b&&(b=P),P>_&&(_=P),I<w&&(w=I),I>S&&(S=I)}return l[h+0]!==x||l[h+1]!==b||l[h+2]!==w||l[h+3]!==E||l[h+4]!==_||l[h+5]!==S?(l[h+0]=x,l[h+1]=b,l[h+2]=w,l[h+3]=E,l[h+4]=_,l[h+5]=S,!0):!1}else{let y=h+8,v=o[h+6],x=y+f,b=v+f,w=p,E=!1,_=!1;t?w||(E=t.has(x),_=t.has(b),w=!E&&!_):(E=!0,_=!0);let S=w||E,T=w||_,M=!1;S&&(M=d(y,f,w));let C=!1;T&&(C=d(v,f,w));let D=M||C;if(D)for(let P=0;P<3;P++){let I=y+P,L=v+P,H=l[I],k=l[I+3],G=l[L],z=l[L+3];l[h+P]=H<G?H:G,l[h+P+3]=k>z?k:z}return D}}}traverse(t,e=0){let n=this._roots[e],r=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=r[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=r[a+6],f=r[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=mi){let n=this._roots,r=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=r.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(hd(n[c]),Ny(0,r,h,t,s),Gf(),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=mi){let n=this._roots,r=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=r.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;hd(n[c]);let f=By(0,r,h,t);Gf(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,r=!1;for(let s of this._roots)if(hd(s),r=QP(0,n,t,e),Gf(),r)break;return r}shapecast(t,e,n){let r=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,p,m,g)=>{let y=p*3;return h(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:n,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=ks.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,p,m,g,y)=>h(f,p,m,g,y)?!0:FS(f,p,r,u,m,g,s)}else l||(u?l=(h,f,p,m)=>FS(h,f,r,u,p,m,s):l=(h,f,p)=>p);let c=!1,d=0;for(let h of this._roots){if(hd(h),c=KP(0,r,a,l,o,d),Gf(),c)break;d+=h.byteLength}return ks.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:r,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;fd.copy(e).invert();let c=ks.getPrimitive(),d=ks.getPrimitive();if(s){let f=function(p,m,g,y,v,x,b,w){for(let E=g,_=g+y;E<_;E++){Bi(d,E*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let S=p,T=p+m;S<T;S++)if(Bi(c,S*3,o,a),c.needsUpdate=!0,s(c,d,S,E,v,x,b,w))return!0}return!1};if(r){let p=r;r=function(m,g,y,v,x,b,w,E){return p(m,g,y,v,x,b,w,E)?!0:f(m,g,y,v,x,b,w,E)}}else r=f}t.getBoundingBox(zS),zS.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>zS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(US.copy(v),US.applyMatrix4(fd),t.shapecast({intersectsBounds:x=>US.intersectsBox(x),intersectsRange:(x,b,w,E,_)=>r(f,p,x,b,g,y,E,_)}))});return ks.releasePrimitive(c),ks.releasePrimitive(d),h}intersectsBox(t,e){return Hl.set(t.min,t.max,e),Hl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Hl.intersectsBox(n),intersectsTriangle:n=>Hl.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Hl.set(t.boundingBox.min,t.boundingBox.max,e),Hl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=ks.getPrimitive(),f=ks.getPrimitive(),p=Vy,m=HW,g=null,y=null;r&&(g=jW,y=WW);let v=1/0,x=null,b=null;return fd.copy(e).invert(),Hf.matrix.copy(fd),this.shapecast({boundsTraverseOrder:w=>Hl.distanceToBox(w),intersectsBounds:(w,E,_)=>_<v&&_<o?(E&&(Hf.min.copy(w.min),Hf.max.copy(w.max),Hf.needsUpdate=!0),!0):!1,intersectsRange:(w,E)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:_=>Hf.distanceToBox(_),intersectsBounds:(_,S,T)=>T<v&&T<o,intersectsRange:(_,S)=>{for(let T=_*3,M=(_+S)*3;T<M;T+=3){Bi(f,T,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=w*3,D=(w+E)*3;C<D;C+=3){Bi(h,C,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,x=C/3,b=T/3),P<s)return!0}}}});{let _=d?d.count:c.count;for(let S=0,T=_;S<T;S+=3){Bi(f,S,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,C=(w+E)*3;M<C;M+=3){Bi(h,M,u,l),h.needsUpdate=!0;let D=h.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=M/3,b=S/3),D<s)return!0}}}}}),ks.releasePrimitive(h),ks.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=v,n.faceIndex=x,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(fd),m.applyMatrix4(fd),r.distance=m.sub(r.point).length(),r.faceIndex=b),n)}closestPointToPoint(t,e={},n=0,r=1/0){let s=n*n,o=r*r,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(jf.copy(t).clamp(c.min,c.max),jf.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,jf);let h=t.distanceToSquared(jf);return h<a&&(Vy.copy(jf),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(Vy):e.point=Vy.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ni(0,new Float32Array(n),ZP),t.union(ZP)}),t}};var ih=$o($P());var qW=.5*(Math.sqrt(3)-1),Wf=(3-Math.sqrt(3))/6,YW=1/3,zs=1/6,oue=(Math.sqrt(5)-1)/4,aue=(5-Math.sqrt(5))/20,qf=i=>Math.floor(i)|0,e2=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]),HS=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 ky(i=Math.random){let t=n2(i),e=new Float64Array(t).map(r=>e2[r%12*2]),n=new Float64Array(t).map(r=>e2[r%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*qW,d=qf(s+c),h=qf(o+c),f=(d+h)*Wf,p=d-f,m=h-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let b=g-v+Wf,w=y-x+Wf,E=g-1+2*Wf,_=y-1+2*Wf,S=d&255,T=h&255,M=.5-g*g-y*y;if(M>=0){let P=S+t[T],I=e[P],L=n[P];M*=M,a=M*M*(I*g+L*y)}let C=.5-b*b-w*w;if(C>=0){let P=S+v+t[T+x],I=e[P],L=n[P];C*=C,l=C*C*(I*b+L*w)}let D=.5-E*E-_*_;if(D>=0){let P=S+1+t[T+1],I=e[P],L=n[P];D*=D,u=D*D*(I*E+L*_)}return 70*(a+l+u)}}function t2(i=Math.random){let t=n2(i),e=new Float64Array(t).map(s=>HS[s%12*3]),n=new Float64Array(t).map(s=>HS[s%12*3+1]),r=new Float64Array(t).map(s=>HS[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*YW,p=qf(o+f),m=qf(a+f),g=qf(l+f),y=(p+m+g)*zs,v=p-y,x=m-y,b=g-y,w=o-v,E=a-x,_=l-b,S,T,M,C,D,P;w>=E?E>=_?(S=1,T=0,M=0,C=1,D=1,P=0):w>=_?(S=1,T=0,M=0,C=1,D=0,P=1):(S=0,T=0,M=1,C=1,D=0,P=1):E<_?(S=0,T=0,M=1,C=0,D=1,P=1):w<_?(S=0,T=1,M=0,C=0,D=1,P=1):(S=0,T=1,M=0,C=1,D=1,P=0);let I=w-S+zs,L=E-T+zs,H=_-M+zs,k=w-C+2*zs,G=E-D+2*zs,z=_-P+2*zs,U=w-1+3*zs,$=E-1+3*zs,F=_-1+3*zs,j=p&255,X=m&255,q=g&255,V=.6-w*w-E*E-_*_;if(V<0)u=0;else{let W=j+t[X+t[q]];V*=V,u=V*V*(e[W]*w+n[W]*E+r[W]*_)}let Z=.6-I*I-L*L-H*H;if(Z<0)c=0;else{let W=j+S+t[X+T+t[q+M]];Z*=Z,c=Z*Z*(e[W]*I+n[W]*L+r[W]*H)}let Q=.6-k*k-G*G-z*z;if(Q<0)d=0;else{let W=j+C+t[X+D+t[q+P]];Q*=Q,d=Q*Q*(e[W]*k+n[W]*G+r[W]*z)}let K=.6-U*U-$*$-F*F;if(K<0)h=0;else{let W=j+1+t[X+1+t[q+1]];K*=K,h=K*K*(e[W]*U+n[W]*$+r[W]*F)}return 32*(u+c+d+h)}}function n2(i){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let r=n+~~(i()*(256-n)),s=e[n];e[n]=e[r],e[r]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var is=new an,Uy=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 r=0;r<t.count;r+=3){let s=1;is.a.fromBufferAttribute(t,r),is.b.fromBufferAttribute(t,r+1),is.c.fromBufferAttribute(t,r+2),s*=is.getArea(),e[r/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let r=0;r<e.length;r++)n+=e[r],this.distribution[r]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*n);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,r=e.length-1,s=-1;for(;n<=r;){let o=Math.ceil((n+r)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?r=o-1:n=o+1}return s}sampleFace(t,e,n){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),is.a.fromBufferAttribute(this.positionAttribute,t*3),is.b.fromBufferAttribute(this.positionAttribute,t*3+1),is.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(is.a,r).addScaledVector(is.b,s).addScaledVector(is.c,1-(r+s)),is.getNormal(n),this}};var i2=$o(jS()),XW=new se,KW=new se,QW=new se,pd;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(pd||(pd={}));var md=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new se;this.copyPreviousMatrix=!0;this.hiddenMatrix=new se;this.matrixWorldRigid=new se;this.shearScale=new se;this.shearScaleInv=new se}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof mt&&(n=n.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===n)return!0;r=r.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(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,n=!0);for(let r of this.children)r.updateMatrixWorld(n)}updateWorldMatrix(n,r){let s=this.parent;if(n&&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)),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(n,r=0){for(let s of this.children)pd.is(s)&&s.traverseObject(n,r+1)}traverseObject(n,r=0){if(n(this,r)!==!0)for(let o of this.children)pd.is(o)&&o.traverseObject(n,r+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,r=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,i2.SVD)(r),l=XW.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=KW.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=QW.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(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,r){this.updateWorldMatrix(!0,!1);let s=new se().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof se?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),r!==void 0&&(this.children.pop(),this.children.splice(r,0,n)),this}copy(n,r=!1){return super.copy(n,r),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,r,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var WS=class extends md(mt){},ZW=i=>i.type==="Mesh",un=class extends WS{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let r=this.children[e];r?.object!==n&&(r&&this.remove(r),r=new un(n),this.add(r),this.children.splice(e,0,this.children.pop()),r.matrixWorldNeedsUpdate=!0,r.matrixAutoUpdate=!1,r.matrix=n.matrix,r.hiddenMatrix=n.hiddenMatrix),r.expand(),e+=1,n=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 ZW(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 jl=new A,Wl=new A,gd=new se,o2=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],JW=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],$W=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],s2=(i,t,e)=>{i.updateEntityBoxSize(jl,Wl),gd.copy(t).multiply(i.matrixWorld),Wl.x===0&&Wl.y===0&&Wl.z===0?e.push(new A(jl.x,jl.y,jl.z).applyMatrix4(gd)):o2.forEach(n=>{e.push(n.clone().multiply(Wl).add(jl).applyMatrix4(gd))})},Yf=class extends Tt{constructor(){super(...arguments);this.matrix=new se;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new se().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,n)}expandByObjectSize(e,n,r=!1){let s=[];return r===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}s2(o,n,s)}}):s2(e,n,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(gd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Wl).multiplyScalar(.5),this.getCenter(jl),gd.copy(this.matrix).setPosition(jl),this.vertices=o2.map(e=>e.clone().multiply(Wl).applyMatrix4(gd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=JW.map(([e,n])=>new Xn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=$W.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var ss={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var YS=class extends uf{constructor(){super()}getPoints(t=12){let e=[],n,r=this.getCurveLengths(),o=r[r.length-1]/r.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?r[a]:r[a]-r[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let p=h[f];n&&n.equals(p)||(e.push(p),n=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var XS=.001;function KS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=XS}function qS(i,t){let e=new A(...i.position),n=new A(...i.controlNext.position),r=new A(...t.controlPrevious.position),s=new A(...t.position);return KS(e,n,s)&&KS(e,r,s)}function Gy(i){let t=i.points.map(c=>new A(...c.data.position)),e=[i.points[0]],n=new A(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)KS(n,t[c],t[c+1])||(e.push(i.points[c]),n=t[c]);e.push(i.points[i.points.length-1]);let r=i.isClosed,s=e.length-(r?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new A(...d.position),f=new A(...d.controlPrevious.position),p=new A(...d.controlNext.position),m={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:p};if(d.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...m,removedLength:0};continue}let g=r&&c==0?o-1:c-1,y=r&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,b=new A(...v.position),w=new A(...x.position),E=b.clone().sub(h).normalize(),_=w.clone().sub(h).normalize();Object.assign(m,{prevDir:E,nextDir:_});let S=qS(v,d),T=qS(d,x);if(!S||!T)a[c]={...m,removedLength:0};else{let M=E.clone().add(_).normalize(),C=M.clone().cross(E).length()/E.dot(M);a[c]={...m,tan:C,removedLength:d.roundness/C}}}for(let c=0;c<s;c++){let d=c,h=r&&c===o-1?0:c+1,f=a[d],p=a[h];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 d=c,h=r&&c===o-1?0:c+1,f=a[d],p=a[h],m=null;if(!qS(e[d].data,e[h].data))f.position.distanceTo(p.position)>XS&&(m=new Al(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)>XS&&(m=new Al(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 d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),p=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),m=d.tan*d.removedLength,g=d.prevDir.clone().add(d.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),b=g.clone().multiplyScalar(-m).add(x),w=h.distanceTo(b)/h.distanceTo(y),E=d.prevDir.clone().multiplyScalar(w*h.distanceTo(f)).add(h),_=E.clone().lerp(b,2),S=f.clone().lerp(E,4/3),T=p.clone().lerp(_,4/3);l[2*c]=new Al(f,S,T,p)}let u=new YS;return l.forEach(c=>{c&&u.add(c)}),u}var at;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(at||(at={}));var Gs=i=>at.is(i),e6={type:"completeState",isfromEntity:!0},t6=["x","y","z"],QS=new A,n6=new A().set(0,1,0),yd=i=>class extends md(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 Yf;this._recursiveBBox=new Yf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let r=this.children[n];if(at.is(r))return r}entityChildrenCount(){let n=this.children.length;for(;n--;)if(at.is(this.children[n]))return n+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 n=this;for(;n.data.type!=="Instance";){let r=n.parent;if(at.is(r))n=r;else return}return n}forInstancesRec(n){this.instances.forEach(r=>{r.disposed||n(r),r.forInstancesRec(n)})}super_Entity(n,r){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=r,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,r,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)No.toOps(this.data,o.data).forEach(l=>{let u=qg.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,r)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=No.patch(this.data,o),No.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,r)}))}s&&this.updateTransformState(this.dataPatched,r),this.stateSelection=n,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(n,r){n.setScalar(0),r.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Gs(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let r;return this.traverseEntity(s=>{s.uuid===n&&(r=s)}),r}traverseSortNextHelper(){let n=this.parent;if(n){let r=n.children,s=r.indexOf(this)+1;if(at.is(r[s]))return r[s];if(at.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&at.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let r=this;for(;n>0&&r!==null;)r=r.parent,n-=1;return r}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let r=this.parent;for(;r;){if(n===r)return!0;r=r.parent}return!1}countToAccestor(n){let r=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,r+=1}return r}forEachEntity(n){for(let r of this.children)Gs(r)&&n(r)}traverseEntityAncestors(n){this.traverseAncestors(r=>{at.is(r)&&n(r)})}traverseConcreteEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.isConcreteEntity&&o.traverseEntity(n,r+1)}traverseEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.traverseEntity(n,r+1)}traverseVisibleEntity(n){n(this);for(let r of this.children)Gs(r)&&r.visible&&r.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){super.updateMatrixWorld(n),this.dispatchEvent({type:"updateMatrixWorld"})}copy(n,r=!1){return super.copy(n,r),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Gs(n))}isAncestorOf(n){if(this.uuid===n)return!1;let r=!1;return this.traverseEntity(s=>{s.uuid===n&&(r=!0)}),r}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x*we.RAD2DEG,this.rotation.y*we.RAD2DEG,this.rotation.z*we.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ou(r,n)}getTransformValues(n,r,s){return r[n].map((o,a)=>s?.shared.getVariable(o,[this.uuid,n,t6[a]])??o)}updateTransformState(n,r){let s=!1;return n.position&&(this.position.fromArray(this.getTransformValues("position",n,r)),s=!0),n.rotation&&(QS.fromArray(this.getTransformValues("rotation",n,r)).multiplyScalar(we.DEG2RAD),this.rotation.setFromVector3(QS),s=!0),n.scale&&(this.scale.fromArray(this.getTransformValues("scale",n,r)),s=!0),n.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??Ma.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(n=!1){if(n){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)at.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{at.is(n)&&n.disposeRecursively()})}toState(n=[]){let r={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Ou(r,n)}updateByObjUpdateOp(n,r){n!==void 0&&this.updateByOp({type:0,props:n,path:[]},{...this.data,...n},r,!1)}updateByOp(n,r,s,o){let a=this.data;this.data=r;let l=n,u=Rr(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(delete d.name,Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=_n.zoom(h,n.path.slice(2));if(f)for(let p in n.props)n.props[p]===void 0&&p in f&&(d[p]=f[p])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=_n.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,No.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Rr(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(Ds.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=_n.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let p=n.props;if(f)for(let[m,g]of Object.entries(n.props))g===void 0&&(p===n.props&&(p={...n.props}),p[m]=f[m]);n={...n,props:p}}h.overrideData=qu.resolve(r.overrides,c),h.updateByOp(n,Tn.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of Fs.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of Fs.rootOverrideProps)if(Rr(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=Ds.filterOp(d.overrideData,c);h&&d.updateByOp(h,Tn.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=Ds.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=r:f=Tn.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,r,s){if(this.dataPatched=r,n.path.length===0&&n.type===0)n.props.type!==void 0&&!ns.is(n.props.type)&&ss.changeEntityProptotype(this,r,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){ss.changeEntityProptotype(this,r,s);for(let o of this.children)at.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,r,s)}updateByPatchedOp(n,r,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Rr(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(r.pathSnapping),Rr(n.path,["cloner"])!==null){let o=Tn.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(r.cloner,s.scene):(this.setFromClonerState(r.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n=this.dataPatched.pathSnapping){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let r=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(r===null)return;let l=n.find(r);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=Gy(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new se;l.updateMatrixWorld();let p=new se().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(p);let m={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new se().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(g).add(h),v=new se().lookAt(h,y,n6),x=QS.setFromEuler(new qt().setFromRotationMatrix(v)).multiplyScalar(we.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(e6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,r){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),r&&"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,r),this.updateVisible()),this.updateTransformState(n,r)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof ss.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,r){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new ss.Cloner(this,n),r.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,r.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var Hy=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=we.clamp(e.thetaLength,0,360);let n=e.width/2,r=e.radiusTop??n,s=e.radiusBottom??n;return r===s?(r=n,s=n):r>s?(r=n,s=s*n/r):(r=r*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:r,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=i.parameters,p;return l===0?(p=new Ee,p.setAttribute("position",new be([],3))):d||f?p=new Xf(u,c,n,r,s,o,a,l*Math.PI/180,d,d,h,f):p=new _l(u,c,n,r,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function Ua(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function a2(i){return new B(i.y,-i.x)}var Xf=class extends Ee{constructor(t,e,n,r,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,r=Math.floor(r)||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=n/2,b=new A,w=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let E=new B(t,x),_=new B(e,-x),S=null,T=null,M=null,C=null,D=E.clone().sub(_),P=0,I=0,L=0;h>0&&(P=Math.min(t,e)*(1-h),I=t-P,L=e-P);let H=E.clone();H.x-=P;let k=Math.PI-D.angle(),G=D.angle(),z=Math.tan(G/2),U=Math.tan(k/2),$=z+U,F=h?$:U,j=h?$:z;if(u=Math.min(u,(t-I)/F,D.length()/$),c=Math.min(c,(e-L)/j,D.length()/$),u>0){let K=u/z;S=E.clone().sub(new B(K,u)),h&&(M=S.clone(),M.x-=P-$*u),E.sub(D.clone().setLength(K))}if(c>0){let K=c/U;T=_.clone().sub(new B(K,-c)),_.add(D.clone().setLength(K)),h&&(C=T.clone(),C.x-=P-$*c,H.sub(D.clone().setLength(K)))}D=E.clone().sub(_);let X=D.length()<.5,q=[];for(let K=0;K<=r;K++){let W=[],ye=K/r,fe=ye*l+a,ie=new B(Math.sin(fe),Math.cos(fe));C&&T?(V(W,ye,ie,k,c,C,-1,!0),V(W,ye,ie,G,c,T,-1,!1)):T?(Z(W,ie,T.x,0,-1),V(W,ye,ie,G,c,T,-1,!1)):o||Z(W,ie,e,L,-1);let Ae=a2(D).normalize();if(Ua(Ae,ie,b),!X)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=D.clone().multiplyScalar(Oe).add(_);Ua(Ie,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}if(M&&S?(V(W,ye,ie,k,u,S,1,!1),V(W,ye,ie,G,u,M,1,!0)):S?(V(W,ye,ie,k,u,S,1,!1),Z(W,ie,S.x,0,1)):o||Z(W,ie,t,I,1),h&&!X){let xe=a2(D).multiplyScalar(-1).normalize();Ua(xe,ie,b);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=D.clone().multiplyScalar(-Ie).add(H);Ua(Pe,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}}h&&!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&&h&&W==s)continue;let ye=q[K][W],fe=q[K+1][W],ie=q[K+1][W+1],Ae=q[K][W+1],xe=m[ie*3+0],Oe=m[ie*3+2];p.push(ye,fe,Ae),(xe!=0||Oe!=0)&&p.push(fe,ie,Ae)}l<Math.PI*2&&(Q(-1,q[0],a),Q(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 V(K,W,ye,fe,ie,Ae,xe,Oe){for(let Ie=0;Ie<d+1;Ie++){let Pe=Ie/d,Te=xe<0?Pe:1-Pe;Oe&&(Te-=1),Te*=fe;let Ue=new B(Math.sin(Te),Math.cos(Te)*xe),ze=Ue.clone().multiplyScalar(ie).add(Ae);Ua(ze,ye,w),m.push(w.x,w.y,w.z),Ua(Ue,ye,b),g.push(b.x,b.y,b.z),y.push(W,.5+w.y/n),K.push(v++)}}function Z(K,W,ye,fe,ie){let Ae=new A,xe=new B,Oe=[ye,fe];ie<0&&Oe.reverse();for(let Ie of Oe)xe.set(Ie,x*ie),Ua(xe,W,Ae),m.push(Ae.x,Ae.y,Ae.z),g.push(0,ie,0),y.push(.5,.5),K.push(v++)}function Q(K,W,ye){let fe=new B(Math.sin(ye),Math.cos(ye)),ie=new B(-Math.cos(ye),Math.sin(ye)),Ae=new A,xe=K<0?(Pe,Te,Ue)=>p.push(Pe,Te,Ue):(Pe,Te,Ue)=>p.push(Pe,Ue,Te),Oe=new B((t+e+I+L)/4,0);Ua(Oe,fe,Ae),m.push(Ae.x,Ae.y,Ae.z),g.push(ie.x,0,ie.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let Te=m.slice(Pe*3,Pe*3+3);m.push(...Te),g.push(ie.x,0,ie.y);let Ue=y.slice(Pe*2,Pe*2+2);y.push(...Ue),v++}for(let Pe=Ie+1;Pe<v-1;Pe++)xe(Ie,Pe,Pe+1);xe(Ie,v-1,Ie+1)}}};var l2=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=we.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:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=i.parameters,h;return l===0?(h=new Ee,h.setAttribute("position",new be([],3))):u>0||c>0||l<360?h=new Xf(0,t/2,n,r,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new zc(t/2,n,r,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"ConeGeometry"}})}};var c2=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:n,widthSegments:r,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new sr(t,e,n,r,s,o):u=new JS(t,e,n,r,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},ZS=Math.PI/2,JS=class extends Ee{constructor(t=1,e=1,n=1,r=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],p=0,m=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,r,0),y("x","y","z",1,-1,1,t,e,n,r,1),y("x","y","z",-1,1,1,t,e,n,r,0),y("x","y","z",1,1,-1,t,e,n,r,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,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(d,3)),this.setAttribute("normal",new be(h,3)),this.setAttribute("uv",new be(f,2));function g(x,b,w,E,_,S,T,M,C,D,P){let I=(S-2*a)/C,L=(T-2*a)/D,H=S/2-a,k=T/2-a,G=M/2,z=C+1,U=D+1,$=0,F=0,j=new A;for(let X=0;X<U;X++){let q=X*L-k;for(let V=0;V<z;V++){let Z=V*I-H;j[x]=Z*E,j[b]=q*_,j[w]=G,d.push(j.x,j.y,j.z),j[x]=0,j[b]=0,j[w]=M>0?1:-1,h.push(j.x,j.y,j.z),f.push(V/C),f.push(1-X/D),$+=1}}for(let X=0;X<D;X++)for(let q=0;q<C;q++){let V=p+q+z*X,Z=p+q+z*(X+1),Q=p+(q+1)+z*(X+1),K=p+(q+1)+z*X;c.push(V,Z,K),c.push(Z,Q,K),F+=6}u.addGroup(m,F,P),m+=F,p+=$}function y(x,b,w,E,_,S,T,M,C,D,P){let I=(T-2*a)/D,L=T/2-a,H=M/2-a,k=C/2,G=D+1,z=0,U=0,$=new A,F=new A;for(let j=0;j<l+1;j++){let X=j/l*ZS,q=Math.sin(X)*a,V=(1-Math.cos(X))*a,Z=Math.sin(X),Q=Math.cos(X);$[b]=(H+q)*_,$[w]=(k-V)*S,F[x]=0,F[b]=Z*Math.sign($[b]),F[w]=Q*Math.sign($[w]);for(let K=0;K<G;K++){let W=K*I-L;$[x]=W*E,d.push($.x,$.y,$.z),h.push(F.x,F.y,F.z),f.push(K/D),f.push(0),z+=1}}for(let j=0;j<l;j++)for(let X=0;X<D;X++){let q=p+X+G*j,V=p+X+G*(j+1),Z=p+(X+1)+G*(j+1),Q=p+(X+1)+G*j;c.push(q,V,Q),c.push(V,Z,Q),U+=6}u.addGroup(m,U,P),m+=U,p+=z}function v(x,b,w){let E=new A,_=new A(t/2,e/2,n/2);_.subScalar(a);let S=[],T=x*b*w>0?(C,D,P)=>c.push(C,D,P):(C,D,P)=>c.push(C,P,D);for(let C=0;C<=l;C++){let D=[],P=ZS*(1-C/l),I=Math.cos(P),L=Math.sin(P),H=0;for(let k=0;k<=C;k++){let G=Math.cos(H),z=Math.sin(H);E.x=I*G,E.y=L,E.z=I*z;let U=_.clone().addScaledVector(E,a);d.push(x*U.x,b*U.y,w*U.z),h.push(x*E.x,b*E.y,w*E.z),f.push(0,0),D.push(p++),H+=ZS/C}S.push(D)}let M=S.length-1;for(let C=0;C<M;C++){let D=S[C],P=S[C+1],I=D.length-1;T(D[0],P[1],P[0]);for(let L=1;L<=I;L++)T(D[L-1],D[L],P[L]),T(D[L],P[L+1],P[L])}}}};var za=class extends Ee{constructor(t=[],e=[],n="",r=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),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}[n],p=new A,m=p.clone(),g=new an,y=s*r,v=r-y,x=o+1,b=new A,w=(z,U)=>b.subVectors(z,U).normalize(),E=(z,U)=>Array(z).fill(void 0).map(U),_=E(t.length/3,(z,U)=>new A().fromArray(t,U*3).setLength(r)),S=[],T=1e6;for(let z=0;z<_.length;z++){let U=_[z],$=[],F,j,X,q=1e10,V=-1;for(;(V=e.indexOf(z,V+1))!=-1;){let W=V-V%3;F=e[W+(V+1)%3],j=e[W+(V+2)%3],X=U.distanceToSquared(_[F]),q=Math.min(q,X),$.push([F,j,X])}q+=1e-6;let Z=[],Q=0,K=$.length;for(let W=0;W<K;W++){[F,j,X]=$[Q];let ye=S[F]?.includes(z)==!0;X<=q&&Z.push(F+ +ye*T),Q=$.findIndex(fe=>fe[0]==j)}S.push(Z)}let M=[];{let z=0,U=0,$,F,j=f==3;for(let X=0;X<=o;X++){$=X*(X+1)/2,F=(X+1)*(X+2)/2;for(let q=0;q<o-X;q++)[z,U]=[$+q+X+2,F+q+X+3],M.push($,F,...j?[U,$]:[z,F],U,z),[$,F]=[z,U];M.push($,F,$+o+2)}}let C=p.clone(),D=p.clone(),P=p.clone(),I=p.clone(),L=p.clone(),H=[],k=E(_.length,()=>E(f,()=>p.clone()));for(let z=0;z<_.length;z++){p.copy(_[z]).normalize(),C.copy(p).multiplyScalar(v);let U=S[z];for(let Z=0;Z<U.length;Z++){let Q=U[Z],K=U[(Z+1)%f];g.setFromPointsAndIndices(_,z,Q%T,K%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,k[z][Z])}let $=[],F=[],j=[],X=new A;o==0&&[...k[z]].reduce((Z,Q)=>Z.add(Q),X).multiplyScalar(1/f);for(let Z=0;Z<f;Z++){let Q=[],K=(Z-1+f)%f,W=k[z][K],ye=k[z][Z];p.copy(W).sub(C),m.copy(ye).sub(C);let fe=C.angleTo(p),ie=p.angleTo(m),Ae=Math.cos(fe)*y;o==0?D.copy(X):D.copy(C).setLength(v+Ae),F.push(Ae);let xe=[D,W,ye];for(let Oe=0;Oe<2;Oe++){let Ie=xe[Oe],Pe=xe[Oe+1];I.subVectors(Ie,C),L.subVectors(Pe,C),P.crossVectors(I,L).normalize();for(let Te=0;Te<x;Te++){let Ue=[fe,ie][Oe]*Te/x;p.copy(I).applyAxisAngle(P,Ue).add(C),$.push(p.clone()),Oe&&(w(p,C),Q.push([Te==0?Ie:p.clone(),b.clone()]))}Oe&&(w(Pe,C),Q.push([Pe,b.clone()]))}j.push(Q)}H.push(j);let q=2*x,V=2;for(let Z=0;Z<f;Z++){let Q=q*Z,K=q*((Z+1)%f),W=[$[Q]];for(let fe=1;fe<x;fe++){I=$[Q+fe],L=$[K+fe],W.push(I);for(let ie=1,Ae=fe-V+1;ie<=Ae;ie++)p.lerpVectors(I,L,ie/(Ae+1)),p.sub(C).setLength(F[Z]).add(C),W.push(p.clone());W.push(L)}for(let fe=0;fe<x;fe++)W.push($[fe+x+Q]);W.push($[K+x]);let ye=M.map(fe=>W[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(w(fe,C),[b.x,b.y,b.z])).flat())}}let G=[];for(let z=0;z<S.length;z++)for(let U=0;U<f;U++){let $=S[z][U];if($<T){let F=S[$].findIndex(q=>q%T==z),j=H[z][U],X=H[$][F];for(let q=0;q<x;q++){let V=j[q],Z=X[x-q],Q=j[q+1],K=X[x-(q+1)];[V,Z,Q,Q,Z,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)})}G.push(j[0][0],X[x][0],j[x][0],X[0][0])}}for(;G.length;){let z,U,$,F;[z,U]=G.splice(0,2);let j=[z];for(;z!=U;)j.push(U),$=G.indexOf(U),F=$%2,U=G.splice($-F,2)[1-F];b.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let X=b.dot(j[0])<0;X&&b.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +X],j[q+1-+X],j[0]].forEach(V=>{a.push(V.x,V.y,V.z),u.push(b.x,b.y,b.z)})}}function d(){let h=new A;for(let _=0;_<a.length;_+=3){h.x=a[_+0],h.y=a[_+1],h.z=a[_+2];let S=w(h)/2/Math.PI+.5,T=E(h)/Math.PI+.5;l.push(S,1-T)}let f=new A,p=new A,m=new A,g=new A,y=new B,v=new B,x=new B,b=(_,S,T,M)=>{M<0&&_.x===1&&(l[S]=_.x-1),T.x===0&&T.z===0&&(l[S]=M/2/Math.PI+.5)};for(let _=0,S=0;_<a.length;_+=9,S+=6){f.set(a[_+0],a[_+1],a[_+2]),p.set(a[_+3],a[_+4],a[_+5]),m.set(a[_+6],a[_+7],a[_+8]),y.set(l[S+0],l[S+1]),v.set(l[S+2],l[S+3]),x.set(l[S+4],l[S+5]),g.copy(f).add(p).add(m).divideScalar(3);let T=w(g);b(y,S+0,f,T),b(v,S+2,p,T),b(x,S+4,m,T)}for(let _=0;_<l.length;_+=6){let S=l[_+0],T=l[_+2],M=l[_+4],C=Math.max(S,T,M),D=Math.min(S,T,M);C>.9&&D<.1&&(S<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),M<.2&&(l[_+4]+=1))}function w(_){return Math.atan2(_.z,-_.x)}function E(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(t){return new za(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var u2=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:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Kf(t*.5,s,o):new Hc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Kf=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=1/r,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,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new Kf(t.radius,t.corner,t.cornerSides)}};var Qf=1e-12,vd=class{constructor(t){this.position=new B;this.startPosition=new B;this.uuid=we.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 vd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},xd=class extends vd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new xd(this.parent).copy(this)}},os=class extends vd{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new xd(this),new xd(this))}static create(e,n){let r=new os(e,new B(...n.position));return r.controls[0].position.set(...n.controlPrevious.position),r.controls[1].position.set(...n.controlNext.position),r.roundness=n.roundness,r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,r}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let r=0,s=this.controls.length;r<s;r++){let o=this.controls[r];this.position.distanceTo(o.position)<=n?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 os(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),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new B,n=new B){let[r,s]=this.computeTangents();return r&&s&&(d2(r,e),d2(s,n)),[e,n]}computeTangent(e=new B){let[n,r]=this.computeTangents();return n&&r&&e.copy(n).add(r).normalize(),e}computeNormal(e=new B){let[n,r]=this.computeNormals();return e.copy(n).add(r).normalize(),e}};function d2(i,t=new B){let e=i.length();return t.set(-i.y/e,i.x/e)}var ew=i=>i,bd=new B,jy=new B,r6=new B,i6=new B,s6=new B,o6=new B,f2=new A,p2=new A;function m2(i){let t=new B;t.addVectors(i.v0,bd.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new B;return e.addVectors(i.v2,jy.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Ir(i.v0,t,e,i.v2)}function Zf(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function a6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function l6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function tw(i,t,e){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),r=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((r*r+n*n-s*s)/(2*r*n))}function g2(i,t,e){return h2(i,t)&&h2(t,e)&&$S(i.position,t.position,e.position)}function $S(i,t,e){return bd.copy(t).sub(i).cross(jy.copy(e).sub(i))===0}function y2(i,t,e,n,r){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 n.set(a+l,o+u),r.set(a-l,o-u),[n,r]}function v2(i,t,e){let n=i.distanceTo(e),r=t.distanceTo(e);return n<r?t:i}function x2(i,t,e,n,r,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)),d;return tw(t,i,e)>Math.PI&&(c*=-1),Zf(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),r.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[r,s]}function nw(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function h2(i,t){return $S(i.position,i.controls[1].position,t.position)&&$S(i.position,t.controls[0].position,t.position)}function b2(i,t,e,n,r=.5){let s=bd.subVectors(t,i).multiplyScalar(r).add(i),o=jy.subVectors(e,t).multiplyScalar(r).add(t),a=r6.subVectors(n,e).multiplyScalar(r).add(e),l=s,u=i6.subVectors(o,s).multiplyScalar(r).add(s),c=s6.subVectors(a,o).multiplyScalar(r).add(o),d=a,h=o6.subVectors(c,u).multiplyScalar(r).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function S2(i,t,e=12,n=!0){let r=p2.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=ew(t[l]),c=bd,d=Ga(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof Ir||u instanceof yi||u instanceof Or){if(u.getPoint(h/d,c),r.set(c.x,c.y,0),s!==void 0&&l6(s,r))continue;s===void 0&&(s=f2),s.copy(r),i.setXYZ(o,r.x,r.y,r.z),o++}}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++),i}function w2(i,t,e,n=12,r=!0){let s=p2.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=ew(t[l]),d=bd,h=Ga(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof Ir||c instanceof yi||c instanceof Or){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=f2:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}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++),a}function rw(i,t=12,e=!1){let n=[];for(let r=0,s=i.length;r<s;r++){let o=i[r],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Ga(o.roundedCurveCorner,t)*.5;r>0&&(n[r-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Ga(o.curveAfter,t)),n.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(n[i.length-1]+=Ga(i[0].roundedCurveCorner,t)*.5),n}function Ga(i,t=12){return i&&i instanceof wl?t*2:i&&(i instanceof Or||i instanceof cf)?1:i&&i instanceof kc?t*i.points.length:t}function A2(i,t,e=12,n=!0){let r,s=0;for(let o=0;o<t.length;o++){let a=ew(t[o]),l=Ga(a,e),u=bd;for(let c=0;c<=l;c++)if(a instanceof Ir||a instanceof yi||a instanceof Or){if(a.getPoint(c/l,u),r!==void 0&&a6(r,u,Qf))continue;r===void 0&&(r=jy),r.copy(u),i.push(u.x,u.y),s++}}return Zf(i[0],i[i.length-2],Qf)&&Zf(i[1],i[i.length-1],Qf)&&(i.pop(),i.pop()),n&&s>1&&!(Zf(i[s-1],i[1],Qf)&&Zf(i[s-2],i[0],Qf))&&(i.push(i[0],i[1]),s++),i}var iw=new B,c6=new B,u6=new B,d6=new B,h6=new B,f6=new B,Pt=class extends _o{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new En(new A(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=we.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,r){let s=new Pt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>os.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Pt.createFromState(o)),n!==void 0&&r!==void 0&&s.applySize(n,r),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 n=0,r=this.points.length;n<r;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,r=this.points.findIndex(s=>s.uuid===e);if(r<0){let s=n;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 r}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let r=iw.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(r),a.controls[0].position.multiply(r),a.controls[1].position.multiply(r)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,r=we.generateUUID()){let s;e instanceof B?s=e:s=new B(e,n);let o=new os(r,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,r=this.shapeHoles.length;n<r;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(r=>r.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,r=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=r?this.roundedCurveDivisions:this.curveDivisions;return S2(e,r?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=rw(this.points,e,!1),this.roundedCurveDivisions=rw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,r=12){return w2(e,this.curves,n,r,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),A2(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Ga(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<r+c)return[l,(a-r+1)/c];r+=c}return[0,1]}getCurveT(e,n,r){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(nw(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(iw.set(r.x,r.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){nw(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,n.curveAfter=r;let s=r.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],r=this.points[this.points.length-1];this._applyCurveForPoint(n,r)}if(this.points.length>2){let n=0;for(let r=0,s=this.points.length;r<s;r++){let o=this.points[r],a=this.points[r-1]??this.points[this.points.length-1],l=this.points[r+1]??this.points[0],u=o.roundness,c=a&&l&&g2(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=d.getLength(),g=h.getLength(),y=Math.min(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),b=1-x/m,w=x/g,E=d.getPointAt(b,iw),_=h.getPointAt(w,c6);this._subSplitCurve(d,f,b,E,void 0),this._subSplitCurve(h,p,w,void 0,_);let S;if(this.useCubicForRoundedCorners){let T=tw(E,o.position,_)/2,M=Math.tan(T)*E.distanceTo(o.position),[C,D]=y2(E,_,M,u6,d6),P=v2(C,D,o.position),[I,L]=x2(P,E,_,M,h6,f6);S=new Ir(E.clone(),I.clone(),L.clone(),_.clone())}else S=new yi(E.clone(),o.position.clone(),_.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(r+n,0,S),n++}}}}_subSplitCurve(e,n,r,s,o){if(e instanceof Or)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(r,0),c=b2(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 n}clone(){let e=new Pt(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let r=0;r<n;r++){let s=r*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],d=e.points[s+5],h=e.points[s+6],f=new os(we.generateUUID(),new B(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(r=>{let s=new Pt;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,n=!1){this.isText=n;let r=(o,a)=>{a instanceof Ir&&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 yi&&(o[l]=m2(o[l]));for(l=0,u=o.length;l<u;l++){let h=o[l],f=l>0?o[l-1]:null,p;h instanceof Ir?(p=this.createPoint(h.v0),p.controls[1].position.copy(h.v1)):h instanceof Or&&(p=this.createPoint(h.v1)),p!==void 0&&(f!==null&&r(p,f),a.push(p))}let c=o[o.length-1],d=!1;return c instanceof Ir?c.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(c.v2),d=!0):c instanceof Or&&c.v2.equals(a[0].position)&&(d=!0),this.isClosed=d,a};return this.points=s(e.curves),e instanceof _o&&(this.shapeHoles=e.holes.map(o=>{let a=new Pt;return a.fromShape(o),a})),this.update(),this}updatePoint(e,n){let r=this.getPointByUuid(e);r&&(n.position!==void 0&&r.position.fromArray(n.position),n.roundness!==void 0&&(r.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var ow=Math.PI*2;function sw({x:i,y:t},e,n,r,s){return{x:i*e+r,y:t*n+s}}function p6(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(i),r=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*e,y:r+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function E2(i,t,e,n){let r=i*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*n));return r*Math.acos(s)}function m6(i,t,e,n,r,s,o,a,l,u){let c=Math.pow(r,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),p=c*d-c*f-d*h;p<0&&(p=0),p/=c*f+d*h,p=Math.sqrt(p)*(l===u?-1:1);let m=p*r/s*a,g=p*-s/r*o,y=m+(i+e)/2,v=g+(t+n)/2,x=(o-m)/r,b=(a-g)/s,w=(-o-m)/r,E=(-a-g)/s,_=E2(1,0,x,b),S=E2(x,b,w,E);return!u&&S>0&&(S-=ow),u&&S<0&&(S+=ow),{centerx:y,centery:v,ang1:_,ang2:S}}function _2({px:i,py:t,cx:e,cy:n,rx:r,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(r===0||s===0)return[];let u=(i-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];r=Math.abs(r),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(r,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(r*=Math.sqrt(d),s*=Math.sqrt(d));let h=m6(i,t,e,n,r,s,u,c,o,a),{ang1:f,ang2:p}=h,{centerx:m,centery:g}=h,y=Math.abs(p)/(ow/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(p6(f,p)),f+=p;return l.map(x=>{let{x:b,y:w}=sw(x[0],r,s,m,g),{x:E,y:_}=sw(x[1],r,s,m,g),{x:S,y:T}=sw(x[2],r,s,m,g);return{x1:b,y1:w,x2:E,y2:_,x:S,y:T}})}var xt;(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"})(xt||(xt={}));var mn;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(mn||(mn={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Qe=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,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?r<s?e.t-t.t+(t.t-n.t)*(r/(r+s)):e.t-n.t+(n.t-t.t)*(s/(r+s)):0},i.edgeSign=function(t,e,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?(e.t-n.t)*r+(e.t-t.t)*s:0},i.transEval=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?r<s?e.s-t.s+(t.s-n.s)*(r/(r+s)):e.s-n.s+(n.s-t.s)*(s/(r+s)):0},i.transSign=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?(e.s-n.s)*r+(e.s-t.s)*s:0},i.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},i.interpolate=function(t,e,n,r){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+r)/2:e+(r-e)*(t/(t+n)):r+(e-r)*(n/(t+n))},i.intersect=function(t,e,n,r,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(n,r)||(l=n,n=r,r=l),i.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.vertLeq(n,e)?i.vertLeq(e,r)?(o=i.edgeEval(t,n,e),a=i.edgeEval(n,e,r),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,e.s)):(o=i.edgeSign(t,n,e),a=-i.edgeSign(t,r,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,r.s)):s.s=(n.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(n,r)||(l=n,n=r,r=l),i.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.transLeq(n,e)?i.transLeq(e,r)?(o=i.transEval(t,n,e),a=i.transEval(n,e,r),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,e.t)):(o=i.transSign(t,n,e),a=-i.transSign(t,r,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,r.t)):s.t=(n.t+e.t)/2},i}(),Jf=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}(),Wy=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}(),Sd=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}(),T2=function(){function i(){var t=new Sd,e=new Jf,n=new Wy(0),r=new Wy(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=r,r.next=r,r.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=r}return i.prototype.makeEdge_=function(t){var e=new Wy(0),n=new Wy(1);t.Sym.side<t.side&&(t=t.Sym);var r=t.Sym.next;return n.next=r,r.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},i.prototype.splice_=function(t,e){var n=t.Onext,r=e.Onext;n.Sym.Lnext=e,r.Sym.Lnext=t,t.Onext=r,e.Onext=n},i.prototype.makeVertex_=function(t,e,n){var r=t;nt(r,"Vertex can't be null!");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e;var o=e;do o.Org=r,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,n){var r=t;nt(r,"Face can't be null");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e,r.trail=null,r.marked=!1,r.inside=n.inside;var o=e;do o.Lface=r,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},i.prototype.killVertex_=function(t,e){var n=t.anEdge,r=n;do r.Org=e,r=r.Onext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var n=t.anEdge,r=n;do r.Lface=e,r=r.Lnext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new Sd,e=new Sd,n=new Jf,r=this.makeEdge_(this.eHead);return this.makeVertex_(t,r,this.vHead),this.makeVertex_(e,r.Sym,this.vHead),this.makeFace_(n,r,this.fHead),r},i.prototype.splice=function(t,e){var n=!1,r=!1;if(t!==e){if(e.Org!==t.Org&&(r=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!r){var s=new Sd;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Jf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!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),!n){var r=new Jf;this.makeFace_(r,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),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var r=new Sd;return this.makeVertex_(r,n,e.Org),e.Lface=n.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},i.prototype.connect=function(t,e){var n=!1,r=this.makeEdge_(t),s=r.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(r,t.Lnext),this.splice_(s,e),r.Org=t.Dst,s.Org=e.Org,r.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Jf;this.makeFace_(o,r,t.Lface)}return r},i.prototype.zapFace=function(t){var e=t.anEdge,n,r,s,o,a;r=e.Lnext;do n=r,r=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},i.prototype.mergeConvexFaces=function(t){var e,n,r,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;r=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Qe.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Qe.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(r=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=r;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,r,s,o,a,l,u;for(s=t,s=t;(r=s.next)!==t;s=r){nt(r.prev===s),l=r.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===r),l=l.Lnext;while(l!==r.anEdge)}for(nt(r.prev===s&&r.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=n,u=n;(l=u.next)!==n;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}(),M2=function(){function i(){this.handle=null}return i}(),C2=function(){function i(){this.key=null,this.node=0}return i}(),g6=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 n=0;n<t+1;n++)this.nodes[n]=new M2,this.handles[n]=new C2;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,nt(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[r].key,n[s].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[r].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[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,n;if(e=++this.size,e*2>this.max){this.max*=2;var r,s;for(s=this.nodes.length,this.nodes.length=this.max+1,r=s;r<this.nodes.length;r++)this.nodes[r]=new M2;for(s=this.handles.length,this.handles.length=this.max+1,r=s;r<this.handles.length;r++)this.handles[r]=new C2}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,r=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),r},i.prototype.delete=function(t){var e=this.nodes,n=this.handles,r;nt(t>=1&&t<=this.max&&n[t].key!==null),r=n[t].node,e[r].handle=e[this.size].handle,n[e[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[e[r>>1].handle].key,n[e[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},i}(),aw=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}(),P2=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),y6=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new P2,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 n=new P2;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),v6=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,n){var r=t.event,s=e.eUp,o=n.eUp;if(s.Dst===r)return o.Dst===r?Qe.vertLeq(s.Org,o.Org)?Qe.edgeSign(o.Dst,s.Org,o.Org)<=0:Qe.edgeSign(s.Dst,o.Org,s.Org)>=0:Qe.edgeSign(o.Dst,r,o.Org)<=0;if(o.Dst===r)return Qe.edgeSign(s.Dst,r,s.Org)>=0;var a=Qe.edgeEval(s.Dst,r,s.Org),l=Qe.edgeEval(o.Dst,r,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,n){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},i.topLeftRegion=function(t,e){var n=e.eUp.Org,r;do e=i.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(r=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),r===null)return null;i.fixUpperEdge(t,e,r),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,n){var r=new aw;return r.eUp=n,r.nodeUp=t.dict.insertBefore(e.nodeUp,r),r.fixUpperEdge=!1,r.sentinel=!1,r.dirty=!1,n.activeRegion=r,r},i.isWindingInside=function(t,e){switch(t.windingRule){case xt.ODD:return(e&1)!==0;case xt.NONZERO:return e!==0;case xt.POSITIVE:return e>0;case xt.NEGATIVE:return e<0;case xt.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 n=e.eUp,r=n.Lface;r.inside=e.inside,r.anEdge=n,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,n){for(var r,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),r=s.eUp,r.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}r=t.mesh.connect(a.Lprev,r.Sym),i.fixUpperEdge(t,s,r)}a.Onext!==r&&(t.mesh.splice(r.Oprev,r),t.mesh.splice(a,r)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,n,r,s,o){var a,l,u,c,d=!0;u=n;do nt(Qe.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==r);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,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),d=!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,n){t.mesh.splice(e,n)},i.vertexWeights=function(t,e,n){var r=Qe.vertL1dist(e,t),s=Qe.vertL1dist(n,t),o=.5*s/(r+s),a=.5*r/(r+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},i.getIntersectData=function(t,e,n,r,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,n,r),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp;if(Qe.vertLeq(r.Org,s.Org)){if(Qe.edgeSign(s.Dst,r.Org,s.Org)>0)return!1;Qe.vertEq(r.Org,s.Org)?r.Org!==s.Org&&(t.pq.delete(r.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,r)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(r,s.Oprev),e.dirty=n.dirty=!0)}else{if(Qe.edgeSign(r.Dst,s.Org,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Oprev,r)}return!0},i.checkForLeftSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o;if(nt(!Qe.vertEq(r.Dst,s.Dst)),Qe.vertLeq(r.Dst,s.Dst)){if(Qe.edgeSign(r.Dst,s.Dst,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(r),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Qe.edgeSign(s.Dst,r.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(r.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o=r.Org,a=s.Org,l=r.Dst,u=s.Dst,c,d,h=new Sd,f,p;if(nt(!Qe.vertEq(u,l)),nt(Qe.edgeSign(l,t.event,o)<=0),nt(Qe.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(Qe.vertLeq(o,a)){if(Qe.edgeSign(u,o,a)>0)return!1}else if(Qe.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Qe.intersect(l,o,u,a,h),nt(Math.min(o.t,l.t)<=h.t),nt(h.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=h.s),nt(h.s<=Math.max(a.s,o.s)),Qe.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=Qe.vertLeq(o,a)?o:a,Qe.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),Qe.vertEq(h,o)||Qe.vertEq(h,a)?(i.checkForRightSplice(t,e),!1):!Qe.vertEq(l,t.event)&&Qe.edgeSign(l,t.event,h)>=0||!Qe.vertEq(u,t.event)&&Qe.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Sym,r),e=i.topLeftRegion(t,e),r=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),n),i.addRightEdges(t,e,r.Oprev,r,r,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(r.Lnext,s.Oprev),n=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=i.finishLeftRegions(t,n,null),i.addRightEdges(t,e,s.Onext,r.Rprev,p,!0),!0):(Qe.edgeSign(l,t.event,h)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),r.Org.s=t.event.s,r.Org.t=t.event.t),Qe.edgeSign(u,t.event,h)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(r.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,r),r.Org.s=h.s,r.Org.t=h.t,r.Org.pqHandle=t.pq.insert(r.Org),i.getIntersectData(t,r.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var n=i.regionBelow(e),r,s;;){for(;n.dirty;)e=n,n=i.regionBelow(n);if(!e.dirty&&(n=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,r=e.eUp,s=n.eUp,r.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(i.deleteRegion(t,n),t.mesh.delete(s),n=i.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n),r=e.eUp)),r.Org!==s.Org)if(r.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(r.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);r.Org===s.Org&&r.Dst===s.Dst&&(i.addWinding(s,r),i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n))}},i.connectRightVertex=function(t,e,n){var r,s=n.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Qe.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),Qe.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,n.Onext,s,s,!0);return}Qe.vertLeq(l.Org,a.Org)?r=l.Oprev:r=a,r=t.mesh.connect(n.Lprev,r),i.addRightEdges(t,e,r,r.Onext,r.Onext,!1),r.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,n){var r,s,o,a,l;if(r=e.eUp,Qe.vertEq(r.Org,n)){nt(!1),i.spliceMergeVertices(t,r,n.anEdge);return}if(!Qe.vertEq(r.Dst,n)){t.mesh.splitEdge(r.Sym),e.fixUpperEdge&&(t.mesh.delete(r.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,r),i.sweepEvent(t,n);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(n.anEdge,o),Qe.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var n,r,s,o,a,l,u=new aw;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,r=i.regionBelow(n),!!r){if(o=n.eUp,a=r.eUp,Qe.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,n,e);return}if(s=Qe.vertLeq(a.Dst,o.Dst)?n:r,n.inside||s.fixUpperEdge){if(s===n)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,n,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){i.connectLeftVertex(t,e);return}var r=i.topLeftRegion(t,n.activeRegion);nt(r!==null);var s=i.regionBelow(r),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,r,a):i.addRightEdges(t,r,a.Onext,o,o,!0)},i.addSentinel=function(t,e,n,r){var s=new aw,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=r,o.Dst.s=e,o.Dst.t=r,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 y6(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],r=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;i.addSentinel(t,r,s,o),i.addSentinel(t,r,s,a)},i.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++n===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,n,r,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,r=e.Lnext,Qe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,r,e),t.mesh.delete(e),e=r,r=e.Lnext),r.Lnext===e&&(r!==e&&((r===n||r===n.Sym)&&(n=n.next),t.mesh.delete(r)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,n,r,s=0;for(r=t.mesh.vHead,n=r.next;n!==r;n=n.next)s++;for(s+=8,e=t.pq=new g6(s,Qe.vertLeq),r=t.mesh.vHead,n=r.next;n!==r;n=n.next)n.pqHandle=e.insert(n);return n!==r?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var n,r,s;for(n=e.fHead.next;n!==e.fHead;n=r)r=n.next,s=n.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 n,r;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;r=t.pq.min(),!(r===null||!Qe.vertEq(r,n));)r=t.pq.extractMin(),i.spliceMergeVertices(t,n.anEdge,r.anEdge);i.sweepEvent(t,n)}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}(),x6=function(){function i(){this.mesh=new T2,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=xt.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,n,r,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[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,n=p[v],r=f[v],c[0]=n.coords[0]-r.coords[0],c[1]=n.coords[1]-r.coords[1],c[2]=n.coords[2]-r.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-r.coords[0],d[1]=e.coords[1]-r.coords[1],d[2]=e.coords[2]-r.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[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,n=this.mesh.vHead,r,s=0,o=t.next;o!==t;o=o.next)if(r=o.anEdge,!(r.winding<=0))do s+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(s<0){for(e=n.next;e!==n;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],n,r,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),n=this.sUnit,r=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,r);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 n,r;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Qe.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Qe.vertLeq(n.Org,n.Dst);n=n.Lnext);r=n.Lprev;for(var s=void 0;n.Lnext!==r;)if(Qe.vertLeq(n.Dst,r.Org)){for(;r.Lnext!==n&&(Qe.edgeGoesLeft(r.Lnext)||Qe.edgeSign(r.Org,r.Dst,r.Lnext.Dst)<=0);)s=t.connect(r.Lnext,r),r=s.Sym;r=r.Lprev}else{for(;r.Lnext!==n&&(Qe.edgeGoesRight(n.Lprev)||Qe.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(r.Lnext===n)throw"Mono region invalid";for(;r.Lnext.Lnext!==n;)s=t.connect(r.Lnext,r),r=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},i.prototype.setWindingNumber_=function(t,e,n){for(var r,s=t.eHead.next;s!==t.eHead;s=r)r=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?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,n,r){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);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>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===mn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*r,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*r;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],r>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=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[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===mn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var p=l;p<n;++p)this.elements[h++]=-1}}},i.prototype.outputContours_=function(t,e){var n,r,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){r=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==r);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,r=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==r);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new T2),t<2&&(t=2),t>3&&(t=3);for(var n=null,r=0;r<e.length;r+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[r+0],n.Org.coords[1]=e[r+1],t>2?n.Org.coords[2]=e[r+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},i.prototype.tesselate=function(t,e,n,r,s,o){if(t===void 0&&(t=xt.ODD),e===void 0&&(e=mn.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,r<2&&(r=2),r>3&&(r=3),!this.mesh)return!1;this.projectPolygon_(),v6.computeInterior(this,o);var a=this.mesh;return e===mn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===mn.BOUNDARY_CONTOURS?this.outputContours_(a,r):this.outputPolymesh_(a,e,n,r),!0},i}();function as(i){var t=i.windingRule,e=t===void 0?xt.ODD:t,n=i.elementType,r=n===void 0?mn.POLYGONS:n,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,d=i.contours,h=d===void 0?[]:d,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!h&&p)throw new Error("Contours can't be empty");if(!!h){var y=new x6;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,r,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 Nde=xt.ODD,Bde=xt.NONZERO,Fde=xt.POSITIVE,Vde=xt.NEGATIVE,kde=xt.ABS_GEQ_TWO,Ude=mn.POLYGONS,zde=mn.CONNECTED_POLYGONS,Gde=mn.BOUNDARY_CONTOURS;var qy=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*qy.eSize;this.buffer=new ArrayBuffer(n);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*r,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 n=t*qy.eSize,r=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(r,o*s,3*t);o+=3*t;let l=new Float32Array(r,o*s,3*t);o+=3*t;let u=new Float32Array(r,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=r,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 r=this.capacity;for(;e>r;)r*=2;this.realloc(r)}let n=this.size;return this.size=e,n}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)}},$f=qy;$f.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var R2=$o(O2()),ep={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},hw={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},fw={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},dw=(i,t)=>([e,n])=>(n<e&&(n+=t),(i>=e?i:i+t)<=n),ja=class extends Ee{constructor(e,n,r=0,s=12,o=3,a=xt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._curveSegments=s,this._bevelSegmentsInput=o;let u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let D=C.extractShapePointsToFlatArray([],s),P=[];for(let I=D.length-1;I>=1;I-=2){let L=D[I-1],H=D[I-0];P.push(L,H)}return P}),d=[],h=[];for(let C=0;C<u.length;C+=2)h.push([u[C],u[C+1]]);d.push(h);for(let C=0;C<c.length;C++){let D=c[C],P=[];for(let I=0;I<D.length;I+=2)P.push([D[I],D[I+1]]);d.push(P)}let f;e.isText?f=new tu().setFromPoints(e.points.map(D=>D.position)).getSize(new B).length()*.1:d[0].length===0?f=r:f=(0,R2.default)(d).distance,r<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(r,f,n/2),this._bevelSegments=Math.floor(o));let p;try{p=as({windingRule:a,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=ep}let m;try{m=as({windingRule:xt.ODD,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=hw}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 D=m.elements[C],P=C%2===0?p.vertexCount:0;p.elements.push(D+P)}for(let C=0;C<m.vertexIndices.length;C++){let D=m.vertexIndices[C],P=p.vertexCount;p.vertexIndices.push(D+P)}for(let C=0;C<m.vertices.length;C++){let D=m.vertices[C];p.vertices.push(D)}}let y=1/0,v=-1/0,x=1/0,b=-1/0;for(let C=0,D=p.vertexCount;C<D;C++){let P=C*2,I=p.vertices[P+0],L=p.vertices[P+1];I<y&&(y=I),I>v&&(v=I),L<x&&(x=L),L>b&&(b=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=b-x,this._buffer=new $f(this._computeBufferEstimatedSize(p));let w=[],E=[];for(let C=p.elementCount-1;C>=0;C--){let D=C>=g,P=C*2,I=p.elements[P+0],L=p.elements[P+1],H=I+L,k={start:I,count:L,normals:[],continuous:[],concave:[]},G=I,z=H-1,U=I+1,$=this._shape.roundedCurves.length;do{let V=G-I,Z=p.vertices[z*2+0],Q=p.vertices[z*2+1],K=p.vertices[G*2+0],W=p.vertices[G*2+1],ye=p.vertices[U*2+0],fe=p.vertices[U*2+1],ie=K-Z,Ae=W-Q,xe=Math.sqrt(ie*ie+Ae*Ae);ie/=xe,Ae/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,k.normals[V*2+0]=-Ie,k.normals[V*2+1]=Oe,k.concave[V]=ie*Ie-Ae*Oe>0;let Te=p.vertexIndices[G];if(Array.isArray(Te))k.continuous[V]=!1;else{let[Ue,ze]=this._shape.getCurveIndexFromVertexId(Te-1,!0);if(ze>0&&ze<1)k.continuous[V]=!0;else{let R=ze===1?Ue+1:Ue-1;R=(R+$)%$;let O=ze===1?0:1,ne=this._shape.roundedCurves[Ue].getTangent(ze),ue=this._shape.roundedCurves[R].getTangent(O);k.continuous[V]=ne.dot(ue)>.95}}D&&(k.normals[V*2+0]*=-1,k.normals[V*2+1]*=-1),[z,G,U]=[G,U,U+1],U>=H&&(U-=L)}while(U!==I+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,H*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((V,Z)=>[Z,Z]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,H*2)});let j=0;for(let V=1;V<=this._bevelSegments;V++){let Z=V/this._bevelSegments*Math.PI/2,Q=(1-Math.cos(Z))*this._bevel,K=[],W=[],ye=[],fe=[],ie=0;for(let xe=0;xe<L;xe++){let Oe=xe*2,Ie=(xe-1+L)%L*2,Pe=p.vertices[k.start*2+Oe+0],Te=p.vertices[k.start*2+Oe+1],Ue=-k.normals[Ie+0]*Q,ze=-k.normals[Ie+1]*Q,R=-k.normals[Oe+0]*Q,O=-k.normals[Oe+1]*Q;if(k.concave[xe]||!k.concave[xe]&&D){let ne=Math.atan2(ze,Ue),ue=Math.atan2(O,R);ue>ne&&(ue-=Math.PI*2);let me=ue-ne;if(k.continuous[xe]||D){let De=ne+me/2,Me=Math.cos(De)*Q,_e=Math.sin(De)*Q;K[2*ie+0]=Pe+Me*(D?-1:1),K[2*ie+1]=Te+_e*(D?-1:1),fe[ie]=xe,ie++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Me=0;Me<=De;Me++){let _e=ne+me*(Me/De),le=Math.cos(_e)*Q,Ke=Math.sin(_e)*Q;K[2*ie+0]=Pe+le,K[2*ie+1]=Te+Ke,fe[ie]=xe,ie++}}}else K[2*ie+0]=Pe+Ue,K[2*ie+1]=Te+ze,fe[ie]=xe,W[xe]=ie,ie++,K[2*ie+0]=Pe,K[2*ie+1]=Te,fe[ie]=xe,ie++,K[2*ie+0]=Pe+R,K[2*ie+1]=Te+O,fe[ie]=xe,ye[xe]=ie,ie++}let Ae=as({windingRule:xt.POSITIVE,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],Te=fe[(Ie+1)%fe.length];xe.idx=[Pe,Te],xe.Sym.idx=[Te,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!Ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!Ae.vertexCount){let xe=(V-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<Ae.vertexIndices.length;xe++){let[Oe,Ie]=Ae.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie<Oe&&(Pe+=L);for(let Te=Oe;Te<Pe;Te++){let Ue=Te%L,ze=(Te+1)%L;if(!k.continuous[Ue]||!k.continuous[ze]){Ae.vertexIndices[xe]=[Oe,Ue],Ae.vertexIndices.splice(xe+1,0,[ze,Ie]),Ae.vertices.splice((xe+1)*2,0,Ae.vertices[xe*2],Ae.vertices[xe*2+1]);break}}}F.push({bevelI:V,angle:Z,size:Q,boundary:Ae,reverseMap:fe,insetPoints:K})}let X=(V,Z,Q)=>{let K=0,W=V.boundary.vertexIndices.length;for(;K<W&&Q(V.boundary.vertexIndices[Z]);)Z=(Z+1)%W,K++;return K},q=w.length;for(let V=1;V<F.length;V++){let Z=F[V-1],Q=F[V],K=Z.boundary.vertexIndices.length,W=Q.boundary.vertexIndices.length;if(!K||!W)break;let ye=k.concave.length,fe=0,ie=dw(fe,L);for(;!Z.boundary.vertexIndices.filter(ie).length||!Q.boundary.vertexIndices.filter(ie).length;)fe++,ie=dw(fe,L);let Ae=Z.boundary.vertexIndices.findIndex(ie),xe=Q.boundary.vertexIndices.findIndex(ie);do Ae=(Ae+1)%K;while(ie(Z.boundary.vertexIndices[Ae]));do xe=(xe+1)%W;while(ie(Q.boundary.vertexIndices[xe]));fe=(fe+1)%L;let Oe=fe,Ie=0,Pe=this._buildBevelVert(k,Z,(Ae-1+K)%K,void 0,Ie),Te=this._buildBevelVert(k,Q,(xe-1+W)%W,void 0,Ie),Ue=Pe,ze=Te,R,O,ne=!1;do{Ie=(fe||ye)/ye,ie=dw(fe,L);let ue=X(Z,Ae,ie),me=X(Q,xe,ie),De=ne;if(ne=!1,ue&&!me){for(let Me=0;Me<ue;Me++)R=this._buildBevelVert(k,Z,(Ae+Me)%K,Me/(ue-1),Ie),w.push(Ue.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ue.bottomN,ze.bottomN),Ue=R;ne=!0}else if(!ue&&me)for(let Me=0;Me<me;Me++)O=this._buildBevelVert(k,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(ze.topN,Ue.topP,O.topP),l===!1&&w.push(Ue.bottomP,ze.bottomN,O.bottomP),ze=O;else if(ue&&me)if(R=this._buildBevelVert(k,Z,Ae,0,Ie),O=this._buildBevelVert(k,Q,xe,0,Ie),De?(w.push(Ue.topN,O.topP,ze.topN),w.push(Ue.topN,R.topP,O.topP),l===!1&&(w.push(O.bottomP,Ue.bottomN,ze.bottomN),w.push(O.bottomP,R.bottomP,Ue.bottomN))):(w.push(ze.topN,Ue.topN,R.topP),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ue.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP))),Ue=R,ze=O,ue===me)for(let Me=1;Me<ue;Me++)R=this._buildBevelVert(k,Z,(Ae+Me)%K,Me/(ue-1),Ie),O=this._buildBevelVert(k,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(Ue.topN,R.topP,ze.topN),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ue.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP)),Ue=R,ze=O;else if(ue>me){let Me=ue/me,_e=0;for(let le=1;le<ue;le++)R=this._buildBevelVert(k,Z,(Ae+le)%K,le/(ue-1),Ie),w.push(Ue.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ue.bottomN,ze.bottomN),Ue=R,le>(_e+1)*Me&&(_e++,O=this._buildBevelVert(k,Q,(xe+_e)%W,_e/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O)}else{let Me=me/ue,_e=0;for(let le=1;le<me;le++)O=this._buildBevelVert(k,Q,(xe+le)%W,le/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O,le>(_e+1)*Me&&(_e++,R=this._buildBevelVert(k,Z,(Ae+_e)%K,_e/(ue-1),Ie),w.push(Ue.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ue.bottomN,ze.bottomN),Ue=R)}Ae=(Ae+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(F,k,w),D){let V=[];for(let Z=w.length-1;Z>=q+2;Z-=3){let Q=w[Z-2],K=w[Z-1],W=w[Z-0];V.push(W,K,Q)}w.splice(q,w.length-q,...V)}if(D){let V=[];for(let Z=F[F.length-1].boundary.vertices.length-1;Z>=1;Z-=2){let Q=F[F.length-1].boundary.vertices[Z-1],K=F[F.length-1].boundary.vertices[Z-0];V.push(Q,K)}E.push(V)}if(!D){let V=F[F.length-1],Z;try{Z=as({windingRule:F.length>1?xt.POSITIVE:xt.ODD,elementType:mn.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...E]})}catch{Z=fw}if(!Z)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Q=0;Q<Z.elementCount*3;Q+=3){let K=this._buildSurfaceVert(Z,Z.elements[Q+0],j),W=this._buildSurfaceVert(Z,Z.elements[Q+1],j),ye=this._buildSurfaceVert(Z,Z.elements[Q+2],j);w.push(K.top,W.top,ye.top),l===!1&&w.push(ye.bottom,W.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ge(Uint32Array.from(w),1),S=new Ge(this._buffer.positions,3),T=new Ge(this._buffer.normals,3),M=new Ge(this._buffer.uvs,2);S.needsUpdate=!0,T.needsUpdate=!0,M.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",T),this.setAttribute("uv",M),this.setIndex(_)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n,r){let s=n.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[n*2+0],a=e.vertices[n*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),d=c*3,h=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[d+0]=o,this._buffer.positions[d+1]=a,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-r,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[h+0]=l,this._buffer.uvs[h+1]=u,this.forPathBevel===!1&&(this._buffer.positions[d+3]=o,this._buffer.positions[d+4]=a,this._buffer.positions[d+5]=r,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[h+2]=l,this._buffer.uvs[h+3]=u),this.vertexCache[s]=f,f}_buildBevelVert(e,n,r,s=1,o){let a=`${n.bevelI}:${r}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,u]=n.boundary.vertexIndices[r],c,d,h,f;l!==u?(d=l,c=u,f=!1,h=e.continuous[d]&&e.continuous[c]):(c=l,d=(c-1+e.count)%e.count,f=e.concave[c]&&n.bevelI>0,h=e.continuous[c]||f);let p=Math.cos(n.angle),m=Math.sin(n.angle),g=r*2,y=c*2,v=d*2,x=n.boundary.vertices[g+0],b=n.boundary.vertices[g+1],w=(1-m)*this._bevel,E=(x-this._minX)/this._width,_=(b-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(E=o),_=1);let S=e.normals[y+0],T=e.normals[y+1],M=e.normals[v+0],C=e.normals[v+1];if(f){let H=M-S,k=C-T;S=S+H*(1-s),T=T+k*(1-s);let G=Math.sqrt(S*S+T*T);S/=G,T/=G}let D=this.forPathBevel?this._buffer.get(h?1:2):this._buffer.get(h?2:4),P=D*3,I=D*2,L={i:r,fi:c,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:o};return this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=S*p,this._buffer.normals[P+1]=T*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=S*p,this._buffer.normals[P+4]=T*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E),h||(this.forPathBevel?(D+=1,P+=3,I+=2):(D+=2,P+=6,I+=4),L.topP=D+0,L.bottomP=D+1,this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=M*p,this._buffer.normals[P+1]=C*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=M*p,this._buffer.normals[P+4]=C*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E)),this.vertexCache[a]=L,L}clone(){let e=new ja(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var wd=class extends Ee{constructor(e,n=12,r={}){super();this.type="ShapeGeometry";this.windingRule=xt.ODD;this.elementType=mn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:xt.ODD,elementType:mn.POLYGONS,polySize:3,vertexSize:2,strict:!0},r);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;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),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=as({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=ep}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(h*3),3),this._normalAttribute=new Ge(new Float32Array(h*3),3),this._uvAttribute=new Ge(new Float32Array(h*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 b=0,w=h;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1];_<p&&(p=_),_>m&&(m=_),S<g&&(g=S),S>y&&(y=S)}let v=m-p,x=y-g;for(let b=0,w=h;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1],T=(_-p)/v,M=(S-g)/x;this._positionAttribute.setXYZ(b,_,S,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,M)}for(let b=0,w=f;b<w;b++){let E=b*3,_=a.elements[E+0],S=a.elements[E+1],T=a.elements[E+2];this._indexAttribute.setX(E+0,_),this._indexAttribute.setX(E+1,S),this._indexAttribute.setX(E+2,T)}}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 wd(this._shape,this._curveSegments);return e.userData=Io(this.userData),e}};var Ad=class extends ja{constructor(e,n,r=0,s=12,o=3,a=xt.ODD){super(e,n,r,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Ad(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var ri=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:xt.ODD},i.parameters),n=Math.abs(e.width),r=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 Pt?(o.width!==n||o.height!==r)&&o.applySize(n,r):o=new Pt(n,r).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Pt(n,r);return{parameters:Object.assign(e,{width:n,height:r,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:r,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new wd(i.shape,r,{windingRule:o}):a=new Ad(i.shape,t,e,r,n,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var N2=Math.PI*2,_d=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=we.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,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:n,angle:r,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,d=e*.5,h=E6(u,c,d,r*Math.PI/180,n,s);u.isClosed=!0,u.update();let f;return r===0?(f=new Ee,f.setAttribute("position",new be([],3))):f=ri.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function E6(i,t,e,n,r,s){if(n>=N2)return r>30||r%4===0?(T6(i,t,e,s),Math.round(r/4)):L2(i,n,r,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=_2({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return r>30||r%u.length===0?_6(i,o.x,o.y,u,r,t,e,s):L2(i,n,r,t,e,s)}function _6(i,t,e,n,r,s,o,a){let l=Math.round(r/n.length);i.addPoint(Ed(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=i.points[u],f=Ed(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),i.addPoint(f)}return a>0?B2(i,s,o,a):i.addPoint(Ed(0,0)),l}function L2(i,t,e,n,r,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*r;i.addPoint(Ed(u,c))}return t<N2?s>0?B2(i,n,r,s):i.addPoint(Ed(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&F2(i,n,r,s)),1}function T6(i,t,e,n=0,r=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Xy(r-t,s,r-t,s-l,r-t,s+l)),i.addPoint(Xy(r,s+e,r-a,s+e,r+a,s+e)),i.addPoint(Xy(r+t,s,r+t,s+l,r+t,s-l)),i.addPoint(Xy(r,s-e,r+a,s-e,r-a,s-e)),n>0&&F2(i,t,e,n)}function Ed(i,t){return new os(we.generateUUID(),new B(i,t))}function Xy(i,t,e,n,r,s){let o=Ed(i,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(r,s),o}function B2(i,t,e,n){V2(i,t,e,n).forEach(s=>i.addPoint(s))}function F2(i,t,e,n){let r=V2(i,t,e,n),s=new Pt;r.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function V2(i,t,e,n){let r=n*t/100,s=r*(Math.abs(e)/Math.abs(t)),o=new B(r/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=we.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 k2=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),n=Math.abs(e.width),r=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:r,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:n,radius:r,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=i.parameters,h=new tp(!1,t,e,n,r,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...i,type:"HelixGeometry"}})}},pw=new Ms([0,0,0],1),tp=class extends Ee{constructor(t=!0,e=1,n=1,r=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let p=()=>new A,m=new A,g=p(),y=p(),v=p(),x,b,w,E,_,S,T,M,C=p(),D=p(),P=p(),I=p(),L=p(),H=p(),k=p(),G=p(),z=n-2*l+.001,U=z/o,$=Math.ceil(a*o),F=$+1,j=z/$,X=-z/2,q=c+1,V=2*Math.PI/c,Z=Math.PI/2/h,Q=.01,K=Math.min((1-d/100)*l,l-Q),W=l-K,ye=0,fe=2,ie=h*fe+fe,Ae=q*ie/fe,xe=Ae+q*F,Oe=Math.max(0,q*(F+ie)),[Ie,Pe,Te]=[3,3,2].map(Ve=>Array(Oe*Ve).fill(0)),Ue=[],ze=s-l;function R(Ve,Le){let je=Math.PI/2;S=Le*j,M=2*Math.PI*(S%U)/U+je,S+=X,T=Math.sin(M)*ze,_=Math.cos(M)*ze,t?Ve.set(_,T,S):Ve.set(_,S,T)}R(m,-1e-10),R(g,0),C.copy(m),R(m,1);let O=m.distanceTo(g),ne=f?0:W+K,ue=O*$+2*ne,me=K,De=ue-ne;for(let Ve=0;Ve<=$;Ve++){R(y,Ve),G.subVectors(y,C).normalize(),C.copy(y),H.copy(y).setComponent(+t+1,0).normalize(),k.crossVectors(G,H).normalize();let Le=Ve===0,je=Ve===$,Je=Le?3*Math.PI/2:Z,St=Le?me:De,Zt=Le?q:xe,Ln=Le?0:Oe-q,Y=G.clone().multiplyScalar(Le?-W:W).add(y),ce=G.clone().multiplyScalar(Le?-1:1).normalize();for(let ve=0;ve<q;ve++){let ke=ve*V;if(D.addVectors(m.copy(H).multiplyScalar(l*Math.cos(ke)),g.copy(k).multiplyScalar(l*Math.sin(ke))),P.copy(D).normalize(),Le||je){f||(ye=Ln+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=Y.getComponent(Be),Pe[ye*3+Be]=ce.getComponent(Be)}),Te[ye*2]=+je,Te[ye*2+1]=ve/c),g.copy(P).multiplyScalar(K),v.addVectors(y,g);for(let Be=0;Be<h;Be++){let wt=Be*Z+Je;I.addVectors(m.copy(G).multiplyScalar(W*Math.sin(wt)),g.copy(P).multiplyScalar(W*Math.cos(wt))),L.copy(I).normalize(),g.addVectors(v,I),I.normalize(),ye=Zt+Be*q+ve,[0,1,2].forEach(Sn=>{Ie[ye*3+Sn]=g.getComponent(Sn),Pe[ye*3+Sn]=L.getComponent(Sn)});let Nn=+Le+Math.sin(wt);Te[ye*2]=(St+W*Nn)/ue,Te[ye*2+1]=ve/c}}g.addVectors(y,D),ye=Ae+Ve*q+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=g.getComponent(Be),Pe[ye*3+Be]=P.getComponent(Be)}),Te[ye*2]=(ne+Ve*O)/ue,Te[ye*2+1]=ve/c}}let Me=F+2*h+fe,_e=1,[le,Ke]=[+f,Me-1];for(let Ve=le;Ve<=Ke-1;Ve++){let Le=f&&Ve===Ke-1;for(let je=0;je<q-1;je++)x=Ve*q+je,b=x+1,w=(Le?je:x)+q,E=(Le?je+1:b)+q,Ve===0?Ue.push(b,E,w):Ve===Me-2?Ue.push(x,b,w):Ue.push(x,b,w,b,E,w)}this.setIndex(Ue),this.setAttribute("position",new be(Ie,3)),this.setAttribute("normal",new be(Pe,3)),this.setAttribute("uv",new be(Te,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,r=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let h=0;h<t.radialSegments;h++)s=c*n+h,o=s+1,a=(d?h:s)+n,l=(d?h+1:o)+n,r[u++]=s,r[u++]=o,r[u++]=a,r[u++]=o,r[u++]=l,r[u++]=a;return r.length=u,pw.array=r,pw.count=r.length,pw}};var U2=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:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new np(t*.5,s,o):new Wc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},np=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],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,n),this.type=a}static fromJSON(t){return new np(t.radius,t.corner,t.cornerSides)}};var z2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[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:n}=i.parameters,r=new _o;r.moveTo(t[0].x,t[0].y),r.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Uc(r.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Hs=new se,mw=new mt,Ky=new A,Wa=class extends Ht{constructor(){super(),this.uuid=we.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 $t().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];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 Hs.makeRotationX(t),this.applyMatrix4(Hs),this}rotateY(t){return Hs.makeRotationY(t),this.applyMatrix4(Hs),this}rotateZ(t){return Hs.makeRotationZ(t),this.applyMatrix4(Hs),this}translate(t,e,n){return Hs.makeTranslation(t,e,n),this.applyMatrix4(Hs),this}scale(t,e,n){return Hs.makeScale(t,e,n),this.applyMatrix4(Hs),this}lookAt(t){return mw.lookAt(t),mw.updateMatrix(),this.applyMatrix4(mw.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,o=r.normal,a=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Fe().fromBufferAttribute(a,h));function c(h,f,p,m){let g=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,p)],v=new Td(h,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new B().fromBufferAttribute(l,h),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,p)]),u!==void 0&&e.faceVertexUvs[1].push([new B().fromBufferAttribute(u,h),new B().fromBufferAttribute(u,f),new B().fromBufferAttribute(u,p)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+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(Ky).negate(),this.translate(Ky.x,Ky.y,Ky.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new se;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],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 n=0,r=this.vertices.length;n<r;n++)e[n]=new A;if(t){let n=new A,r=new A;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];n.subVectors(c,u),r.subVectors(l,u),n.cross(r),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],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 n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,o=r.vertexNormals.length;s<o;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let t=new Wa;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;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 A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let r=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=r.faceNormals[s],u=r.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,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Tt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ln),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(r=new $t().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let m=a[h].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let p=u[h],m,g,y=p.vertexNormals,v=p.vertexColors,x=new Td(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,w=y.length;b<w;b++)m=y[b].clone(),r!==void 0&&m.applyMatrix3(r).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let b=0,w=v.length;b<w;b++)g=v[b],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let p=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++)v.push(y[x].clone());this.faceVertexUvs[h].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={},n=[],r=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),r[l]=n.length-1):r[l]=r[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=r[c.a],c.b=r[c.b],c.c=r[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+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,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new A(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;r&&r.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(r[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 n=[],r=[],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,b=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,E=m.vertexColors.length>0,_=0;if(_=c(_,0,0),_=c(_,1,g),_=c(_,2,y),_=c(_,3,v),_=c(_,4,x),_=c(_,5,b),_=c(_,6,w),_=c(_,7,E),n.push(_),n.push(m.a,m.b,m.c),n.push(m.materialIndex),v){let S=this.faceVertexUvs[0][p];n.push(f(S[0]),f(S[1]),f(S[2]))}if(x&&n.push(d(m.normal)),b){let S=m.vertexNormals;n.push(d(S[0]),d(S[1]),d(S[2]))}if(w&&n.push(h(m.color)),E){let S=m.vertexColors;n.push(h(S[0]),h(S[1]),h(S[2]))}}function c(p,m,g){return g?p|1<<m:p&~(1<<m)}function d(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=r.length/3,r.push(p.x,p.y,p.z)),s[m]}function h(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=r,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new Wa().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 h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let r=t.faces;for(let h=0,f=r.length;h<f;h++)this.faces.push(r[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let p=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let p={};if(p.name=s[h].name,s[h].vertices!==void 0){p.vertices=[];for(let m=0,g=s[h].vertices.length;m<g;m++)p.vertices.push(s[h].vertices[m].clone())}if(s[h].normals!==void 0){p.normals=[];for(let m=0,g=s[h].normals.length;m<g;m++)p.normals.push(s[h].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let p={};if(o[h].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[h].vertexNormals.length;m<g;m++){let y=o[h].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[h].faceNormals.length;m<g;m++)p.faceNormals.push(o[h].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.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 gw().fromGeometry(this),e=new Ee,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Qy.call(new Ge(n,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);e.setAttribute("normal",Qy.call(new Ge(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);e.setAttribute("color",G2.call(new Ge(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);e.setAttribute("uv",H2.call(new Ge(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",H2.call(new Ge(r,2),t.uvs2))}e.groups=t.groups;for(let r in t.morphTargets){let s=[],o=t.morphTargets[r];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(Qy.call(c,u.data))}e.morphAttributes[r]=s}if(t.skinIndices.length>0){let r=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",j2.call(r,t.skinIndices))}if(t.skinWeights.length>0){let r=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",j2.call(r,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 Ee,n=t.geometry;if(t.isPoints||t.isLine){let r=new be(n.vertices.length*3,3),s=new be(n.colors.length*3,3);if(e.setAttribute("position",Qy.call(r,n.vertices)),e.setAttribute("color",G2.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new be(n.lineDistances.length,1);e.setAttribute("lineDistance",M6.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};Wa.prototype.isGeometry=!0;var gw=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=[],n,r,s,o=t.faces;for(r=0;r<o.length;r++){let a=o[r];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=r*3-n.start,e.push(n)),n={start:r*3,materialIndex:s})}n!==void 0&&(n.count=r*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[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,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,p=t.skinWeights,m=f.length===n.length,g=p.length===n.length;n.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(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][y];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new B,new B,new B))}if(o===!0){let w=r[1][y];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new B,new B,new B))}for(let w=0;w<l;w++){let E=a[w].vertices;u[w].data.push(E[v.a],E[v.b],E[v.c])}for(let w=0;w<d;w++){let E=c[w].vertexNormals[y];h[w].data.push(E.a,E.b,E.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}},Td=class{constructor(t,e,n,r,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new A,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Fe,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,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function M6(i){return this.array.set(i),this}function G2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Fe),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function H2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new B),t[e++]=s.x,t[e++]=s.y}return this}function Qy(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function j2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Xe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var C6=["a","b","c"];function P6(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function yw(i,t,e){let n=Math.min(i,t),r=Math.max(i,t),s=n+"_"+r;return e.get(s)}function vw(i,t,e,n,r,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(r),s[i].edges.push(u),s[t].edges.push(u)}function D6(i,t,e,n){let r,s,o;for(r=0,s=i.length;r<s;r++)e[r]={edges:[]};for(r=0,s=t.length;r<s;r++)o=t[r],vw(o.a,o.b,i,n,o,e),vw(o.b,o.c,i,n,o,e),vw(o.c,o.a,i,n,o,e)}function Zy(i,t,e,n,r){i.push(new Td(t,e,n,void 0,void 0,r))}function Md(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Jy(i,t,e,n){i.push([t.clone(),e.clone(),n.clone()])}var $y=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ee?t=new Wa().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 A,n,r,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;D6(l,u,h,f);let p=[],m,g,y,v,x,b,w;for(let Q of Array.from(f.keys())){for(g=f.get(Q),y=new A,x=3/8,b=1/8,w=g.faces.length,w!=2&&(x=.5,b=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=g.faces[o],a=0;a<3&&(m=l[P6(v,C6[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(b),y.add(e),g.newEdge=p.length,p.push(y)}let E,_,S,T,M,C,D,P=[];for(r=0,s=l.length;r<s;r++){for(C=l[r],M=h[r].edges,n=M.length,n==3?E=3/16:n>3&&(E=3/(8*n)),_=1-n*Number(E),S=E,n<=2&&(n==2?(_=3/4,S=1/8):n==1||n==0),D=C.clone().multiplyScalar(_),e.set(0,0,0),o=0;o<n;o++)T=M[o],m=T.a!==C?T.a:T.b,e.add(m);e.multiplyScalar(Number(S)),D.add(e),P.push(D)}let I=P.concat(p),L=P.length,H,k,G,z=[],U=[],$,F,j,X,q=new B,V=new B,Z=new B;for(r=0,s=u.length;r<s;r++)v=u[r],H=Number(yw(v.a,v.b,f).newEdge)+L,k=Number(yw(v.b,v.c,f).newEdge)+L,G=Number(yw(v.c,v.a,f).newEdge)+L,Zy(z,H,k,G,v.materialIndex),Zy(z,v.a,H,G,v.materialIndex),Zy(z,v.b,k,H,v.materialIndex),Zy(z,v.c,G,k,v.materialIndex),d&&($=c[r],F=$[0],j=$[1],X=$[2],q.set(Md(F.x,j.x),Md(F.y,j.y)),V.set(Md(j.x,X.x),Md(j.y,X.y)),Z.set(Md(F.x,X.x),Md(F.y,X.y)),Jy(U,q,V,Z),Jy(U,F,q,Z),Jy(U,j,V,q),Jy(U,X,Z,V));t.vertices=I,t.faces=z,d&&(t.faceVertexUvs[0]=U)}};var Jn=new A,W2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ee().copy(new sr(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Jn),n={width:Jn.x,height:Jn.y,depth:Jn.z,subdivisions:0}):n=t.parameters;let r={...n,...i.parameters};return{parameters:{width:Math.abs(r.width),height:Math.abs(r.height),depth:Math.abs(r.depth),subdivisions:Math.abs(r.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:n,subdivisions:r}=i.parameters,s=i.geometry??new Ee().copy(new sr(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Jn)):Jn.set(o.width,o.height,o.depth),(t!==Jn.x||e!==Jn.y||n!==Jn.z)&&s.scale(Jn.x===0?1:t/Jn.x,Jn.y===0?1:e/Jn.y,Jn.z===0?1:n/Jn.z);let a=s.originalGeometry;try{r>0?(a===void 0||o?.subdivisions!==r)&&(a===void 0&&(a=s),s=new $y(r).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 $c(e).load(i,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Jn);let o=100/Jn.x;Object.assign(s.parameters,{width:100,height:Jn.y*o,depth:Jn.z*o}),t(this.build(s))})}};var ev=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 Pt?i.shape:new Pt,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:n,cornerRadius:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let m=0;m<n;m++){let g=f*m,y=d+Math.sin(g)*u,v=h+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=r;l.roundness=r,l.update();let p=ri.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var q2=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:n,radialSegments:r,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new bw(t*.5,e,r,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function rp(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function xw(i,t,e,n,r,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===r){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,r/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function I6(i,t,e){let n=i.clone().sub(t),r=e.clone().sub(t);return n.projectOnVector(r),n.add(t)}var bw=class extends Ee{constructor(t=.5,e=1,n=4,r=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),r=Math.floor(r),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,p=Math.PI/n,m=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),b=new A(0,f,0),w=new B(t,-f),E=new B(m,-f),_=new B(0,b.y).sub(E),S=new B(0,b.y).sub(w),T=new B(_.y,-_.x).normalize(),M=new B(S.y,-S.x).normalize(),D=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,D);let P;{let U=new A(T.x,T.y,0),$=new A(Math.cos(g)*U.x,U.y,Math.sin(g)*U.x);P=U.angleTo($)}let I=o/Math.tan((Math.PI-_.angle())/2),L=o/Math.tan((Math.PI-P)/2),H=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let U=h++,$=[],F=w.clone(),j=I/Math.cos(Math.PI/n);F.x-=j;for(let X=0;X<n;X++){let q=X/n*Math.PI*2+p,V=new B(Math.sin(q),Math.cos(q));rp(F,V,H),u.push(H.x,H.y,H.z),c.push(0,-1,0),d.push(0,0),$.push(h++)}for(let X=0;X<$.length;X++)l.push($[X],U,$[(X+1)%$.length])}let k=[];{let U=new A,$=new A,F=new A,j=new A,X=new A,q=new A;for(let V=0;V<n;V++){let Z=V/n*Math.PI*2+p,Q=(V+.5)/n*Math.PI*2+p,K=(V+1)/n*Math.PI*2+p,W=new B(Math.sin(Z),Math.cos(Z)),ye=new B(Math.sin(Q),Math.cos(Q)),fe=new B(Math.sin(K),Math.cos(K));rp(w,W,$),rp(w,fe,F),rp(T,ye,U),xw(b,$,F,L,L,j),u.push(j.x,j.y,j.z),xw($,b,F,L,I,X),u.push(X.x,X.y,X.z),xw(F,$,b,I,L,q),u.push(q.x,q.y,q.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),d.push(0,0),d.push(0,0),d.push(0,0);let ie=h++,Ae=h++,xe=h++;if(l.push(ie,Ae,xe),o>0){{let Pe=$.clone().add(F).multiplyScalar(.5),Te=b.clone().sub(Pe).normalize(),ze=x.clone().sub(Pe).normalize().add(Te).normalize().multiplyScalar(-1),R=q.clone().sub(X);G(Pe,R,ze,_.angle())}let Oe,Ie;{let Pe=new A;rp(M,fe,Pe);let Te=q.clone().add(j).multiplyScalar(.5);Te=I6(Te,F,b);let Ue=q.clone().sub(j);[Oe,Ie]=G(Te,Ue,Pe,P,j.y)}{let Pe=Oe,Te=Pe.clone().setY(0).normalize(),Ue=new A(0,-1,0),ze=Te.clone().cross(Ue);z(Pe,Te,Ue,ze)}k.concat(Ie);{let Pe=_.angle(),Te=Math.PI-Pe,Ue=b.clone();Ue.y-=o/Math.sin(Pe-Math.PI/2);let ze=new A,R=[];for(let ne=0;ne<a;ne++){let ue=[],me=Math.PI/2-Te*ne/a,De=Math.cos(me),Me=Math.sin(me),_e=Q;for(let le=0;le<=ne;le++){let Ke=Math.cos(_e),Ve=Math.sin(_e);U.x=De*Ve,U.y=Me,U.z=De*Ke,ze.copy(Ue).addScaledVector(U,o),u.push(ze.x,ze.y,ze.z),c.push(U.x,U.y,U.z),d.push(0,0),ue.push(h++),_e+=Math.PI*2/ne/n}R.push(ue)}Ie.reverse(),R.push(Ie);let O=R.length-1;for(let ne=0;ne<O;ne++){let ue=R[ne],me=R[ne+1],De=ue.length-1;l.push(me[1],ue[0],me[0]);for(let Me=1;Me<=De;Me++)l.push(ue[Me],ue[Me-1],me[Me]),l.push(me[Me+1],ue[Me],me[Me])}}}}}this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(d,2));function G(U,$,F,j,X){let q=-j/2,V=(Math.PI-j)/2,Z=$.clone().normalize().cross(F);U.addScaledVector(F,-o/Math.sin(V));let Q=new A,K=new A,W=1,ye=h,fe=[];for(let ie=0;ie<=a;ie++){let Ae=q+ie/a*j;K.set(0,0,0),K.addScaledVector(Z,Math.sin(Ae)),K.addScaledVector(F,Math.cos(Ae));for(let xe=0;xe<=W;xe++){let Oe=xe/W-.5;if(Q.copy(U),Q.addScaledVector($,Oe),Q.addScaledVector(K,o),X!=null){let Ie=Math.max(0,Q.y-X);Q.addScaledVector($,-Ie/$.y)}u.push(Q.x,Q.y,Q.z),c.push(K.x,K.y,K.z),d.push(0,0),xe===0&&fe.push(h),h++}}for(let ie=0;ie<a;ie++)for(let Ae=0;Ae<W;Ae++){let xe=ye+Ae+(W+1)*ie,Oe=xe+(W+1),Ie=Oe+1,Pe=xe+1;l.push(xe,Oe,Pe),l.push(Oe,Ie,Pe)}return[U.clone().addScaledVector($,.5),fe]}function z(U,$,F,j){let X=Math.PI/2,q=S.angle()-X,V=[],Z=new A,Q=new A;for(let W=0;W<=a;W++){let ye=[],fe=W/a;for(let ie=0;ie<=W;ie++){let xe=((W?ie/W:0)-.5)*v,Oe=Math.cos(xe),Ie=Math.sin(xe),Pe=Math.atan(Math.tan(q)*Oe),Te=(X+Pe)*fe,Ue=Math.cos(Te),ze=Math.sin(Te);Z.set(0,0,0),Z.addScaledVector($,ze*Oe),Z.addScaledVector(F,Ue),Z.addScaledVector(j,ze*Ie),Q.copy(U).addScaledVector(Z,o),u.push(Q.x,Q.y,Q.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),ye.push(h++)}V.push(ye)}let K=V.length-1;for(let W=0;W<K;W++){let ye=V[W],fe=V[W+1],ie=ye.length-1;l.push(ye[0],fe[1],fe[0]);for(let Ae=1;Ae<=ie;Ae++)l.push(ye[Ae-1],ye[Ae],fe[Ae]),l.push(ye[Ae],fe[Ae+1],fe[Ae])}}}};var tv=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),n=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(i){let t=i.shape,{width:e,height:n,cornerRadius:r,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(b,w,E){return w>e&&E>n?Math.min(b*e/w,b*n/E):w>e?b*e/w:E>n?b*n/E:b}let f=[];f[0]=r[0]===0?0:h(r[0],r[0]+r[3],r[0]+r[1]),f[1]=r[1]===0?0:h(r[1],r[1]+r[2],r[1]+r[0]),f[2]=r[2]===0?0:h(r[2],r[2]+r[1],r[2]+r[3]),f[3]=r[3]===0?0:h(r[3],r[3]+r[0],r[3]+r[2]);let p=c.x,m=d.x,g=d.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 b=0,w=t.points.length;b<w;b++)t.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=ri.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var Y2=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=we.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:n=t,widthSegments:r=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ee,c.setAttribute("position",new be([],3))):c=new Ml(.5*t,r,s,o,a,l,u*we.DEG2RAD),c.scale(1,e/t,n/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var X2=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:n=8,heightSegments:r=8}=i.parameters,s=new Ao(t,e,n,r);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var K2=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:n,angle:r,cornerRadius:s,cornerSegments:o}=i.parameters,a=new Sw(t,e,n,r,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},Sw=class extends Ee{constructor(t=1,e=1,n=1,r=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),r=Math.min(180-c,r),r*=Math.PI/180;let d=[],h=Math.PI/2,f=(Q=0,K=0,W=0)=>new A(Q,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,b=+y,[w,E,_]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],S=(Q,K=!1)=>Math.sin(Q-Math.PI/(1+ +K)),T=(Q,K=!1)=>Math.cos(Q-Math.PI/(1+ +K));_.y=Math.sin(r)*e-g;let M=Math.cos(r)*e-v,C=w.z-c;r<=h?(_.z=Math.min(M,C),_.z==C&&(_.y-=(M-C)/Math.tan(h-r))):E.z=Math.min(E.z-M-v,w.z-c),p.subVectors(w,E),m.subVectors(_,E);let D=Math.min(p.length(),m.length())*s/100,P=D*Math.tan(r/2),I=D/Math.cos(r/2),L=p.clone().normalize().add(m.normalize()).setLength(I).add(E);p.set(0,S(r,!0),T(r,!0)),d.push([_,p.clone()]);let H=(Math.PI-r)/o;for(let Q=0;Q<=o;Q++){let K=h+r+Q*H;p.set(0,Math.sin(K)*P,Math.cos(K)*P),p.add(L),m.set(0,S(K),T(K)),d.push([p.clone(),m.clone()])}d.push([w,f(0,1,0)]);let k=Math.sin(H/2)*P*2,G=d.length-1,z=d[0][0].distanceTo(d[1][0]),U=d[G-1][0].distanceTo(d[G][0]),$=z+k*o+U;d[0].push(1);for(let Q=0;Q<=o;Q++)d[Q+1].push(1-(z+Q*k)/$);d[G].push(0);let[F,j,X]=d[0],q,V,Z;for(let Q=1;Q<d.length;Q++)[q,V,Z]=d[Q],a.push(x,F.y,F.z,x,q.y,q.z,b,F.y,F.z,b,F.y,F.z,x,q.y,q.z,b,q.y,q.z),l.push(0,j.y,j.z,0,V.y,V.z,0,j.y,j.z,0,j.y,j.z,0,V.y,V.z,0,V.y,V.z),u.push(0,X,0,Z,1,X,1,X,0,Z,1,Z),[F,j,X]=[q,V,Z];this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(l,3)),this.setAttribute("uv",new be(u,2))}};var nv=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 Pt?i.shape:new Pt,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:n,spikes:r,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,d=t*.5,h=e*.5,f=0,p=0,m=o*Math.PI/360/r,g=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(r===3&&n===50){m=2*Math.PI/r;for(let b=0;b<r;b++){let w=m*b,E=f+Math.sin(w)*d,_=p+Math.cos(w)*h;c.addPoint(c.createPoint(E,_))}}else for(let b=0;b<r;b++){let w=f+Math.cos(g)*d,E=p+Math.sin(g)*h;c.addPoint(c.createPoint(w,E)),g+=m,w=f+Math.cos(g)*y,E=p+Math.sin(g)*v,b<=r,c.addPoint(c.createPoint(w,E)),g+=m}c.isClosed=!0;for(let b=0,w=c.points.length;b<w;b++)c.points[b].roundness=s;c.roundness=s,c.update();let x=ri.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var Q2=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,n=new Ao(t,e);return Object.assign(n,{userData:{...i,type:"TextFrameGeometry"}})}};var Z2=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),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:r,depth:s})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=O6(t,e,n,t*.5,o,s,0,0,r,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function O6(i,t,e,n,r,s,o,a,l,u,c){[t,e]=[e,t],o=t/2;let d=we.clamp(r/360,0,1);if(d===0){let h=new Ee;return h.setAttribute("position",new be([],3)),h}return d===1&&(u=0),new tp(!0,i,t,e,n,d,s,o,a,l,u,c)}var J2=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:n,radialSegments:r,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new qc(a,e,n,r,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var $2=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 Pt?i.shape:new Pt,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:n,depth:r,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 h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=ri.create({shape:l,parameters:{roundness:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...i,type:"TriangleGeometry"}})}};function eD(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var ww=class{add(t,e,n){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(r){this[r]=this[r]||[],e&&this[r][n?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(n){n.call(e&&e.context?e.context:e,e)})}},Aw=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,n){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,n?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 n={context:this,node:e};return ae.hooks.run(t,n),n.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(n){return n.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=[],n,r;for(;this.index<this.expr.length;)if(n=this.code,n===ae.SEMCOL_CODE||n===ae.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())e.push(r);else if(this.index<this.expr.length){if(n===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,n,r,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),r=[o,s,a];e=this.gobbleBinaryOp();){if(n=ae.binaryPrecedence(e),n===0){this.index-=e.length;break}s={value:e,prec:n,right_a:ae.right_associative.has(e)},u=e;let c=d=>s.right_a&&d.right_a?n>d.prec:n<=d.prec;for(;r.length>2&&c(r[r.length-2]);)a=r.pop(),e=r.pop().value,o=r.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},r.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),r.push(s,t)}for(l=r.length-1,t=r[l];l>1;)t={type:ae.BINARY_EXP,operator:r[l-1].value,left:r[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)r=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),n=e.length;n>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+=n;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,--n)}ae.isIdentifierStart(t)?(r=this.gobbleIdentifier(),ae.literals.hasOwnProperty(r.name)?r={type:ae.LITERAL,value:ae.literals[r.name],raw:r.name}:r.name===ae.this_str&&(r={type:ae.THIS_EXP})):t===ae.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):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 n;if(e===ae.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ae.PERIOD_CODE)break;n=!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||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:ae.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,n;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 n=this.code,ae.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(n===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,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===n){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
3138
+ }`;function QV(i,t,e){let n=new of,r=new B,s=new B,o=new Xe,a=new af({depthPacking:bb}),l=new Kx,u={},c=e.maxTextureSize,d={[mi]:Un,[Un]:mi,[Ur]:Ur},h=new ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:XV,fragmentShader:KV}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ee;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new kn(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=sg,this.render=function(b,w,E){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=i.getRenderTarget(),S=i.getActiveCubeFace(),T=i.getActiveMipmapLevel(),M=i.state;M.setBlending(Bt),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let C=0,D=b.length;C<D;C++){let P=b[C],I=P.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;r.copy(I.mapSize);let L=I.getFrameExtents();if(r.multiply(L),s.copy(I.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/L.x),r.x=s.x*L.x,I.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/L.y),r.y=s.y*L.y,I.mapSize.y=s.y)),I.map===null){let k=this.type!==Kh?{minFilter:Nt,magFilter:Nt}:{};I.map=new ut(r.x,r.y,k),I.map.texture.name=P.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let H=I.getViewportCount();for(let k=0;k<H;k++){let G=I.getViewport(k);o.set(s.x*G.x,s.y*G.y,s.x*G.z,s.y*G.w),M.viewport(o),I.updateMatrices(P,k),n=I.getFrustum(),x(w,E,I.camera,P,this.type)}I.isPointLightShadow!==!0&&this.type===Kh&&y(I,E),I.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(_,S,T)};function y(b,w){let E=t.update(m);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new ut(r.x,r.y)),h.uniforms.shadow_pass.value=b.map.texture,h.uniforms.resolution.value=b.mapSize,h.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(w,null,E,h,m,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(w,null,E,f,m,null)}function v(b,w,E,_,S,T){let M=null,C=E.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)M=C;else if(M=E.isPointLight===!0?l:a,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let D=M.uuid,P=w.uuid,I=u[D];I===void 0&&(I={},u[D]=I);let L=I[P];L===void 0&&(L=M.clone(),I[P]=L),M=L}return M.visible=w.visible,M.wireframe=w.wireframe,T===Kh?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:d[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,E.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(E.matrixWorld),M.nearDistance=_,M.farDistance=S),M}function x(b,w,E,_,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===Kh)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,b.matrixWorld);let C=t.update(b),D=b.material;if(Array.isArray(D)){let P=C.groups;for(let I=0,L=P.length;I<L;I++){let H=P[I],k=D[H.materialIndex];if(k&&k.visible){let G=v(b,k,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,G,b,H)}}}else if(D.visible){let P=v(b,D,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,P,b,null)}}let M=b.children;for(let C=0,D=M.length;C<D;C++)x(M[C],w,E,_,S)}}function ZV(i,t,e){let n=e.isWebGL2;function r(){let Y=!1,ce=new Xe,ve=null,ke=new Xe(0,0,0,0);return{setMask:function(Be){ve!==Be&&!Y&&(i.colorMask(Be,Be,Be,Be),ve=Be)},setLocked:function(Be){Y=Be},setClear:function(Be,wt,Nn,Sn,ol){ol===!0&&(Be*=Sn,wt*=Sn,Nn*=Sn),ce.set(Be,wt,Nn,Sn),ke.equals(ce)===!1&&(i.clearColor(Be,wt,Nn,Sn),ke.copy(ce))},reset:function(){Y=!1,ve=null,ke.set(-1,0,0,0)}}}function s(){let Y=!1,ce=null,ve=null,ke=null;return{setTest:function(Be){Be?Z(2929):Q(2929)},setMask:function(Be){ce!==Be&&!Y&&(i.depthMask(Be),ce=Be)},setFunc:function(Be){if(ve!==Be){switch(Be){case ML:i.depthFunc(512);break;case CL:i.depthFunc(519);break;case PL:i.depthFunc(513);break;case Lx:i.depthFunc(515);break;case DL:i.depthFunc(514);break;case IL:i.depthFunc(518);break;case OL:i.depthFunc(516);break;case RL:i.depthFunc(517);break;default:i.depthFunc(515)}ve=Be}},setLocked:function(Be){Y=Be},setClear:function(Be){ke!==Be&&(i.clearDepth(Be),ke=Be)},reset:function(){Y=!1,ce=null,ve=null,ke=null}}}function o(){let Y=!1,ce=null,ve=null,ke=null,Be=null,wt=null,Nn=null,Sn=null,ol=null;return{setTest:function(on){Y||(on?Z(2960):Q(2960))},setMask:function(on){ce!==on&&!Y&&(i.stencilMask(on),ce=on)},setFunc:function(on,uo,_i){(ve!==on||ke!==uo||Be!==_i)&&(i.stencilFunc(on,uo,_i),ve=on,ke=uo,Be=_i)},setOp:function(on,uo,_i){(wt!==on||Nn!==uo||Sn!==_i)&&(i.stencilOp(on,uo,_i),wt=on,Nn=uo,Sn=_i)},setLocked:function(on){Y=on},setClear:function(on){ol!==on&&(i.clearStencil(on),ol=on)},reset:function(){Y=!1,ce=null,ve=null,ke=null,Be=null,wt=null,Nn=null,Sn=null,ol=null}}}let a=new r,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=null,I=null,L=i.getParameter(35661),H=!1,k=0,G=i.getParameter(7938);G.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(G)[1]),H=k>=1):G.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=k>=2);let z=null,U={},$=i.getParameter(3088),F=i.getParameter(2978),j=new Xe().fromArray($),X=new Xe().fromArray(F);function q(Y,ce,ve){let ke=new Uint8Array(4),Be=i.createTexture();i.bindTexture(Y,Be),i.texParameteri(Y,10241,9728),i.texParameteri(Y,10240,9728);for(let wt=0;wt<ve;wt++)i.texImage2D(ce+wt,0,6408,1,1,0,6408,5121,ke);return Be}let V={};V[3553]=q(3553,3553,1),V[34067]=q(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),Z(2929),l.setFunc(Lx),Oe(!1),Ie(VA),Z(2884),Ae(Bt);function Z(Y){h[Y]!==!0&&(i.enable(Y),h[Y]=!0)}function Q(Y){h[Y]!==!1&&(i.disable(Y),h[Y]=!1)}function K(Y,ce){return f[Y]!==ce?(i.bindFramebuffer(Y,ce),f[Y]=ce,n&&(Y===36009&&(f[36160]=ce),Y===36160&&(f[36009]=ce)),!0):!1}function W(Y,ce){let ve=m,ke=!1;if(Y)if(ve=p.get(ce),ve===void 0&&(ve=[],p.set(ce,ve)),Y.isWebGLMultipleRenderTargets){let Be=Y.texture;if(ve.length!==Be.length||ve[0]!==36064){for(let wt=0,Nn=Be.length;wt<Nn;wt++)ve[wt]=36064+wt;ve.length=Be.length,ke=!0}}else ve[0]!==36064&&(ve[0]=36064,ke=!0);else ve[0]!==1029&&(ve[0]=1029,ke=!0);ke&&(e.isWebGL2?i.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ye(Y){return g!==Y?(i.useProgram(Y),g=Y,!0):!1}let fe={[Cc]:32774,[gL]:32778,[yL]:32779};if(n)fe[GA]=32775,fe[HA]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(fe[GA]=Y.MIN_EXT,fe[HA]=Y.MAX_EXT)}let ie={[vL]:0,[xL]:1,[bL]:768,[m_]:770,[TL]:776,[EL]:774,[wL]:772,[SL]:769,[g_]:771,[_L]:775,[AL]:773};function Ae(Y,ce,ve,ke,Be,wt,Nn,Sn){if(Y===Bt){y===!0&&(Q(3042),y=!1);return}if(y===!1&&(Z(3042),y=!0),Y!==mL){if(Y!==v||Sn!==T){if((x!==Cc||E!==Cc)&&(i.blendEquation(32774),x=Cc,E=Cc),Sn)switch(Y){case Rc:i.blendFuncSeparate(1,771,1,771);break;case kA:i.blendFunc(1,1);break;case UA:i.blendFuncSeparate(0,769,0,1);break;case zA:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Rc:i.blendFuncSeparate(770,771,1,771);break;case kA:i.blendFunc(770,1);break;case UA:i.blendFuncSeparate(0,769,0,1);break;case zA:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,_=null,S=null,v=Y,T=Sn}return}Be=Be||ce,wt=wt||ve,Nn=Nn||ke,(ce!==x||Be!==E)&&(i.blendEquationSeparate(fe[ce],fe[Be]),x=ce,E=Be),(ve!==b||ke!==w||wt!==_||Nn!==S)&&(i.blendFuncSeparate(ie[ve],ie[ke],ie[wt],ie[Nn]),b=ve,w=ke,_=wt,S=Nn),v=Y,T=!1}function xe(Y,ce){Y.side===Ur?Q(2884):Z(2884);let ve=Y.side===Un;ce&&(ve=!ve),Oe(ve),Y.blending===Rc&&Y.transparent===!1?Ae(Bt):Ae(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),a.setMask(Y.colorWrite);let ke=Y.stencilWrite;u.setTest(ke),ke&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),Te(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?Z(32926):Q(32926)}function Oe(Y){M!==Y&&(Y?i.frontFace(2304):i.frontFace(2305),M=Y)}function Ie(Y){Y!==hL?(Z(2884),Y!==C&&(Y===VA?i.cullFace(1029):Y===fL?i.cullFace(1028):i.cullFace(1032))):Q(2884),C=Y}function Pe(Y){Y!==D&&(H&&i.lineWidth(Y),D=Y)}function Te(Y,ce,ve){Y?(Z(32823),(P!==ce||I!==ve)&&(i.polygonOffset(ce,ve),P=ce,I=ve)):Q(32823)}function Ue(Y){Y?Z(3089):Q(3089)}function ze(Y){Y===void 0&&(Y=33984+L-1),z!==Y&&(i.activeTexture(Y),z=Y)}function R(Y,ce,ve){ve===void 0&&(z===null?ve=33984+L-1:ve=z);let ke=U[ve];ke===void 0&&(ke={type:void 0,texture:void 0},U[ve]=ke),(ke.type!==Y||ke.texture!==ce)&&(z!==ve&&(i.activeTexture(ve),z=ve),i.bindTexture(Y,ce||V[Y]),ke.type=Y,ke.texture=ce)}function O(){let Y=U[z];Y!==void 0&&Y.type!==void 0&&(i.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ne(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{i.texSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{i.texSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Me(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function _e(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function le(){try{i.texStorage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ke(){try{i.texStorage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ve(){try{i.texImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{i.texImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(Y){j.equals(Y)===!1&&(i.scissor(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function Je(Y){X.equals(Y)===!1&&(i.viewport(Y.x,Y.y,Y.z,Y.w),X.copy(Y))}function St(Y,ce){let ve=d.get(ce);ve===void 0&&(ve=new WeakMap,d.set(ce,ve));let ke=ve.get(Y);ke===void 0&&(ke=i.getUniformBlockIndex(ce,Y.name),ve.set(Y,ke))}function Zt(Y,ce){let ke=d.get(ce).get(Y);c.get(ce)!==ke&&(i.uniformBlockBinding(ce,ke,Y.__bindingPointIndex),c.set(ce,ke))}function Ln(){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),n===!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),h={},z=null,U={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=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:Z,disable:Q,bindFramebuffer:K,drawBuffers:W,useProgram:ye,setBlending:Ae,setMaterial:xe,setFlipSided:Oe,setCullFace:Ie,setLineWidth:Pe,setPolygonOffset:Te,setScissorTest:Ue,activeTexture:ze,bindTexture:R,unbindTexture:O,compressedTexImage2D:ne,compressedTexImage3D:ue,texImage2D:Ve,texImage3D:Le,updateUBOMapping:St,uniformBlockBinding:Zt,texStorage2D:le,texStorage3D:Ke,texSubImage2D:me,texSubImage3D:De,compressedTexSubImage2D:Me,compressedTexSubImage3D:_e,scissor:je,viewport:Je,reset:Ln}}function JV(i,t,e,n,r,s,o){let a=r.isWebGL2,l=r.maxTextures,u=r.maxCubemapSize,c=r.maxTextureSize,d=r.maxSamples,h=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(R,O){return y?new OffscreenCanvas(R,O):Bm("canvas")}function x(R,O,ne,ue){let me=1;if((R.width>ue||R.height>ue)&&(me=ue/Math.max(R.width,R.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let De=O?Nm:Math.floor,Me=De(me*R.width),_e=De(me*R.height);m===void 0&&(m=v(Me,_e));let le=ne?v(Me,_e):m;return le.width=Me,le.height=_e,le.getContext("2d").drawImage(R,0,0,Me,_e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Me+"x"+_e+")."),le}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Ux(R.width)&&Ux(R.height)}function w(R){return a?!1:R.wrapS!==Jt||R.wrapT!==Jt||R.minFilter!==Nt&&R.minFilter!==Ze}function E(R,O){return R.generateMipmaps&&O&&R.minFilter!==Nt&&R.minFilter!==Ze}function _(R){i.generateMipmap(R)}function S(R,O,ne,ue,me=!1){if(a===!1)return O;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let De=O;return O===6403&&(ne===5126&&(De=33326),ne===5131&&(De=33325),ne===5121&&(De=33321)),O===33319&&(ne===5126&&(De=33328),ne===5131&&(De=33327),ne===5121&&(De=33323)),O===6408&&(ne===5126&&(De=34836),ne===5131&&(De=34842),ne===5121&&(De=ue===$e&&me===!1?35907:32856),ne===32819&&(De=32854),ne===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function T(R,O,ne){return E(R,ne)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Ze?Math.log2(Math.max(O.width,O.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?O.mipmaps.length:1}function M(R){return R===Nt||R===jA||R===Z0?9728:9729}function C(R){let O=R.target;O.removeEventListener("dispose",C),P(O),O.isVideoTexture&&p.delete(O)}function D(R){let O=R.target;O.removeEventListener("dispose",D),L(O)}function P(R){let O=n.get(R);if(O.__webglInit===void 0)return;let ne=R.source,ue=g.get(ne);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(R),Object.keys(ue).length===0&&g.delete(ne)}n.remove(R)}function I(R){let O=n.get(R);i.deleteTexture(O.__webglTexture);let ne=R.source,ue=g.get(ne);delete ue[O.__cacheKey],o.memory.textures--}function L(R){let O=R.texture,ne=n.get(R),ue=n.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(ne.__webglFramebuffer[me]),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(ne.__webglFramebuffer),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&i.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let me=0;me<ne.__webglColorRenderbuffer.length;me++)ne.__webglColorRenderbuffer[me]&&i.deleteRenderbuffer(ne.__webglColorRenderbuffer[me]);ne.__webglDepthRenderbuffer&&i.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let me=0,De=O.length;me<De;me++){let Me=n.get(O[me]);Me.__webglTexture&&(i.deleteTexture(Me.__webglTexture),o.memory.textures--),n.remove(O[me])}n.remove(O),n.remove(R)}let H=0;function k(){H=0}function G(){let R=H;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),H+=1,R}function z(R){let O=[];return O.push(R.wrapS),O.push(R.wrapT),O.push(R.wrapR||0),O.push(R.magFilter),O.push(R.minFilter),O.push(R.anisotropy),O.push(R.internalFormat),O.push(R.format),O.push(R.type),O.push(R.generateMipmaps),O.push(R.premultiplyAlpha),O.push(R.flipY),O.push(R.unpackAlignment),O.push(R.encoding),O.join()}function U(R,O){let ne=n.get(R);if(R.isVideoTexture&&Ue(R),R.isRenderTargetTexture===!1&&R.version>0&&ne.__version!==R.version){let ue=R.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{Q(ne,R,O);return}}e.bindTexture(3553,ne.__webglTexture,33984+O)}function $(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(35866,ne.__webglTexture,33984+O)}function F(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(32879,ne.__webglTexture,33984+O)}function j(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){K(ne,R,O);return}e.bindTexture(34067,ne.__webglTexture,33984+O)}let X={[Zi]:10497,[Jt]:33071,[Fx]:33648},q={[Nt]:9728,[jA]:9984,[Z0]:9986,[Ze]:9729,[zL]:9985,[yl]:9987};function V(R,O,ne){if(ne?(i.texParameteri(R,10242,X[O.wrapS]),i.texParameteri(R,10243,X[O.wrapT]),(R===32879||R===35866)&&i.texParameteri(R,32882,X[O.wrapR]),i.texParameteri(R,10240,q[O.magFilter]),i.texParameteri(R,10241,q[O.minFilter])):(i.texParameteri(R,10242,33071),i.texParameteri(R,10243,33071),(R===32879||R===35866)&&i.texParameteri(R,32882,33071),(O.wrapS!==Jt||O.wrapT!==Jt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,10240,M(O.magFilter)),i.texParameteri(R,10241,M(O.minFilter)),O.minFilter!==Nt&&O.minFilter!==Ze&&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===Nt||O.minFilter!==Z0&&O.minFilter!==yl||O.type===wr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===vl&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(i.texParameterf(R,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,r.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy)}}function Z(R,O){let ne=!1;R.__webglInit===void 0&&(R.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=z(O);if(De!==R.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),me[De].usedTimes++;let Me=me[R.__cacheKey];Me!==void 0&&(me[R.__cacheKey].usedTimes--,Me.usedTimes===0&&I(O)),R.__cacheKey=De,R.__webglTexture=me[De].texture}return ne}function Q(R,O,ne){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=Z(R,O),De=O.source;e.bindTexture(ue,R.__webglTexture,33984+ne);let Me=n.get(De);if(De.version!==Me.__version||me===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let _e=w(O)&&b(O.image)===!1,le=x(O.image,_e,!1,c);le=ze(O,le);let Ke=b(le)||a,Ve=s.convert(O.format,O.encoding),Le=s.convert(O.type),je=S(O.internalFormat,Ve,Le,O.encoding,O.isVideoTexture);V(ue,O,Ke);let Je,St=O.mipmaps,Zt=a&&O.isVideoTexture!==!0,Ln=Me.__version===void 0||me===!0,Y=T(O,le,Ke);if(O.isDepthTexture)je=6402,a?O.type===wr?je=36012:O.type===xo?je=33190:O.type===sa?je=35056:je=33189:O.type===wr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===ml&&je===6402&&O.type!==x_&&O.type!==xo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=xo,Le=s.convert(O.type)),O.format===la&&je===6402&&(je=34041,O.type!==sa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=sa,Le=s.convert(O.type))),Ln&&(Zt?e.texStorage2D(3553,1,je,le.width,le.height):e.texImage2D(3553,0,je,le.width,le.height,0,Ve,Le,null));else if(O.isDataTexture)if(St.length>0&&Ke){Zt&&Ln&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,Ve,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,Ve,Le,Je.data);O.generateMipmaps=!1}else Zt?(Ln&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,le.width,le.height,Ve,Le,le.data)):e.texImage2D(3553,0,je,le.width,le.height,0,Ve,Le,le.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Zt&&Ln&&e.texStorage3D(35866,Y,je,St[0].width,St[0].height,le.depth);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==pi?Ve!==null?Zt?e.compressedTexSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,Ve,Je.data,0,0):e.compressedTexImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,Je.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,Ve,Le,Je.data):e.texImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,Ve,Le,Je.data)}else{Zt&&Ln&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==pi?Ve!==null?Zt?e.compressedTexSubImage2D(3553,ce,0,0,Je.width,Je.height,Ve,Je.data):e.compressedTexImage2D(3553,ce,je,Je.width,Je.height,0,Je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,Ve,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,Ve,Le,Je.data)}else if(O.isDataArrayTexture)Zt?(Ln&&e.texStorage3D(35866,Y,je,le.width,le.height,le.depth),e.texSubImage3D(35866,0,0,0,0,le.width,le.height,le.depth,Ve,Le,le.data)):e.texImage3D(35866,0,je,le.width,le.height,le.depth,0,Ve,Le,le.data);else if(O.isData3DTexture)Zt?(Ln&&e.texStorage3D(32879,Y,je,le.width,le.height,le.depth),e.texSubImage3D(32879,0,0,0,0,le.width,le.height,le.depth,Ve,Le,le.data)):e.texImage3D(32879,0,je,le.width,le.height,le.depth,0,Ve,Le,le.data);else if(O.isFramebufferTexture){if(Ln)if(Zt)e.texStorage2D(3553,Y,je,le.width,le.height);else{let ce=le.width,ve=le.height;for(let ke=0;ke<Y;ke++)e.texImage2D(3553,ke,je,ce,ve,0,Ve,Le,null),ce>>=1,ve>>=1}}else if(St.length>0&&Ke){Zt&&Ln&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,Ve,Le,Je):e.texImage2D(3553,ce,je,Ve,Le,Je);O.generateMipmaps=!1}else Zt?(Ln&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,Ve,Le,le)):e.texImage2D(3553,0,je,Ve,Le,le);E(O,Ke)&&_(ue),Me.__version=De.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function K(R,O,ne){if(O.image.length!==6)return;let ue=Z(R,O),me=O.source;e.bindTexture(34067,R.__webglTexture,33984+ne);let De=n.get(me);if(me.version!==De.__version||ue===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Me=O.isCompressedTexture||O.image[0].isCompressedTexture,_e=O.image[0]&&O.image[0].isDataTexture,le=[];for(let ce=0;ce<6;ce++)!Me&&!_e?le[ce]=x(O.image[ce],!1,!0,u):le[ce]=_e?O.image[ce].image:O.image[ce],le[ce]=ze(O,le[ce]);let Ke=le[0],Ve=b(Ke)||a,Le=s.convert(O.format,O.encoding),je=s.convert(O.type),Je=S(O.internalFormat,Le,je,O.encoding),St=a&&O.isVideoTexture!==!0,Zt=De.__version===void 0||ue===!0,Ln=T(O,Ke,Ve);V(34067,O,Ve);let Y;if(Me){St&&Zt&&e.texStorage2D(34067,Ln,Je,Ke.width,Ke.height);for(let ce=0;ce<6;ce++){Y=le[ce].mipmaps;for(let ve=0;ve<Y.length;ve++){let ke=Y[ve];O.format!==pi?Le!==null?St?e.compressedTexSubImage2D(34069+ce,ve,0,0,ke.width,ke.height,Le,ke.data):e.compressedTexImage2D(34069+ce,ve,Je,ke.width,ke.height,0,ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):St?e.texSubImage2D(34069+ce,ve,0,0,ke.width,ke.height,Le,je,ke.data):e.texImage2D(34069+ce,ve,Je,ke.width,ke.height,0,Le,je,ke.data)}}}else{Y=O.mipmaps,St&&Zt&&(Y.length>0&&Ln++,e.texStorage2D(34067,Ln,Je,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(_e){St?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Le,je,le[ce].data):e.texImage2D(34069+ce,0,Je,le[ce].width,le[ce].height,0,Le,je,le[ce].data);for(let ve=0;ve<Y.length;ve++){let Be=Y[ve].image[ce].image;St?e.texSubImage2D(34069+ce,ve+1,0,0,Be.width,Be.height,Le,je,Be.data):e.texImage2D(34069+ce,ve+1,Je,Be.width,Be.height,0,Le,je,Be.data)}}else{St?e.texSubImage2D(34069+ce,0,0,0,Le,je,le[ce]):e.texImage2D(34069+ce,0,Je,Le,je,le[ce]);for(let ve=0;ve<Y.length;ve++){let ke=Y[ve];St?e.texSubImage2D(34069+ce,ve+1,0,0,Le,je,ke.image[ce]):e.texImage2D(34069+ce,ve+1,Je,Le,je,ke.image[ce])}}}E(O,Ve)&&_(34067),De.__version=me.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function W(R,O,ne,ue,me){let De=s.convert(ne.format,ne.encoding),Me=s.convert(ne.type),_e=S(ne.internalFormat,De,Me,ne.encoding);n.get(O).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,_e,O.width,O.height,O.depth,0,De,Me,null):e.texImage2D(me,0,_e,O.width,O.height,0,De,Me,null)),e.bindFramebuffer(36160,R),Te(O)?h.framebufferTexture2DMultisampleEXT(36160,ue,me,n.get(ne).__webglTexture,0,Pe(O)):(me===3553||me>=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,n.get(ne).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(R,O,ne){if(i.bindRenderbuffer(36161,R),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(ne||Te(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===wr?ue=36012:me.type===xo&&(ue=33190));let De=Pe(O);Te(O)?h.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,R)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);ne&&Te(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):Te(O)?h.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,R)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<ue.length;me++){let De=ue[me],Me=s.convert(De.format,De.encoding),_e=s.convert(De.type),le=S(De.internalFormat,Me,_e,De.encoding),Ke=Pe(O);ne&&Te(O)===!1?i.renderbufferStorageMultisample(36161,Ke,le,O.width,O.height):Te(O)?h.renderbufferStorageMultisampleEXT(36161,Ke,le,O.width,O.height):i.renderbufferStorage(36161,le,O.width,O.height)}}i.bindRenderbuffer(36161,null)}function fe(R,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.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),U(O.depthTexture,0);let ue=n.get(O.depthTexture).__webglTexture,me=Pe(O);if(O.depthTexture.format===ml)Te(O)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,me):i.framebufferTexture2D(36160,36096,3553,ue,0);else if(O.depthTexture.format===la)Te(O)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,me):i.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ie(R){let O=n.get(R),ne=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!O.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");fe(O.__webglFramebuffer,R)}else if(ne){O.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)e.bindFramebuffer(36160,O.__webglFramebuffer[ue]),O.__webglDepthbuffer[ue]=i.createRenderbuffer(),ye(O.__webglDepthbuffer[ue],R,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=i.createRenderbuffer(),ye(O.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function Ae(R,O,ne){let ue=n.get(R);O!==void 0&&W(ue.__webglFramebuffer,R,R.texture,36064,3553),ne!==void 0&&ie(R)}function xe(R){let O=R.texture,ne=n.get(R),ue=n.get(O);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=O.version,o.memory.textures++);let me=R.isWebGLCubeRenderTarget===!0,De=R.isWebGLMultipleRenderTargets===!0,Me=b(R)||a;if(me){ne.__webglFramebuffer=[];for(let _e=0;_e<6;_e++)ne.__webglFramebuffer[_e]=i.createFramebuffer()}else{if(ne.__webglFramebuffer=i.createFramebuffer(),De)if(r.drawBuffers){let _e=R.texture;for(let le=0,Ke=_e.length;le<Ke;le++){let Ve=n.get(_e[le]);Ve.__webglTexture===void 0&&(Ve.__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&&R.samples>0&&Te(R)===!1){let _e=De?O:[O];ne.__webglMultisampledFramebuffer=i.createFramebuffer(),ne.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer);for(let le=0;le<_e.length;le++){let Ke=_e[le];ne.__webglColorRenderbuffer[le]=i.createRenderbuffer(),i.bindRenderbuffer(36161,ne.__webglColorRenderbuffer[le]);let Ve=s.convert(Ke.format,Ke.encoding),Le=s.convert(Ke.type),je=S(Ke.internalFormat,Ve,Le,Ke.encoding,R.isXRRenderTarget===!0),Je=Pe(R);i.renderbufferStorageMultisample(36161,Je,je,R.width,R.height),i.framebufferRenderbuffer(36160,36064+le,36161,ne.__webglColorRenderbuffer[le])}i.bindRenderbuffer(36161,null),R.depthBuffer&&(ne.__webglDepthRenderbuffer=i.createRenderbuffer(),ye(ne.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ue.__webglTexture),V(34067,O,Me);for(let _e=0;_e<6;_e++)W(ne.__webglFramebuffer[_e],R,O,36064,34069+_e);E(O,Me)&&_(34067),e.unbindTexture()}else if(De){let _e=R.texture;for(let le=0,Ke=_e.length;le<Ke;le++){let Ve=_e[le],Le=n.get(Ve);e.bindTexture(3553,Le.__webglTexture),V(3553,Ve,Me),W(ne.__webglFramebuffer,R,Ve,36064+le,3553),E(Ve,Me)&&_(3553)}e.unbindTexture()}else{let _e=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?_e=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(_e,ue.__webglTexture),V(_e,O,Me),W(ne.__webglFramebuffer,R,O,36064,_e),E(O,Me)&&_(_e),e.unbindTexture()}R.depthBuffer&&ie(R)}function Oe(R){let O=b(R)||a,ne=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ue=0,me=ne.length;ue<me;ue++){let De=ne[ue];if(E(De,O)){let Me=R.isWebGLCubeRenderTarget?34067:3553,_e=n.get(De).__webglTexture;e.bindTexture(Me,_e),_(Me),e.unbindTexture()}}}function Ie(R){if(a&&R.samples>0&&Te(R)===!1){let O=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ne=R.width,ue=R.height,me=16384,De=[],Me=R.stencilBuffer?33306:36096,_e=n.get(R),le=R.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke<O.length;Ke++)e.bindFramebuffer(36160,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,null),e.bindFramebuffer(36160,_e.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,null,0);e.bindFramebuffer(36008,_e.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,_e.__webglFramebuffer);for(let Ke=0;Ke<O.length;Ke++){De.push(36064+Ke),R.depthBuffer&&De.push(Me);let Ve=_e.__ignoreDepthValues!==void 0?_e.__ignoreDepthValues:!1;if(Ve===!1&&(R.depthBuffer&&(me|=256),R.stencilBuffer&&(me|=1024)),le&&i.framebufferRenderbuffer(36008,36064,36161,_e.__webglColorRenderbuffer[Ke]),Ve===!0&&(i.invalidateFramebuffer(36008,[Me]),i.invalidateFramebuffer(36009,[Me])),le){let Le=n.get(O[Ke]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Le,0)}i.blitFramebuffer(0,0,ne,ue,0,0,ne,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,_e.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,_e.__webglColorRenderbuffer[Ke]);let Ve=n.get(O[Ke]).__webglTexture;e.bindFramebuffer(36160,_e.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,Ve,0)}e.bindFramebuffer(36009,_e.__webglMultisampledFramebuffer)}}function Pe(R){return Math.min(d,R.samples)}function Te(R){let O=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ue(R){let O=o.render.frame;p.get(R)!==O&&(p.set(R,O),R.update())}function ze(R,O){let ne=R.encoding,ue=R.format,me=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===kx||ne!==gi&&(ne===$e?a===!1?t.has("EXT_sRGB")===!0&&ue===pi?(R.format=kx,R.minFilter=Ze,R.generateMipmaps=!1):O=Fm.sRGBToLinear(O):(ue!==pi||me!==nn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ne)),O}this.allocateTextureUnit=G,this.resetTextureUnits=k,this.setTexture2D=U,this.setTexture2DArray=$,this.setTexture3D=F,this.setTextureCube=j,this.rebindTextures=Ae,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ie,this.setupFrameBufferTexture=W,this.useMultisampledRTT=Te}function $V(i,t,e){let n=e.isWebGL2;function r(s,o=null){let a;if(s===nn)return 5121;if(s===WL)return 32819;if(s===qL)return 32820;if(s===GL)return 5120;if(s===HL)return 5122;if(s===x_)return 5123;if(s===jL)return 5124;if(s===xo)return 5125;if(s===wr)return 5126;if(s===vl)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===YL)return 6406;if(s===pi)return 6408;if(s===XL)return 6409;if(s===KL)return 6410;if(s===ml)return 6402;if(s===la)return 34041;if(s===kx)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===QL)return 6403;if(s===ZL)return 36244;if(s===gb)return 33319;if(s===JL)return 33320;if(s===$L)return 36249;if(s===J0||s===$0||s===ex||s===tx)if(o===$e)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===J0)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===$0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===ex)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===tx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===J0)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===$0)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===ex)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===tx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===WA||s===qA||s===YA||s===XA)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===WA)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===qA)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===YA)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===XA)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===e3)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===KA||s===QA)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===KA)return o===$e?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===QA)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===ZA||s===JA||s===$A||s===eE||s===tE||s===nE||s===rE||s===iE||s===sE||s===oE||s===aE||s===lE||s===cE||s===uE)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===ZA)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===JA)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===$A)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===eE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===tE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===nE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===rE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===iE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===sE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===oE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===aE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===lE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===cE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===uE)return o===$e?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===$e?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===t3||s===dE||s===hE||s===fE)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===nx)return a.COMPRESSED_RED_RGTC1_EXT;if(s===dE)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===hE)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===fE)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===sa?n?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:r}}var Qx=class extends An{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Ts=class extends mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},ek={type:"move"},$h=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ts,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 Ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),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 n of t.hand.values())this._getHandJoint(e,n)}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,n){let r=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,n),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"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,p=.005;u.inputState.pinching&&h>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=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,n),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&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(ek)))}return a!==null&&(a.visible=r!==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 n=new Ts;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Ci=class extends en{constructor(t,e,n,r,s,o,a,l,u,c){if(c=c!==void 0?c:ml,c!==ml&&c!==la)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===ml&&(n=xo),n===void 0&&c===la&&(n=sa),super(null,r,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Nt,this.minFilter=l!==void 0?l:Nt,this.flipY=!1,this.generateMipmaps=!1}},Zx=class extends Ht{constructor(t,e){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],b=new Set,w=new Map,E=new An;E.layers.enable(1),E.viewport=new Xe;let _=new An;_.layers.enable(2),_.viewport=new Xe;let S=[E,_],T=new Qx;T.layers.enable(1),T.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let j=v[F];return j===void 0&&(j=new $h,v[F]=j),j.getTargetRaySpace()},this.getControllerGrip=function(F){let j=v[F];return j===void 0&&(j=new $h,v[F]=j),j.getGripSpace()},this.getHand=function(F){let j=v[F];return j===void 0&&(j=new $h,v[F]=j),j.getHandSpace()};function D(F){let j=x.indexOf(F.inputSource);if(j===-1)return;let X=v[j];X!==void 0&&X.dispatchEvent({type:F.type,data:F.inputSource})}function P(){r.removeEventListener("select",D),r.removeEventListener("selectstart",D),r.removeEventListener("selectend",D),r.removeEventListener("squeeze",D),r.removeEventListener("squeezestart",D),r.removeEventListener("squeezeend",D),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",I);for(let F=0;F<v.length;F++){let j=x[F];j!==null&&(x[F]=null,v[F].disconnect(j))}M=null,C=null,t.setRenderTarget(g),f=null,h=null,d=null,r=null,y=null,$.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(F){u=F},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(F){if(r=F,r!==null){if(g=t.getRenderTarget(),r.addEventListener("select",D),r.addEventListener("selectstart",D),r.addEventListener("selectend",D),r.addEventListener("squeeze",D),r.addEventListener("squeezestart",D),r.addEventListener("squeezeend",D),r.addEventListener("end",P),r.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),r.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let j={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,e,j),r.updateRenderState({baseLayer:f}),y=new ut(f.framebufferWidth,f.framebufferHeight,{format:pi,type:nn,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let j=null,X=null,q=null;m.depth&&(q=m.stencil?35056:33190,j=m.stencil?la:ml,X=m.stencil?sa:xo);let V={colorFormat:32856,depthFormat:q,scaleFactor:s};d=new XRWebGLBinding(r,e),h=d.createProjectionLayer(V),r.updateRenderState({layers:[h]}),y=new ut(h.textureWidth,h.textureHeight,{format:pi,type:nn,depthTexture:new Ci(h.textureWidth,h.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 Z=t.properties.get(y);Z.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await r.requestReferenceSpace(a),$.setContext(r),$.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function I(F){for(let j=0;j<F.removed.length;j++){let X=F.removed[j],q=x.indexOf(X);q>=0&&(x[q]=null,v[q].disconnect(X))}for(let j=0;j<F.added.length;j++){let X=F.added[j],q=x.indexOf(X);if(q===-1){for(let Z=0;Z<v.length;Z++)if(Z>=x.length){x.push(X),q=Z;break}else if(x[Z]===null){x[Z]=X,q=Z;break}if(q===-1)break}let V=v[q];V&&V.connect(X)}}let L=new A,H=new A;function k(F,j,X){L.setFromMatrixPosition(j.matrixWorld),H.setFromMatrixPosition(X.matrixWorld);let q=L.distanceTo(H),V=j.projectionMatrix.elements,Z=X.projectionMatrix.elements,Q=V[14]/(V[10]-1),K=V[14]/(V[10]+1),W=(V[9]+1)/V[5],ye=(V[9]-1)/V[5],fe=(V[8]-1)/V[0],ie=(Z[8]+1)/Z[0],Ae=Q*fe,xe=Q*ie,Oe=q/(-fe+ie),Ie=Oe*-fe;j.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(Ie),F.translateZ(Oe),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let Pe=Q+Oe,Te=K+Oe,Ue=Ae-Ie,ze=xe+(q-Ie),R=W*K/Te*Pe,O=ye*K/Te*Pe;F.projectionMatrix.makePerspective(Ue,ze,R,O,Pe,Te)}function G(F,j){j===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(j.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(r===null)return;T.near=_.near=E.near=F.near,T.far=_.far=E.far=F.far,(M!==T.near||C!==T.far)&&(r.updateRenderState({depthNear:T.near,depthFar:T.far}),M=T.near,C=T.far);let j=F.parent,X=T.cameras;G(T,j);for(let V=0;V<X.length;V++)G(X[V],j);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),F.matrix.copy(T.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);let q=F.children;for(let V=0,Z=q.length;V<Z;V++)q[V].updateMatrixWorld(!0);X.length===2?k(T,E,_):T.projectionMatrix.copy(E.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(F){l=F,h!==null&&(h.fixedFoveation=F),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=F)},this.getPlanes=function(){return b};let z=null;function U(F,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!==T.cameras.length&&(T.cameras.length=0,q=!0);for(let V=0;V<X.length;V++){let Z=X[V],Q=null;if(f!==null)Q=f.getViewport(Z);else{let W=d.getViewSubImage(h,Z);Q=W.viewport,V===0&&(t.setRenderTargetTextures(y,W.colorTexture,h.ignoreDepthValues?void 0:W.depthStencilTexture),t.setRenderTarget(y))}let K=S[V];K===void 0&&(K=new An,K.layers.enable(V),K.viewport=new Xe,S[V]=K),K.matrix.fromArray(Z.transform.matrix),K.projectionMatrix.fromArray(Z.projectionMatrix),K.viewport.set(Q.x,Q.y,Q.width,Q.height),V===0&&T.matrix.copy(K.matrix),q===!0&&T.cameras.push(K)}}for(let X=0;X<v.length;X++){let q=x[X],V=v[X];q!==null&&V!==void 0&&V.update(q,j,u||o)}if(z&&z(F,j),j.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:j.detectedPlanes});let X=null;for(let q of b)j.detectedPlanes.has(q)||(X===null&&(X=[]),X.push(q));if(X!==null)for(let q of X)b.delete(q),w.delete(q),n.dispatchEvent({type:"planeremoved",data:q});for(let q of j.detectedPlanes)if(!b.has(q))b.add(q),w.set(q,j.lastChangedTime),n.dispatchEvent({type:"planeadded",data:q});else{let V=w.get(q);q.lastChangedTime>V&&(w.set(q,q.lastChangedTime),n.dispatchEvent({type:"planechanged",data:q}))}}p=null}let $=new E_;$.setAnimationLoop(U),this.setAnimationLoop=function(F){z=F},this.dispose=function(){}}};function tk(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,A_(i)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),c(m,g)):g.isMeshPhongMaterial?(r(m,g),u(m,g)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&h(m,g,x)):g.isMeshMatcapMaterial?(r(m,g),f(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),p(m,g)):g.isMeshNormalMaterial?r(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 r(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===Un&&(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===Un&&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 b=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}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 d(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 h(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===Un&&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:n}}function nk(i,t,e,n){let r={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let b=x.program;n.uniformBlockBinding(v,b)}function u(v,x){let b=r[v.id];b===void 0&&(p(v),b=c(v),r[v.id]=b,v.addEventListener("dispose",g));let w=x.program;n.updateUBOMapping(v,w);let E=t.render.frame;s[v.id]!==E&&(h(v),s[v.id]=E)}function c(v){let x=d();v.__bindingPointIndex=x;let b=i.createBuffer(),w=v.__size,E=v.usage;return i.bindBuffer(35345,b),i.bufferData(35345,w,E),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,b),b}function d(){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 h(v){let x=r[v.id],b=v.uniforms,w=v.__cache;i.bindBuffer(35345,x);for(let E=0,_=b.length;E<_;E++){let S=b[E];if(f(S,E,w)===!0){let T=S.__offset,M=Array.isArray(S.value)?S.value:[S.value],C=0;for(let D=0;D<M.length;D++){let P=M[D],I=m(P);typeof P=="number"?(S.__data[0]=P,i.bufferSubData(35345,T+C,S.__data)):P.isMatrix3?(S.__data[0]=P.elements[0],S.__data[1]=P.elements[1],S.__data[2]=P.elements[2],S.__data[3]=P.elements[0],S.__data[4]=P.elements[3],S.__data[5]=P.elements[4],S.__data[6]=P.elements[5],S.__data[7]=P.elements[0],S.__data[8]=P.elements[6],S.__data[9]=P.elements[7],S.__data[10]=P.elements[8],S.__data[11]=P.elements[0]):(P.toArray(S.__data,C),C+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,T,S.__data)}}i.bindBuffer(35345,null)}function f(v,x,b){let w=v.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let E=Array.isArray(w)?w:[w],_=[];for(let S=0;S<E.length;S++)_.push(E[S].clone());b[x]=_}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let E=Array.isArray(b[x])?b[x]:[b[x]],_=Array.isArray(w)?w:[w];for(let S=0;S<E.length;S++){let T=E[S];if(T.equals(_[S])===!1)return T.copy(_[S]),!0}}return!1}function p(v){let x=v.uniforms,b=0,w=16,E=0;for(let _=0,S=x.length;_<S;_++){let T=x[_],M={boundary:0,storage:0},C=Array.isArray(T.value)?T.value:[T.value];for(let D=0,P=C.length;D<P;D++){let I=C[D],L=m(I);M.boundary+=L.boundary,M.storage+=L.storage}if(T.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=b,_>0){E=b%w;let D=w-E;E!==0&&D-M.boundary<0&&(b+=w-E,T.__offset=b)}b+=M.storage}return E=b%w,E>0&&(b+=w-E),v.__size=b,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 b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function y(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:u,dispose:y}}function rk(){let i=Bm("canvas");return i.style.display="block",i}function Ab(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:rk(),e=i.context!==void 0?i.context:null,n=i.depth!==void 0?i.depth:!0,r=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 d=null,h=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=gi,this.physicallyCorrectLights=!1,this.toneMapping=So,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,b=-1,w=null,E=new Xe,_=new Xe,S=null,T=t.width,M=t.height,C=1,D=null,P=null,I=new Xe(0,0,T,M),L=new Xe(0,0,T,M),H=!1,k=new of,G=!1,z=!1,U=null,$=new se,F=new B,j=new A,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let V=e;function Z(N,te){for(let de=0;de<N.length;de++){let ee=N[de],pe=t.getContext(ee,te);if(pe!==null)return pe}return null}try{let N={alpha:!0,depth:n,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${To}`),t.addEventListener("webglcontextlost",je,!1),t.addEventListener("webglcontextrestored",Je,!1),t.addEventListener("webglcontextcreationerror",St,!1),V===null){let te=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&te.shift(),V=Z(te,N),V===null)throw Z(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let Q,K,W,ye,fe,ie,Ae,xe,Oe,Ie,Pe,Te,Ue,ze,R,O,ne,ue,me,De,Me,_e,le,Ke;function Ve(){Q=new EF(V),K=new vF(V,Q,i),Q.init(K),_e=new $V(V,Q,K),W=new ZV(V,Q,K),ye=new MF,fe=new kV,ie=new JV(V,Q,W,fe,K,_e,ye),Ae=new bF(m),xe=new AF(m),Oe=new B3(V,K),le=new gF(V,Q,Oe,K),Ie=new _F(V,Oe,ye,le),Pe=new IF(V,Ie,Oe,ye),me=new DF(V,K,ie),O=new xF(fe),Te=new VV(m,Ae,xe,Q,K,le,O),Ue=new tk(m,fe),ze=new zV,R=new YV(Q,K),ue=new mF(m,Ae,xe,W,Pe,c,o),ne=new QV(m,Pe,K),Ke=new nk(V,ye,K,W),De=new yF(V,Q,ye,K),Me=new TF(V,Q,ye,K),ye.programs=Te.programs,m.capabilities=K,m.extensions=Q,m.properties=fe,m.renderLists=ze,m.shadowMap=ne,m.state=W,m.info=ye}Ve();let Le=new Zx(m,V);this.xr=Le,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let N=Q.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=Q.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(N){N!==void 0&&(C=N,this.setSize(T,M,!1))},this.getSize=function(N){return N.set(T,M)},this.setSize=function(N,te,de){if(Le.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=N,M=te,t.width=Math.floor(N*C),t.height=Math.floor(te*C),de!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(T*C,M*C).floor()},this.setDrawingBufferSize=function(N,te,de){T=N,M=te,C=de,t.width=Math.floor(N*de),t.height=Math.floor(te*de),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(E)},this.getViewport=function(N){return N.copy(I)},this.setViewport=function(N,te,de,ee){N.isVector4?I.set(N.x,N.y,N.z,N.w):I.set(N,te,de,ee),W.viewport(E.copy(I).multiplyScalar(C).floor())},this.getScissor=function(N){return N.copy(L)},this.setScissor=function(N,te,de,ee){N.isVector4?L.set(N.x,N.y,N.z,N.w):L.set(N,te,de,ee),W.scissor(_.copy(L).multiplyScalar(C).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(N){W.setScissorTest(H=N)},this.setOpaqueSort=function(N){D=N},this.setTransparentSort=function(N){P=N},this.getClearColor=function(N){return N.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(N=!0,te=!0,de=!0){let ee=0;N&&(ee|=16384),te&&(ee|=256),de&&(ee|=1024),V.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",je,!1),t.removeEventListener("webglcontextrestored",Je,!1),t.removeEventListener("webglcontextcreationerror",St,!1),ze.dispose(),R.dispose(),fe.dispose(),Ae.dispose(),xe.dispose(),Pe.dispose(),le.dispose(),Ke.dispose(),Te.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",ke),Le.removeEventListener("sessionend",Be),U&&(U.dispose(),U=null),wt.stop()};function je(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Je(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=ye.autoReset,te=ne.enabled,de=ne.autoUpdate,ee=ne.needsUpdate,pe=ne.type;Ve(),ye.autoReset=N,ne.enabled=te,ne.autoUpdate=de,ne.needsUpdate=ee,ne.type=pe}function St(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function Zt(N){let te=N.target;te.removeEventListener("dispose",Zt),Ln(te)}function Ln(N){Y(N),fe.remove(N)}function Y(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(de){Te.releaseProgram(de)}),N.isShaderMaterial&&Te.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,de,ee,pe,it){te===null&&(te=X);let dt=pe.isMesh&&pe.matrixWorld.determinant()<0,pt=nL(N,te,de,ee,pe);W.setMaterial(ee,dt);let vt=de.index,It=1;ee.wireframe===!0&&(vt=Ie.getWireframeAttribute(de),It=2);let At=de.drawRange,Et=de.attributes.position,Bn=At.start*It,ui=(At.start+At.count)*It;it!==null&&(Bn=Math.max(Bn,it.start*It),ui=Math.min(ui,(it.start+it.count)*It)),vt!==null?(Bn=Math.max(Bn,0),ui=Math.min(ui,vt.count)):Et!=null&&(Bn=Math.max(Bn,0),ui=Math.min(ui,Et.count));let ho=ui-Bn;if(ho<0||ho===1/0)return;le.setup(pe,ee,pt,de,vt);let al,Fn=De;if(vt!==null&&(al=Oe.get(vt),Fn=Me,Fn.setIndex(al)),pe.isMesh)ee.wireframe===!0?(W.setLineWidth(ee.wireframeLinewidth*q()),Fn.setMode(1)):Fn.setMode(4);else if(pe.isLine){let _t=ee.linewidth;_t===void 0&&(_t=1),W.setLineWidth(_t*q()),pe.isLineSegments?Fn.setMode(1):pe.isLineLoop?Fn.setMode(2):Fn.setMode(3)}else pe.isPoints?Fn.setMode(0):pe.isSprite&&Fn.setMode(4);if(pe.isInstancedMesh)Fn.renderInstances(Bn,ho,pe.count);else if(de.isInstancedBufferGeometry){let _t=de._maxInstanceCount!==void 0?de._maxInstanceCount:1/0,Y0=Math.min(de.instanceCount,_t);Fn.renderInstances(Bn,ho,Y0)}else Fn.render(Bn,ho)},this.compile=function(N,te){function de(ee,pe,it){ee.transparent===!0&&ee.side===Ur&&ee.forceSinglePass===!1?(ee.side=Un,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=mi,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=Ur):_i(ee,pe,it)}h=R.get(N),h.init(),p.push(h),N.traverseVisible(function(ee){ee.isLight&&ee.layers.test(te.layers)&&(h.pushLight(ee),ee.castShadow&&h.pushShadow(ee))}),h.setupLights(m.physicallyCorrectLights),N.traverse(function(ee){let pe=ee.material;if(pe)if(Array.isArray(pe))for(let it=0;it<pe.length;it++){let dt=pe[it];de(dt,N,ee)}else de(pe,N,ee)}),p.pop(),h=null};let ce=null;function ve(N){ce&&ce(N)}function ke(){wt.stop()}function Be(){wt.start()}let wt=new E_;wt.setAnimationLoop(ve),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(N){ce=N,Le.setAnimationLoop(N),N===null?wt.stop():wt.start()},Le.addEventListener("sessionstart",ke),Le.addEventListener("sessionend",Be),this.render=function(N,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;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Le.enabled===!0&&Le.isPresenting===!0&&(Le.cameraAutoUpdate===!0&&Le.updateCamera(te),te=Le.getCamera()),N.isScene===!0&&N.onBeforeRender(m,N,te,x),h=R.get(N,p.length),h.init(),p.push(h),$.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),k.setFromProjectionMatrix($),z=this.localClippingEnabled,G=O.init(this.clippingPlanes,z),d=ze.get(N,f.length),d.init(),f.push(d),Nn(N,te,0,m.sortObjects),d.finish(),m.sortObjects===!0&&d.sort(D,P),G===!0&&O.beginShadows();let de=h.state.shadowsArray;if(ne.render(de,N,te),G===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(d,N),h.setupLights(m.physicallyCorrectLights),te.isArrayCamera){let ee=te.cameras;for(let pe=0,it=ee.length;pe<it;pe++){let dt=ee[pe];Sn(d,N,dt,dt.viewport)}}else Sn(d,N,te);x!==null&&(ie.updateMultisampleRenderTarget(x),ie.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(m,N,te),le.resetDefaultState(),b=-1,w=null,p.pop(),p.length>0?h=p[p.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function Nn(N,te,de,ee){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)de=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||k.intersectsSprite(N)){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let dt=Pe.update(N),pt=N.material;pt.visible&&d.push(N,dt,pt,de,j.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==ye.render.frame&&(N.skeleton.update(),N.skeleton.frame=ye.render.frame),!N.frustumCulled||k.intersectsObject(N))){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let dt=Pe.update(N),pt=N.material;if(Array.isArray(pt)){let vt=dt.groups;for(let It=0,At=vt.length;It<At;It++){let Et=vt[It],Bn=pt[Et.materialIndex];Bn&&Bn.visible&&d.push(N,dt,Bn,de,j.z,Et)}}else pt.visible&&d.push(N,dt,pt,de,j.z,null)}}let it=N.children;for(let dt=0,pt=it.length;dt<pt;dt++)Nn(it[dt],te,de,ee)}function Sn(N,te,de,ee){let pe=N.opaque,it=N.transmissive,dt=N.transparent;h.setupLightsView(de),G===!0&&O.setGlobalState(m.clippingPlanes,de),it.length>0&&ol(pe,te,de),ee&&W.viewport(E.copy(ee)),pe.length>0&&on(pe,te,de),it.length>0&&on(it,te,de),dt.length>0&&on(dt,te,de),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function ol(N,te,de){let ee=K.isWebGL2;U===null&&(U=new ut(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?vl:nn,minFilter:yl,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(F),ee?U.setSize(F.x,F.y):U.setSize(Nm(F.x),Nm(F.y));let pe=m.getRenderTarget();m.setRenderTarget(U),m.clear();let it=m.toneMapping;m.toneMapping=So,on(N,te,de),m.toneMapping=it,ie.updateMultisampleRenderTarget(U),ie.updateRenderTargetMipmap(U),m.setRenderTarget(pe)}function on(N,te,de){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,it=N.length;pe<it;pe++){let dt=N[pe],pt=dt.object,vt=dt.geometry,It=ee===null?dt.material:ee,At=dt.group;pt.layers.test(de.layers)&&uo(pt,te,de,vt,It,At)}}function uo(N,te,de,ee,pe,it){N.onBeforeRender(m,te,de,ee,pe,it),N.modelViewMatrix.multiplyMatrices(de.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),pe.onBeforeRender(m,te,de,ee,N,it),pe.transparent===!0&&pe.side===Ur&&pe.forceSinglePass===!1?(pe.side=Un,pe.needsUpdate=!0,m.renderBufferDirect(de,te,ee,pe,N,it),pe.side=mi,pe.needsUpdate=!0,m.renderBufferDirect(de,te,ee,pe,N,it),pe.side=Ur):m.renderBufferDirect(de,te,ee,pe,N,it),N.onAfterRender(m,te,de,ee,pe,it)}function _i(N,te,de){te.isScene!==!0&&(te=X);let ee=fe.get(N),pe=h.state.lights,it=h.state.shadowsArray,dt=pe.state.version,pt=Te.getParameters(N,pe.state,it,te,de),vt=Te.getProgramCacheKey(pt),It=ee.programs;ee.environment=N.isMeshStandardMaterial?te.environment:null,ee.fog=te.fog,ee.envMap=(N.isMeshStandardMaterial?xe:Ae).get(N.envMap||ee.environment),It===void 0&&(N.addEventListener("dispose",Zt),It=new Map,ee.programs=It);let At=It.get(vt);if(At!==void 0){if(ee.currentProgram===At&&ee.lightsStateVersion===dt)return RA(N,pt),At}else pt.uniforms=Te.getUniforms(N),N.onBuild(de,pt,m),N.onBeforeCompile(pt,m),At=Te.acquireProgram(pt,vt),It.set(vt,At),ee.uniforms=pt.uniforms;let Et=ee.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(Et.clippingPlanes=O.uniform),RA(N,pt),ee.needsLights=iL(N),ee.lightsStateVersion=dt,ee.needsLights&&(Et.ambientLightColor.value=pe.state.ambient,Et.lightProbe.value=pe.state.probe,Et.directionalLights.value=pe.state.directional,Et.directionalLightShadows.value=pe.state.directionalShadow,Et.spotLights.value=pe.state.spot,Et.spotLightShadows.value=pe.state.spotShadow,Et.rectAreaLights.value=pe.state.rectArea,Et.ltc_1.value=pe.state.rectAreaLTC1,Et.ltc_2.value=pe.state.rectAreaLTC2,Et.pointLights.value=pe.state.point,Et.pointLightShadows.value=pe.state.pointShadow,Et.hemisphereLights.value=pe.state.hemi,Et.directionalShadowMap.value=pe.state.directionalShadowMap,Et.directionalShadowMatrix.value=pe.state.directionalShadowMatrix,Et.spotShadowMap.value=pe.state.spotShadowMap,Et.spotLightMatrix.value=pe.state.spotLightMatrix,Et.spotLightMap.value=pe.state.spotLightMap,Et.pointShadowMap.value=pe.state.pointShadowMap,Et.pointShadowMatrix.value=pe.state.pointShadowMatrix);let Bn=At.getUniforms(),ui=Lc.seqWithValue(Bn.seq,Et);return ee.currentProgram=At,ee.uniformsList=ui,At}function RA(N,te){let de=fe.get(N);de.outputEncoding=te.outputEncoding,de.instancing=te.instancing,de.skinning=te.skinning,de.morphTargets=te.morphTargets,de.morphNormals=te.morphNormals,de.morphColors=te.morphColors,de.morphTargetsCount=te.morphTargetsCount,de.numClippingPlanes=te.numClippingPlanes,de.numIntersection=te.numClipIntersection,de.vertexAlphas=te.vertexAlphas,de.vertexTangents=te.vertexTangents,de.toneMapping=te.toneMapping}function nL(N,te,de,ee,pe){te.isScene!==!0&&(te=X),ie.resetTextureUnits();let it=te.fog,dt=ee.isMeshStandardMaterial?te.environment:null,pt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:gi,vt=(ee.isMeshStandardMaterial?xe:Ae).get(ee.envMap||dt),It=ee.vertexColors===!0&&!!de.attributes.color&&de.attributes.color.itemSize===4,At=!!ee.normalMap&&!!de.attributes.tangent,Et=!!de.morphAttributes.position,Bn=!!de.morphAttributes.normal,ui=!!de.morphAttributes.color,ho=ee.toneMapped?m.toneMapping:So,al=de.morphAttributes.position||de.morphAttributes.normal||de.morphAttributes.color,Fn=al!==void 0?al.length:0,_t=fe.get(ee),Y0=h.state.lights;if(G===!0&&(z===!0||N!==w)){let di=N===w&&ee.id===b;O.setState(ee,N,di)}let rr=!1;ee.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==Y0.state.version||_t.outputEncoding!==pt||pe.isInstancedMesh&&_t.instancing===!1||!pe.isInstancedMesh&&_t.instancing===!0||pe.isSkinnedMesh&&_t.skinning===!1||!pe.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==vt||ee.fog===!0&&_t.fog!==it||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==O.numPlanes||_t.numIntersection!==O.numIntersection)||_t.vertexAlphas!==It||_t.vertexTangents!==At||_t.morphTargets!==Et||_t.morphNormals!==Bn||_t.morphColors!==ui||_t.toneMapping!==ho||K.isWebGL2===!0&&_t.morphTargetsCount!==Fn)&&(rr=!0):(rr=!0,_t.__version=ee.version);let ll=_t.currentProgram;rr===!0&&(ll=_i(ee,te,pe));let LA=!1,Uh=!1,X0=!1,Sr=ll.getUniforms(),cl=_t.uniforms;if(W.useProgram(ll.program)&&(LA=!0,Uh=!0,X0=!0),ee.id!==b&&(b=ee.id,Uh=!0),LA||w!==N){if(Sr.setValue(V,"projectionMatrix",N.projectionMatrix),K.logarithmicDepthBuffer&&Sr.setValue(V,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),w!==N&&(w=N,Uh=!0,X0=!0),ee.isShaderMaterial||ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshStandardMaterial||ee.envMap){let di=Sr.map.cameraPosition;di!==void 0&&di.setValue(V,j.setFromMatrixPosition(N.matrixWorld))}(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&Sr.setValue(V,"isOrthographic",N.isOrthographicCamera===!0),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial||ee.isShadowMaterial||pe.isSkinnedMesh)&&Sr.setValue(V,"viewMatrix",N.matrixWorldInverse)}if(pe.isSkinnedMesh){Sr.setOptional(V,pe,"bindMatrix"),Sr.setOptional(V,pe,"bindMatrixInverse");let di=pe.skeleton;di&&(K.floatVertexTextures?(di.boneTexture===null&&di.computeBoneTexture(),Sr.setValue(V,"boneTexture",di.boneTexture,ie),Sr.setValue(V,"boneTextureSize",di.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 K0=de.morphAttributes;if((K0.position!==void 0||K0.normal!==void 0||K0.color!==void 0&&K.isWebGL2===!0)&&me.update(pe,de,ee,ll),(Uh||_t.receiveShadow!==pe.receiveShadow)&&(_t.receiveShadow=pe.receiveShadow,Sr.setValue(V,"receiveShadow",pe.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(cl.envMap.value=vt,cl.flipEnvMap.value=vt.isCubeTexture&&vt.isRenderTargetTexture===!1?-1:1),Uh&&(Sr.setValue(V,"toneMappingExposure",m.toneMappingExposure),_t.needsLights&&rL(cl,X0),it&&ee.fog===!0&&Ue.refreshFogUniforms(cl,it),Ue.refreshMaterialUniforms(cl,ee,C,M,U),Lc.upload(V,_t.uniformsList,cl,ie)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(Lc.upload(V,_t.uniformsList,cl,ie),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&Sr.setValue(V,"center",pe.center),Sr.setValue(V,"modelViewMatrix",pe.modelViewMatrix),Sr.setValue(V,"normalMatrix",pe.normalMatrix),Sr.setValue(V,"modelMatrix",pe.matrixWorld),pe.previousModelViewMatrix&&Sr.setValue(V,"previousModelViewMatrix",pe.previousModelViewMatrix),N.previousProjectionMatrix&&Sr.setValue(V,"previousProjectionMatrix",N.previousProjectionMatrix),ee.isShaderMaterial||ee.isRawShaderMaterial){let di=ee.uniformsGroups;for(let Q0=0,sL=di.length;Q0<sL;Q0++)if(K.isWebGL2){let NA=di[Q0];Ke.update(NA,ll),Ke.bind(NA,ll)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ll}function rL(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function iL(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,de){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=de;let ee=fe.get(N);ee.__hasExternalTextures=!0,ee.__hasExternalTextures&&(ee.__autoAllocateDepthBuffer=de===void 0,ee.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ee.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let de=fe.get(N);de.__webglFramebuffer=te,de.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,de=0){x=N,y=te,v=de;let ee=!0,pe=null,it=!1,dt=!1;if(N){let vt=fe.get(N);vt.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(36160,null),ee=!1):vt.__webglFramebuffer===void 0?ie.setupRenderTarget(N):vt.__hasExternalTextures&&ie.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let It=N.texture;(It.isData3DTexture||It.isDataArrayTexture||It.isCompressedArrayTexture)&&(dt=!0);let At=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(pe=At[te],it=!0):K.isWebGL2&&N.samples>0&&ie.useMultisampledRTT(N)===!1?pe=fe.get(N).__webglMultisampledFramebuffer:pe=At,E.copy(N.viewport),_.copy(N.scissor),S=N.scissorTest}else E.copy(I).multiplyScalar(C).floor(),_.copy(L).multiplyScalar(C).floor(),S=H;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(N,pe),W.viewport(E),W.scissor(_),W.setScissorTest(S),it){let vt=fe.get(N.texture);V.framebufferTexture2D(36160,36064,34069+te,vt.__webglTexture,de)}else if(dt){let vt=fe.get(N.texture),It=te||0;V.framebufferTextureLayer(36160,36064,vt.__webglTexture,de||0,It)}b=-1},this.readRenderTargetPixels=function(N,te,de,ee,pe,it,dt){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&dt!==void 0&&(pt=pt[dt]),pt){W.bindFramebuffer(36160,pt);try{let vt=N.texture,It=vt.format,At=vt.type;if(It!==pi&&_e.convert(It)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Et=At===vl&&(Q.has("EXT_color_buffer_half_float")||K.isWebGL2&&Q.has("EXT_color_buffer_float"));if(At!==nn&&_e.convert(At)!==V.getParameter(35738)&&!(At===wr&&(K.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!Et){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-ee&&de>=0&&de<=N.height-pe&&V.readPixels(te,de,ee,pe,_e.convert(It),_e.convert(At),it)}finally{let vt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,vt)}}},this.copyFramebufferToTexture=function(N,te,de=0){let ee=Math.pow(2,-de),pe=Math.floor(te.image.width*ee),it=Math.floor(te.image.height*ee);ie.setTexture2D(te,0),V.copyTexSubImage2D(3553,de,0,0,N.x,N.y,pe,it),W.unbindTexture()},this.copyTextureToTexture=function(N,te,de,ee=0){let pe=te.image.width,it=te.image.height,dt=_e.convert(de.format),pt=_e.convert(de.type);ie.setTexture2D(de,0),V.pixelStorei(37440,de.flipY),V.pixelStorei(37441,de.premultiplyAlpha),V.pixelStorei(3317,de.unpackAlignment),te.isDataTexture?V.texSubImage2D(3553,ee,N.x,N.y,pe,it,dt,pt,te.image.data):te.isCompressedTexture?V.compressedTexSubImage2D(3553,ee,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,dt,te.mipmaps[0].data):V.texSubImage2D(3553,ee,N.x,N.y,dt,pt,te.image),ee===0&&de.generateMipmaps&&V.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(N,te,de,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let it=N.max.x-N.min.x+1,dt=N.max.y-N.min.y+1,pt=N.max.z-N.min.z+1,vt=_e.convert(ee.format),It=_e.convert(ee.type),At;if(ee.isData3DTexture)ie.setTexture3D(ee,0),At=32879;else if(ee.isDataArrayTexture)ie.setTexture2DArray(ee,0),At=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(37440,ee.flipY),V.pixelStorei(37441,ee.premultiplyAlpha),V.pixelStorei(3317,ee.unpackAlignment);let Et=V.getParameter(3314),Bn=V.getParameter(32878),ui=V.getParameter(3316),ho=V.getParameter(3315),al=V.getParameter(32877),Fn=de.isCompressedTexture?de.mipmaps[0]:de.image;V.pixelStorei(3314,Fn.width),V.pixelStorei(32878,Fn.height),V.pixelStorei(3316,N.min.x),V.pixelStorei(3315,N.min.y),V.pixelStorei(32877,N.min.z),de.isDataTexture||de.isData3DTexture?V.texSubImage3D(At,pe,te.x,te.y,te.z,it,dt,pt,vt,It,Fn.data):de.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(At,pe,te.x,te.y,te.z,it,dt,pt,vt,Fn.data)):V.texSubImage3D(At,pe,te.x,te.y,te.z,it,dt,pt,vt,It,Fn),V.pixelStorei(3314,Et),V.pixelStorei(32878,Bn),V.pixelStorei(3316,ui),V.pixelStorei(3315,ho),V.pixelStorei(32877,al),pe===0&&ee.generateMipmaps&&V.generateMipmap(At),W.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ie.setTextureCube(N,0):N.isData3DTexture?ie.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ie.setTexture2DArray(N,0):ie.setTexture2D(N,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 Jx=class extends Ab{};Jx.prototype.isWebGL1Renderer=!0;var Vc=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Fe(t),this.near=e,this.far=n}clone(){return new Vc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Ar=class extends mt{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}},jm=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Vx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Mi()}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,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];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=Mi()),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]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}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=Mi()),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}}},Vr=new A,bl=class{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}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,n=this.data.count;e<n;e++)Vr.fromBufferAttribute(this,e),Vr.applyMatrix4(t),this.setXYZ(e,Vr.x,Vr.y,Vr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Vr.fromBufferAttribute(this,e),Vr.applyNormalMatrix(t),this.setXYZ(e,Vr.x,Vr.y,Vr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Vr.fromBufferAttribute(this,e),Vr.transformDirection(t),this.setXYZ(e,Vr.x,Vr.y,Vr.z);return this}setX(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Wt(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=bo(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=bo(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=bo(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=bo(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array),s=Wt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,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 n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+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 bl(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 n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+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 lf=class extends mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Eo=class extends en{constructor(t=null,e=1,n=1,r,s,o,a,l,u=Nt,c=Nt,d,h){super(null,o,a,l,u,c,r,s,d,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},YE=new se,ik=new se,ca=class{constructor(t=[],e=[]){this.uuid=Mi(),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 n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new se)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new se;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:ik;YE.multiplyMatrices(a,e[s]),YE.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ca(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=b_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new Eo(e,t,t,pi,wr);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){let s=t.bones[n],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new lf),this.bones.push(o),this.boneInverses.push(new se().fromArray(t.boneInverses[n]))}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,n=this.boneInverses;for(let r=0,s=e.length;r<s;r++){let o=e[r];t.bones.push(o.uuid);let a=n[r];t.boneInverses.push(a.toArray())}return t}},Wm=class extends Ge{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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 Pi=class extends xl{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Fe(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}},XE=new A,KE=new A,QE=new se,Cx=new Ji,Am=new ln,Sl=class extends mt{constructor(t=new Ee,e=new Pi){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,n=[0];for(let r=1,s=e.count;r<s;r++)XE.fromBufferAttribute(e,r-1),KE.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=XE.distanceTo(KE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,r=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Am.copy(n.boundingSphere),Am.applyMatrix4(r),Am.radius+=s,t.ray.intersectsSphere(Am)===!1)return;QE.copy(r).invert(),Cx.copy(t.ray).applyMatrix4(QE);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,f=this.isLineSegments?2:1,p=n.index,g=n.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,b=v-1;x<b;x+=f){let w=p.getX(x),E=p.getX(x+1);if(u.fromBufferAttribute(g,w),c.fromBufferAttribute(g,E),Cx.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(h);S<t.near||S>t.far||e.push({distance:S,point:d.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,b=v-1;x<b;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),Cx.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let E=t.ray.origin.distanceTo(h);E<t.near||E>t.far||e.push({distance:E,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},ZE=new A,JE=new A,ua=class extends Sl{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,n=[];for(let r=0,s=e.count;r<s;r+=2)ZE.fromBufferAttribute(e,r),JE.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+ZE.distanceTo(JE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var qm=class extends en{constructor(t,e,n,r,s,o,a,l,u){super(t,e,n,r,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ze,this.magFilter=s!==void 0?s:Ze,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}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 Di=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/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=[],n,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),r=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),u=n[r]-o,u<0)a=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===o)return r/(s-1);let c=n[r],h=n[r+1]-c,f=(o-c)/h;return(r+f)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),l=e||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,r=[],s=[],o=[],a=new A,l=new se;for(let f=0;f<=t;f++){let p=f/t;r[f]=this.getTangentAt(p,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[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(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Wn(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(e===!0){let f=Math.acos(Wn(s[0].dot(s[t]),-1,1));f/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,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 Di{constructor(t=0,e=0,n=1,r=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=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new B,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);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),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.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}},$x=class extends wl{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Eb(){let i=0,t=0,e=0,n=0;function r(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){r(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+n*a}}}var Em=new A,Px=new Eb,Dx=new Eb,Ix=new Eb,eb=class extends Di{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new A){let n=e,r=this.points,s=r.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=r[(a-1)%s]:(Em.subVectors(r[0],r[1]).add(r[0]),u=Em);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?c=r[(a+2)%s]:(Em.subVectors(r[s-1],r[s-2]).add(r[s-1]),c=Em),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(u.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),Px.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,p,m,g),Dx.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,p,m,g),Ix.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(Px.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),Dx.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),Ix.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(Px.calc(l),Dx.calc(l),Ix.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.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,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.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,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new A().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function $E(i,t,e,n,r){let s=(n-t)*.5,o=(r-e)*.5,a=i*i,l=i*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*i+e}function sk(i,t){let e=1-i;return e*e*t}function ok(i,t){return 2*(1-i)*i*t}function ak(i,t){return i*i*t}function ef(i,t,e,n){return sk(i,t)+ok(i,e)+ak(i,n)}function lk(i,t){let e=1-i;return e*e*e*t}function ck(i,t){let e=1-i;return 3*e*e*i*t}function uk(i,t){return 3*(1-i)*i*i*t}function dk(i,t){return i*i*i*t}function tf(i,t,e,n,r){return lk(i,t)+ck(i,e)+uk(i,n)+dk(i,r)}var Ir=class extends Di{constructor(t=new B,e=new B,n=new B,r=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(tf(t,r.x,s.x,o.x,a.x),tf(t,r.y,s.y,o.y,a.y)),n}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}},Al=class extends Di{constructor(t=new A,e=new A,n=new A,r=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(tf(t,r.x,s.x,o.x,a.x),tf(t,r.y,s.y,o.y,a.y),tf(t,r.z,s.z,o.z,a.z)),n}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}},Or=class extends Di{constructor(t=new B,e=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new B){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}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}},cf=class extends Di{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}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}},yi=class extends Di{constructor(t=new B,e=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(ef(t,r.x,s.x,o.x),ef(t,r.y,s.y,o.y)),n}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}},tb=class extends Di{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(ef(t,r.x,s.x,o.x),ef(t,r.y,s.y,o.y),ef(t,r.z,s.z,o.z)),n}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}},kc=class extends Di{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new B){let n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],u=r[o],c=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return n.set($E(a,l.x,u.x,c.x,d.x),$E(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new B().fromArray(r))}return this}},hk=Object.freeze({__proto__:null,ArcCurve:$x,CatmullRomCurve3:eb,CubicBezierCurve:Ir,CubicBezierCurve3:Al,EllipseCurve:wl,LineCurve:Or,LineCurve3:cf,QuadraticBezierCurve:yi,QuadraticBezierCurve3:tb,SplineCurve:kc}),uf=class extends Di{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 Or(e,t))}getPoint(t,e){let n=t*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,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 n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],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];n&&n.equals(c)||(e.push(c),n=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,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new hk[r.type]().fromJSON(r))}return this}},El=class extends uf{constructor(t){super(),this.type="Path",this.currentPoint=new B,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;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 n=new Or(this.currentPoint.clone(),new B(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){let s=new yi(this.currentPoint.clone(),new B(t,e),new B(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){let a=new Ir(this.currentPoint.clone(),new B(t,e),new B(n,r),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new kc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,r,s,o,a,l),this}absellipse(t,e,n,r,s,o,a,l){let u=new wl(t,e,n,r,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.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}},Uc=class extends Ee{constructor(t=[new B(0,-.5),new B(.5,0),new B(0,.5)],e=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:r},e=Math.floor(e),r=Wn(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new B,f=new A,p=new A,m=new A,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=n+v*c*r,b=Math.sin(x),w=Math.cos(x);for(let E=0;E<=t.length-1;E++){d.x=t[E].x*b,d.y=t[E].y,d.z=t[E].x*w,o.push(d.x,d.y,d.z),h.x=v/e,h.y=E/(t.length-1),a.push(h.x,h.y);let _=l[3*E+0]*b,S=l[3*E+1],T=l[3*E+0]*w;u.push(_,S,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,w=b,E=b+t.length,_=b+t.length+1,S=b+1;s.push(w,E,S),s.push(_,S,E)}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 Uc(t.points,t.segments,t.phiStart,t.phiLength)}};var _l=class extends Ee{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;r=Math.floor(r),s=Math.floor(s);let c=[],d=[],h=[],f=[],p=0,m=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(d,3)),this.setAttribute("normal",new be(h,3)),this.setAttribute("uv",new be(f,2));function v(){let b=new A,w=new A,E=0,_=(e-t)/n;for(let S=0;S<=s;S++){let T=[],M=S/s,C=M*(e-t)+t;for(let D=0;D<=r;D++){let P=D/r,I=P*l+a,L=Math.sin(I),H=Math.cos(I);w.x=C*L,w.y=-M*n+g,w.z=C*H,d.push(w.x,w.y,w.z),b.set(L,_,H).normalize(),h.push(b.x,b.y,b.z),f.push(P,1-M),T.push(p++)}m.push(T)}for(let S=0;S<r;S++)for(let T=0;T<s;T++){let M=m[T][S],C=m[T+1][S],D=m[T+1][S+1],P=m[T][S+1];c.push(M,C,P),c.push(C,D,P),E+=6}u.addGroup(y,E,0),y+=E}function x(b){let w=p,E=new B,_=new A,S=0,T=b===!0?t:e,M=b===!0?1:-1;for(let D=1;D<=r;D++)d.push(0,g*M,0),h.push(0,M,0),f.push(.5,.5),p++;let C=p;for(let D=0;D<=r;D++){let I=D/r*l+a,L=Math.cos(I),H=Math.sin(I);_.x=T*H,_.y=g*M,_.z=T*L,d.push(_.x,_.y,_.z),h.push(0,M,0),E.x=L*.5+.5,E.y=H*.5*M+.5,f.push(E.x,E.y),p++}for(let D=0;D<r;D++){let P=w+D,I=C+D;b===!0?c.push(I,I+1,P):c.push(I+1,I,P),S+=3}u.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new _l(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},zc=class extends _l{constructor(t=1,e=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new zc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Gc=class extends Ee{constructor(t=[],e=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};let s=[],o=[];a(r),u(n),c(),this.setAttribute("position",new be(s,3)),this.setAttribute("normal",new be(s.slice(),3)),this.setAttribute("uv",new be(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,b=new A,w=new A;for(let E=0;E<e.length;E+=3)f(e[E+0],x),f(e[E+1],b),f(e[E+2],w),l(x,b,w,v)}function l(v,x,b,w){let E=w+1,_=[];for(let S=0;S<=E;S++){_[S]=[];let T=v.clone().lerp(b,S/E),M=x.clone().lerp(b,S/E),C=E-S;for(let D=0;D<=C;D++)D===0&&S===E?_[S][D]=T:_[S][D]=T.clone().lerp(M,D/C)}for(let S=0;S<E;S++)for(let T=0;T<2*(E-S)-1;T++){let M=Math.floor(T/2);T%2===0?(h(_[S][M+1]),h(_[S+1][M]),h(_[S][M])):(h(_[S][M+1]),h(_[S+1][M+1]),h(_[S+1][M]))}}function u(v){let x=new A;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(v),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function c(){let v=new A;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 b=g(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(b,1-w)}p(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],w=o[v+4],E=Math.max(x,b,w),_=Math.min(x,b,w);E>.9&&_<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let b=v*3;x.x=t[b+0],x.y=t[b+1],x.z=t[b+2]}function p(){let v=new A,x=new A,b=new A,w=new A,E=new B,_=new B,S=new B;for(let T=0,M=0;T<s.length;T+=9,M+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),E.set(o[M+0],o[M+1]),_.set(o[M+2],o[M+3]),S.set(o[M+4],o[M+5]),w.copy(v).add(x).add(b).divideScalar(3);let C=g(w);m(E,M+0,v,C),m(_,M+2,x,C),m(S,M+4,b,C)}}function m(v,x,b,w){w<0&&v.x===1&&(o[x]=v.x-1),b.x===0&&b.z===0&&(o[x]=w/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 Gc(t.vertices,t.indices,t.radius,t.details)}},Hc=class extends Gc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],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 Hc(t.radius,t.detail)}};var _o=class extends El{constructor(t){super(t),this.uuid=Mi(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].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,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new El().fromJSON(r))}return this}},fk={triangulate:function(i,t,e=2){let n=t&&t.length,r=n?t[0]*e:i.length,s=P_(i,0,r,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=vk(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let p=e;p<r;p+=e)d=i[p],h=i[p+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return df(s,o,e,a,l,f,0),o}};function P_(i,t,e,n,r){let s,o;if(r===Pk(i,t,e,n)>0)for(s=t;s<e;s+=n)o=e_(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=e_(s,i[s],i[s+1],o);return o&&ag(o,o.next)&&(ff(o),o=o.next),o}function Tl(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(ag(e,e.next)||fn(e.prev,e,e.next)===0)){if(ff(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function df(i,t,e,n,r,s,o){if(!i)return;!o&&s&&Ak(i,n,r,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?mk(i,n,r,s):pk(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),ff(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=gk(Tl(i),t,e),df(i,t,e,n,r,s,2)):o===2&&yk(i,t,e,n,r,s):df(Tl(i),t,e,n,r,s,1);break}}}function pk(i){let t=i.prev,e=i,n=i.next;if(fn(t,e,n)>=0)return!1;let r=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=r<s?r<o?r:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=r>s?r>o?r:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=n.next;for(;p!==t;){if(p.x>=c&&p.x<=h&&p.y>=d&&p.y<=f&&Oc(r,a,s,l,o,u,p.x,p.y)&&fn(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function mk(i,t,e,n){let r=i.prev,s=i,o=i.next;if(fn(r,s,o)>=0)return!1;let a=r.x,l=s.x,u=o.x,c=r.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,p=c<d?c<h?c:h:d<h?d:h,m=a>l?a>u?a:u:l>u?l:u,g=c>d?c>h?c:h:d>h?d:h,y=nb(f,p,t,e,n),v=nb(m,g,t,e,n),x=i.prevZ,b=i.nextZ;for(;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Oc(a,c,l,d,u,h,x.x,x.y)&&fn(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Oc(a,c,l,d,u,h,b.x,b.y)&&fn(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Oc(a,c,l,d,u,h,x.x,x.y)&&fn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Oc(a,c,l,d,u,h,b.x,b.y)&&fn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function gk(i,t,e){let n=i;do{let r=n.prev,s=n.next.next;!ag(r,s)&&D_(r,n,n.next,s)&&hf(r,s)&&hf(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),ff(n),ff(n.next),n=i=s),n=n.next}while(n!==i);return Tl(n)}function yk(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Tk(o,a)){let l=I_(o,a);o=Tl(o,o.next),l=Tl(l,l.next),df(o,t,e,n,r,s,0),df(l,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function vk(i,t,e,n){let r=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:i.length,u=P_(i,a,l,n,!1),u===u.next&&(u.steiner=!0),r.push(_k(u));for(r.sort(xk),s=0;s<r.length;s++)e=bk(r[s],e);return e}function xk(i,t){return i.x-t.x}function bk(i,t){let e=Sk(i,t);if(!e)return t;let n=I_(e,i);return Tl(n,n.next),Tl(e,e.next)}function Sk(i,t){let e=t,n=-1/0,r,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,r=e.x<e.next.x?e:e.next,h===s))return r}e=e.next}while(e!==t);if(!r)return null;let a=r,l=r.x,u=r.y,c=1/0,d;e=r;do s>=e.x&&e.x>=l&&s!==e.x&&Oc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),hf(e,i)&&(d<c||d===c&&(e.x>r.x||e.x===r.x&&wk(r,e)))&&(r=e,c=d)),e=e.next;while(e!==a);return r}function wk(i,t){return fn(i.prev,i,t.prev)<0&&fn(t.next,i,i.next)<0}function Ak(i,t,e,n){let r=i;do r.z===0&&(r.z=nb(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Ek(r)}function Ek(i){let t,e,n,r,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,u*=2}while(o>1);return i}function nb(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|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 _k(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 Oc(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function Tk(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Mk(i,t)&&(hf(i,t)&&hf(t,i)&&Ck(i,t)&&(fn(i.prev,i,t.prev)||fn(i,t.prev,t))||ag(i,t)&&fn(i.prev,i,i.next)>0&&fn(t.prev,t,t.next)>0)}function fn(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ag(i,t){return i.x===t.x&&i.y===t.y}function D_(i,t,e,n){let r=Tm(fn(i,t,e)),s=Tm(fn(i,t,n)),o=Tm(fn(e,n,i)),a=Tm(fn(e,n,t));return!!(r!==s&&o!==a||r===0&&_m(i,e,t)||s===0&&_m(i,n,t)||o===0&&_m(e,i,n)||a===0&&_m(e,t,n))}function _m(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 Tm(i){return i>0?1:i<0?-1:0}function Mk(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&&D_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function hf(i,t){return fn(i.prev,i,i.next)<0?fn(i,t,i.next)>=0&&fn(i,i.prev,t)>=0:fn(i,t,i.prev)<0||fn(i,i.next,t)<0}function Ck(i,t){let e=i,n=!1,r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function I_(i,t){let e=new rb(i.i,i.x,i.y),n=new rb(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function e_(i,t,e,n){let r=new rb(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ff(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 rb(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 Pk(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var jc=class{static area(t){let e=t.length,n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return jc.area(t)<0}static triangulateShape(t,e){let n=[],r=[],s=[];t_(t),n_(n,t);let o=t.length;e.forEach(t_);for(let l=0;l<e.length;l++)r.push(o),o+=e[l].length,n_(n,e[l]);let a=fk.triangulate(n,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function t_(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function n_(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var Wc=class extends Gc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=[-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],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Wc(t.radius,t.detail)}};var Ml=class extends Ee{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],d=new A,h=new A,f=[],p=[],m=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,b=0;y==0&&o==0?b=.5/e:y==n&&l==Math.PI&&(b=-.5/e);for(let w=0;w<=e;w++){let E=w/e;d.x=-t*Math.cos(r+E*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(r+E*s)*Math.sin(o+x*a),p.push(d.x,d.y,d.z),h.copy(d).normalize(),m.push(h.x,h.y,h.z),g.push(E+b,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],b=c[y][v],w=c[y+1][v],E=c[y+1][v+1];(y!==0||o>0)&&f.push(x,b,E),(y!==n-1||l<Math.PI)&&f.push(b,w,E)}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 Ml(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var qc=class extends Ee{constructor(t=1,e=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],l=[],u=[],c=[],d=new A,h=new A,f=new A,p=new A,m=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let b=x/n*s*Math.PI*2;v(b,s,o,t,f),v(b+.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 w=0;w<=r;++w){let E=w/r*Math.PI*2,_=-e*Math.cos(E),S=e*Math.sin(E);d.x=f.x+(_*y.x+S*m.x),d.y=f.y+(_*y.y+S*m.y),d.z=f.z+(_*y.z+S*m.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(w/r)}}for(let x=1;x<=n;x++)for(let b=1;b<=r;b++){let w=(r+1)*(x-1)+(b-1),E=(r+1)*x+(b-1),_=(r+1)*x+b,S=(r+1)*(x-1)+b;a.push(w,E,S),a.push(E,_,S)}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,b,w,E,_){let S=Math.cos(x),T=Math.sin(x),M=w/b*x,C=Math.cos(M);_.x=E*(2+C)*.5*S,_.y=E*(2+C)*T*.5,_.z=E*Math.sin(M)*.5}}static fromJSON(t){return new qc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function ia(i,t,e){return O_(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Mm(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 O_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Dk(i){function t(r,s){return i[r]-i[s]}let e=i.length,n=new Array(e);for(let r=0;r!==e;++r)n[r]=r;return n.sort(t),n}function r_(i,t,e){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=e[s]*t;for(let l=0;l!==t;++l)r[o++]=i[a+l]}return r}function R_(i,t,e,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=i[r++];while(s!==void 0)}var Yc=class{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],s=e[n-1];e:{t:{let o;n:{r:if(!(t<r)){for(let a=n+2;;){if(r===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=e[++n],t<r)break t}o=e.length;break n}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=e[--n-1],t>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(r=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r;for(let o=0;o!==r;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},ib=class extends Yc{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Pc,endingEnd:Pc}}intervalChanged_(t,e,n){let r=this.parameterPositions,s=t-2,o=t+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Dc:s=t,a=2*e-n;break;case Lm:s=r.length-2,a=e+r[s]-r[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Dc:o=t,l=2*n-e;break;case Lm:o=1,l=n+r[1]-r[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,p=(n-e)/(r-e),m=p*p,g=m*p,y=-h*g+2*h*m-h*p,v=(1+h)*g+(-1.5-2*h)*m+(-.5+h)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,b=f*g-f*m;for(let w=0;w!==a;++w)s[w]=y*o[c+w]+v*o[u+w]+x*o[l+w]+b*o[d+w];return s}},Ym=class extends Yc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(r-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},sb=class extends Yc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}},Ii=class{constructor(t,e,n,r){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=Mm(e,this.TimeBufferType),this.values=Mm(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Mm(t.times,Array),values:Mm(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new sb(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ym(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ib(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Om:e=this.InterpolantFactoryMethodDiscrete;break;case Rm:e=this.InterpolantFactoryMethodLinear;break;case rx:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="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(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Om;case this.InterpolantFactoryMethodLinear:return Rm;case this.InterpolantFactoryMethodSmooth:return rx}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=ia(n,s,o),this.values=ia(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 n=this.times,r=this.values,s=n.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=n[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(r!==void 0&&O_(r))for(let a=0,l=r.length;a!==l;++a){let u=r[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=ia(this.times),e=ia(this.values),n=this.getValueSize(),r=this.getInterpolation()===rx,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(r)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let p=0;p!==n;++p){let m=e[d+p];if(m!==e[h+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=ia(t,0,o),this.values=ia(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=ia(this.times,0),e=ia(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}};Ii.prototype.TimeBufferType=Float32Array;Ii.prototype.ValueBufferType=Float32Array;Ii.prototype.DefaultInterpolation=Rm;var da=class extends Ii{};da.prototype.ValueTypeName="bool";da.prototype.ValueBufferType=Array;da.prototype.DefaultInterpolation=Om;da.prototype.InterpolantFactoryMethodLinear=void 0;da.prototype.InterpolantFactoryMethodSmooth=void 0;var Xm=class extends Ii{};Xm.prototype.ValueTypeName="color";var Xc=class extends Ii{};Xc.prototype.ValueTypeName="number";var ob=class extends Yc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(r-e),u=t*a;for(let c=u+a;u!==c;u+=4)Ye.slerpFlat(s,0,o,u-a,o,u,l);return s}},Cl=class extends Ii{InterpolantFactoryMethodLinear(t){return new ob(this.times,this.values,this.getValueSize(),t)}};Cl.prototype.ValueTypeName="quaternion";Cl.prototype.DefaultInterpolation=Rm;Cl.prototype.InterpolantFactoryMethodSmooth=void 0;var ha=class extends Ii{};ha.prototype.ValueTypeName="string";ha.prototype.ValueBufferType=Array;ha.prototype.DefaultInterpolation=Om;ha.prototype.InterpolantFactoryMethodLinear=void 0;ha.prototype.InterpolantFactoryMethodSmooth=void 0;var Kc=class extends Ii{};Kc.prototype.ValueTypeName="vector";var Qc=class{constructor(t,e=-1,n,r=xb){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=Mi(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(Ok(n[o]).scale(r));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=n.length;s!==o;++s)e.push(Ii.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(t,e,n,r){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=Dk(l);l=r_(l,1,c),u=r_(u,1,c),!r&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new Xc(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let r={},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 d=c[1],h=r[d];h||(r[d]=h=[]),h.push(u)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(d,h,f,p,m){if(f.length!==0){let g=[],y=[];R_(f,g,y,p),g.length!==0&&m.push(new d(h,g,y))}},r=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let d=0;d<u.length;d++){let h=u[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)f[h[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==h[p].morphTargets.length;++v){let x=h[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}r.push(new Xc(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[d].name+"]";n(Kc,f+".position",h,"pos",r),n(Cl,f+".quaternion",h,"rot",r),n(Kc,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let s=this.tracks[n];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 Ik(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Xc;case"vector":case"vector2":case"vector3":case"vector4":return Kc;case"color":return Xm;case"quaternion":return Cl;case"bool":case"boolean":return da;case"string":return ha}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Ok(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Ik(i.type);if(i.times===void 0){let e=[],n=[];R_(i.keys,e,n,"value"),i.times=e,i.values=n}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var i_={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={}}},pf=class{constructor(t,e,n){let r=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&r.onStart!==void 0&&r.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,r.onProgress!==void 0&&r.onProgress(c,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],p=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}},Rk=new pf,Zc=class{constructor(t){this.manager=t!==void 0?t:Rk,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(r,s){n.load(t,r,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}},vo={},ab=class extends Error{constructor(t,e){super(t),this.response=e}},Jc=class extends Zc{constructor(t){super(t)}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=i_.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(vo[t]!==void 0){vo[t].push({onLoad:e,onProgress:n,onError:r});return}vo[t]=[],vo[t].push({onLoad:e,onProgress:n,onError:r});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=vo[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:b})=>{if(x)y.close();else{m+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let E=0,_=c.length;E<_;E++){let S=c[E];S.onProgress&&S.onProgress(w)}y.enqueue(b),v()}})}}});return new Response(g)}else throw new ab(`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 d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{i_.add(t,u);let c=vo[t];delete vo[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=vo[t];if(c===void 0)throw this.manager.itemError(t),u;delete vo[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];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 fa=class extends mt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Fe(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}},Km=class extends fa{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Fe(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},Ox=new se,s_=new A,o_=new A,mf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new se,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new of,this._frameExtents=new B(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,n=this.matrix;s_.setFromMatrixPosition(t.matrixWorld),e.position.copy(s_),o_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(o_),e.updateMatrixWorld(),Ox.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ox),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ox)}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}},lb=class extends mf{constructor(){super(new An(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=rf*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||r!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=r,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Qm=class extends fa{constructor(t,e,n=0,r=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new lb}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}},a_=new se,Xh=new A,Rx=new A,cb=class extends mf{constructor(){super(new An(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(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 A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Xh.setFromMatrixPosition(t.matrixWorld),n.position.copy(Xh),Rx.copy(n.position),Rx.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Rx),n.updateMatrixWorld(),r.makeTranslation(-Xh.x,-Xh.y,-Xh.z),a_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(a_)}},Zm=class extends fa{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new cb}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}},ub=class extends mf{constructor(){super(new Fc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Jm=class extends fa{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.shadow=new ub}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var db=class extends Ee{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}},$c=class extends Zc{constructor(t){super(t)}load(t,e,n,r){let s=this,o=new Jc(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){r?r(l):console.error(l),s.manager.itemError(t)}},n,r)}parse(t){let e={},n={};function r(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=im(g.type,y),x=new jm(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(n[p]!==void 0)return n[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return n[p]=y,y}let o=t.isInstancedBufferGeometry?new db:new Ee,a=t.data.index;if(a!==void 0){let f=im(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=r(t.data,p.data);m=new bl(g,p.itemSize,p.offset,p.normalized)}else{let g=im(p.type,p.array),y=p.isInstancedBufferAttribute?Wm: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 b=r(t.data,v.data);x=new bl(b,v.itemSize,v.offset,v.normalized)}else{let b=im(v.type,v.array);x=new Ge(b,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 d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,p=d.length;f!==p;++f){let m=d[f];o.addGroup(m.start,m.count,m.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new ln(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var $m=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=l_(),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=l_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function l_(){return(typeof performance>"u"?Date:performance).now()}var hb=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let r,s,o;switch(e){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,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 n=this.buffer,r=this.valueSize,s=t*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,r=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(n,r,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){a.setValue(n,r);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let s=n,o=r;s!==o;++s)e[s]=e[r+s%n];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 n=t;n<e;n++)this.buffer[n]=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 n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,r){Ye.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,s){let o=this._workIndex*s;Ye.multiplyQuaternionsFlat(t,o,t,e,t,n),Ye.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[n+o]*r}}},_b="\\[\\]\\.:\\/",Lk=new RegExp("["+_b+"]","g"),Tb="[^"+_b+"]",Nk="[^"+_b.replace("\\.","")+"]",Bk=/((?:WC+[\/:])*)/.source.replace("WC",Tb),Fk=/(WCOD+)?/.source.replace("WCOD",Nk),Vk=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Tb),kk=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Tb),Uk=new RegExp("^"+Bk+Fk+Vk+kk+"$"),zk=["material","materials","bones","map"],fb=class{constructor(t,e,n){let r=n||Lt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Lt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Lt.parseTrackName(e),this.node=Lt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Lt.Composite(t,e,n):new Lt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Lk,"")}static parseTrackName(t){let e=Uk.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);zk.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=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=n(a.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)t[e++]=n[r]}_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 n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=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,n=e.objectName,r=e.propertyName,s=e.propertyIndex;if(t||(t=Lt.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(n){let u=e.objectIndex;switch(n){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[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}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[r];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" 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(r==="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=r;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}};Lt.Composite=fb;Lt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Lt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Lt.prototype.GetterByBindingType=[Lt.prototype._getValue_direct,Lt.prototype._getValue_array,Lt.prototype._getValue_arrayElement,Lt.prototype._getValue_toArray];Lt.prototype.SetterByBindingTypeAndVersioning=[[Lt.prototype._setValue_direct,Lt.prototype._setValue_direct_setNeedsUpdate,Lt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_array,Lt.prototype._setValue_array_setNeedsUpdate,Lt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_arrayElement,Lt.prototype._setValue_arrayElement_setNeedsUpdate,Lt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_fromArray,Lt.prototype._setValue_fromArray_setNeedsUpdate,Lt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var pb=class{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Pc,endingEnd:Pc};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=vb,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,n){if(t.fadeOut(e),this.fadeIn(e),n){let r=this._clip.duration,s=t._clip.duration,o=s/r,a=r/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}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,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+n,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,n,r){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*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 n3:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case xb:default:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulate(r,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,r=this.time+t,s=this._loopCount,o=n===yf;if(t===0)return s===-1?r:o&&(s&1)===1?e-r:r;if(n===yb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=e)r=e;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction: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)),r>=e||r<0){let a=Math.floor(r/e);r-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,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=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return e-r}return r}_setEndings(t,e,n){let r=this._interpolantSettings;n?(r.endingStart=Dc,r.endingEnd=Dc):(t?r.endingStart=this.zeroSlopeAtStart?Dc:Pc:r.endingStart=Lm,e?r.endingEnd=this.zeroSlopeAtEnd?Dc:Pc:r.endingEnd=Lm)}_scheduleFading(t,e,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}},Gk=new Float32Array(1),eg=class extends Ht{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,s=r.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let d=0;d!==s;++d){let h=r[d],f=h.name,p=c[f];if(p!==void 0)++p.referenceCount,o[d]=p;else{if(p=o[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[d].binding.parsedPath;p=new hb(Lt.create(n,f,m),h.ValueTypeName,h.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,s=this._actionsByClip[r];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--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,n){let r=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=r.length,r.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,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 d=a.actionByRoot,h=(t._localRoot||this._root).uuid;delete d[h],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[e];o===void 0&&(o={},r[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],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[r]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new Ym(new Float32Array(2),new Float32Array(2),1,Gk),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,s=e[r];t.__cacheIndex=r,e[r]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){let r=e||this._root,s=r.uuid,o=typeof t=="string"?Qc.findByName(r,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(n===void 0&&(o!==null?n=o.blendMode:n=xb),l!==void 0){let d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===n)return d;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new pb(this,o,e,n);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let n=e||this._root,r=n.uuid,s=typeof t=="string"?Qc.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,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,n=t.uuid,r=this._actionsByClip,s=r[n];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,d=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,d._cacheIndex=c,e[c]=d,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},oe=class{constructor(t){this.value=t}clone(){return new oe(this.value.clone===void 0?this.value:this.value.clone())}};var eu=class{constructor(t,e,n=0,r=1/0){this.ray=new Ji(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new sf,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,n=[]){return mb(t,this,n,e),n.sort(c_),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)mb(t[r],this,n,e);return n.sort(c_),n}};function c_(i,t){return i.distance-t.distance}function mb(i,t,e,n){if(i.layers.test(t.layers)&&i.raycast(t,e),n===!0){let r=i.children;for(let s=0,o=r.length;s<o;s++)mb(r[s],t,e,!0)}}var gf=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,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,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Wn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var u_=new B,tu=class{constructor(t=new B(1/0,1/0),e=new B(-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,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=u_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),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 u_.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)}},d_=new A,Cm=new A,Xn=class{constructor(t=new A,e=new A){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){d_.subVectors(t,this.start),Cm.subVectors(this.end,this.start);let n=Cm.dot(Cm),s=Cm.dot(d_)/n;return e&&(s=Wn(s,0,1)),s}closestPointToPoint(t,e,n){let r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).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)}},h_=new A,tg=class extends mt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Ee,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;r.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new be(r,3));let s=new Pi({fog:!1,toneMapped:!1});this.cone=new ua(n,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),h_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(h_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var ng=class extends kn{constructor(t,e,n){let r=new Ml(e,4,2),s=new wo({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=t,this.color=n,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 f_=new A,Pm=new A,p_=new A,rg=class extends mt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let r=new Ee;r.setAttribute("position",new be([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Pi({fog:!1,toneMapped:!1});this.lightPlane=new Sl(r,s),this.add(this.lightPlane),r=new Ee,r.setAttribute("position",new be([0,0,0,0,0,1],3)),this.targetLine=new Sl(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),f_.setFromMatrixPosition(this.light.matrixWorld),Pm.setFromMatrixPosition(this.light.target.matrixWorld),p_.subVectors(Pm,f_),this.lightPlane.lookAt(Pm),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(Pm),this.targetLine.scale.z=p_.length()}},Dm=new A,yn=new $i,pa=class extends ua{constructor(t){let e=new Ee,n=new Pi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],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){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}e.setAttribute("position",new be(r,3)),e.setAttribute("color",new be(s,3)),super(e,n),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 Fe(16755200),c=new Fe(16711680),d=new Fe(43775),h=new Fe(16777215),f=new Fe(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,r,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,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,r=1;yn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),wn("c",e,t,yn,0,0,-1),wn("t",e,t,yn,0,0,1),wn("n1",e,t,yn,-n,-r,-1),wn("n2",e,t,yn,n,-r,-1),wn("n3",e,t,yn,-n,r,-1),wn("n4",e,t,yn,n,r,-1),wn("f1",e,t,yn,-n,-r,1),wn("f2",e,t,yn,n,-r,1),wn("f3",e,t,yn,-n,r,1),wn("f4",e,t,yn,n,r,1),wn("u1",e,t,yn,n*.7,r*1.1,-1),wn("u2",e,t,yn,-n*.7,r*1.1,-1),wn("u3",e,t,yn,0,r*2,-1),wn("cf1",e,t,yn,-n,0,1),wn("cf2",e,t,yn,n,0,1),wn("cf3",e,t,yn,0,-r,1),wn("cf4",e,t,yn,0,r,1),wn("cn1",e,t,yn,-n,0,-1),wn("cn2",e,t,yn,n,0,-1),wn("cn3",e,t,yn,0,-r,-1),wn("cn4",e,t,yn,0,r,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function wn(i,t,e,n,r,s,o){Dm.set(r,s,o).unproject(n);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],Dm.x,Dm.y,Dm.z)}}var ma=class extends ua{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ee;s.setIndex(new Ge(n,1)),s.setAttribute("position",new be(r,3)),super(s,new Pi({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 ig=class extends ua{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ee;r.setAttribute("position",new be(e,3)),r.setAttribute("color",new be(n,3));let s=new Pi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(t,e,n){let r=new Fe,s=this.geometry.attributes.color.array;return r.set(t),r.toArray(s,0),r.toArray(s,3),r.set(e),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:To}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=To);var iu=".",vf=Symbol("target"),Mb=Symbol("unsubscribe");function xf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function L_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var xi=Array.isArray;function Pl(i){return typeof i=="symbol"}var Hk={after:(i,t)=>xi(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>xi(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=iu),Pl(t)?i+t.toString():i+t):i,initial:i=>{if(xi(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(xi(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(xi(i))for(let e of i)t(e);else if(i!==""){let e=0,n=i.indexOf(iu);if(n===-1)t(i);else for(;e<i.length;)n===-1&&(n=i.length),t(i.slice(e,n)),e=n+1,n=i.indexOf(iu,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},zr=Hk;function Cb(i){return typeof i=="object"&&typeof i.next=="function"}function Pb(i,t,e,n,r){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=r(o.value[0],t,o.value[0],n),o.value[1]=r(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[vf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=r(a.value,t,o.next().value,n)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=r(o.value,t,o.value,n)),o};return i}function lg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Pl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var bf=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(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),r=n[e];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(t,e),n[e]=r),r}getProxy(t,e,n,r){if(this.isUnsubscribed)return t;let s=t[r],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,n):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,zr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,r,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,r):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(t);r&&(delete r[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let r=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&r!==void 0&&Object.is(t.value,r.value)&&(t.writable||!1)===(r.writable||!1)&&(t.enumerable||!1)===(r.enumerable||!1)&&(t.configurable||!1)===(r.configurable||!1)&&t.get===r.get&&t.set===r.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function su(i){return toString.call(i)==="[object Object]"}function ou(){return!0}function ga(i,t){return i.length!==t.length||i.some((e,n)=>t[n]!==e)}var cg=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var jk=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Db={push:ou,pop:ou,shift:ou,unshift:ou,copyWithin:ga,reverse:ga,sort:ga,splice:ga,flat:ga,fill:ga},N_=new Set([...cg,...jk,...Object.keys(Db)]);function au(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var Ib=["keys","values","entries"],Ob=new Set(["has","toString"]),Rb={add:au,clear:au,delete:au,forEach:au},B_=new Set([...Ob,...Object.keys(Rb),...Ib]);function lu(i,t){if(i.size!==t.size)return!0;let e;for(let[n,r]of i)if(e=t.get(n),e!==r||e===void 0&&!t.has(n))return!0;return!1}var Wk=new Set([...Ob,"get"]),Lb={set:lu,clear:lu,delete:lu,forEach:lu},F_=new Set([...Wk,...Object.keys(Lb),...Ib]);var ar=class{constructor(t,e,n,r){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return cg.has(t)}_shallowClone(t){let e=t;if(su(t))e={...t};else if(xi(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,r]of t.entries())e.set(n,this._shallowClone(r))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,r){return t?(xi(r)?this._onIsChanged=Db[e]:r instanceof Set?this._onIsChanged=Rb[e]:r instanceof Map&&(this._onIsChanged=Lb[e]),r):n}update(t,e,n){let r=zr.after(t,this._path);if(e!=="length"){let s=this.clone;zr.walk(r,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:r,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],zr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var cu=class extends ar{static isHandledMethod(t){return N_.has(t)}};var Sf=class extends ar{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var uu=class extends ar{static isHandledMethod(t){return B_.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 du=class extends ar{static isHandledMethod(t){return F_.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var wf=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._arg1=n[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 Af=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._weakKey=n[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 ts=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return su(t)||xi(t)||xf(t)}static isHandledMethod(t,e){return su(t)?ar.isHandledMethod(e):xi(t)?cu.isHandledMethod(e):t instanceof Set?uu.isHandledMethod(e):t instanceof Map?du.isHandledMethod(e):xf(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let r=ar;xi(t)?r=cu:t instanceof Date?r=Sf:t instanceof Set?r=uu:t instanceof Map?r=du:t instanceof WeakSet?r=wf:t instanceof WeakMap&&(r=Af),this._stack.push(new r(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:r}=t,s=ts.isHandledMethod(n,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var qk={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Nb=(i,t,e={})=>{e={...qk,...e};let n=Symbol("ProxyTarget"),{equals:r,isShallow:s,ignoreDetached:o,details:a}=e,l=new bf(r),u=typeof e.onValidate=="function",c=new ts(u),d=(v,x,b,w,E)=>!u||c.isCloning||e.onValidate(zr.concat(l.getPath(v),x),b,w,E)===!0,h=(v,x,b,w)=>{!lg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,b,w)},f=(v,x,b,w,E)=>{c.isCloning?c.update(v,x,w):t(zr.concat(v,x),b,w,E)},p=v=>v&&(v[n]||v),m=(v,x,b,w)=>L_(v)||b==="constructor"||s&&!ts.isHandledMethod(x,b)||lg(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,zr.concat(w,b),g,n)),g={get(v,x,b){if(Pl(x)){if(x===n||x===vf)return v;if(x===Mb&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=xf(v)?Reflect.get(v,x):Reflect.get(v,x,b);return m(w,v,x)},set(v,x,b,w){b=p(b);let E=v[n]||v,_=E[x];if(r(_,b)&&x in v)return!0;let S=d(v,x,b,_);return S&&l.setProperty(E,x,b,w,_)?(h(v,x,v[x],_),!0):!S},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let w=v[x];d(v,x,b.value,w)&&l.defineProperty(v,x,b,w)&&h(v,x,b.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),w=d(v,x,void 0,b);return w&&l.deleteProperty(v,x,b)?(h(v,x,void 0,b),!0):!w},apply(v,x,b){let w=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,b);if((a===!1||a!==!0&&!a.includes(v.name))&&ts.isHandledType(w)){let E=zr.initial(l.getPath(v)),_=ts.isHandledMethod(w,v.name);c.start(w,E,b);let S=Reflect.apply(v,c.preferredThisArg(v,x,w),_?b.map(C=>p(C)):b),T=c.isChanged(w,r),M=c.stop();if(ts.isHandledType(S)&&_&&(x instanceof Map&&v.name==="get"&&(E=zr.concat(E,b[0])),S=l.getProxy(S,E,g)),T){let C={name:v.name,args:b,result:S},D=c.isCloning?zr.initial(E):E,P=c.isCloning?zr.last(E):"";d(zr.get(i,D),P,w,M,C)?f(D,P,w,M,C):c.undo(w)}return(x instanceof Map||x instanceof Set)&&Cb(S)?Pb(S,v,x,E,m):S}return Reflect.apply(v,x,b)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};Nb.target=i=>i&&i[vf]||i;Nb.unsubscribe=i=>i[Mb]||i;var Bb=Nb;var Yk=typeof global=="object"&&global&&global.Object===Object&&global,ug=Yk;var Xk=typeof self=="object"&&self&&self.Object===Object&&self,Kk=ug||Xk||Function("return this")(),vn=Kk;var Qk=vn.Symbol,lr=Qk;var V_=Object.prototype,Zk=V_.hasOwnProperty,Jk=V_.toString,Ef=lr?lr.toStringTag:void 0;function $k(i){var t=Zk.call(i,Ef),e=i[Ef];try{i[Ef]=void 0;var n=!0}catch{}var r=Jk.call(i);return n&&(t?i[Ef]=e:delete i[Ef]),r}var k_=$k;var eU=Object.prototype,tU=eU.toString;function nU(i){return tU.call(i)}var U_=nU;var rU="[object Null]",iU="[object Undefined]",z_=lr?lr.toStringTag:void 0;function sU(i){return i==null?i===void 0?iU:rU:z_&&z_ in Object(i)?k_(i):U_(i)}var bi=sU;function oU(i){return i!=null&&typeof i=="object"}var Er=oU;var aU="[object Symbol]";function lU(i){return typeof i=="symbol"||Er(i)&&bi(i)==aU}var ya=lU;function cU(i,t){for(var e=-1,n=i==null?0:i.length,r=Array(n);++e<n;)r[e]=t(i[e],e,i);return r}var dg=cU;var uU=Array.isArray,Kn=uU;var dU=1/0,G_=lr?lr.prototype:void 0,H_=G_?G_.toString:void 0;function j_(i){if(typeof i=="string")return i;if(Kn(i))return dg(i,j_)+"";if(ya(i))return H_?H_.call(i):"";var t=i+"";return t=="0"&&1/i==-dU?"-0":t}var W_=j_;var hU=/\s/;function fU(i){for(var t=i.length;t--&&hU.test(i.charAt(t)););return t}var q_=fU;var pU=/^\s+/;function mU(i){return i&&i.slice(0,q_(i)+1).replace(pU,"")}var Y_=mU;function gU(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var zn=gU;var X_=0/0,yU=/^[-+]0x[0-9a-f]+$/i,vU=/^0b[01]+$/i,xU=/^0o[0-7]+$/i,bU=parseInt;function SU(i){if(typeof i=="number")return i;if(ya(i))return X_;if(zn(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=zn(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Y_(i);var e=vU.test(i);return e||xU.test(i)?bU(i.slice(2),e?2:8):yU.test(i)?X_:+i}var Fb=SU;function wU(i){return i}var K_=wU;var AU="[object AsyncFunction]",EU="[object Function]",_U="[object GeneratorFunction]",TU="[object Proxy]";function MU(i){if(!zn(i))return!1;var t=bi(i);return t==EU||t==_U||t==AU||t==TU}var hg=MU;var CU=vn["__core-js_shared__"],fg=CU;var Q_=function(){var i=/[^.]+$/.exec(fg&&fg.keys&&fg.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function PU(i){return!!Q_&&Q_ in i}var Z_=PU;var DU=Function.prototype,IU=DU.toString;function OU(i){if(i!=null){try{return IU.call(i)}catch{}try{return i+""}catch{}}return""}var Mo=OU;var RU=/[\\^$.*+?()[\]{}|]/g,LU=/^\[object .+?Constructor\]$/,NU=Function.prototype,BU=Object.prototype,FU=NU.toString,VU=BU.hasOwnProperty,kU=RegExp("^"+FU.call(VU).replace(RU,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function UU(i){if(!zn(i)||Z_(i))return!1;var t=hg(i)?kU:LU;return t.test(Mo(i))}var J_=UU;function zU(i,t){return i?.[t]}var $_=zU;function GU(i,t){var e=$_(i,t);return J_(e)?e:void 0}var Kr=GU;var HU=Kr(vn,"WeakMap"),pg=HU;var eT=Object.create,jU=function(){function i(){}return function(t){if(!zn(t))return{};if(eT)return eT(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),tT=jU;function WU(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 nT=WU;function qU(i,t){var e=-1,n=i.length;for(t||(t=Array(n));++e<n;)t[e]=i[e];return t}var rT=qU;var YU=800,XU=16,KU=Date.now;function QU(i){var t=0,e=0;return function(){var n=KU(),r=XU-(n-e);if(e=n,r>0){if(++t>=YU)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var iT=QU;function ZU(i){return function(){return i}}var sT=ZU;var JU=function(){try{var i=Kr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),hu=JU;var $U=hu?function(i,t){return hu(i,"toString",{configurable:!0,enumerable:!1,value:sT(t),writable:!0})}:K_,oT=$U;var ez=iT(oT),aT=ez;function tz(i,t){for(var e=-1,n=i==null?0:i.length;++e<n&&t(i[e],e,i)!==!1;);return i}var lT=tz;var nz=9007199254740991,rz=/^(?:0|[1-9]\d*)$/;function iz(i,t){var e=typeof i;return t=t??nz,!!t&&(e=="number"||e!="symbol"&&rz.test(i))&&i>-1&&i%1==0&&i<t}var fu=iz;function sz(i,t,e){t=="__proto__"&&hu?hu(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var mg=sz;function oz(i,t){return i===t||i!==i&&t!==t}var pu=oz;var az=Object.prototype,lz=az.hasOwnProperty;function cz(i,t,e){var n=i[t];(!(lz.call(i,t)&&pu(n,e))||e===void 0&&!(t in i))&&mg(i,t,e)}var mu=cz;function uz(i,t,e,n){var r=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),r?mg(e,a,l):mu(e,a,l)}return e}var Cs=uz;var cT=Math.max;function dz(i,t,e){return t=cT(t===void 0?i.length-1:t,0),function(){for(var n=arguments,r=-1,s=cT(n.length-t,0),o=Array(s);++r<s;)o[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=e(o),nT(i,this,a)}}var uT=dz;var hz=9007199254740991;function fz(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=hz}var gu=fz;function pz(i){return i!=null&&gu(i.length)&&!hg(i)}var gg=pz;var mz=Object.prototype;function gz(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||mz;return i===e}var yu=gz;function yz(i,t){for(var e=-1,n=Array(i);++e<i;)n[e]=t(e);return n}var dT=yz;var vz="[object Arguments]";function xz(i){return Er(i)&&bi(i)==vz}var Vb=xz;var hT=Object.prototype,bz=hT.hasOwnProperty,Sz=hT.propertyIsEnumerable,wz=Vb(function(){return arguments}())?Vb:function(i){return Er(i)&&bz.call(i,"callee")&&!Sz.call(i,"callee")},vu=wz;function Az(){return!1}var fT=Az;var gT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pT=gT&&typeof module=="object"&&module&&!module.nodeType&&module,Ez=pT&&pT.exports===gT,mT=Ez?vn.Buffer:void 0,_z=mT?mT.isBuffer:void 0,Tz=_z||fT,Dl=Tz;var Mz="[object Arguments]",Cz="[object Array]",Pz="[object Boolean]",Dz="[object Date]",Iz="[object Error]",Oz="[object Function]",Rz="[object Map]",Lz="[object Number]",Nz="[object Object]",Bz="[object RegExp]",Fz="[object Set]",Vz="[object String]",kz="[object WeakMap]",Uz="[object ArrayBuffer]",zz="[object DataView]",Gz="[object Float32Array]",Hz="[object Float64Array]",jz="[object Int8Array]",Wz="[object Int16Array]",qz="[object Int32Array]",Yz="[object Uint8Array]",Xz="[object Uint8ClampedArray]",Kz="[object Uint16Array]",Qz="[object Uint32Array]",rn={};rn[Gz]=rn[Hz]=rn[jz]=rn[Wz]=rn[qz]=rn[Yz]=rn[Xz]=rn[Kz]=rn[Qz]=!0;rn[Mz]=rn[Cz]=rn[Uz]=rn[Pz]=rn[zz]=rn[Dz]=rn[Iz]=rn[Oz]=rn[Rz]=rn[Lz]=rn[Nz]=rn[Bz]=rn[Fz]=rn[Vz]=rn[kz]=!1;function Zz(i){return Er(i)&&gu(i.length)&&!!rn[bi(i)]}var yT=Zz;function Jz(i){return function(t){return i(t)}}var xu=Jz;var vT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_f=vT&&typeof module=="object"&&module&&!module.nodeType&&module,$z=_f&&_f.exports===vT,kb=$z&&ug.process,eG=function(){try{var i=_f&&_f.require&&_f.require("util").types;return i||kb&&kb.binding&&kb.binding("util")}catch{}}(),Co=eG;var xT=Co&&Co.isTypedArray,tG=xT?xu(xT):yT,yg=tG;var nG=Object.prototype,rG=nG.hasOwnProperty;function iG(i,t){var e=Kn(i),n=!e&&vu(i),r=!e&&!n&&Dl(i),s=!e&&!n&&!r&&yg(i),o=e||n||r||s,a=o?dT(i.length,String):[],l=a.length;for(var u in i)(t||rG.call(i,u))&&!(o&&(u=="length"||r&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||fu(u,l)))&&a.push(u);return a}var vg=iG;function sG(i,t){return function(e){return i(t(e))}}var xg=sG;var oG=xg(Object.keys,Object),bT=oG;var aG=Object.prototype,lG=aG.hasOwnProperty;function cG(i){if(!yu(i))return bT(i);var t=[];for(var e in Object(i))lG.call(i,e)&&e!="constructor"&&t.push(e);return t}var ST=cG;function uG(i){return gg(i)?vg(i):ST(i)}var bu=uG;function dG(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var wT=dG;var hG=Object.prototype,fG=hG.hasOwnProperty;function pG(i){if(!zn(i))return wT(i);var t=yu(i),e=[];for(var n in i)n=="constructor"&&(t||!fG.call(i,n))||e.push(n);return e}var AT=pG;function mG(i){return gg(i)?vg(i,!0):AT(i)}var Su=mG;var gG=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yG=/^\w*$/;function vG(i,t){if(Kn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ya(i)?!0:yG.test(i)||!gG.test(i)||t!=null&&i in Object(t)}var ET=vG;var xG=Kr(Object,"create"),Po=xG;function bG(){this.__data__=Po?Po(null):{},this.size=0}var _T=bG;function SG(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var TT=SG;var wG="__lodash_hash_undefined__",AG=Object.prototype,EG=AG.hasOwnProperty;function _G(i){var t=this.__data__;if(Po){var e=t[i];return e===wG?void 0:e}return EG.call(t,i)?t[i]:void 0}var MT=_G;var TG=Object.prototype,MG=TG.hasOwnProperty;function CG(i){var t=this.__data__;return Po?t[i]!==void 0:MG.call(t,i)}var CT=CG;var PG="__lodash_hash_undefined__";function DG(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Po&&t===void 0?PG:t,this}var PT=DG;function wu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}wu.prototype.clear=_T;wu.prototype.delete=TT;wu.prototype.get=MT;wu.prototype.has=CT;wu.prototype.set=PT;var Ub=wu;function IG(){this.__data__=[],this.size=0}var DT=IG;function OG(i,t){for(var e=i.length;e--;)if(pu(i[e][0],t))return e;return-1}var va=OG;var RG=Array.prototype,LG=RG.splice;function NG(i){var t=this.__data__,e=va(t,i);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():LG.call(t,e,1),--this.size,!0}var IT=NG;function BG(i){var t=this.__data__,e=va(t,i);return e<0?void 0:t[e][1]}var OT=BG;function FG(i){return va(this.__data__,i)>-1}var RT=FG;function VG(i,t){var e=this.__data__,n=va(e,i);return n<0?(++this.size,e.push([i,t])):e[n][1]=t,this}var LT=VG;function Au(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}Au.prototype.clear=DT;Au.prototype.delete=IT;Au.prototype.get=OT;Au.prototype.has=RT;Au.prototype.set=LT;var xa=Au;var kG=Kr(vn,"Map"),ba=kG;function UG(){this.size=0,this.__data__={hash:new Ub,map:new(ba||xa),string:new Ub}}var NT=UG;function zG(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var BT=zG;function GG(i,t){var e=i.__data__;return BT(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Sa=GG;function HG(i){var t=Sa(this,i).delete(i);return this.size-=t?1:0,t}var FT=HG;function jG(i){return Sa(this,i).get(i)}var VT=jG;function WG(i){return Sa(this,i).has(i)}var kT=WG;function qG(i,t){var e=Sa(this,i),n=e.size;return e.set(i,t),this.size+=e.size==n?0:1,this}var UT=qG;function Eu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}Eu.prototype.clear=NT;Eu.prototype.delete=FT;Eu.prototype.get=VT;Eu.prototype.has=kT;Eu.prototype.set=UT;var Il=Eu;var YG="Expected a function";function zb(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(YG);var e=function(){var n=arguments,r=t?t.apply(this,n):n[0],s=e.cache;if(s.has(r))return s.get(r);var o=i.apply(this,n);return e.cache=s.set(r,o)||s,o};return e.cache=new(zb.Cache||Il),e}zb.Cache=Il;var zT=zb;var XG=500;function KG(i){var t=zT(i,function(n){return e.size===XG&&e.clear(),n}),e=t.cache;return t}var GT=KG;var QG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ZG=/\\(\\)?/g,JG=GT(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(QG,function(e,n,r,s){t.push(r?s.replace(ZG,"$1"):n||e)}),t}),HT=JG;function $G(i){return i==null?"":W_(i)}var jT=$G;function e4(i,t){return Kn(i)?i:ET(i,t)?[i]:HT(jT(i))}var Oi=e4;var t4=1/0;function n4(i){if(typeof i=="string"||ya(i))return i;var t=i+"";return t=="0"&&1/i==-t4?"-0":t}var wa=n4;function r4(i,t){t=Oi(t,i);for(var e=0,n=t.length;i!=null&&e<n;)i=i[wa(t[e++])];return e&&e==n?i:void 0}var bg=r4;function i4(i,t){for(var e=-1,n=t.length,r=i.length;++e<n;)i[r+e]=t[e];return i}var _u=i4;var WT=lr?lr.isConcatSpreadable:void 0;function s4(i){return Kn(i)||vu(i)||!!(WT&&i&&i[WT])}var qT=s4;function YT(i,t,e,n,r){var s=-1,o=i.length;for(e||(e=qT),r||(r=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?YT(a,t-1,e,n,r):_u(r,a):n||(r[r.length]=a)}return r}var XT=YT;function o4(i){var t=i==null?0:i.length;return t?XT(i,1):[]}var KT=o4;function a4(i){return aT(uT(i,void 0,KT),i+"")}var Sg=a4;var l4=xg(Object.getPrototypeOf,Object),Tu=l4;var c4="[object Object]",u4=Function.prototype,d4=Object.prototype,QT=u4.toString,h4=d4.hasOwnProperty,f4=QT.call(Object);function p4(i){if(!Er(i)||bi(i)!=c4)return!1;var t=Tu(i);if(t===null)return!0;var e=h4.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&QT.call(e)==f4}var ZT=p4;function m4(i,t,e){var n=-1,r=i.length;t<0&&(t=-t>r?0:r+t),e=e>r?r:e,e<0&&(e+=r),r=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(r);++n<r;)s[n]=i[n+t];return s}var JT=m4;function g4(){this.__data__=new xa,this.size=0}var $T=g4;function y4(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var eM=y4;function v4(i){return this.__data__.get(i)}var tM=v4;function x4(i){return this.__data__.has(i)}var nM=x4;var b4=200;function S4(i,t){var e=this.__data__;if(e instanceof xa){var n=e.__data__;if(!ba||n.length<b4-1)return n.push([i,t]),this.size=++e.size,this;e=this.__data__=new Il(n)}return e.set(i,t),this.size=e.size,this}var rM=S4;function Mu(i){var t=this.__data__=new xa(i);this.size=t.size}Mu.prototype.clear=$T;Mu.prototype.delete=eM;Mu.prototype.get=tM;Mu.prototype.has=nM;Mu.prototype.set=rM;var Cu=Mu;function w4(i,t){return i&&Cs(t,bu(t),i)}var iM=w4;function A4(i,t){return i&&Cs(t,Su(t),i)}var sM=A4;var cM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,oM=cM&&typeof module=="object"&&module&&!module.nodeType&&module,E4=oM&&oM.exports===cM,aM=E4?vn.Buffer:void 0,lM=aM?aM.allocUnsafe:void 0;function _4(i,t){if(t)return i.slice();var e=i.length,n=lM?lM(e):new i.constructor(e);return i.copy(n),n}var uM=_4;function T4(i,t){for(var e=-1,n=i==null?0:i.length,r=0,s=[];++e<n;){var o=i[e];t(o,e,i)&&(s[r++]=o)}return s}var dM=T4;function M4(){return[]}var wg=M4;var C4=Object.prototype,P4=C4.propertyIsEnumerable,hM=Object.getOwnPropertySymbols,D4=hM?function(i){return i==null?[]:(i=Object(i),dM(hM(i),function(t){return P4.call(i,t)}))}:wg,Pu=D4;function I4(i,t){return Cs(i,Pu(i),t)}var fM=I4;var O4=Object.getOwnPropertySymbols,R4=O4?function(i){for(var t=[];i;)_u(t,Pu(i)),i=Tu(i);return t}:wg,Ag=R4;function L4(i,t){return Cs(i,Ag(i),t)}var pM=L4;function N4(i,t,e){var n=t(i);return Kn(i)?n:_u(n,e(i))}var Eg=N4;function B4(i){return Eg(i,bu,Pu)}var Tf=B4;function F4(i){return Eg(i,Su,Ag)}var _g=F4;var V4=Kr(vn,"DataView"),Tg=V4;var k4=Kr(vn,"Promise"),Mg=k4;var U4=Kr(vn,"Set"),Cg=U4;var mM="[object Map]",z4="[object Object]",gM="[object Promise]",yM="[object Set]",vM="[object WeakMap]",xM="[object DataView]",G4=Mo(Tg),H4=Mo(ba),j4=Mo(Mg),W4=Mo(Cg),q4=Mo(pg),Ol=bi;(Tg&&Ol(new Tg(new ArrayBuffer(1)))!=xM||ba&&Ol(new ba)!=mM||Mg&&Ol(Mg.resolve())!=gM||Cg&&Ol(new Cg)!=yM||pg&&Ol(new pg)!=vM)&&(Ol=function(i){var t=bi(i),e=t==z4?i.constructor:void 0,n=e?Mo(e):"";if(n)switch(n){case G4:return xM;case H4:return mM;case j4:return gM;case W4:return yM;case q4:return vM}return t});var Do=Ol;var Y4=Object.prototype,X4=Y4.hasOwnProperty;function K4(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&X4.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var bM=K4;var Q4=vn.Uint8Array,Du=Q4;function Z4(i){var t=new i.constructor(i.byteLength);return new Du(t).set(new Du(i)),t}var Iu=Z4;function J4(i,t){var e=t?Iu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var SM=J4;var $4=/\w*$/;function eH(i){var t=new i.constructor(i.source,$4.exec(i));return t.lastIndex=i.lastIndex,t}var wM=eH;var AM=lr?lr.prototype:void 0,EM=AM?AM.valueOf:void 0;function tH(i){return EM?Object(EM.call(i)):{}}var _M=tH;function nH(i,t){var e=t?Iu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var TM=nH;var rH="[object Boolean]",iH="[object Date]",sH="[object Map]",oH="[object Number]",aH="[object RegExp]",lH="[object Set]",cH="[object String]",uH="[object Symbol]",dH="[object ArrayBuffer]",hH="[object DataView]",fH="[object Float32Array]",pH="[object Float64Array]",mH="[object Int8Array]",gH="[object Int16Array]",yH="[object Int32Array]",vH="[object Uint8Array]",xH="[object Uint8ClampedArray]",bH="[object Uint16Array]",SH="[object Uint32Array]";function wH(i,t,e){var n=i.constructor;switch(t){case dH:return Iu(i);case rH:case iH:return new n(+i);case hH:return SM(i,e);case fH:case pH:case mH:case gH:case yH:case vH:case xH:case bH:case SH:return TM(i,e);case sH:return new n;case oH:case cH:return new n(i);case aH:return wM(i);case lH:return new n;case uH:return _M(i)}}var MM=wH;function AH(i){return typeof i.constructor=="function"&&!yu(i)?tT(Tu(i)):{}}var CM=AH;var EH="[object Map]";function _H(i){return Er(i)&&Do(i)==EH}var PM=_H;var DM=Co&&Co.isMap,TH=DM?xu(DM):PM,IM=TH;var MH="[object Set]";function CH(i){return Er(i)&&Do(i)==MH}var OM=CH;var RM=Co&&Co.isSet,PH=RM?xu(RM):OM,LM=PH;var DH=1,IH=2,OH=4,NM="[object Arguments]",RH="[object Array]",LH="[object Boolean]",NH="[object Date]",BH="[object Error]",BM="[object Function]",FH="[object GeneratorFunction]",VH="[object Map]",kH="[object Number]",FM="[object Object]",UH="[object RegExp]",zH="[object Set]",GH="[object String]",HH="[object Symbol]",jH="[object WeakMap]",WH="[object ArrayBuffer]",qH="[object DataView]",YH="[object Float32Array]",XH="[object Float64Array]",KH="[object Int8Array]",QH="[object Int16Array]",ZH="[object Int32Array]",JH="[object Uint8Array]",$H="[object Uint8ClampedArray]",e5="[object Uint16Array]",t5="[object Uint32Array]",tn={};tn[NM]=tn[RH]=tn[WH]=tn[qH]=tn[LH]=tn[NH]=tn[YH]=tn[XH]=tn[KH]=tn[QH]=tn[ZH]=tn[VH]=tn[kH]=tn[FM]=tn[UH]=tn[zH]=tn[GH]=tn[HH]=tn[JH]=tn[$H]=tn[e5]=tn[t5]=!0;tn[BH]=tn[BM]=tn[jH]=!1;function Pg(i,t,e,n,r,s){var o,a=t&DH,l=t&IH,u=t&OH;if(e&&(o=r?e(i,n,r,s):e(i)),o!==void 0)return o;if(!zn(i))return i;var c=Kn(i);if(c){if(o=bM(i),!a)return rT(i,o)}else{var d=Do(i),h=d==BM||d==FH;if(Dl(i))return uM(i,a);if(d==FM||d==NM||h&&!r){if(o=l||h?{}:CM(i),!a)return l?pM(i,sM(o,i)):fM(i,iM(o,i))}else{if(!tn[d])return r?i:{};o=MM(i,d,a)}}s||(s=new Cu);var f=s.get(i);if(f)return f;s.set(i,o),LM(i)?i.forEach(function(g){o.add(Pg(g,t,e,g,i,s))}):IM(i)&&i.forEach(function(g,y){o.set(y,Pg(g,t,e,y,i,s))});var p=u?l?_g:Tf:l?Su:bu,m=c?void 0:p(i);return lT(m||i,function(g,y){m&&(y=g,g=i[y]),mu(o,y,Pg(g,t,e,y,i,s))}),o}var Dg=Pg;var n5=1,r5=4;function i5(i){return Dg(i,n5|r5)}var Io=i5;var s5="__lodash_hash_undefined__";function o5(i){return this.__data__.set(i,s5),this}var VM=o5;function a5(i){return this.__data__.has(i)}var kM=a5;function Ig(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Il;++t<e;)this.add(i[t])}Ig.prototype.add=Ig.prototype.push=VM;Ig.prototype.has=kM;var UM=Ig;function l5(i,t){for(var e=-1,n=i==null?0:i.length;++e<n;)if(t(i[e],e,i))return!0;return!1}var zM=l5;function c5(i,t){return i.has(t)}var GM=c5;var u5=1,d5=2;function h5(i,t,e,n,r,s){var o=e&u5,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 d=-1,h=!0,f=e&d5?new UM:void 0;for(s.set(i,t),s.set(t,i);++d<a;){var p=i[d],m=t[d];if(n)var g=o?n(m,p,d,t,i,s):n(p,m,d,i,t,s);if(g!==void 0){if(g)continue;h=!1;break}if(f){if(!zM(t,function(y,v){if(!GM(f,v)&&(p===y||r(p,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(p===m||r(p,m,e,n,s))){h=!1;break}}return s.delete(i),s.delete(t),h}var Og=h5;function f5(i){var t=-1,e=Array(i.size);return i.forEach(function(n,r){e[++t]=[r,n]}),e}var HM=f5;function p5(i){var t=-1,e=Array(i.size);return i.forEach(function(n){e[++t]=n}),e}var jM=p5;var m5=1,g5=2,y5="[object Boolean]",v5="[object Date]",x5="[object Error]",b5="[object Map]",S5="[object Number]",w5="[object RegExp]",A5="[object Set]",E5="[object String]",_5="[object Symbol]",T5="[object ArrayBuffer]",M5="[object DataView]",WM=lr?lr.prototype:void 0,Gb=WM?WM.valueOf:void 0;function C5(i,t,e,n,r,s,o){switch(e){case M5:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case T5:return!(i.byteLength!=t.byteLength||!s(new Du(i),new Du(t)));case y5:case v5:case S5:return pu(+i,+t);case x5:return i.name==t.name&&i.message==t.message;case w5:case E5:return i==t+"";case b5:var a=HM;case A5:var l=n&m5;if(a||(a=jM),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;n|=g5,o.set(i,t);var c=Og(a(i),a(t),n,r,s,o);return o.delete(i),c;case _5:if(Gb)return Gb.call(i)==Gb.call(t)}return!1}var qM=C5;var P5=1,D5=Object.prototype,I5=D5.hasOwnProperty;function O5(i,t,e,n,r,s){var o=e&P5,a=Tf(i),l=a.length,u=Tf(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:I5.call(t,h)))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;++d<l;){h=a[d];var y=i[h],v=t[h];if(n)var x=o?n(v,y,h,t,i,s):n(y,v,h,i,t,s);if(!(x===void 0?y===v||r(y,v,e,n,s):x)){m=!1;break}g||(g=h=="constructor")}if(m&&!g){var b=i.constructor,w=t.constructor;b!=w&&"constructor"in i&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return s.delete(i),s.delete(t),m}var YM=O5;var R5=1,XM="[object Arguments]",KM="[object Array]",Rg="[object Object]",L5=Object.prototype,QM=L5.hasOwnProperty;function N5(i,t,e,n,r,s){var o=Kn(i),a=Kn(t),l=o?KM:Do(i),u=a?KM:Do(t);l=l==XM?Rg:l,u=u==XM?Rg:u;var c=l==Rg,d=u==Rg,h=l==u;if(h&&Dl(i)){if(!Dl(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new Cu),o||yg(i)?Og(i,t,e,n,r,s):qM(i,t,l,e,n,r,s);if(!(e&R5)){var f=c&&QM.call(i,"__wrapped__"),p=d&&QM.call(t,"__wrapped__");if(f||p){var m=f?i.value():i,g=p?t.value():t;return s||(s=new Cu),r(m,g,e,n,s)}}return h?(s||(s=new Cu),YM(i,t,e,n,r,s)):!1}var ZM=N5;function JM(i,t,e,n,r){return i===t?!0:i==null||t==null||!Er(i)&&!Er(t)?i!==i&&t!==t:ZM(i,t,e,n,JM,r)}var $M=JM;function B5(i,t){return i!=null&&t in Object(i)}var eC=B5;function F5(i,t,e){t=Oi(t,i);for(var n=-1,r=t.length,s=!1;++n<r;){var o=wa(t[n]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++n!=r?s:(r=i==null?0:i.length,!!r&&gu(r)&&fu(o,r)&&(Kn(i)||vu(i)))}var tC=F5;function V5(i,t){return i!=null&&tC(i,t,eC)}var nC=V5;var k5=function(){return vn.Date.now()},Lg=k5;var U5="Expected a function",z5=Math.max,G5=Math.min;function H5(i,t,e){var n,r,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof i!="function")throw new TypeError(U5);t=Fb(t)||0,zn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?z5(Fb(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(E){var _=n,S=r;return n=r=void 0,u=E,o=i.apply(S,_),o}function p(E){return u=E,a=setTimeout(y,t),c?f(E):o}function m(E){var _=E-l,S=E-u,T=t-_;return d?G5(T,s-S):T}function g(E){var _=E-l,S=E-u;return l===void 0||_>=t||_<0||d&&S>=s}function y(){var E=Lg();if(g(E))return v(E);a=setTimeout(y,m(E))}function v(E){return a=void 0,h&&n?f(E):(n=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0}function b(){return a===void 0?o:v(Lg())}function w(){var E=Lg(),_=g(E);if(n=arguments,r=this,l=E,_){if(a===void 0)return p(l);if(d)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=b,w}var Rl=H5;function j5(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var rC=j5;function W5(i,t){return t.length<2?i:bg(i,JT(t,0,-1))}var iC=W5;function q5(i,t){return $M(i,t)}var Mf=q5;function Y5(i,t){return t=Oi(t,i),i=iC(i,t),i==null||delete i[wa(rC(t))]}var sC=Y5;function X5(i){return ZT(i)?void 0:i}var oC=X5;var K5=1,Q5=2,Z5=4,J5=Sg(function(i,t){var e={};if(i==null)return e;var n=!1;t=dg(t,function(s){return s=Oi(s,i),n||(n=s.length>1),s}),Cs(i,_g(i),e),n&&(e=Dg(e,K5|Q5|Z5,oC));for(var r=t.length;r--;)sC(e,t[r]);return e}),Ou=J5;function $5(i,t,e,n){if(!zn(i))return i;t=Oi(t,i);for(var r=-1,s=t.length,o=s-1,a=i;a!=null&&++r<s;){var l=wa(t[r]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(r!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=zn(c)?c:fu(t[r+1])?[]:{})}mu(a,l,u),a=a[l]}return i}var aC=$5;function ej(i,t,e){for(var n=-1,r=t.length,s={};++n<r;){var o=t[n],a=bg(i,o);e(a,o)&&aC(s,Oi(o,i),a)}return s}var lC=ej;function tj(i,t){return lC(i,t,function(e,n){return nC(i,n)})}var cC=tj;var nj=Sg(function(i,t){return i==null?{}:cC(i,t)}),Si=nj;var rj="Expected a function";function ij(i,t,e){var n=!0,r=!0;if(typeof i!="function")throw new TypeError(rj);return zn(e)&&(n="leading"in e?!!e.leading:n,r="trailing"in e?!!e.trailing:r),Rl(i,t,{leading:n,maxWait:t,trailing:r})}var Hb=ij;function uC(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Qr(i,t){return Object.setPrototypeOf(i,t),i}var sj=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),oj=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),aj=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ll&&"ontouchend"in document,lj=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,cj=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,uj=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},dj=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},hj=()=>{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"},fj=sj(),tie=fj?hj():void 0,Ll=oj(),Ng=aj(),dC=lj(),Qn=cj(),jb=uj(),Wb=Number(dj());function Bg(i){return Array.isArray(i)?i:[i]}function hC(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 Cf(i){return Ll?i.metaKey:i.ctrlKey}var We=[],Vg={},Pf={},Fg={};function fC(i){We.includes(i)||We.push(i)}function Ru(i){delete Vg[i.pointerId];for(let t=0;t<We.length;t++)if(We[t].pointerId===i.pointerId){We.splice(t,1);break}}function pC(){We.splice(0,We.length)}function kg(i){if(i.pointerType!=="touch")return;let t=Vg[i.pointerId];t===void 0&&(t={x:0,y:0},Vg[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function Ug(i){let t=i.pointerId===We[0].pointerId?We[1]:We[0];return Vg[t.pointerId]}function mC(i){Pf[i.key]=!0,Fg[i.key]=Fg[i.key]===void 0?1:Fg[i.key]+1}function gC(i){if(Ll&&Pf.Meta)for(let t in Pf)Pf[t]=!1;else Pf[i.key]=!1;Fg={}}function yC(i){i.addEventListener("pointerdown",fC,!0),i.addEventListener("pointerdown",kg,!0),i.addEventListener("pointermove",kg,!0),i.addEventListener("pointerup",Ru,!0),i.addEventListener("pointercancel",Ru,!0),i.addEventListener("pointerleave",Ru,!0),window.addEventListener("keydown",mC,!0),window.addEventListener("keyup",gC,!0)}function vC(i){i.removeEventListener("pointerdown",fC,!0),i.removeEventListener("pointerdown",kg,!0),i.removeEventListener("pointermove",kg,!0),i.removeEventListener("pointerup",Ru,!0),i.removeEventListener("pointercancel",Ru,!0),i.removeEventListener("pointerleave",Ru,!0),window.removeEventListener("keydown",mC,!0),window.removeEventListener("keyup",gC,!0)}var xC,bC=new Promise(i=>{xC=i});var zg;function SC(){if(zg)return zg;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.495/build",r=import("./navmesh.js"),[s,o]=await Promise.all([r,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});xC(l)}return zg=i(),zg}var wC,AC=new Promise(i=>{wC=i});var Gg;function EC(){if(Gg)return Gg;async function i(){let e=await import("./physics.js");await e.init(),wC(e)}return Gg=i(),Gg}var tt=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,tt.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 n=e[t.id],r;n===void 0?r={type:2,id:t.id}:r={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,tt.prototype),{data:a,actual:t,reverse:r}}else if(t.type===2){let{id:n}=t,r=e[n];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,tt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:r}}}}return null}};function Df(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let n=i[e];n&&typeof n=="object"&&Df(n)}return Object.freeze(i)}function _C(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 Lu=class extends Error{};function Hg(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ps(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 n=[],r=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*r;n.push(o)}return n}function Nu(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 TC(){return typeof process<"u"}function MC(i,t){for(let e of i)t(e.id,e.data)!==!0&&MC(e.children,t)}function CC(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)CC(e,t)}var cn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,cn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Df(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let r of e.children)this.fillCaches0(r,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,n){if(!this.has(e))return!0;for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}rootAcestor(e){for(;e;){let n=this.parent(e);if(n)e=n;else return e}return e}isDescendantOf(e,n){for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}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,n){if(e===null)this.traverse(n);else{let r=this.get(e);r&&CC(r,n)}}traverse(e){MC(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,n){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:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let r=e,s=n;for(;r!==null;){let a=s,l=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);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,cn.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:n}){if(this.get(e)!==void 0)return!0;for(let r of n)if(this.checkDuplicatedIdRec(r))return!0;return!1}addOp(e){let{parent:n,fi:r,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:r,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let r=this.parent(n);if(r===void 0)return null;let s=this.childrenArray(r),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(r,s),actual:e,reverse:{type:7,...a,parent:r}}}}moveOp(e){let{parent:n,fi:r,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Lu("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],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:r},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let r=null;for(let s of this.childrenArray(e)){if(s.id===n)return r;r=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)+1;if(s<r.length)return r[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(r[s].id):n}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push({...r,...s})}n.sort((r,s)=>_C(r.sortKey,s.sortKey));for(let r of n)delete r.sortKey;return n}getWithSortKey(e){var n=e;let r=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)r.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:r}}}insertBeforeHelper(e,n,r){return this.insertAfterHelper(e,this.previous(e,n),r)}insertAfterHelper(e,n,r){let s=this.childrenArray(e);if(n===null){if(s.length===0)return Ps(0,r,r);{let o=s[0].fi;return Ps(o-r,o,r)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==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 Ps(l,l+r,r)}else return Ps(o.fi,a.fi,r)}}};var Bu;(t=>{function i(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let r=n.props,s={},o=[...e],a=!1;if(r)for(let l of Object.keys(r)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=r[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let r=n.props,s={},o={...e},a=!1;if(r)for(let l of Object.keys(r)){s[l]=o[l];let u=r[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=i})(Bu||(Bu={}));var Re=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Re.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Df(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,n){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:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Re.prototype);let n=e;return TC()||n.fillCaches(),n}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:n,id:r,data:s}=e,o=this,a={fi:n,id:r,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:r}}}deleteOp(e){let{id:n}=e,r=this,s=r.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,r=[...r];let o=r.splice(s,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:r}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===r);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let r of this){if(r.id===e)return n;n=r.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let r=this;if(e===null){if(r.length===0)return Ps(0,n,n);{let s=r[0].fi;return Ps(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=r.find(a=>a.fi>s.fi);if(o===void 0){let a=r[r.length-1].fi;return Ps(a,a+n,n)}else return Ps(s.fi,o.fi,n)}}};function Fu(i){return i&&typeof i=="object"&&i instanceof Yt}var Yt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,r=0,s={};for(;r<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[r]],n!==void 0&&!Fu(n))return null;r+=1}n=n?Hg(n):new Yt;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;r>0;){if(Object.keys(n).length===0){let l=e[r-1];l&&(n=Hg(l),delete n[t.path[r-1]])}else{let l=e[r-1];if(l){let u=Hg(l);u[t.path[r-1]]=n,n=u}else{let u=new Yt;u[t.path[r-1]]=n,n=u}}r-=1}let o=Object.setPrototypeOf(n,Yt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Ds;(n=>{function i(r,s){return If(r,s)??r}n.apply=i;function t(r,s){return Yb(r,s)}n.merge=t;function e(r,s){let o=0,a=s.path,l=r;for(;o<a.length&&l!==void 0;){if(l=_n.zoomOnce(l,a[o]),l===void 0)return s;if(!Fu(l))return;o+=1}if(l===void 0)return s;if(!!Fu(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=qb([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(Ds||(Ds={}));function qb(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=If(r.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=r.data),r.children){let a=qb(r.children,t);return a!==void 0?e=!0:a=r.children,{...r,id:s,data:o,children:a}}else return{...r,id:s,data:o}});if(e)return n}function pj(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=If(r.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=r.data),{...r,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function If(i,t){if(!Fu(t))return t;if(i instanceof cn){let e=qb(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Re)return pj(i,t);if(Array.isArray(i)){let e=!1,n=i.map((r,s)=>{let o=If(r,t[s]);return e=e||o!==void 0,o===void 0&&(o=r),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else{if(i instanceof Yt)return Yb(i,t);if(i&&typeof i=="object"){let e={},n=!1;for(let[r,s]of Object.entries(i)){let o=If(s,t[r]);n=n||o!==void 0,o===void 0&&(o=s),e[r]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Yb(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Fu(t))return t;if(!Fu(i))return Ds.apply(i,t);let e=new Set;for(let r of Object.keys(i))e.add(r);for(let r of Object.keys(t))e.add(r);let n=new Yt;for(let r of e){let s=Yb(i===void 0?void 0:i[r],t===void 0?void 0:t[r]);n[r]=s}return n}function PC(i,t){let e={cur:[],result:[],len:0};return i=Of(i,t,e)??i,[i,e.result]}function jg(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Wg(i){i&&(i.len-=1)}function mj(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function DC(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Of(s.data,t,jg(e,o));Wg(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=DC(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return r}function gj(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Of(s.data,t,jg(e,o));return Wg(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Of(i,t,e){if(i instanceof cn){let n=DC(i,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}else{if(i instanceof Re)return gj(i,t,e);if(Array.isArray(i)){let n=!1,r=i.map((s,o)=>{let a=Of(s,t,jg(e,o));return Wg(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(i&&typeof i=="object"&&!Nu(i)){let n={},r=!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");r=!0,s=a}let l=Of(o,t,jg(e,s));Wg(e),r=r||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(typeof i=="string"){let n=t[i];return n!==void 0&&mj(e),n}else return}}var qg;(t=>{function i(e,n){let r=_n.zoom(n,e.path);if(typeof r=="object"){let s={};for(let o of Object.keys(e.props))s[o]=r[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(qg||(qg={}));var Tn;(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 d=[];;){let h;if(l instanceof Yt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof cn||l instanceof Re||l instanceof tt?h=l.runOp(u):h=Bu.runOp(l,u)),h!==void 0)if(h!==null){let m=h.data;for(let g=d.length-1;g>=0;g--){let y=c[g],v=d[g];if(v instanceof cn){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Re){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof tt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Yt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Yt.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:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],p;if(l instanceof cn){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Re){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)d.push(l),l=p;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function r(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=r;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&r(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(Tn||(Tn={}));var Rf;(l=>{function i(){return[]}l.empty=i;function t(u,c){let d=[];for(let h of u){let[f,...p]=h.path;f===c&&d.push({...h,path:p})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function r(u,c){return[...u.filter(h=>!c.some(f=>Tn.subsumed(h,f))),...c]}l.compress=r;function s(u,c){return u.every(d=>c.every(h=>Tn.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],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=_n.zoom(d,[...p.path,p.id]),y=Tn.apply(d,{...p,type:2})):(m=_n.zoom(d,[...p.path,p.id,"value"]),y=Tn.apply(d,p)),y!==null){d=y.data;let[v,x]=PC(d,{[p.id]:m});d=v;for(let b=0;b<x.length;b++){let w=x[b],E=w.pop();if(typeof E=="number"){let _=[E];for(let T=b+1;T<x.length;T++){let M=x[T],C=M[M.length-1];if(typeof C=="number"&&_n.equal(w,M.slice(0,M.length-1)))_.push(C),x.splice(T,1);else break}let S=_n.zoom(d,w);g=S.map((T,M)=>_.includes(M)?p.id:T),m=S,E=w.pop()}else{if(E==="alphaOverride"||E==="alpha"){m/=100;let _=m,S=_n.zoom(d,w.slice(0,w.length-2)),T=S.layers.map(M=>M.id===w[w.length-1]?{...M,data:{...M.data,[E]:_}}:M);Object.setPrototypeOf(T,Object.getPrototypeOf(S.layers)),S.layers=T}g=p.id}h.push({type:0,path:w,props:{[E]:m}}),f.push({type:0,path:w,props:{[E]:g}})}f.push(y.reverse),h.push(y.actual)}}else{let m=Tn.apply(d,p);m!==null&&(h.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Lu)return null;throw m}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(Rf||(Rf={}));var IC=Symbol(),yj=Symbol(),Xg=Symbol(),Nl=class{reportOp(t,e,n=[]){let r=this;if(e===null)return;r._current=e.data;let s=n;for(;!(r instanceof Yg);){let o=r._path,a=r._current;if(o!==""&&s.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[Xg];n&&n(),delete this._children[t]}}}},Kb=class extends Nl{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}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,Bu.runOp(this._current,t),t.path)}},Qb=class extends Nl{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,tt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},OC={get(i,t){if(t===Xg)return()=>{i._parent=null};if(t===IC)return i._current;if(t===yj)return i;let{_current:e,_children:n}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e[t],o=Kg(i,t,s);return o!==s?(n===void 0&&(n={},i._children=n),n[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,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},vj={...OC,set(i,t,e){let n={type:0,props:{[t]:pn(e)??e}};return i.deleteChildren(t),i.runOp(n),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},xj={...OC,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}},Vu=class extends Nl{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Xg]=()=>{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,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Kg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,r,s){this.runOp({type:7,parent:t,fi:e,id:n,data:r,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}moveBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[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)}},ku=class extends Nl{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Xg]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),r,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id;if(t(this.data(r),r))return this.get(r)}}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:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Kg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Xb(i,t,e){if(i.length>0){let n=i[i.length-1];if(n.type===0&&t.type===0&&_n.equal(n.path,e)){Object.assign(n.props,t.props);return}}i.push({...t,path:e})}var Yg=class extends Nl{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,n,r){Xb(this.ts,e,t),Xb(this.actual,n,t),Xb(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Kg(i,t,e){return e instanceof cn?new Vu(i,t,e):e instanceof Re?new ku(i,t,e):e instanceof tt?new Proxy(new Qb(i,t,e),xj):e!==null&&typeof e=="object"?Nu(e)?e:new Proxy(new Kb(i,t,e),vj):e}function Zb(i){let t=new Yg(i);return[Kg(t,"",i),t]}function Aa(i,t){let[e,n]=Zb(i);return t(e),n.result()}function pn(i){return i instanceof Vu||i instanceof ku?i._current:i!==null&&typeof i=="object"?i[IC]:i}var _n;(r=>{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}r.equal=i;function t(s,o,a){let l=n(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}r.removeOverridden=t;function e(s,o){if((s instanceof cn||s instanceof Vu)&&typeof o=="string")return s.data(o);if((s instanceof Re||s instanceof ku)&&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]}r.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}r.zoom=n})(_n||(_n={}));function RC(i,t){let e=[];if(t.length===i.length)for(var n=0;n<i.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}function Rr(i,t){let e=[];if(t.length<=i.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}var Qg=class{},Lf=class extends Qg{constructor(e){super();this.id=e}},Nf=class extends Qg{constructor(e){super();this.data=e}};var $b;try{$b=new TextDecoder}catch{}var Ne,_a,J=0;var zC=[],eS=zC,tS=0,Zr={},Ot,Ea,Ri=0,Is=0,wi,Oo,Gr=[],kt,LC={useRecords:!1,mapsAsObjects:!0},Bf=class{},rS=new Bf;rS.name="MessagePack 0xC1";var Uu=!1,Os=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(Ne)return qC(()=>(Jg(),this?this.unpack(t,e):Os.prototype.unpack.call(LC,t,e)));_a=e>-1?e:t.length,J=0,tS=0,Is=0,Ea=null,eS=zC,wi=null,Ne=t;try{kt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Ne=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Os){if(Zr=this,this.structures)return Ot=this.structures,Zg();(!Ot||Ot.length>0)&&(Ot=[])}else Zr=LC,(!Ot||Ot.length>0)&&(Ot=[]);return Zg()}unpackMultiple(t,e){let n,r=0;try{Uu=!0;let s=t.length,o=this?this.unpack(t,s):ty.unpack(t,s);if(e){for(e(o);J<s;)if(r=J,e(Zg())===!1)return}else{for(n=[o];J<s;)r=J,n.push(Zg());return n}}catch(s){throw s.lastPosition=r,s.values=n,s}finally{Uu=!1,Jg()}}_mergeStructures(t,e){t=t||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let r=t[n],s=e[n];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[n]=r),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Zg(){try{if(!Zr.trusted&&!Uu){let t=Ot.sharedLength||0;t<Ot.length&&(Ot.length=t)}let i=xn();if(J==_a)Ot.restoreStructures&&NC(),Ot=null,Ne=null,Oo&&(Oo=null);else if(J>_a){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Uu)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Ot.restoreStructures&&NC(),Jg(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function NC(){for(let i in Ot.restoreStructures)Ot[i]=Ot.restoreStructures[i];Ot.restoreStructures=null}function xn(){let i=Ne[J++];if(i<160)if(i<128){if(i<64)return i;{let t=Ot[i&63]||Zr.getStructures&&GC()[i&63];return t?(t.read||(t.read=iS(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[jC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}else if(i<192){let t=i-160;if(Is>=J)return Ea.slice(J-Ri,(J+=t)-Ri);if(Is==0&&_a<140){let e=t<16?sS(t):HC(t);if(e!=null)return e}return nS(t)}else{let t;switch(i){case 192:return null;case 193:return wi?(t=xn(),t>0?wi[1].slice(wi.position1,wi.position1+=t):wi[0].slice(wi.position0,wi.position0-=t)):rS;case 194:return!1;case 195:return!0;case 196:return Jb(Ne[J++]);case 197:return t=kt.getUint16(J),J+=2,Jb(t);case 198:return t=kt.getUint32(J),J+=4,Jb(t);case 199:return Bl(Ne[J++]);case 200:return t=kt.getUint16(J),J+=2,Bl(t);case 201:return t=kt.getUint32(J),J+=4,Bl(t);case 202:if(t=kt.getFloat32(J),Zr.useFloat32>2){let e=ey[(Ne[J]&127)<<1|Ne[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=kt.getFloat64(J),J+=8,t;case 204:return Ne[J++];case 205:return t=kt.getUint16(J),J+=2,t;case 206:return t=kt.getUint32(J),J+=4,t;case 207:return Zr.int64AsNumber?(t=kt.getUint32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigUint64(J),J+=8,t;case 208:return kt.getInt8(J++);case 209:return t=kt.getInt16(J),J+=2,t;case 210:return t=kt.getInt32(J),J+=4,t;case 211:return Zr.int64AsNumber?(t=kt.getInt32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigInt64(J),J+=8,t;case 212:if(t=Ne[J++],t==114)return UC(Ne[J++]&63);{let e=Gr[t];if(e)return e.read?(J++,e.read(xn())):e.noBuffer?(J++,e()):e(Ne.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=Ne[J],t==114?(J++,UC(Ne[J++]&63,Ne[J++])):Bl(2);case 214:return Bl(4);case 215:return Bl(8);case 216:return Bl(16);case 217:return t=Ne[J++],Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):Sj(t);case 218:return t=kt.getUint16(J),J+=2,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):wj(t);case 219:return t=kt.getUint32(J),J+=4,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):Aj(t);case 220:return t=kt.getUint16(J),J+=2,FC(t);case 221:return t=kt.getUint32(J),J+=4,FC(t);case 222:return t=kt.getUint16(J),J+=2,VC(t);case 223:return t=kt.getUint32(J),J+=4,VC(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 bj=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function iS(i,t){function e(){if(e.count++>2){let r=i.read=new Function("r","return function(){return {"+i.map(s=>bj.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(xn);return i.highByte===0&&(i.read=BC(t,i.read)),r()}let n={};for(let r=0,s=i.length;r<s;r++){let o=i[r];n[o]=xn()}return n}return e.count=0,i.highByte===0?BC(t,e):e}var BC=(i,t)=>function(){let e=Ne[J++];if(e===0)return t();let n=i<32?-(i+(e<<5)):i+(e<<5),r=Ot[n]||GC()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=iS(r,i)),r.read()};function GC(){let i=qC(()=>(Ne=null,Zr.getStructures()));return Ot=Zr._mergeStructures(i,Ot)}var nS=$g,Sj=$g,wj=$g,Aj=$g;function $g(i){let t;if(i<16&&(t=sS(i)))return t;if(i>64&&$b)return $b.decode(Ne.subarray(J,J+=i));let e=J+i,n=[];for(t="";J<e;){let r=Ne[J++];if((r&128)===0)n.push(r);else if((r&224)===192){let s=Ne[J++]&63;n.push((r&31)<<6|s)}else if((r&240)===224){let s=Ne[J++]&63,o=Ne[J++]&63;n.push((r&31)<<12|s<<6|o)}else if((r&248)===240){let s=Ne[J++]&63,o=Ne[J++]&63,a=Ne[J++]&63,l=(r&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(r);n.length>=4096&&(t+=ur.apply(String,n),n.length=0)}return n.length>0&&(t+=ur.apply(String,n)),t}function FC(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}function VC(i){if(Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[jC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}}var ur=String.fromCharCode;function HC(i){let t=J,e=new Array(i);for(let n=0;n<i;n++){let r=Ne[J++];if((r&128)>0){J=t;return}e[n]=r}return ur.apply(String,e)}function sS(i){if(i<4)if(i<2){if(i===0)return"";{let t=Ne[J++];if((t&128)>1){J-=1;return}return ur(t)}}else{let t=Ne[J++],e=Ne[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(i<3)return ur(t,e);let n=Ne[J++];if((n&128)>0){J-=3;return}return ur(t,e,n)}else{let t=Ne[J++],e=Ne[J++],n=Ne[J++],r=Ne[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(r&128)>0){J-=4;return}if(i<6){if(i===4)return ur(t,e,n,r);{let s=Ne[J++];if((s&128)>0){J-=5;return}return ur(t,e,n,r,s)}}else if(i<8){let s=Ne[J++],o=Ne[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(i<7)return ur(t,e,n,r,s,o);let a=Ne[J++];if((a&128)>0){J-=7;return}return ur(t,e,n,r,s,o,a)}else{let s=Ne[J++],o=Ne[J++],a=Ne[J++],l=Ne[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(i<10){if(i===8)return ur(t,e,n,r,s,o,a,l);{let u=Ne[J++];if((u&128)>0){J-=9;return}return ur(t,e,n,r,s,o,a,l,u)}}else if(i<12){let u=Ne[J++],c=Ne[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(i<11)return ur(t,e,n,r,s,o,a,l,u,c);let d=Ne[J++];if((d&128)>0){J-=11;return}return ur(t,e,n,r,s,o,a,l,u,c,d)}else{let u=Ne[J++],c=Ne[J++],d=Ne[J++],h=Ne[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(i<14){if(i===12)return ur(t,e,n,r,s,o,a,l,u,c,d,h);{let f=Ne[J++];if((f&128)>0){J-=13;return}return ur(t,e,n,r,s,o,a,l,u,c,d,h,f)}}else{let f=Ne[J++],p=Ne[J++];if((f&128)>0||(p&128)>0){J-=14;return}if(i<15)return ur(t,e,n,r,s,o,a,l,u,c,d,h,f,p);let m=Ne[J++];if((m&128)>0){J-=15;return}return ur(t,e,n,r,s,o,a,l,u,c,d,h,f,p,m)}}}}}function Jb(i){return Zr.copyBuffers?Uint8Array.prototype.slice.call(Ne,J,J+=i):Ne.subarray(J,J+=i)}function Bl(i){let t=Ne[J++];if(Gr[t])return Gr[t](Ne.subarray(J,J+=i));throw new Error("Unknown extension type "+t)}var kC=new Array(4096);function jC(){let i=Ne[J++];if(i>=160&&i<192){if(i=i-160,Is>=J)return Ea.slice(J-Ri,(J+=i)-Ri);if(!(Is==0&&_a<180))return nS(i)}else return J--,xn();let t=(i<<5^(i>1?kt.getUint16(J):i>0?Ne[J]:0))&4095,e=kC[t],n=J,r=J+i-3,s,o=0;if(e&&e.bytes==i){for(;n<r;){if(s=kt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(r+=3;n<r;)if(s=Ne[n++],s!=e[o++]){n=1879048192;break}if(n===r)return J=n,e.string;r-=3,n=J}for(e=[],kC[t]=e,e.bytes=i;n<r;)s=kt.getUint32(n),e.push(s),n+=4;for(r+=3;n<r;)s=Ne[n++],e.push(s);let a=i<16?sS(i):HC(i);return a!=null?e.string=a:e.string=nS(i)}var UC=(i,t)=>{var e=xn();let n=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let r=Ot[i];return r&&r.isShared&&((Ot.restoreStructures||(Ot.restoreStructures=[]))[i]=r),Ot[i]=e,e.read=iS(e,n),e.read()},WC=typeof self=="object"?self:global;Gr[0]=()=>{};Gr[0].noBuffer=!0;Gr[101]=()=>{let i=xn();return(WC[i[0]]||Error)(i[1])};Gr[105]=i=>{let t=kt.getUint32(J-4);Oo||(Oo=new Map);let e=Ne[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let r={target:n};Oo.set(t,r);let s=xn();return r.used?Object.assign(n,s):(r.target=s,s)};Gr[112]=i=>{let t=kt.getUint32(J-4),e=Oo.get(t);return e.used=!0,e.target};Gr[115]=()=>new Set(xn());var oS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Gr[116]=i=>{let t=i[0],e=oS[t];if(!e)throw new Error("Could not find typed array for code "+t);return new WC[e](Uint8Array.prototype.slice.call(i,1).buffer)};Gr[120]=()=>{let i=xn();return new RegExp(i[0],i[1])};Gr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=J;J+=t-4,wi=[xn(),xn()],wi.position0=0,wi.position1=0;let n=J;J=e;try{return xn()}finally{J=n}};Gr[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 qC(i){let t=_a,e=J,n=tS,r=Ri,s=Is,o=Ea,a=eS,l=Oo,u=wi,c=new Uint8Array(Ne.slice(0,_a)),d=Ot,h=Ot.slice(0,Ot.length),f=Zr,p=Uu,m=i();return _a=t,J=e,tS=n,Ri=r,Is=s,Ea=o,eS=a,Oo=l,wi=u,Ne=c,Uu=p,Ot=d,Ot.splice(0,Ot.length,...h),Zr=f,kt=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),m}function Jg(){Ne=null,Oo=null,Ot=null}function YC(i){i.unpack?Gr[i.type]=i.unpack:Gr[i.type]=i}var ey=new Array(147);for(let i=0;i<256;i++)ey[i]=+("1e"+Math.floor(45.15-i*.30103));var ty=new Os({useRecords:!1}),Ej=ty.unpack,_j=ty.unpackMultiple,Tj=ty.unpack,ny={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Mj=new Float32Array(1),hse=new Uint8Array(Mj.buffer,0,4);var ry;try{ry=new TextEncoder}catch{}var iy,lS,sy=typeof Buffer<"u",aS=sy?Buffer.allocUnsafeSlow:Uint8Array,ZC=sy?Buffer:Uint8Array,XC=sy?4294967296:2144337920,he,Mn,re=0,Rs,Ls=null,Cj=/[\u0080-\uFFFF]/,Ff=Symbol("record-id"),Fl=class extends Os{constructor(t){super(t),this.offset=0;let e,n,r,s,o,a,l=0,u=ZC.prototype.utf8Write?function(S,T,M){return he.utf8Write(S,T,M)}:ry&&ry.encodeInto?function(S,T){return ry.encodeInto(S,he.subarray(T)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=h?32:64),d&&!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,b=0;this.pack=this.encode=function(S,T){if(he||(he=new aS(8192),Mn=new DataView(he.buffer,0,8192),re=0),Rs=he.length-10,Rs-re<2048?(he=new aS(he.length),Mn=new DataView(he.buffer,0,he.length),Rs=he.length-10,re=0):re=re+7&2147483640,n=re,a=c.structuredClone?new Map:null,c.bundleStrings?(Ls=["",""],he[re++]=214,he[re++]=98,Ls.position=re-n,re+=4):Ls=null,r=c.structures,r){r.uninitialized&&(r=c._mergeStructures(c.getStructures()));let M=r.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let D=r[C];if(!D)continue;let P,I=r.transitions;for(let L=0,H=D.length;L<H;L++){let k=D[L];P=I[k],P||(P=I[k]=Object.create(null)),I=P}I[Ff]=C+64}l=M}d||(r.nextId=M+64)}s&&(s=!1),o=r||[];try{if(w(S),Ls){Mn.setUint32(Ls.position+n,re-Ls.position-n);let M=Ls;Ls=null,w(M[0]),w(M[1])}if(c.offset=re,a&&a.idsToInsert){re+=a.idsToInsert.length*6,re>Rs&&_(re),c.offset=re;let M=Dj(he.subarray(n,re),a.idsToInsert);return a=null,M}return T&$C?(he.start=n,he.end=re,he):he.subarray(n,re)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,C=v.length;M<C;M++)v[M][Ff]=0;v=[]}if(s&&c.saveStructures){let M=r.sharedLength||f;r.length>M&&(r=r.slice(0,M));let C=he.subarray(n,re);return c.saveStructures(r,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(S)):(l=M,C)}}T&Fj&&(re=n)}};let w=S=>{re>Rs&&(he=_(re));var T=typeof S,M;if(T==="string"){let C=S.length;if(Ls&&C>=8&&C<4096){let I=Cj.test(S);Ls[I?0:1]+=S,he[re++]=193,w(I?-C:C);return}let D;C<32?D=1:C<256?D=2:C<65536?D=3:D=5;let P=C*3;if(re+P>Rs&&(he=_(re+P)),C<64||!u){let I,L,H,k=re+D;for(I=0;I<C;I++)L=S.charCodeAt(I),L<128?he[k++]=L:L<2048?(he[k++]=L>>6|192,he[k++]=L&63|128):(L&64512)===55296&&((H=S.charCodeAt(I+1))&64512)===56320?(L=65536+((L&1023)<<10)+(H&1023),I++,he[k++]=L>>18|240,he[k++]=L>>12&63|128,he[k++]=L>>6&63|128,he[k++]=L&63|128):(he[k++]=L>>12|224,he[k++]=L>>6&63|128,he[k++]=L&63|128);M=k-re-D}else M=u(S,re+D,P);M<32?he[re++]=160|M:M<256?(D<2&&he.copyWithin(re+2,re+1,re+1+M),he[re++]=217,he[re++]=M):M<65536?(D<3&&he.copyWithin(re+3,re+2,re+2+M),he[re++]=218,he[re++]=M>>8,he[re++]=M&255):(D<5&&he.copyWithin(re+5,re+3,re+3+M),he[re++]=219,Mn.setUint32(re,M),re+=4),re+=M}else if(T==="number")if(S>>>0===S)S<64?he[re++]=S:S<256?(he[re++]=204,he[re++]=S):S<65536?(he[re++]=205,he[re++]=S>>8,he[re++]=S&255):(he[re++]=206,Mn.setUint32(re,S),re+=4);else if(S>>0===S)S>=-32?he[re++]=256+S:S>=-128?(he[re++]=208,he[re++]=S+256):S>=-32768?(he[re++]=209,Mn.setInt16(re,S),re+=2):(he[re++]=210,Mn.setInt32(re,S),re+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){he[re++]=202,Mn.setFloat32(re,S);let D;if(C<4||(D=S*ey[(he[re]&127)<<1|he[re+1]>>7])>>0===D){re+=4;return}else re--}he[re++]=203,Mn.setFloat64(re,S),re+=8}else if(T==="object")if(!S)he[re++]=192;else{if(a){let D=a.get(S);if(D){if(!D.id){let P=a.idsToInsert||(a.idsToInsert=[]);D.id=P.push(D)}he[re++]=214,he[re++]=112,Mn.setUint32(re,D.id),re+=4;return}else a.set(S,{offset:re-n})}let C=S.constructor;if(C===Object)E(S,!0);else if(C===Array){M=S.length,M<16?he[re++]=144|M:M<65536?(he[re++]=220,he[re++]=M>>8,he[re++]=M&255):(he[re++]=221,Mn.setUint32(re,M),re+=4);for(let D=0;D<M;D++)w(S[D])}else if(C===Map){M=S.size,M<16?he[re++]=128|M:M<65536?(he[re++]=222,he[re++]=M>>8,he[re++]=M&255):(he[re++]=223,Mn.setUint32(re,M),re+=4);for(let[D,P]of S)w(D),w(P)}else{for(let D=0,P=iy.length;D<P;D++){let I=lS[D];if(S instanceof I){let L=iy[D];if(L.write){L.type&&(he[re++]=212,he[re++]=L.type,he[re++]=0),w(L.write.call(this,S));return}let H=he,k=Mn,G=re;he=null;let z;try{z=L.pack.call(this,S,U=>(he=H,H=null,re+=U,re>Rs&&_(re),{target:he,targetView:Mn,position:re-U}),w)}finally{H&&(he=H,Mn=k,re=G,Rs=he.length-10)}z&&(z.length+re>Rs&&_(z.length+re),re=Pj(z,he,re,L.type));return}}E(S,!S.hasOwnProperty)}}else if(T==="boolean")he[re++]=S?195:194;else if(T==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))he[re++]=211,Mn.setBigInt64(re,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)he[re++]=207,Mn.setBigUint64(re,S);else if(this.largeBigIntToFloat)he[re++]=203,Mn.setFloat64(re,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");re+=8}else if(T==="undefined")this.encodeUndefinedAsNil?he[re++]=192:(he[re++]=212,he[re++]=0,he[re++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},E=this.useRecords===!1?this.variableMapSize?S=>{let T=Object.keys(S),M=T.length;M<16?he[re++]=128|M:M<65536?(he[re++]=222,he[re++]=M>>8,he[re++]=M&255):(he[re++]=223,Mn.setUint32(re,M),re+=4);let C;for(let D=0;D<M;D++)w(C=T[D]),w(S[C])}:(S,T)=>{he[re++]=222;let M=re-n;re+=2;let C=0;for(let D in S)(T||S.hasOwnProperty(D))&&(w(D),w(S[D]),C++);he[M+++n]=C>>8,he[M+n]=C&255}:S=>{let T=Object.keys(S),M,C=o.transitions||(o.transitions=Object.create(null)),D=0;for(let I=0,L=T.length;I<L;I++){let H=T[I];M=C[H],M||(M=C[H]=Object.create(null),D++),C=M}let P=C[Ff];if(P)P>=96&&m?(he[re++]=((P-=96)&31)+96,he[re++]=P>>5):he[re++]=P;else{P=o.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(P=o.nextOwnId,P<y||(P=g),o.nextOwnId=P+1):(P>=y&&(P=g),o.nextId=P+1);let I=T.highByte=P>=96&&m?P-96>>5:-1;C[Ff]=P,o[P-64]=T,P<g?(T.isShared=!0,o.sharedLength=P-63,s=!0,I>=0?(he[re++]=(P&31)+96,he[re++]=I):he[re++]=P):(I>=0?(he[re++]=213,he[re++]=114,he[re++]=(P&31)+96,he[re++]=I):(he[re++]=212,he[re++]=114,he[re++]=P),D&&(x+=b*D),v.length>=p&&(v.shift()[Ff]=0),v.push(C),w(T))}for(let I=0,L=T.length;I<L;I++)w(S[T[I]])},_=S=>{let T;if(S>16777216){if(S-n>XC)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(XC,Math.round(Math.max((S-n)*(S>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(S-n<<2,he.length-1)>>12)+1<<12;let M=new aS(T);return Mn=new DataView(M.buffer,0,T),he.copy?he.copy(M,0,n,S):M.set(he.slice(n,S)),re-=n,n=0,Rs=M.length-10,he=M}}useBuffer(t){he=t,Mn=new DataView(he.buffer,he.byteOffset,he.byteLength),re=0}};lS=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Bf];iy=[{pack(i,t,e){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:s,position:o}=t(6);r[o++]=214,r[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:r,targetView:s,position:o}=t(10);r[o++]=215,r[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:r,targetView:s,position:o}=t(3);r[o++]=212,r[o++]=255,r[o++]=255}else{let{target:r,targetView:s,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(i,t,e){let n=Array.from(i),{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=115,r[s++]=0),e(n)}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=101,n[r++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=120,n[r++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?KC(i,16,t):QC(sy?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==ZC&&this.structuredClone?KC(i,oS.indexOf(e.name),t):QC(i,t)}},{pack(i,t){let{target:e,position:n}=t(1);e[n]=193}}];function KC(i,t,e,n){let r=i.byteLength;if(r+1<256){var{target:s,position:o}=e(4+r);s[o++]=199,s[o++]=r+1}else if(r+1<65536){var{target:s,position:o}=e(5+r);s[o++]=200,s[o++]=r+1>>8,s[o++]=r+1&255}else{var{target:s,position:o,targetView:a}=e(7+r);s[o++]=201,a.setUint32(o,r+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function QC(i,t){let e=i.byteLength;var n,r;if(e<256){var{target:n,position:r}=t(e+2);n[r++]=196,n[r++]=e}else if(e<65536){var{target:n,position:r}=t(e+3);n[r++]=197,n[r++]=e>>8,n[r++]=e&255}else{var{target:n,position:r,targetView:s}=t(e+5);n[r++]=198,s.setUint32(r,e),r+=4}n.set(i,r)}function Pj(i,t,e,n){let r=i.length;switch(r){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:r<256?(t[e++]=199,t[e++]=r):r<65536?(t[e++]=200,t[e++]=r>>8,t[e++]=r&255):(t[e++]=201,t[e++]=r>>24,t[e++]=r>>16&255,t[e++]=r>>8&255,t[e++]=r&255)}return t[e++]=n,t.set(i,e),e+=r,e}function Dj(i,t){let e,n=t.length*6,r=i.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+n,s,r),n-=6;let a=s+n;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,r=s}return i}function Ta(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)");lS.unshift(i.Class),iy.unshift(i)}YC(i)}var JC=new Fl({useRecords:!1}),Ij=JC.pack,Oj=JC.pack;var{NEVER:Rj,ALWAYS:Lj,DECIMAL_ROUND:Nj,DECIMAL_FIT:Bj}=ny,$C=512,Fj=1024;var eP=new Fl({structuredClone:!0});Ta({Class:tt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,tt.prototype),i}});Ta({Class:Re.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Re.prototype),i}});Ta({Class:cn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,cn.prototype),i}});Ta({Class:Lf.prototype.constructor,type:4,write(i){return i.id},read(i){return new Lf(i)}});Ta({Class:Nf.prototype.constructor,type:5,write(i){return i.data},read(i){return new Nf(i)}});Ta({Class:Yt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Yt.prototype),i}});function Vj(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let n=i[e];t=(t<<5)-t+n,t=t&t}return t}function cS(i){if(Nu(i))return i;if(Array.isArray(i))return i.map(cS);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=cS(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var oy;(n=>{function i(r){return eP.pack(r)}n.serialize=i;function t(r){return eP.unpack(r)}n.deserialize=t;function e(r){return Vj(i(cS(r))).toString()}n.checksum=e})(oy||(oy={}));var tP;(e=>{function i(n){return n.type==="Conditional"?n.condition.type==="Distance"?"Distance":"StateChange":n.type}e.toEventUIType=i;function t(n){return n==="Distance"||n==="StateChange"?"Conditional":n}e.fromEventUIType=t})(tP||(tP={}));var Jr={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],["GameControl"]:["Transition","Animation","Audio","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Resize"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["VariableChange"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},nP;(e=>{function i(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=i;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,runMode:"Once",actions:new Re}:{type:n,disabled:!1,key:void 0,runMode:"Once",actions:new Re}}e.defaultData=t})(nP||(nP={}));var ay;(e=>{function i(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(ay||(ay={}));var uS;(n=>{function i(r){return{type:"Comparison",operator:"==",lOperand:ay.propertyDefaultData(r),rOperand:{...ay.valueDefaultData}}}n.comparisonDefaultData=i;function t(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}}n.distanceDefaultData=t;function e(r,s){return{type:"State",object:r??null,state:s??null}}n.stateDefaultData=e})(uS||(uS={}));var rP;(e=>{function i(n){return n.type==="Conditional"}e.is=i;function t(n){return{type:"Conditional",disabled:!1,inActions:new Re,outActions:new Re,condition:uS.distanceDefaultData(n)}}e.defaultData=t})(rP||(rP={}));var iP;(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 Re,drop:new Re}})(iP||(iP={}));var ly;(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 Re})(ly||(ly={}));var cy;(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})(cy||(cy={}));var sP;(e=>{function i(n){return n.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Re}}e.defaultData=t})(sP||(sP={}));var oP;(e=>{function i(n){return n.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 Re}}e.defaultData=t})(oP||(oP={}));var aP;(e=>{function i(n){return n.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Re}}e.defaultData=t})(aP||(aP={}));var lP;(e=>{function i(n){return n.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Re}}e.defaultData=t})(lP||(lP={}));var cP;(e=>{function i(n){return n.type==="Trigger"}e.is=i;function t(n,r){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Re,triggerZone:"box",position:r.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}e.defaultData=t})(cP||(cP={}));var uy;(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 n(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=n;function r(){let a={size:"mobile",operator:"<",actions:new Re},l={size:"tablet",operator:"<",actions:new Re},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Re},c=new Re;return c.push({id:we.generateUUID(),fi:0,data:a},{id:we.generateUUID(),fi:1,data:l},{id:we.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=r;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Re}}o.defaultBreakpointData=s})(uy||(uy={}));var dy;(n=>{n.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}n.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Re,variableId:"",objectId:null,property:"Position X"}}n.defaultData=e})(dy||(dy={}));var Li="personal camera",Ca="a218fcc3-276b-49b9-b485-49037fd14f5f",hP=2960946,Zn=5526619;var Vl;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s]}e.lerp=t})(Vl||(Vl={}));var Ns;(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 n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function r(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=r;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})(Ns||(Ns={}));var Vf;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s,n[2]+(r[2]-n[2])*s,n[3]+(r[3]-n[3])*s]}e.lerp=t})(Vf||(Vf={}));var Ma;(r=>{r.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}r.isEqual=t;function e(s){return s??r.identity}r.simplify=e;function n(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}r.applyMatrix4=n})(Ma||(Ma={}));var dr;(c=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.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 r(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=r;function s(d){return{r:d.r,g:d.g,b:d.b}}c.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=a;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}c.equals=l;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}c.lerp=u})(dr||(dr={}));var Hr;(a=>{a.white={...dr.white,a:1},a.transparent={...dr.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...dr.fromHex(l),a:u}}a.fromHexAndA=n;function r(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=r;function s(l,u){return dr.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})(Hr||(Hr={}));var hy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(hy||(hy={}));var uP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(uP||(uP={}));var dP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(dP||(dP={}));var Ro;(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]))(Ro||(Ro={}));function fP(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 ns;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(ns||(ns={}));var Pa;(r=>{r.DefaultUp=[0,1,0],r.DefaultTargetOffset=1e3,r.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:r.DefaultUp,isUpVectorFlipped:!1,targetOffset:r.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}r.getZoom=n})(Pa||(Pa={}));var Bs;(e=>{function i(n,r=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[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:[n[0]+n[0]*r,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+r)),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(n,r){let s={...n};if(dS.forEach(o=>{Object.assign(s,{[o]:r[o]??n[o]})}),s.radial={...n.radial},r.radial){let o=n.radial,a=r.radial;hS.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},r.linear){let o=n.linear,a=r.linear;fS.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},r.grid){let o=n.grid,a=r.grid;pS.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},r.toObject){let o=n.toObject,a=r.toObject;mS.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},r.randomnessObject){let o=n.randomnessObject,a=r.randomnessObject;gS.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Bs||(Bs={}));var fy;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(r,s){let o=[];r.count!==void 0&&o.push({type:0,path:s,props:{count:r.count}});for(let a of t){let l=r[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(fy||(fy={}));var dS=["count"],hS=["radius","start","end","position","scale","rotation"],fS=["position","scale","rotation"],pS=["count","size"],mS=["count","position","scale","rotation"],gS=["strength","scale","rotation","position","movement","seed","freqScale"];var py;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(py||(py={}));var my;(e=>{function i(n){return t(n)}e.defaultData=i;function t(n){if(n==="PointLight")return{type:n,color:Hr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(n==="SpotLight")return{type:n,color:Hr.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(n==="DirectionalLight")return{type:n,color:Hr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(my||(my={}));var Da;(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]})(Da||(Da={}));var yS;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,r){return n.castShadow===r.castShadow&&n.receiveShadow===r.receiveShadow}e.equals=t})(yS||(yS={}));var vS;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe}e.equals=t})(vS||(vS={}));var gy;(t=>t.defaultData={...vS.defaultData,...yS.defaultData})(gy||(gy={}));var pP;(t=>{function i(e,n){let r=[];if("material"in e){let s=typeof e.material=="string"?n.materials[e.material]??n.lib.materials[e.material]?.asset:e.material;s&&r.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?n.materials[s]??n.lib.materials[s]?.asset:s;o&&r.push(o)}return r}t.getMaterialData=i})(pP||(pP={}));var zu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(zu||(zu={}));var mP;(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})(mP||(mP={}));function yP(i){return i.type!=="displace"}var gP;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(gP||(gP={}));var yy=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],vP=["wrapping","image","video","name"],hr;(r=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}r.patch=i;function t(s,o){return s==="light"&&o?e(o):n(s)}r.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 n(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:zu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:dr.fromHex(Zn)};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:{...dr.fromHex(6710886),a:1},colorB:{...dr.fromHex(6710886),a:1},colorC:{...dr.fromHex(16777215),a:1},colorD:{...dr.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:Hr.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:Hr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Hr.fromHexAndA(0,1),contourColor:Hr.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:{...dr.fromHex(0),a:1},colorB:{...dr.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}}}})(hr||(hr={}));var Cn;(l=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${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 Re}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function r(u,c){return{...u,name:c}}l.withName=r;function s(u,c="layer1",d="layer2"){let h=new Re;return h.push({fi:0,data:hr.defaultData("light",u),id:c}),h.push({fi:1,data:hr.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=hr.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Re;return p.push({fi:0,data:f,id:d}),p.push({fi:1,data:hr.defaultData("light",c),id:h}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=hr.defaultData("video");Object.assign(f.texture,{video:u});let p=new Re;return p.push({fi:0,data:f,id:d}),p.push({fi:1,data:hr.defaultData("light",c),id:h}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Cn||(Cn={}));var Gu;(t=>{function i(){return{points:new Re,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Gu||(Gu={}));var Hu;(t=>{function i(){return{points:new Re,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Hu||(Hu={}));var xS={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var vy;(t=>{function i(e,n){let r={...e};return bS.forEach(s=>{Object.assign(r,{[s]:n[s]??e[s]})}),r}t.merge=i})(vy||(vy={}));var xy={shape:xS,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},bS=["depth","offset","angle","twist","startScale","endScale"];var kf;(e=>{function i(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=i;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(kf||(kf={}));var by;(t=>{function i(e,n){let r={...e};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...e.extrusion},Object.assign(r.extrusion,vy.merge(r.extrusion,n.extrusion))),r}t.merge=i})(by||(by={}));var Ia;(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:Hu.defaultData(),extrusion:xy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Gu.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})(Ia||(Ia={}));var SS=["width","height","depth"];var Sy;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:dr.white,near:.1,far:2e3})(Sy||(Sy={}));var ju;(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}}})(ju||(ju={}));var wS;(t=>t.defaultData={softShadowQuality:"low"})(wS||(wS={}));var AS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(AS||(AS={}));var ES;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(ES||(ES={}));var Oa;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Oa||(Oa={}));var _S;(t=>t.defaultData={playCamera:Li,gameControlObject:null})(_S||(_S={}));var wy;(t=>t.defaultData={backgroundColor:Hr.fromHexAndA(hP,1),postprocessing:ju.defaultData,fog:Sy.defaultData,globalPhysics:Oa.defaultData,ambient:AS.defaultData,ao:ES.defaultData,shadow:wS.defaultData,publish:_S.defaultData})(wy||(wy={}));var xP;(e=>{function i(n){return n==="Component"||n==="Instance"}e.isComponentRelated=i;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(xP||(xP={}));var Wu;(r=>{r.identity={...hy.identity,hiddenMatrix:Ma.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}r.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}}r.merge=e;function n(s,o){return uC({position:Ns.isEqual(s.position,o.position)?void 0:o.position,rotation:Ns.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Ns.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Ma.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}r.diff=n})(Wu||(Wu={}));var _r;(t=>t.defaultData={states:new Re,events:new Re,visible:!0,raycastLock:!1,physics:Da.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Wu.identity,cloner:null})(_r||(_r={}));var Ay;(t=>t.defaultData={type:"Empty",..._r.defaultData})(Ay||(Ay={}));var bP;(t=>t.defaultData={type:"Component",..._r.defaultData})(bP||(bP={}));var kl;(t=>t.defaultData={type:"Mesh",..._r.defaultData,...gy.defaultData})(kl||(kl={}));var Ul;(t=>t.defaultData={..._r.defaultData,...Wu.identity,position:[0,0,Pa.DefaultTargetOffset],...Pa.defaultData})(Ul||(Ul={}));var Ey;(e=>{function i(n){return{..._r.defaultData,...my.defaultData(n)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Ey||(Ey={}));var qu;(e=>{function i(n,r,s=0){for(;s<r.length;){let o=n?n[r[s]]:void 0;if(r.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(n,r,s=0){let o=i(n,r,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(qu||(qu={}));var Fs;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{..._r.defaultData,...a,component:o,overrides:new Yt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=n;function r(o){let a=Wu.fromObject(o.data);return n(o.id,a)}s.fromComponentData=r})(Fs||(Fs={}));var Lo;(t=>t.defaultData={type:"Page",..._r.defaultData,physics:{...Da.defaultData,fusedBody:!1},...wy.defaultData,camera:Ul.defaultData})(Lo||(Lo={}));var _y;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ma.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Da.defaultData,states:new Re,events:new Re,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Pa.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",..._r.defaultData,...kl.defaultData,geometry:Ia.defaultData("RectangleGeometry"),material:Cn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",..._r.defaultData,...kl.defaultData,geometry:Ia.defaultData("BooleanGeometry"),material:Cn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",..._r.defaultData,...kl.defaultData,geometry:Ia.defaultData("TextGeometry"),material:Cn.defaultTwoLayerData("phong","layer1","layer2")}))(_y||(_y={}));var No;(r=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Yt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Yt})))):ns.is(s.type)&&(a.perspective={},a.orthographic={}),a}r.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=Aa(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&hr.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Aa(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&hr.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,p]of Object.entries(h.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",f],props:g,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...fy.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,p]of Object.entries(h))c(["materials",f],p);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}r.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Wu.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})}),ns.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:by.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(py.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=dr.clone(l.color))}return a}r.patch=n})(No||(No={}));var Xu;(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})(Xu||(Xu={}));var Vs;(t=>t.defaultData={orbitControls:Xu.defaultData,playPage:Ca,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let r=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?r=30:(n===4||n===11||n===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Vs||(Vs={}));var TS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(TS||(TS={}));var MS;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(MS||(MS={}));var Ra;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...TS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:MS.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ra||(Ra={}));var La;(e=>{function i(n){return n.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(n,r,s){n.scene.objects.traverseFrom(r,(o,a)=>{if(a.type==="Instance"){let l=Ku.getComponentData(n,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(La||(La={}));var Na;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=_y.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:Ey.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 d=new cn;return d.push({fi:1,id:Ca,data:{...Lo.defaultData,name:"Scene 1"},children:u}),d}a.defaultData={objects:t(),publish:Vs.defaultData,styles:Ra.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new cn,publish:Vs.defaultData,styles:Ra.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:Vs.defaultData,styles:Ra.defaultData()}};function s(l){return{...a.defaultData,objects:Qr(l,cn.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(Na||(Na={}));var Qu;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Qu||(Qu={}));var Zu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Zu||(Zu={}));var fr;(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 n(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=n;function r(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=r})(fr||(fr={}));var CS;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(CS||(CS={}));var SP;(t=>t.all=[...CS.all,"components"])(SP||(SP={}));var wP;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(wP||(wP={}));var Ba;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(Ba||(Ba={}));var $r;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Qr(o,tt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Zu.emptyImage,name:"AI generated image"}),Qr(a,tt.prototype)}s.defaultImages=t;function e(){return{catelogs:new tt,materials:new tt,images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,variables:new Re,lib:Ba.defaultData()}}s.emptyData=e;function n(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=n;function r(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=r})($r||($r={}));var Ju;(t=>t.list=["idle","move","jump","run"])(Ju||(Ju={}));var $u;(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 Re,move:new Re,jump:new Re,run:new Re},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Hr.fromHexAndA(3728051,1)}}))($u||($u={}));function AP(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,r=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)r.push(r[1]),s.push(1);let o={...Si(pn(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:r,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={...pn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Bo(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Fo(i,t){i.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach((r,s)=>{r===void 0&&(n.materials[s]=Cn.defaultData(),r=n.materials[s]),typeof r!="string"&&t(r)}):"material"in n?typeof n.material!="string"&&(n.material===void 0&&(n.material=Cn.defaultData()),t(n.material)):n.type==="Mesh"&&(n.material===void 0&&(n.material=Cn.defaultData()),t(n.material)),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&t(r.material)})})}function Uj(i){Object.assign(i.scene.publish,{orbitControls:{...Xu.defaultData,...pn(i.scene.publish.orbitControls)}})}function zj(i){Object.assign(i.scene.publish.settings,{video:{...Vs.defaultData.settings.video,...pn(i.scene.publish.settings.video)}})}function Gj(i){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[r,s]of Object.entries(n))if((yy.includes(r)||typeof s=="boolean")&&delete n[r],r==="texture")for(let[o,a]of Object.entries(s))(vP.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,n)=>{n.states.forEach(r=>{let s=r;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function Hj(i){i.scene.publish.withBackground=!0}function jj(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Wj(i){i.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(r=>r+1),n.linear.scale=n.linear.scale.map(r=>r+1))})}function qj(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function Yj(i){i.scene.objects.traverse((t,e)=>{let n=i.scene.objects.unproxy().parent(t);if(n){let r=pn(i.scene.objects.data(n));r&&r.type==="Mesh"&&r.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=pn(e).booleanExclude!==!0)}})}function Xj(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function Kj(i){function t(n){Object.setPrototypeOf(n,Yt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Yt.prototype)}function e(n){Object.setPrototypeOf(n,Yt.prototype);for(let r in n)t(n[r])}i.scene.objects.traverse((n,r)=>{r.states.forEach(s=>{let o=s;if(o.material){let a=pn(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=pn(l).layers;e(u),l.layers=u}})})}function EP(i){i.layers===void 0&&Object.assign(i,Cn.defaultTwoLayerData("lambert"))}function PS(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 n=[...t.steps];n.push(t.steps[9]);let r={...pn(t),colors:e,steps:n};Object.assign(t,r)}})}function Qj(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function _P(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&PS(n)}):"material"in e&&typeof e.material!="string"&&PS(e.material)}),Object.values(i.shared.materials).forEach(t=>PS(t))}function Zj(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 Jj(i){i.shared.audios=Qr({},tt.prototype)}function $j(i){i.shared.videos=Qr({},tt.prototype)}function eW(i){let t=i.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let r={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]:r})}})}function tW(i){Object.entries(pn(i.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.images[n]}),Object.entries(pn(i.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.audios[n]})}function nW(i){i.scene.publish.settings.web.preload=!1}function TP(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 MP(i){i.layers&&i.layers.forEach(t=>{yP(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 rW(i){i.shared.fonts=Qr({},tt.prototype)}function iW(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 sW(i){let t=[];i.scene.objects.traverse((e,n)=>{let r=n;if(r.type==="TextFrame"){let s=Cn.defaultTwoLayerData("phong"),o=typeof r.color=="string"?i.shared.colors[r.color]:r.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=r.alpha;let a=iW(r.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:r.name,..._r.defaultData,...kl.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ia.defaultData("TextGeometry"),width:r.width,height:r.height,font:a,depth:0,horizontalAlign:r.horizontalAlign,verticalAlign:r.verticalAlign,fontSize:r.fontSize*1.40625,lineHeight:r.lineHeight/1.40625,letterSpacing:r.letterSpacing-1,text:r.text,textTransform:r.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:pn(r.states),events:pn(r.events),visible:r.visible,raycastLock:r.raycastLock,position:r.position,rotation:r.rotation,scale:r.scale,hiddenMatrix:r.hiddenMatrix},u=pn(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 oW(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,n)=>{n.events.forEach(r=>{if(!!t[Number(r.type)])if(Object.assign(r,{type:t[Number(r.type)]}),r.type==="Audio"&&"audioEvent"in r&&(Object.assign(r,{playAudio:r.audioEvent}),delete r.audioEvent),r.type==="GameControl")Object.assign(r,{gameActions:{idle:new Re,move:new Re,jump:new Re}});else{let s=new Re;Object.assign(r,{actions:s}),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp")&&"url"in r&&s.push({fi:0,id:we.generateUUID(),data:{type:"Link",url:r.url,delay:0}}),"targets"in r&&(r.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,Si(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Re({fi:0,id:we.generateUUID(),data:u},{fi:1,id:we.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete r.targets)}})})}function aW(i){i.scene.objects.traverse((t,e)=>{function n(r,s){let o=new Re,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Si(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")&&(d={...Si(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===r)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:we.generateUUID(),data:{type:r,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function CP(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=hr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function PP(i){Bo(i,CP),Fo(i,CP)}function lW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function cW(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 uW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Cn.defaultTwoLayerData("phong"))})}function dW(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 hW(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 fW(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 pW(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function mW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function gW(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function yW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=$u.defaultDataThirdPerson.navmesh)})})}function vW(i){i.scene.styles||(i.scene.styles=Ra.defaultData())}function DP(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function xW(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}),Fo(i,DP),Bo(i,DP)}function bW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&Object.assign(n.gameActions,{run:new Re})})})}function SW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.keyAssignments=[...n.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function IP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function OP(i,t){if(t<1&&(Fo(i,AP),Bo(i,AP),i.schema=1),t<2&&(Uj(i),i.schema=2),t<3&&(Gj(i),i.schema=3),t<4&&(Hj(i),i.schema=4),t<5&&(jj(i),i.schema=5),t<6&&(Wj(i),i.schema=6),t<7&&(qj(i),i.schema=7),t<8&&(i.schema=8),t<9&&(_P(i),i.schema=9),t<10&&(Qj(i),i.schema=10),t<11&&(Zj(i),i.schema=11),t<12&&(_P(i),i.schema=12),t<13&&(Jj(i),i.schema=13),t<14&&(eW(i),i.schema=14),t<15&&(tW(i),i.schema=15),t<16&&(nW(i),i.schema=16),t<17&&(Fo(i,TP),Bo(i,TP),i.schema=17),t<18&&(Fo(i,EP),Bo(i,EP),i.schema=18),t<19&&(zj(i),i.schema=19),t<20&&(rW(i),sW(i),i.schema=20),t<21&&(oW(i),aW(i),i.schema=21),t<22&&(PP(i),i.schema=22),t<23&&(lW(i),i.schema=23),t<24&&(cW(i),i.schema=24),(t<25||i.shared.videos===void 0)&&($j(i),t<25&&(i.schema=25)),t<26&&(Yj(i),i.schema=26),t<27&&(Xj(i),i.schema=27),t<28&&(PP(i),i.schema=28),t<29&&(Kj(i),i.schema=29),t<30&&(uW(i),i.schema=30),t<31&&(dW(i),i.schema=31),t<33&&(hW(i),i.schema=33),t<34&&(fW(i),i.schema=34),t<35&&(pW(i),i.schema=35),t<36&&(mW(i),i.schema=36),t<37&&(gW(i),i.schema=37),t<38&&(Fo(i,MP),Bo(i,MP),i.schema=38),t<39&&(yW(i),i.schema=39),t<40&&(vW(i),i.schema=40),t<41&&(xW(i),i.schema=41),t<42&&(bW(i),i.schema=42),t<43&&(SW(i),i.schema=43),t<99){Fo(i,IP),Bo(i,IP),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Li);let e=pn(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=Ca,n.insertBefore(null,null,[{id:Ca,data:{...Lo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Si(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Si(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Oa.defaultData,...Si(i.scene.environment,"usePhysics","gravity")},camera:pn(i.scene.ownerCamera)??Lo.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Na.TRASH_CAN_ID&&n.move(Ca,o.fi,o.id);let r=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(r,2)],r+=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,Da.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function RP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function wW(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}var ed=180/Math.PI;function LP(i){i.rotation=i.rotation.slice(0,3).map(t=>t*ed)}function NP(i){LP(i),i.type==="Page"&&LP(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(n=>n*ed))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=t.thetaLength*ed),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ed),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ed,t.extrusion.twist*=ed),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(pn(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 AW(i){i.shared.variables=Qr({},tt.prototype)}function EW(i){let t=pn(i.shared.variables);i.shared.variables=Qr(Object.entries(t??{}).map(([e,n],r)=>({fi:r,id:e,data:n})),Re.prototype)}var Vo=107;function BP(i,t){t(i.data);for(let e of i.children)BP(e,t)}function _W(i){let t=i.schema??104;t!==Vo&&t<105&&(BP(i.asset,NP),i.schema=105)}function Ty(i){let t=i.schema??0;if(t!==Vo){console.warn("updating from ",t,"to ",Vo),OP(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Vs.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Fo(i,RP),Bo(i,RP),i.schema=101),t<102&&(wW(i),i.schema=102),t<104&&(i.shared.catelogs=new tt,i.shared.lib=Ba.defaultData(),i.schema=104),t<105&&(AW(i),i.scene.objects.traverse((e,n)=>{NP(n)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))_W(e);t<106&&(EW(i),i.schema=106),t<107&&(i.shared.lib.variables=Ba.defaultData().variables,i.schema=107)}}var Ku;(a=>{a.defaultData={schema:Vo,scene:Na.defaultData,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qu.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors()}},a.emptyDataForImports=function(l){let u=Na.emptyDataWithPage(l);return{schema:Vo,scene:u,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qu.defaultData),shared:{...$r.emptyData(),colors:$r.defaultColors(),images:$r.defaultImages(l)}}},a.emptyData=function(){return{schema:Vo,scene:Na.emptyDataWithPage(),frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qu.defaultData),shared:$r.emptyData()}},a.collabHelper={...Rf,updateSchema(l){return(l.schema??0)<Vo?Aa(l,Ty):(l.schema??0)-Vo}};function r(l){let u=a.collabHelper.updateSchema(l);return typeof u=="number"?u===0?l:null:u.data}a.updateSchemaDirectly=r;function s(l){return{...l,shared:{...l.shared,lib:Ba.defaultData()}}}a.withoutLib=s;function o(l,u){let c=l.scene.objects.get(u);if(c&&c.data.type==="Component")return c;{let d=l.shared.lib.components[u];if(d)return d.asset}}a.getComponentData=o})(Ku||(Ku={}));function rs(i,t=!1){let e=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ee,u=0;for(let c=0;c<i.length;++c){let d=i[c],h=0;if(e!==(d.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 d.attributes){if(!n.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(d.attributes[f]),h++}if(h!==n.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!==d.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 d.morphAttributes){if(!r.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(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=d.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,d=[];for(let h=0;h<i.length;++h){let f=i[h].index;for(let p=0;p<f.count;++p)d.push(f.getX(p)+c);c+=i[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=FP(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][h]);let p=FP(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 FP(i){let t,e,n,r=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(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=l.array.length}let s=new t(r),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,n)}var VP=Math.pow(2,-24);var zl=class{constructor(){}};function Ni(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 DS(i){let t=-1,e=-1/0;for(let n=0;n<3;n++){let r=i[n+3]-i[n];r>e&&(e=r,t=n)}return t}function IS(i,t){t.set(i)}function OS(i,t,e){let n,r;for(let s=0;s<3;s++){let o=s+3;n=i[s],r=t[s],e[s]=n<r?n:r,n=i[o],r=t[o],e[o]=n>r?n:r}}function Uf(i,t,e){for(let n=0;n<3;n++){let r=t[i+2*n],s=t[i+2*n+1],o=r-s,a=r+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function td(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function CW(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r;e>65535?r=new Uint32Array(new n(4*e)):r=new Uint16Array(new n(2*e)),i.setIndex(new Ge(r,1));for(let s=0;s<e;s++)r[s]=s}}function PW(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let r of i.groups)e.add(r.start),e.add(r.start+r.count);let n=Array.from(e.values()).sort((r,s)=>r-s);for(let r=0;r<n.length-1;r++){let s=n[r],o=n[r+1];t.push({offset:s/3,count:(o-s)/3})}return t}function LS(i,t,e,n,r=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=r!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=i[v+0],w=i[v+1],E=b-w,_=b+w;E<s&&(s=E),_>l&&(l=_),y&&b<d&&(d=b),y&&b>p&&(p=b);let S=i[v+2],T=i[v+3],M=S-T,C=S+T;M<o&&(o=M),C>u&&(u=C),y&&S<h&&(h=S),y&&S>m&&(m=S);let D=i[v+4],P=i[v+5],I=D-P,L=D+P;I<a&&(a=I),L>c&&(c=L),y&&D<f&&(f=D),y&&D>g&&(g=D)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(r[0]=d,r[1]=h,r[2]=f,r[3]=p,r[4]=m,r[5]=g)}function DW(i,t,e,n){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=i[c+0];h<r&&(r=h),h>a&&(a=h);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)}n[0]=r,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function IW(i,t,e,n,r){let s=e,o=e+n-1,a=r.pos,l=r.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 d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var ko=32,OW=(i,t)=>i.candidate-t.candidate,Fa=new Array(ko).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),My=new Float32Array(6);function RW(i,t,e,n,r,s){let o=-1,a=0;if(s===0)o=DS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=DS(i),o!==-1&&(a=LW(e,n,r,o));else if(s===2){let l=td(i),u=1.25*r,c=n*6,d=(n+r)*6;for(let h=0;h<3;h++){let f=t[h],g=(t[h+3]-f)/ko;if(r<ko/4){let y=[...Fa];y.length=r;let v=0;for(let b=c;b<d;b+=6,v++){let w=y[v];w.candidate=e[b+2*h],w.count=0;let{bounds:E,leftCacheBounds:_,rightCacheBounds:S}=w;for(let T=0;T<3;T++)S[T]=1/0,S[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0,E[T]=1/0,E[T+3]=-1/0;Uf(b,e,E)}y.sort(OW);let x=r;for(let b=0;b<x;b++){let w=y[b];for(;b+1<x&&y[b+1].candidate===w.candidate;)y.splice(b+1,1),x--}for(let b=c;b<d;b+=6){let w=e[b+2*h];for(let E=0;E<x;E++){let _=y[E];w>=_.candidate?Uf(b,e,_.rightCacheBounds):(Uf(b,e,_.leftCacheBounds),_.count++)}}for(let b=0;b<x;b++){let w=y[b],E=w.count,_=r-w.count,S=w.leftCacheBounds,T=w.rightCacheBounds,M=0;E!==0&&(M=td(S)/l);let C=0;_!==0&&(C=td(T)/l);let D=1+1.25*(M*E+C*_);D<u&&(o=h,u=D,a=w.candidate)}}else{for(let x=0;x<ko;x++){let b=Fa[x];b.count=0,b.candidate=f+g+x*g;let w=b.bounds;for(let E=0;E<3;E++)w[E]=1/0,w[E+3]=-1/0}for(let x=c;x<d;x+=6){let E=~~((e[x+2*h]-f)/g);E>=ko&&(E=ko-1);let _=Fa[E];_.count++,Uf(x,e,_.bounds)}let y=Fa[ko-1];IS(y.bounds,y.rightCacheBounds);for(let x=ko-2;x>=0;x--){let b=Fa[x],w=Fa[x+1];OS(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<ko-1;x++){let b=Fa[x],w=b.count,E=b.bounds,S=Fa[x+1].rightCacheBounds;w!==0&&(v===0?IS(E,My):OS(E,My,My)),v+=w;let T=0,M=0;v!==0&&(T=td(My)/l);let C=r-v;C!==0&&(M=td(S)/l);let D=1+1.25*(T*v+M*C);D<u&&(o=h,u=D,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function LW(i,t,e,n){let r=0;for(let s=t,o=t+e;s<o;s++)r+=i[s*6+n*2];return r/e}function NW(i,t){let e=i.attributes.position,n=i.index.array,r=n.length/3,s=new Float32Array(r*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 d=0;d<r;d++){let h=d*3,f=d*6,p,m,g;o?(p=n[h+0],m=n[h+1],g=n[h+2]):(p=n[h+0]*u+l,m=n[h+1]*u+l,g=n[h+2]*u+l);for(let y=0;y<3;y++){let v,x,b;o?(v=e[c[y]](p),x=e[c[y]](m),b=e[c[y]](g)):(v=a[p+y],x=a[m+y],b=a[g+y]);let w=v;x<w&&(w=x),b<w&&(w=b);let E=v;x>E&&(E=x),b>E&&(E=b);let _=(E-w)/2,S=y*2;s[f+S+0]=w+_,s[f+S+1]=_+(Math.abs(w)+_)*VP,w<t[y]&&(t[y]=w),E>t[y+3]&&(t[y+3]=E)}}return s}function BW(i,t){function e(y){h&&h(y/f)}function n(y,v,x,b=null,w=0){if(!p&&w>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||w>=l)return e(v+x),y.offset=v,y.count=x,y;let E=RW(y.boundingData,b,o,v,x,d);if(E.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let _=IW(a,o,v,x,E);if(_===v||_===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=E.axis;let S=new zl,T=v,M=_-v;y.left=S,S.boundingData=new Float32Array(6),LS(o,T,M,S.boundingData,s),n(S,T,M,s,w+1);let C=new zl,D=_,P=x-M;y.right=C,C.boundingData=new Float32Array(6),LS(o,D,P,C.boundingData,s),n(C,D,P,s,w+1)}return y}CW(i,t);let r=new Float32Array(6),s=new Float32Array(6),o=NW(i,r),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=i.index.count/3,p=!1,m=[],g=PW(i);if(g.length===1){let y=g[0],v=new zl;v.boundingData=r,DW(o,y.offset,y.count,s),n(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new zl;v.boundingData=new Float32Array(6),LS(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),m.push(v)}return m}function zP(i,t){let e=BW(i,t),n,r,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),r=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,p=!!d.count,m=d.boundingData;for(let g=0;g<6;g++)n[h+g]=m[g];if(p){let g=d.offset,y=d.count;return r[h+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=d.left,y=d.right,v=d.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 r[h+6]=x/4,x=u(x,y),r[h+7]=v,x}}}var ei=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,r=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}setFromPoints(t,e){let n=1/0,r=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}};ei.prototype.setFromBox=function(){let i=new A;return function(e,n){let r=n.min,s=n.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=r.x*l+s.x*(1-l),i.y=r.y*u+s.y*(1-u),i.z=r.z*c+s.z*(1-c);let d=e.dot(i);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var fce=function(){let i=new ei;return function(e,n){let r=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let d=o[c],h=s[c];if(i.setFromPoints(h,a),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(i.setFromPoints(h,r),d.isSeparated(i))return!1}}}();var FW=function(){let i=new A,t=new A,e=new A;return function(r,s,o){let a=r.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),p=e.dot(l),g=l.dot(l)*f-h*h,y,v;g!==0?y=(d*h-p*f)/g:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),zf=function(){let i=new B,t=new A,e=new A;return function(r,s,o,a){FW(r,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){r.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=r.start:c=r.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),GP=function(){let i=new A,t=new A,e=new En,n=new Xn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(n.start=c,n.end=d,n.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 VW=1e-15;function nd(i){return Math.abs(i)<VW}var ti=class extends an{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new ei),this.points=[this.a,this.b,this.c],this.sphere=new ln,this.plane=new En,this.needsUpdate=!0}intersectsSphere(t){return GP(t,this)}update(){let t=this.a,e=this.b,n=this.c,r=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,r);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,r);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,r);let f=s[3],p=o[3];f.subVectors(n,t),p.setFromPoints(f,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};ti.prototype.closestPointToSegment=function(){let i=new A,t=new A,e=new Xn;return function(r,s=null,o=null){let{start:a,end:l}=r,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),zf(e,r,i,t),c=i.distanceToSquared(t),c<d&&(d=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(d)}}();ti.prototype.intersectsTriangle=function(){let i=new ti,t=new Array(3),e=new Array(3),n=new ei,r=new ei,s=new A,o=new A,a=new A,l=new A,u=new Xn,c=new Xn,d=new Xn;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 E=0;E<4;E++){let _=v[E],S=x[E];if(n.setFromPoints(S,e),_.isSeparated(n))return!1}let b=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let E=0;E<4;E++){let _=b[E],S=w[E];if(n.setFromPoints(S,t),_.isSeparated(n))return!1}for(let E=0;E<4;E++){let _=x[E];for(let S=0;S<4;S++){let T=w[S];if(s.crossVectors(_,T),n.setFromPoints(s,t),r.setFromPoints(s,e),n.isSeparated(r))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,b=0;for(let I=0;I<3;I++){let L=v[I],H=v[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(o);let k=x?c.start:c.end,G=nd(y.distanceToPoint(L));if(nd(y.normal.dot(o))&&G){c.copy(u),b=2;break}if((y.intersectLine(u,k)||G)&&!nd(k.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let w=f.points,E=!1,_=0;for(let I=0;I<3;I++){let L=w[I],H=w[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(a);let k=E?d.start:d.end,G=nd(g.distanceToPoint(L));if(nd(g.normal.dot(a))&&G){d.copy(u),_=2;break}if((g.intersectLine(u,k)||G)&&!nd(k.distanceTo(H))){if(_++,E)break;E=!0}}if(_===1&&this.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(_!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let I=d.start;d.start=d.end,d.end=I}let S=c.start.dot(o),T=c.end.dot(o),M=d.start.dot(o),C=d.end.dot(o),D=T<M,P=S<C;return S!==C&&M!==T&&D===P?!1:(p&&(l.subVectors(c.start,d.start),l.dot(o)>0?p.start.copy(c.start):p.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(d.end)),!0)}}}();ti.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();ti.prototype.distanceToTriangle=function(){let i=new A,t=new A,e=["a","b","c"],n=new Xn,r=new Xn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],p=o[f];this.closestPointToPoint(p,i),h=p.distanceToSquared(i),h<c&&(c=h,a&&a.copy(i),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,i),h=m.distanceToSquared(i),h<c&&(c=h,a&&a.copy(m),l&&l.copy(i))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];r.set(o[m],o[g]),zf(n,r,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var ni=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new A,this.max=new A,this.matrix=new se,this.invMatrix=new se,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new ei),this.alignedSatBounds=new Array(3).fill().map(()=>new ei),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};ni.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,r=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=r[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=r[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=r[h];c.subVectors(a,f),d.setFromPoints(c,r)}let l=this.alignedSatBounds;l[0].setFromPointsField(r,"x"),l[1].setFromPointsField(r,"y"),l[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ni.prototype.intersectsBox=function(){let i=new ei;return function(e){this.needsUpdate&&this.update();let n=e.min,r=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=n.x,i.max=r.x,a[0].isSeparated(i)||(i.min=n.y,i.max=r.y,a[1].isSeparated(i))||(i.min=n.z,i.max=r.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}}();ni.prototype.intersectsTriangle=function(){let i=new ti,t=new Array(3),e=new ei,n=new ei,r=new A;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 h=0;h<3;h++){let f=a[h],p=l[h];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],p=c[h];if(e.setFromPoints(p,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let p=0;p<4;p++){let m=c[p];if(r.crossVectors(f,m),e.setFromPoints(r,t),n.setFromPoints(r,d),e.isSeparated(n))return!1}}return!0}}();ni.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}}();ni.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();ni.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Xn),e=new Array(12).fill().map(()=>new Xn),n=new A,r=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(r),this.closestPointToPoint(r,n),o.closestPointToPoint(n,r),l&&l.copy(n),u&&u.copy(r)),0;let c=a*a,d=o.min,h=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];r.copy(y).clamp(d,h);let v=y.distanceToSquared(r);if(v<p&&(p=v,l&&l.copy(y),u&&u.copy(r),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,b=(g+2)%3,w=y<<x|v<<b,E=1<<g|y<<x|v<<b,_=f[w],S=f[E];t[m].set(_,S);let M=i[g],C=i[x],D=i[b],P=e[m],I=P.start,L=P.end;I[M]=d[M],I[C]=y?d[C]:h[C],I[D]=v?d[D]:h[C],L[M]=h[M],L[C]=y?d[C]:h[C],L[D]=v?d[D]:h[C],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){r.x=g?h.x:d.x,r.y=y?h.y:d.y,r.z=v?h.z:d.z,this.closestPointToPoint(r,n);let x=r.distanceToSquared(n);if(x<p&&(p=x,l&&l.copy(n),u&&u.copy(r),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];zf(y,x,n,r);let b=n.distanceToSquared(r);if(b<p&&(p=b,l&&l.copy(n),u&&u.copy(r),b<c))return Math.sqrt(b)}}return Math.sqrt(p)}}();var rd=new A,id=new A,sd=new A,Py=new B,Dy=new B,Iy=new B,HP=new A,jP=new A,WP=new A,Oy=new A;function kW(i,t,e,n,r,s){let o;return s===Un?o=i.intersectTriangle(n,e,t,!0,r):o=i.intersectTriangle(t,e,n,s!==Ur,r),o===null?null:{distance:i.origin.distanceTo(r),point:r.clone()}}function UW(i,t,e,n,r,s,o,a,l){rd.fromBufferAttribute(t,s),id.fromBufferAttribute(t,o),sd.fromBufferAttribute(t,a);let u=kW(i,rd,id,sd,Oy,l);if(u){n&&(Py.fromBufferAttribute(n,s),Dy.fromBufferAttribute(n,o),Iy.fromBufferAttribute(n,a),u.uv=an.getInterpolation(Oy,rd,id,sd,Py,Dy,Iy,new B)),r&&(Py.fromBufferAttribute(r,s),Dy.fromBufferAttribute(r,o),Iy.fromBufferAttribute(r,a),u.uv1=an.getInterpolation(Oy,rd,id,sd,Py,Dy,Iy,new B)),e&&(HP.fromBufferAttribute(e,s),jP.fromBufferAttribute(e,o),WP.fromBufferAttribute(e,a),u.normal=an.getInterpolation(Oy,rd,id,sd,HP,jP,WP,new A),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new A,materialIndex:0};an.getNormal(rd,id,sd,c.normal),u.face=c,u.faceIndex=s}return u}function BS(i,t,e,n,r){let s=n*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:d,uv1:h}=i.attributes,f=UW(e,u,c,d,h,o,a,l,t);return f?(f.faceIndex=n,r&&r.push(f),f):null}function qP(i,t,e,n,r,s){for(let o=n,a=n+r;o<a;o++)BS(i,t,e,o,s)}function YP(i,t,e,n,r){let s=1/0,o=null;for(let a=n,l=n+r;a<l;a++){let u=BS(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Bi(i,t,e,n){let r=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)),r.x=n.getX(a),r.y=n.getY(a),r.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function FS(i,t,e,n,r,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Bi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,r,s))return!0;return!1}var od=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 Uo(i,t){return t[i+15]===65535}function Gl(i,t){return t[i+6]}function ad(i,t){return t[i+14]}function ld(i){return i+8}function cd(i,t){return t[i+6]}function XP(i,t){return t[i+7]}var ud=new Tt,Ly=new A,GW=["x","y","z"];function Ny(i,t,e,n,r){let s=i*2,o=dd,a=Va,l=ka;if(Uo(s,a)){let c=Gl(i,l),d=ad(s,a);qP(t,e,n,c,d,r)}else{let c=ld(i);Fy(c,o,n,Ly)&&Ny(c,t,e,n,r);let d=cd(i,l);Fy(d,o,n,Ly)&&Ny(d,t,e,n,r)}}function By(i,t,e,n){let r=i*2,s=dd,o=Va,a=ka;if(Uo(r,o)){let u=Gl(i,a),c=ad(r,o);return YP(t,e,n,u,c)}else{let u=XP(i,a),c=GW[u],h=n.direction[c]>=0,f,p;h?(f=ld(i),p=cd(i,a)):(f=cd(i,a),p=ld(i));let g=Fy(f,s,n,Ly)?By(f,t,e,n):null;if(g){let x=g.point[c];if(h?x<=s[p+u]:x>=s[p+u+3])return g}let v=Fy(p,s,n,Ly)?By(p,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var KP=function(){let i,t,e=[],n=new od(()=>new Tt);return function(...o){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let a=r(...o);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function r(s,o,a,l,u=null,c=0,d=0){function h(x){let b=x*2,w=Va,E=ka;for(;!Uo(b,w);)x=ld(x),b=x*2;return Gl(x,E)}function f(x){let b=x*2,w=Va,E=ka;for(;!Uo(b,w);)x=cd(x,E),b=x*2;return Gl(x,E)+ad(b,w)}let p=s*2,m=dd,g=Va,y=ka;if(Uo(p,g)){let x=Gl(s,y),b=ad(p,g);return Ni(s,m,i),l(x,b,!1,d,c+s,i)}else{let x=ld(s),b=cd(s,y),w=x,E=b,_,S,T,M;if(u&&(T=i,M=t,Ni(w,m,T),Ni(E,m,M),_=u(T),S=u(M),S<_)){w=b,E=x;let k=_;_=S,S=k,T=M}T||(T=i,Ni(w,m,T));let C=Uo(w*2,g),D=a(T,C,_,d+1,c+w),P;if(D===2){let k=h(w),z=f(w)-k;P=l(k,z,!0,d+1,c+w,T)}else P=D&&r(w,o,a,l,u,c,d+1);if(P)return!0;M=t,Ni(E,m,M);let I=Uo(E*2,g),L=a(M,I,S,d+1,c+E),H;if(L===2){let k=h(E),z=f(E)-k;H=l(k,z,!0,d+1,c+E,M)}else H=L&&r(E,o,a,l,u,c,d+1);return!!H}}}(),QP=function(){let i=new ti,t=new ti,e=new se,n=new ni,r=new ni;return function s(o,a,l,u,c=null){let d=o*2,h=dd,f=Va,p=ka;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),Uo(d,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,b=l.attributes.position,w=Gl(o,p),E=ad(d,f);if(e.copy(u).invert(),l.boundsTree)return Ni(o,h,r),r.matrix.copy(e),r.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>r.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(u),S.b.applyMatrix4(u),S.c.applyMatrix4(u),S.needsUpdate=!0;for(let T=w*3,M=(E+w)*3;T<M;T+=3)if(Bi(t,T,y,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let _=w*3,S=E+w*3;_<S;_+=3){Bi(i,_,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let T=0,M=x.count;T<M;T+=3)if(Bi(t,T,x,b),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return Ni(g,h,ud),!!(c.intersectsBox(ud)&&s(g,a,l,u,c)||(Ni(y,h,ud),c.intersectsBox(ud)&&s(y,a,l,u,c)))}}}();function Fy(i,t,e,n){return Ni(i,t,ud),e.intersectBox(ud,n)}var VS=[],Ry,dd,Va,ka;function hd(i){Ry&&VS.push(Ry),Ry=i,dd=new Float32Array(i),Va=new Uint16Array(i),ka=new Uint32Array(i)}function Gf(){Ry=null,dd=null,Va=null,ka=null,VS.length&&hd(VS.pop())}var kS=Symbol("skip tree generation"),US=new Tt,zS=new Tt,fd=new se,Hl=new ni,Hf=new ni,jf=new A,Vy=new A,HW=new A,jW=new A,WW=new A,ZP=new Tt,ks=new od(()=>new ti),Us=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."),Us.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,r=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:r.map(a=>a.slice()),index:s.array.slice()}:o={roots:r,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Us.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:r,roots:s}=t,o=new Us(e,{...n,[kS]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==r&&(a.array.set(r),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,[kS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[kS]||(this._roots=zP(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Tt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,r=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let h=0,f=c.length;h<f;h++)s=c[h],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,u),u+=s.byteLength;function d(h,f,p=!1){let m=h*2;if(a[m+15]===65535){let y=o[h+6],v=a[m+14],x=1/0,b=1/0,w=1/0,E=-1/0,_=-1/0,S=-1/0;for(let T=3*y,M=3*(y+v);T<M;T++){let C=n[T],D=r.getX(C),P=r.getY(C),I=r.getZ(C);D<x&&(x=D),D>E&&(E=D),P<b&&(b=P),P>_&&(_=P),I<w&&(w=I),I>S&&(S=I)}return l[h+0]!==x||l[h+1]!==b||l[h+2]!==w||l[h+3]!==E||l[h+4]!==_||l[h+5]!==S?(l[h+0]=x,l[h+1]=b,l[h+2]=w,l[h+3]=E,l[h+4]=_,l[h+5]=S,!0):!1}else{let y=h+8,v=o[h+6],x=y+f,b=v+f,w=p,E=!1,_=!1;t?w||(E=t.has(x),_=t.has(b),w=!E&&!_):(E=!0,_=!0);let S=w||E,T=w||_,M=!1;S&&(M=d(y,f,w));let C=!1;T&&(C=d(v,f,w));let D=M||C;if(D)for(let P=0;P<3;P++){let I=y+P,L=v+P,H=l[I],k=l[I+3],G=l[L],z=l[L+3];l[h+P]=H<G?H:G,l[h+P+3]=k>z?k:z}return D}}}traverse(t,e=0){let n=this._roots[e],r=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=r[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=r[a+6],f=r[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=mi){let n=this._roots,r=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=r.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(hd(n[c]),Ny(0,r,h,t,s),Gf(),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=mi){let n=this._roots,r=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=r.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;hd(n[c]);let f=By(0,r,h,t);Gf(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,r=!1;for(let s of this._roots)if(hd(s),r=QP(0,n,t,e),Gf(),r)break;return r}shapecast(t,e,n){let r=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,p,m,g)=>{let y=p*3;return h(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:n,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=ks.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,p,m,g,y)=>h(f,p,m,g,y)?!0:FS(f,p,r,u,m,g,s)}else l||(u?l=(h,f,p,m)=>FS(h,f,r,u,p,m,s):l=(h,f,p)=>p);let c=!1,d=0;for(let h of this._roots){if(hd(h),c=KP(0,r,a,l,o,d),Gf(),c)break;d+=h.byteLength}return ks.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:r,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;fd.copy(e).invert();let c=ks.getPrimitive(),d=ks.getPrimitive();if(s){let f=function(p,m,g,y,v,x,b,w){for(let E=g,_=g+y;E<_;E++){Bi(d,E*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let S=p,T=p+m;S<T;S++)if(Bi(c,S*3,o,a),c.needsUpdate=!0,s(c,d,S,E,v,x,b,w))return!0}return!1};if(r){let p=r;r=function(m,g,y,v,x,b,w,E){return p(m,g,y,v,x,b,w,E)?!0:f(m,g,y,v,x,b,w,E)}}else r=f}t.getBoundingBox(zS),zS.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>zS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(US.copy(v),US.applyMatrix4(fd),t.shapecast({intersectsBounds:x=>US.intersectsBox(x),intersectsRange:(x,b,w,E,_)=>r(f,p,x,b,g,y,E,_)}))});return ks.releasePrimitive(c),ks.releasePrimitive(d),h}intersectsBox(t,e){return Hl.set(t.min,t.max,e),Hl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Hl.intersectsBox(n),intersectsTriangle:n=>Hl.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Hl.set(t.boundingBox.min,t.boundingBox.max,e),Hl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=ks.getPrimitive(),f=ks.getPrimitive(),p=Vy,m=HW,g=null,y=null;r&&(g=jW,y=WW);let v=1/0,x=null,b=null;return fd.copy(e).invert(),Hf.matrix.copy(fd),this.shapecast({boundsTraverseOrder:w=>Hl.distanceToBox(w),intersectsBounds:(w,E,_)=>_<v&&_<o?(E&&(Hf.min.copy(w.min),Hf.max.copy(w.max),Hf.needsUpdate=!0),!0):!1,intersectsRange:(w,E)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:_=>Hf.distanceToBox(_),intersectsBounds:(_,S,T)=>T<v&&T<o,intersectsRange:(_,S)=>{for(let T=_*3,M=(_+S)*3;T<M;T+=3){Bi(f,T,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=w*3,D=(w+E)*3;C<D;C+=3){Bi(h,C,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,x=C/3,b=T/3),P<s)return!0}}}});{let _=d?d.count:c.count;for(let S=0,T=_;S<T;S+=3){Bi(f,S,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,C=(w+E)*3;M<C;M+=3){Bi(h,M,u,l),h.needsUpdate=!0;let D=h.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=M/3,b=S/3),D<s)return!0}}}}}),ks.releasePrimitive(h),ks.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=v,n.faceIndex=x,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(fd),m.applyMatrix4(fd),r.distance=m.sub(r.point).length(),r.faceIndex=b),n)}closestPointToPoint(t,e={},n=0,r=1/0){let s=n*n,o=r*r,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(jf.copy(t).clamp(c.min,c.max),jf.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,jf);let h=t.distanceToSquared(jf);return h<a&&(Vy.copy(jf),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(Vy):e.point=Vy.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ni(0,new Float32Array(n),ZP),t.union(ZP)}),t}};var ih=$o($P());var qW=.5*(Math.sqrt(3)-1),Wf=(3-Math.sqrt(3))/6,YW=1/3,zs=1/6,oue=(Math.sqrt(5)-1)/4,aue=(5-Math.sqrt(5))/20,qf=i=>Math.floor(i)|0,e2=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]),HS=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 ky(i=Math.random){let t=n2(i),e=new Float64Array(t).map(r=>e2[r%12*2]),n=new Float64Array(t).map(r=>e2[r%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*qW,d=qf(s+c),h=qf(o+c),f=(d+h)*Wf,p=d-f,m=h-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let b=g-v+Wf,w=y-x+Wf,E=g-1+2*Wf,_=y-1+2*Wf,S=d&255,T=h&255,M=.5-g*g-y*y;if(M>=0){let P=S+t[T],I=e[P],L=n[P];M*=M,a=M*M*(I*g+L*y)}let C=.5-b*b-w*w;if(C>=0){let P=S+v+t[T+x],I=e[P],L=n[P];C*=C,l=C*C*(I*b+L*w)}let D=.5-E*E-_*_;if(D>=0){let P=S+1+t[T+1],I=e[P],L=n[P];D*=D,u=D*D*(I*E+L*_)}return 70*(a+l+u)}}function t2(i=Math.random){let t=n2(i),e=new Float64Array(t).map(s=>HS[s%12*3]),n=new Float64Array(t).map(s=>HS[s%12*3+1]),r=new Float64Array(t).map(s=>HS[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*YW,p=qf(o+f),m=qf(a+f),g=qf(l+f),y=(p+m+g)*zs,v=p-y,x=m-y,b=g-y,w=o-v,E=a-x,_=l-b,S,T,M,C,D,P;w>=E?E>=_?(S=1,T=0,M=0,C=1,D=1,P=0):w>=_?(S=1,T=0,M=0,C=1,D=0,P=1):(S=0,T=0,M=1,C=1,D=0,P=1):E<_?(S=0,T=0,M=1,C=0,D=1,P=1):w<_?(S=0,T=1,M=0,C=0,D=1,P=1):(S=0,T=1,M=0,C=1,D=1,P=0);let I=w-S+zs,L=E-T+zs,H=_-M+zs,k=w-C+2*zs,G=E-D+2*zs,z=_-P+2*zs,U=w-1+3*zs,$=E-1+3*zs,F=_-1+3*zs,j=p&255,X=m&255,q=g&255,V=.6-w*w-E*E-_*_;if(V<0)u=0;else{let W=j+t[X+t[q]];V*=V,u=V*V*(e[W]*w+n[W]*E+r[W]*_)}let Z=.6-I*I-L*L-H*H;if(Z<0)c=0;else{let W=j+S+t[X+T+t[q+M]];Z*=Z,c=Z*Z*(e[W]*I+n[W]*L+r[W]*H)}let Q=.6-k*k-G*G-z*z;if(Q<0)d=0;else{let W=j+C+t[X+D+t[q+P]];Q*=Q,d=Q*Q*(e[W]*k+n[W]*G+r[W]*z)}let K=.6-U*U-$*$-F*F;if(K<0)h=0;else{let W=j+1+t[X+1+t[q+1]];K*=K,h=K*K*(e[W]*U+n[W]*$+r[W]*F)}return 32*(u+c+d+h)}}function n2(i){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let r=n+~~(i()*(256-n)),s=e[n];e[n]=e[r],e[r]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var is=new an,Uy=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 r=0;r<t.count;r+=3){let s=1;is.a.fromBufferAttribute(t,r),is.b.fromBufferAttribute(t,r+1),is.c.fromBufferAttribute(t,r+2),s*=is.getArea(),e[r/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let r=0;r<e.length;r++)n+=e[r],this.distribution[r]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*n);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,r=e.length-1,s=-1;for(;n<=r;){let o=Math.ceil((n+r)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?r=o-1:n=o+1}return s}sampleFace(t,e,n){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),is.a.fromBufferAttribute(this.positionAttribute,t*3),is.b.fromBufferAttribute(this.positionAttribute,t*3+1),is.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(is.a,r).addScaledVector(is.b,s).addScaledVector(is.c,1-(r+s)),is.getNormal(n),this}};var i2=$o(jS()),XW=new se,KW=new se,QW=new se,pd;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(pd||(pd={}));var md=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new se;this.copyPreviousMatrix=!0;this.hiddenMatrix=new se;this.matrixWorldRigid=new se;this.shearScale=new se;this.shearScaleInv=new se}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof mt&&(n=n.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===n)return!0;r=r.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(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,n=!0);for(let r of this.children)r.updateMatrixWorld(n)}updateWorldMatrix(n,r){let s=this.parent;if(n&&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)),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(n,r=0){for(let s of this.children)pd.is(s)&&s.traverseObject(n,r+1)}traverseObject(n,r=0){if(n(this,r)!==!0)for(let o of this.children)pd.is(o)&&o.traverseObject(n,r+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,r=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,i2.SVD)(r),l=XW.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=KW.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=QW.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(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,r){this.updateWorldMatrix(!0,!1);let s=new se().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof se?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),r!==void 0&&(this.children.pop(),this.children.splice(r,0,n)),this}copy(n,r=!1){return super.copy(n,r),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,r,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var WS=class extends md(mt){},ZW=i=>i.type==="Mesh",un=class extends WS{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let r=this.children[e];r?.object!==n&&(r&&this.remove(r),r=new un(n),this.add(r),this.children.splice(e,0,this.children.pop()),r.matrixWorldNeedsUpdate=!0,r.matrixAutoUpdate=!1,r.matrix=n.matrix,r.hiddenMatrix=n.hiddenMatrix),r.expand(),e+=1,n=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 ZW(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 jl=new A,Wl=new A,gd=new se,o2=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],JW=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],$W=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],s2=(i,t,e)=>{i.updateEntityBoxSize(jl,Wl),gd.copy(t).multiply(i.matrixWorld),Wl.x===0&&Wl.y===0&&Wl.z===0?e.push(new A(jl.x,jl.y,jl.z).applyMatrix4(gd)):o2.forEach(n=>{e.push(n.clone().multiply(Wl).add(jl).applyMatrix4(gd))})},Yf=class extends Tt{constructor(){super(...arguments);this.matrix=new se;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new se().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,n)}expandByObjectSize(e,n,r=!1){let s=[];return r===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}s2(o,n,s)}}):s2(e,n,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(gd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Wl).multiplyScalar(.5),this.getCenter(jl),gd.copy(this.matrix).setPosition(jl),this.vertices=o2.map(e=>e.clone().multiply(Wl).applyMatrix4(gd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=JW.map(([e,n])=>new Xn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=$W.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var ss={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var YS=class extends uf{constructor(){super()}getPoints(t=12){let e=[],n,r=this.getCurveLengths(),o=r[r.length-1]/r.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?r[a]:r[a]-r[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let p=h[f];n&&n.equals(p)||(e.push(p),n=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var XS=.001;function KS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=XS}function qS(i,t){let e=new A(...i.position),n=new A(...i.controlNext.position),r=new A(...t.controlPrevious.position),s=new A(...t.position);return KS(e,n,s)&&KS(e,r,s)}function Gy(i){let t=i.points.map(c=>new A(...c.data.position)),e=[i.points[0]],n=new A(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)KS(n,t[c],t[c+1])||(e.push(i.points[c]),n=t[c]);e.push(i.points[i.points.length-1]);let r=i.isClosed,s=e.length-(r?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new A(...d.position),f=new A(...d.controlPrevious.position),p=new A(...d.controlNext.position),m={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:p};if(d.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...m,removedLength:0};continue}let g=r&&c==0?o-1:c-1,y=r&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,b=new A(...v.position),w=new A(...x.position),E=b.clone().sub(h).normalize(),_=w.clone().sub(h).normalize();Object.assign(m,{prevDir:E,nextDir:_});let S=qS(v,d),T=qS(d,x);if(!S||!T)a[c]={...m,removedLength:0};else{let M=E.clone().add(_).normalize(),C=M.clone().cross(E).length()/E.dot(M);a[c]={...m,tan:C,removedLength:d.roundness/C}}}for(let c=0;c<s;c++){let d=c,h=r&&c===o-1?0:c+1,f=a[d],p=a[h];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 d=c,h=r&&c===o-1?0:c+1,f=a[d],p=a[h],m=null;if(!qS(e[d].data,e[h].data))f.position.distanceTo(p.position)>XS&&(m=new Al(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)>XS&&(m=new Al(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 d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),p=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),m=d.tan*d.removedLength,g=d.prevDir.clone().add(d.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),b=g.clone().multiplyScalar(-m).add(x),w=h.distanceTo(b)/h.distanceTo(y),E=d.prevDir.clone().multiplyScalar(w*h.distanceTo(f)).add(h),_=E.clone().lerp(b,2),S=f.clone().lerp(E,4/3),T=p.clone().lerp(_,4/3);l[2*c]=new Al(f,S,T,p)}let u=new YS;return l.forEach(c=>{c&&u.add(c)}),u}var at;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(at||(at={}));var Gs=i=>at.is(i),e6={type:"completeState",isfromEntity:!0},t6=["x","y","z"],QS=new A,n6=new A().set(0,1,0),yd=i=>class extends md(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 Yf;this._recursiveBBox=new Yf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let r=this.children[n];if(at.is(r))return r}entityChildrenCount(){let n=this.children.length;for(;n--;)if(at.is(this.children[n]))return n+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 n=this;for(;n.data.type!=="Instance";){let r=n.parent;if(at.is(r))n=r;else return}return n}forInstancesRec(n){this.instances.forEach(r=>{r.disposed||n(r),r.forInstancesRec(n)})}super_Entity(n,r){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=r,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,r,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)No.toOps(this.data,o.data).forEach(l=>{let u=qg.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,r)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=No.patch(this.data,o),No.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,r)}))}s&&this.updateTransformState(this.dataPatched,r),this.stateSelection=n,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(n,r){n.setScalar(0),r.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Gs(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let r;return this.traverseEntity(s=>{s.uuid===n&&(r=s)}),r}traverseSortNextHelper(){let n=this.parent;if(n){let r=n.children,s=r.indexOf(this)+1;if(at.is(r[s]))return r[s];if(at.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&at.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let r=this;for(;n>0&&r!==null;)r=r.parent,n-=1;return r}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let r=this.parent;for(;r;){if(n===r)return!0;r=r.parent}return!1}countToAccestor(n){let r=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,r+=1}return r}forEachEntity(n){for(let r of this.children)Gs(r)&&n(r)}traverseEntityAncestors(n){this.traverseAncestors(r=>{at.is(r)&&n(r)})}traverseConcreteEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.isConcreteEntity&&o.traverseEntity(n,r+1)}traverseEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.traverseEntity(n,r+1)}traverseVisibleEntity(n){n(this);for(let r of this.children)Gs(r)&&r.visible&&r.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){super.updateMatrixWorld(n),this.dispatchEvent({type:"updateMatrixWorld"})}copy(n,r=!1){return super.copy(n,r),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Gs(n))}isAncestorOf(n){if(this.uuid===n)return!1;let r=!1;return this.traverseEntity(s=>{s.uuid===n&&(r=!0)}),r}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x*we.RAD2DEG,this.rotation.y*we.RAD2DEG,this.rotation.z*we.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ou(r,n)}getTransformValues(n,r,s){return r[n].map((o,a)=>s?.shared.getVariable(o,[this.uuid,n,t6[a]])??o)}updateTransformState(n,r){let s=!1;return n.position&&(this.position.fromArray(this.getTransformValues("position",n,r)),s=!0),n.rotation&&(QS.fromArray(this.getTransformValues("rotation",n,r)).multiplyScalar(we.DEG2RAD),this.rotation.setFromVector3(QS),s=!0),n.scale&&(this.scale.fromArray(this.getTransformValues("scale",n,r)),s=!0),n.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??Ma.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(n=!1){if(n){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)at.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{at.is(n)&&n.disposeRecursively()})}toState(n=[]){let r={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Ou(r,n)}updateByObjUpdateOp(n,r){n!==void 0&&this.updateByOp({type:0,props:n,path:[]},{...this.data,...n},r,!1)}updateByOp(n,r,s,o){let a=this.data;this.data=r;let l=n,u=Rr(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(delete d.name,Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=_n.zoom(h,n.path.slice(2));if(f)for(let p in n.props)n.props[p]===void 0&&p in f&&(d[p]=f[p])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=_n.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,No.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Rr(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(Ds.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=_n.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let p=n.props;if(f)for(let[m,g]of Object.entries(n.props))g===void 0&&(p===n.props&&(p={...n.props}),p[m]=f[m]);n={...n,props:p}}h.overrideData=qu.resolve(r.overrides,c),h.updateByOp(n,Tn.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of Fs.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of Fs.rootOverrideProps)if(Rr(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=Ds.filterOp(d.overrideData,c);h&&d.updateByOp(h,Tn.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=Ds.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=r:f=Tn.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,r,s){if(this.dataPatched=r,n.path.length===0&&n.type===0)n.props.type!==void 0&&!ns.is(n.props.type)&&ss.changeEntityProptotype(this,r,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){ss.changeEntityProptotype(this,r,s);for(let o of this.children)at.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,r,s)}updateByPatchedOp(n,r,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Rr(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(r.pathSnapping),Rr(n.path,["cloner"])!==null){let o=Tn.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(r.cloner,s.scene):(this.setFromClonerState(r.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n=this.dataPatched.pathSnapping){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let r=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(r===null)return;let l=n.find(r);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=Gy(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new se;l.updateMatrixWorld();let p=new se().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(p);let m={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new se().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(g).add(h),v=new se().lookAt(h,y,n6),x=QS.setFromEuler(new qt().setFromRotationMatrix(v)).multiplyScalar(we.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(e6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,r){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),r&&"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,r),this.updateVisible()),this.updateTransformState(n,r)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof ss.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,r){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new ss.Cloner(this,n),r.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,r.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var Hy=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=we.clamp(e.thetaLength,0,360);let n=e.width/2,r=e.radiusTop??n,s=e.radiusBottom??n;return r===s?(r=n,s=n):r>s?(r=n,s=s*n/r):(r=r*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:r,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=i.parameters,p;return l===0?(p=new Ee,p.setAttribute("position",new be([],3))):d||f?p=new Xf(u,c,n,r,s,o,a,l*Math.PI/180,d,d,h,f):p=new _l(u,c,n,r,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function Ua(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function a2(i){return new B(i.y,-i.x)}var Xf=class extends Ee{constructor(t,e,n,r,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,r=Math.floor(r)||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=n/2,b=new A,w=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let E=new B(t,x),_=new B(e,-x),S=null,T=null,M=null,C=null,D=E.clone().sub(_),P=0,I=0,L=0;h>0&&(P=Math.min(t,e)*(1-h),I=t-P,L=e-P);let H=E.clone();H.x-=P;let k=Math.PI-D.angle(),G=D.angle(),z=Math.tan(G/2),U=Math.tan(k/2),$=z+U,F=h?$:U,j=h?$:z;if(u=Math.min(u,(t-I)/F,D.length()/$),c=Math.min(c,(e-L)/j,D.length()/$),u>0){let K=u/z;S=E.clone().sub(new B(K,u)),h&&(M=S.clone(),M.x-=P-$*u),E.sub(D.clone().setLength(K))}if(c>0){let K=c/U;T=_.clone().sub(new B(K,-c)),_.add(D.clone().setLength(K)),h&&(C=T.clone(),C.x-=P-$*c,H.sub(D.clone().setLength(K)))}D=E.clone().sub(_);let X=D.length()<.5,q=[];for(let K=0;K<=r;K++){let W=[],ye=K/r,fe=ye*l+a,ie=new B(Math.sin(fe),Math.cos(fe));C&&T?(V(W,ye,ie,k,c,C,-1,!0),V(W,ye,ie,G,c,T,-1,!1)):T?(Z(W,ie,T.x,0,-1),V(W,ye,ie,G,c,T,-1,!1)):o||Z(W,ie,e,L,-1);let Ae=a2(D).normalize();if(Ua(Ae,ie,b),!X)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=D.clone().multiplyScalar(Oe).add(_);Ua(Ie,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}if(M&&S?(V(W,ye,ie,k,u,S,1,!1),V(W,ye,ie,G,u,M,1,!0)):S?(V(W,ye,ie,k,u,S,1,!1),Z(W,ie,S.x,0,1)):o||Z(W,ie,t,I,1),h&&!X){let xe=a2(D).multiplyScalar(-1).normalize();Ua(xe,ie,b);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=D.clone().multiplyScalar(-Ie).add(H);Ua(Pe,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}}h&&!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&&h&&W==s)continue;let ye=q[K][W],fe=q[K+1][W],ie=q[K+1][W+1],Ae=q[K][W+1],xe=m[ie*3+0],Oe=m[ie*3+2];p.push(ye,fe,Ae),(xe!=0||Oe!=0)&&p.push(fe,ie,Ae)}l<Math.PI*2&&(Q(-1,q[0],a),Q(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 V(K,W,ye,fe,ie,Ae,xe,Oe){for(let Ie=0;Ie<d+1;Ie++){let Pe=Ie/d,Te=xe<0?Pe:1-Pe;Oe&&(Te-=1),Te*=fe;let Ue=new B(Math.sin(Te),Math.cos(Te)*xe),ze=Ue.clone().multiplyScalar(ie).add(Ae);Ua(ze,ye,w),m.push(w.x,w.y,w.z),Ua(Ue,ye,b),g.push(b.x,b.y,b.z),y.push(W,.5+w.y/n),K.push(v++)}}function Z(K,W,ye,fe,ie){let Ae=new A,xe=new B,Oe=[ye,fe];ie<0&&Oe.reverse();for(let Ie of Oe)xe.set(Ie,x*ie),Ua(xe,W,Ae),m.push(Ae.x,Ae.y,Ae.z),g.push(0,ie,0),y.push(.5,.5),K.push(v++)}function Q(K,W,ye){let fe=new B(Math.sin(ye),Math.cos(ye)),ie=new B(-Math.cos(ye),Math.sin(ye)),Ae=new A,xe=K<0?(Pe,Te,Ue)=>p.push(Pe,Te,Ue):(Pe,Te,Ue)=>p.push(Pe,Ue,Te),Oe=new B((t+e+I+L)/4,0);Ua(Oe,fe,Ae),m.push(Ae.x,Ae.y,Ae.z),g.push(ie.x,0,ie.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let Te=m.slice(Pe*3,Pe*3+3);m.push(...Te),g.push(ie.x,0,ie.y);let Ue=y.slice(Pe*2,Pe*2+2);y.push(...Ue),v++}for(let Pe=Ie+1;Pe<v-1;Pe++)xe(Ie,Pe,Pe+1);xe(Ie,v-1,Ie+1)}}};var l2=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=we.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:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=i.parameters,h;return l===0?(h=new Ee,h.setAttribute("position",new be([],3))):u>0||c>0||l<360?h=new Xf(0,t/2,n,r,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new zc(t/2,n,r,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"ConeGeometry"}})}};var c2=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:n,widthSegments:r,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new sr(t,e,n,r,s,o):u=new JS(t,e,n,r,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},ZS=Math.PI/2,JS=class extends Ee{constructor(t=1,e=1,n=1,r=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],p=0,m=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,r,0),y("x","y","z",1,-1,1,t,e,n,r,1),y("x","y","z",-1,1,1,t,e,n,r,0),y("x","y","z",1,1,-1,t,e,n,r,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,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(d,3)),this.setAttribute("normal",new be(h,3)),this.setAttribute("uv",new be(f,2));function g(x,b,w,E,_,S,T,M,C,D,P){let I=(S-2*a)/C,L=(T-2*a)/D,H=S/2-a,k=T/2-a,G=M/2,z=C+1,U=D+1,$=0,F=0,j=new A;for(let X=0;X<U;X++){let q=X*L-k;for(let V=0;V<z;V++){let Z=V*I-H;j[x]=Z*E,j[b]=q*_,j[w]=G,d.push(j.x,j.y,j.z),j[x]=0,j[b]=0,j[w]=M>0?1:-1,h.push(j.x,j.y,j.z),f.push(V/C),f.push(1-X/D),$+=1}}for(let X=0;X<D;X++)for(let q=0;q<C;q++){let V=p+q+z*X,Z=p+q+z*(X+1),Q=p+(q+1)+z*(X+1),K=p+(q+1)+z*X;c.push(V,Z,K),c.push(Z,Q,K),F+=6}u.addGroup(m,F,P),m+=F,p+=$}function y(x,b,w,E,_,S,T,M,C,D,P){let I=(T-2*a)/D,L=T/2-a,H=M/2-a,k=C/2,G=D+1,z=0,U=0,$=new A,F=new A;for(let j=0;j<l+1;j++){let X=j/l*ZS,q=Math.sin(X)*a,V=(1-Math.cos(X))*a,Z=Math.sin(X),Q=Math.cos(X);$[b]=(H+q)*_,$[w]=(k-V)*S,F[x]=0,F[b]=Z*Math.sign($[b]),F[w]=Q*Math.sign($[w]);for(let K=0;K<G;K++){let W=K*I-L;$[x]=W*E,d.push($.x,$.y,$.z),h.push(F.x,F.y,F.z),f.push(K/D),f.push(0),z+=1}}for(let j=0;j<l;j++)for(let X=0;X<D;X++){let q=p+X+G*j,V=p+X+G*(j+1),Z=p+(X+1)+G*(j+1),Q=p+(X+1)+G*j;c.push(q,V,Q),c.push(V,Z,Q),U+=6}u.addGroup(m,U,P),m+=U,p+=z}function v(x,b,w){let E=new A,_=new A(t/2,e/2,n/2);_.subScalar(a);let S=[],T=x*b*w>0?(C,D,P)=>c.push(C,D,P):(C,D,P)=>c.push(C,P,D);for(let C=0;C<=l;C++){let D=[],P=ZS*(1-C/l),I=Math.cos(P),L=Math.sin(P),H=0;for(let k=0;k<=C;k++){let G=Math.cos(H),z=Math.sin(H);E.x=I*G,E.y=L,E.z=I*z;let U=_.clone().addScaledVector(E,a);d.push(x*U.x,b*U.y,w*U.z),h.push(x*E.x,b*E.y,w*E.z),f.push(0,0),D.push(p++),H+=ZS/C}S.push(D)}let M=S.length-1;for(let C=0;C<M;C++){let D=S[C],P=S[C+1],I=D.length-1;T(D[0],P[1],P[0]);for(let L=1;L<=I;L++)T(D[L-1],D[L],P[L]),T(D[L],P[L+1],P[L])}}}};var za=class extends Ee{constructor(t=[],e=[],n="",r=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),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}[n],p=new A,m=p.clone(),g=new an,y=s*r,v=r-y,x=o+1,b=new A,w=(z,U)=>b.subVectors(z,U).normalize(),E=(z,U)=>Array(z).fill(void 0).map(U),_=E(t.length/3,(z,U)=>new A().fromArray(t,U*3).setLength(r)),S=[],T=1e6;for(let z=0;z<_.length;z++){let U=_[z],$=[],F,j,X,q=1e10,V=-1;for(;(V=e.indexOf(z,V+1))!=-1;){let W=V-V%3;F=e[W+(V+1)%3],j=e[W+(V+2)%3],X=U.distanceToSquared(_[F]),q=Math.min(q,X),$.push([F,j,X])}q+=1e-6;let Z=[],Q=0,K=$.length;for(let W=0;W<K;W++){[F,j,X]=$[Q];let ye=S[F]?.includes(z)==!0;X<=q&&Z.push(F+ +ye*T),Q=$.findIndex(fe=>fe[0]==j)}S.push(Z)}let M=[];{let z=0,U=0,$,F,j=f==3;for(let X=0;X<=o;X++){$=X*(X+1)/2,F=(X+1)*(X+2)/2;for(let q=0;q<o-X;q++)[z,U]=[$+q+X+2,F+q+X+3],M.push($,F,...j?[U,$]:[z,F],U,z),[$,F]=[z,U];M.push($,F,$+o+2)}}let C=p.clone(),D=p.clone(),P=p.clone(),I=p.clone(),L=p.clone(),H=[],k=E(_.length,()=>E(f,()=>p.clone()));for(let z=0;z<_.length;z++){p.copy(_[z]).normalize(),C.copy(p).multiplyScalar(v);let U=S[z];for(let Z=0;Z<U.length;Z++){let Q=U[Z],K=U[(Z+1)%f];g.setFromPointsAndIndices(_,z,Q%T,K%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,k[z][Z])}let $=[],F=[],j=[],X=new A;o==0&&[...k[z]].reduce((Z,Q)=>Z.add(Q),X).multiplyScalar(1/f);for(let Z=0;Z<f;Z++){let Q=[],K=(Z-1+f)%f,W=k[z][K],ye=k[z][Z];p.copy(W).sub(C),m.copy(ye).sub(C);let fe=C.angleTo(p),ie=p.angleTo(m),Ae=Math.cos(fe)*y;o==0?D.copy(X):D.copy(C).setLength(v+Ae),F.push(Ae);let xe=[D,W,ye];for(let Oe=0;Oe<2;Oe++){let Ie=xe[Oe],Pe=xe[Oe+1];I.subVectors(Ie,C),L.subVectors(Pe,C),P.crossVectors(I,L).normalize();for(let Te=0;Te<x;Te++){let Ue=[fe,ie][Oe]*Te/x;p.copy(I).applyAxisAngle(P,Ue).add(C),$.push(p.clone()),Oe&&(w(p,C),Q.push([Te==0?Ie:p.clone(),b.clone()]))}Oe&&(w(Pe,C),Q.push([Pe,b.clone()]))}j.push(Q)}H.push(j);let q=2*x,V=2;for(let Z=0;Z<f;Z++){let Q=q*Z,K=q*((Z+1)%f),W=[$[Q]];for(let fe=1;fe<x;fe++){I=$[Q+fe],L=$[K+fe],W.push(I);for(let ie=1,Ae=fe-V+1;ie<=Ae;ie++)p.lerpVectors(I,L,ie/(Ae+1)),p.sub(C).setLength(F[Z]).add(C),W.push(p.clone());W.push(L)}for(let fe=0;fe<x;fe++)W.push($[fe+x+Q]);W.push($[K+x]);let ye=M.map(fe=>W[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(w(fe,C),[b.x,b.y,b.z])).flat())}}let G=[];for(let z=0;z<S.length;z++)for(let U=0;U<f;U++){let $=S[z][U];if($<T){let F=S[$].findIndex(q=>q%T==z),j=H[z][U],X=H[$][F];for(let q=0;q<x;q++){let V=j[q],Z=X[x-q],Q=j[q+1],K=X[x-(q+1)];[V,Z,Q,Q,Z,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)})}G.push(j[0][0],X[x][0],j[x][0],X[0][0])}}for(;G.length;){let z,U,$,F;[z,U]=G.splice(0,2);let j=[z];for(;z!=U;)j.push(U),$=G.indexOf(U),F=$%2,U=G.splice($-F,2)[1-F];b.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let X=b.dot(j[0])<0;X&&b.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +X],j[q+1-+X],j[0]].forEach(V=>{a.push(V.x,V.y,V.z),u.push(b.x,b.y,b.z)})}}function d(){let h=new A;for(let _=0;_<a.length;_+=3){h.x=a[_+0],h.y=a[_+1],h.z=a[_+2];let S=w(h)/2/Math.PI+.5,T=E(h)/Math.PI+.5;l.push(S,1-T)}let f=new A,p=new A,m=new A,g=new A,y=new B,v=new B,x=new B,b=(_,S,T,M)=>{M<0&&_.x===1&&(l[S]=_.x-1),T.x===0&&T.z===0&&(l[S]=M/2/Math.PI+.5)};for(let _=0,S=0;_<a.length;_+=9,S+=6){f.set(a[_+0],a[_+1],a[_+2]),p.set(a[_+3],a[_+4],a[_+5]),m.set(a[_+6],a[_+7],a[_+8]),y.set(l[S+0],l[S+1]),v.set(l[S+2],l[S+3]),x.set(l[S+4],l[S+5]),g.copy(f).add(p).add(m).divideScalar(3);let T=w(g);b(y,S+0,f,T),b(v,S+2,p,T),b(x,S+4,m,T)}for(let _=0;_<l.length;_+=6){let S=l[_+0],T=l[_+2],M=l[_+4],C=Math.max(S,T,M),D=Math.min(S,T,M);C>.9&&D<.1&&(S<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),M<.2&&(l[_+4]+=1))}function w(_){return Math.atan2(_.z,-_.x)}function E(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(t){return new za(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var u2=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:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Kf(t*.5,s,o):new Hc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Kf=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=1/r,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,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new Kf(t.radius,t.corner,t.cornerSides)}};var Qf=1e-12,vd=class{constructor(t){this.position=new B;this.startPosition=new B;this.uuid=we.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 vd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},xd=class extends vd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new xd(this.parent).copy(this)}},os=class extends vd{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new xd(this),new xd(this))}static create(e,n){let r=new os(e,new B(...n.position));return r.controls[0].position.set(...n.controlPrevious.position),r.controls[1].position.set(...n.controlNext.position),r.roundness=n.roundness,r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,r}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let r=0,s=this.controls.length;r<s;r++){let o=this.controls[r];this.position.distanceTo(o.position)<=n?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 os(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),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new B,n=new B){let[r,s]=this.computeTangents();return r&&s&&(d2(r,e),d2(s,n)),[e,n]}computeTangent(e=new B){let[n,r]=this.computeTangents();return n&&r&&e.copy(n).add(r).normalize(),e}computeNormal(e=new B){let[n,r]=this.computeNormals();return e.copy(n).add(r).normalize(),e}};function d2(i,t=new B){let e=i.length();return t.set(-i.y/e,i.x/e)}var ew=i=>i,bd=new B,jy=new B,r6=new B,i6=new B,s6=new B,o6=new B,f2=new A,p2=new A;function m2(i){let t=new B;t.addVectors(i.v0,bd.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new B;return e.addVectors(i.v2,jy.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Ir(i.v0,t,e,i.v2)}function Zf(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function a6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function l6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function tw(i,t,e){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),r=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((r*r+n*n-s*s)/(2*r*n))}function g2(i,t,e){return h2(i,t)&&h2(t,e)&&$S(i.position,t.position,e.position)}function $S(i,t,e){return bd.copy(t).sub(i).cross(jy.copy(e).sub(i))===0}function y2(i,t,e,n,r){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 n.set(a+l,o+u),r.set(a-l,o-u),[n,r]}function v2(i,t,e){let n=i.distanceTo(e),r=t.distanceTo(e);return n<r?t:i}function x2(i,t,e,n,r,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)),d;return tw(t,i,e)>Math.PI&&(c*=-1),Zf(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),r.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[r,s]}function nw(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function h2(i,t){return $S(i.position,i.controls[1].position,t.position)&&$S(i.position,t.controls[0].position,t.position)}function b2(i,t,e,n,r=.5){let s=bd.subVectors(t,i).multiplyScalar(r).add(i),o=jy.subVectors(e,t).multiplyScalar(r).add(t),a=r6.subVectors(n,e).multiplyScalar(r).add(e),l=s,u=i6.subVectors(o,s).multiplyScalar(r).add(s),c=s6.subVectors(a,o).multiplyScalar(r).add(o),d=a,h=o6.subVectors(c,u).multiplyScalar(r).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function S2(i,t,e=12,n=!0){let r=p2.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=ew(t[l]),c=bd,d=Ga(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof Ir||u instanceof yi||u instanceof Or){if(u.getPoint(h/d,c),r.set(c.x,c.y,0),s!==void 0&&l6(s,r))continue;s===void 0&&(s=f2),s.copy(r),i.setXYZ(o,r.x,r.y,r.z),o++}}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++),i}function w2(i,t,e,n=12,r=!0){let s=p2.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=ew(t[l]),d=bd,h=Ga(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof Ir||c instanceof yi||c instanceof Or){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=f2:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}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++),a}function rw(i,t=12,e=!1){let n=[];for(let r=0,s=i.length;r<s;r++){let o=i[r],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Ga(o.roundedCurveCorner,t)*.5;r>0&&(n[r-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Ga(o.curveAfter,t)),n.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(n[i.length-1]+=Ga(i[0].roundedCurveCorner,t)*.5),n}function Ga(i,t=12){return i&&i instanceof wl?t*2:i&&(i instanceof Or||i instanceof cf)?1:i&&i instanceof kc?t*i.points.length:t}function A2(i,t,e=12,n=!0){let r,s=0;for(let o=0;o<t.length;o++){let a=ew(t[o]),l=Ga(a,e),u=bd;for(let c=0;c<=l;c++)if(a instanceof Ir||a instanceof yi||a instanceof Or){if(a.getPoint(c/l,u),r!==void 0&&a6(r,u,Qf))continue;r===void 0&&(r=jy),r.copy(u),i.push(u.x,u.y),s++}}return Zf(i[0],i[i.length-2],Qf)&&Zf(i[1],i[i.length-1],Qf)&&(i.pop(),i.pop()),n&&s>1&&!(Zf(i[s-1],i[1],Qf)&&Zf(i[s-2],i[0],Qf))&&(i.push(i[0],i[1]),s++),i}var iw=new B,c6=new B,u6=new B,d6=new B,h6=new B,f6=new B,Pt=class extends _o{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new En(new A(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=we.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,r){let s=new Pt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>os.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Pt.createFromState(o)),n!==void 0&&r!==void 0&&s.applySize(n,r),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 n=0,r=this.points.length;n<r;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,r=this.points.findIndex(s=>s.uuid===e);if(r<0){let s=n;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 r}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let r=iw.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(r),a.controls[0].position.multiply(r),a.controls[1].position.multiply(r)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,r=we.generateUUID()){let s;e instanceof B?s=e:s=new B(e,n);let o=new os(r,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,r=this.shapeHoles.length;n<r;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(r=>r.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,r=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=r?this.roundedCurveDivisions:this.curveDivisions;return S2(e,r?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=rw(this.points,e,!1),this.roundedCurveDivisions=rw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,r=12){return w2(e,this.curves,n,r,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),A2(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Ga(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<r+c)return[l,(a-r+1)/c];r+=c}return[0,1]}getCurveT(e,n,r){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(nw(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(iw.set(r.x,r.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){nw(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,n.curveAfter=r;let s=r.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],r=this.points[this.points.length-1];this._applyCurveForPoint(n,r)}if(this.points.length>2){let n=0;for(let r=0,s=this.points.length;r<s;r++){let o=this.points[r],a=this.points[r-1]??this.points[this.points.length-1],l=this.points[r+1]??this.points[0],u=o.roundness,c=a&&l&&g2(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=d.getLength(),g=h.getLength(),y=Math.min(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),b=1-x/m,w=x/g,E=d.getPointAt(b,iw),_=h.getPointAt(w,c6);this._subSplitCurve(d,f,b,E,void 0),this._subSplitCurve(h,p,w,void 0,_);let S;if(this.useCubicForRoundedCorners){let T=tw(E,o.position,_)/2,M=Math.tan(T)*E.distanceTo(o.position),[C,D]=y2(E,_,M,u6,d6),P=v2(C,D,o.position),[I,L]=x2(P,E,_,M,h6,f6);S=new Ir(E.clone(),I.clone(),L.clone(),_.clone())}else S=new yi(E.clone(),o.position.clone(),_.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(r+n,0,S),n++}}}}_subSplitCurve(e,n,r,s,o){if(e instanceof Or)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(r,0),c=b2(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 n}clone(){let e=new Pt(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let r=0;r<n;r++){let s=r*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],d=e.points[s+5],h=e.points[s+6],f=new os(we.generateUUID(),new B(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(r=>{let s=new Pt;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,n=!1){this.isText=n;let r=(o,a)=>{a instanceof Ir&&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 yi&&(o[l]=m2(o[l]));for(l=0,u=o.length;l<u;l++){let h=o[l],f=l>0?o[l-1]:null,p;h instanceof Ir?(p=this.createPoint(h.v0),p.controls[1].position.copy(h.v1)):h instanceof Or&&(p=this.createPoint(h.v1)),p!==void 0&&(f!==null&&r(p,f),a.push(p))}let c=o[o.length-1],d=!1;return c instanceof Ir?c.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(c.v2),d=!0):c instanceof Or&&c.v2.equals(a[0].position)&&(d=!0),this.isClosed=d,a};return this.points=s(e.curves),e instanceof _o&&(this.shapeHoles=e.holes.map(o=>{let a=new Pt;return a.fromShape(o),a})),this.update(),this}updatePoint(e,n){let r=this.getPointByUuid(e);r&&(n.position!==void 0&&r.position.fromArray(n.position),n.roundness!==void 0&&(r.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var ow=Math.PI*2;function sw({x:i,y:t},e,n,r,s){return{x:i*e+r,y:t*n+s}}function p6(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(i),r=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*e,y:r+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function E2(i,t,e,n){let r=i*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*n));return r*Math.acos(s)}function m6(i,t,e,n,r,s,o,a,l,u){let c=Math.pow(r,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),p=c*d-c*f-d*h;p<0&&(p=0),p/=c*f+d*h,p=Math.sqrt(p)*(l===u?-1:1);let m=p*r/s*a,g=p*-s/r*o,y=m+(i+e)/2,v=g+(t+n)/2,x=(o-m)/r,b=(a-g)/s,w=(-o-m)/r,E=(-a-g)/s,_=E2(1,0,x,b),S=E2(x,b,w,E);return!u&&S>0&&(S-=ow),u&&S<0&&(S+=ow),{centerx:y,centery:v,ang1:_,ang2:S}}function _2({px:i,py:t,cx:e,cy:n,rx:r,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(r===0||s===0)return[];let u=(i-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];r=Math.abs(r),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(r,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(r*=Math.sqrt(d),s*=Math.sqrt(d));let h=m6(i,t,e,n,r,s,u,c,o,a),{ang1:f,ang2:p}=h,{centerx:m,centery:g}=h,y=Math.abs(p)/(ow/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(p6(f,p)),f+=p;return l.map(x=>{let{x:b,y:w}=sw(x[0],r,s,m,g),{x:E,y:_}=sw(x[1],r,s,m,g),{x:S,y:T}=sw(x[2],r,s,m,g);return{x1:b,y1:w,x2:E,y2:_,x:S,y:T}})}var xt;(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"})(xt||(xt={}));var mn;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(mn||(mn={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Qe=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,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?r<s?e.t-t.t+(t.t-n.t)*(r/(r+s)):e.t-n.t+(n.t-t.t)*(s/(r+s)):0},i.edgeSign=function(t,e,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?(e.t-n.t)*r+(e.t-t.t)*s:0},i.transEval=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?r<s?e.s-t.s+(t.s-n.s)*(r/(r+s)):e.s-n.s+(n.s-t.s)*(s/(r+s)):0},i.transSign=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?(e.s-n.s)*r+(e.s-t.s)*s:0},i.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},i.interpolate=function(t,e,n,r){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+r)/2:e+(r-e)*(t/(t+n)):r+(e-r)*(n/(t+n))},i.intersect=function(t,e,n,r,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(n,r)||(l=n,n=r,r=l),i.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.vertLeq(n,e)?i.vertLeq(e,r)?(o=i.edgeEval(t,n,e),a=i.edgeEval(n,e,r),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,e.s)):(o=i.edgeSign(t,n,e),a=-i.edgeSign(t,r,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,r.s)):s.s=(n.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(n,r)||(l=n,n=r,r=l),i.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.transLeq(n,e)?i.transLeq(e,r)?(o=i.transEval(t,n,e),a=i.transEval(n,e,r),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,e.t)):(o=i.transSign(t,n,e),a=-i.transSign(t,r,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,r.t)):s.t=(n.t+e.t)/2},i}(),Jf=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}(),Wy=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}(),Sd=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}(),T2=function(){function i(){var t=new Sd,e=new Jf,n=new Wy(0),r=new Wy(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=r,r.next=r,r.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=r}return i.prototype.makeEdge_=function(t){var e=new Wy(0),n=new Wy(1);t.Sym.side<t.side&&(t=t.Sym);var r=t.Sym.next;return n.next=r,r.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},i.prototype.splice_=function(t,e){var n=t.Onext,r=e.Onext;n.Sym.Lnext=e,r.Sym.Lnext=t,t.Onext=r,e.Onext=n},i.prototype.makeVertex_=function(t,e,n){var r=t;nt(r,"Vertex can't be null!");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e;var o=e;do o.Org=r,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,n){var r=t;nt(r,"Face can't be null");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e,r.trail=null,r.marked=!1,r.inside=n.inside;var o=e;do o.Lface=r,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},i.prototype.killVertex_=function(t,e){var n=t.anEdge,r=n;do r.Org=e,r=r.Onext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var n=t.anEdge,r=n;do r.Lface=e,r=r.Lnext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new Sd,e=new Sd,n=new Jf,r=this.makeEdge_(this.eHead);return this.makeVertex_(t,r,this.vHead),this.makeVertex_(e,r.Sym,this.vHead),this.makeFace_(n,r,this.fHead),r},i.prototype.splice=function(t,e){var n=!1,r=!1;if(t!==e){if(e.Org!==t.Org&&(r=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!r){var s=new Sd;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Jf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!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),!n){var r=new Jf;this.makeFace_(r,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),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var r=new Sd;return this.makeVertex_(r,n,e.Org),e.Lface=n.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},i.prototype.connect=function(t,e){var n=!1,r=this.makeEdge_(t),s=r.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(r,t.Lnext),this.splice_(s,e),r.Org=t.Dst,s.Org=e.Org,r.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Jf;this.makeFace_(o,r,t.Lface)}return r},i.prototype.zapFace=function(t){var e=t.anEdge,n,r,s,o,a;r=e.Lnext;do n=r,r=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},i.prototype.mergeConvexFaces=function(t){var e,n,r,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;r=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Qe.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Qe.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(r=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=r;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,r,s,o,a,l,u;for(s=t,s=t;(r=s.next)!==t;s=r){nt(r.prev===s),l=r.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===r),l=l.Lnext;while(l!==r.anEdge)}for(nt(r.prev===s&&r.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=n,u=n;(l=u.next)!==n;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}(),M2=function(){function i(){this.handle=null}return i}(),C2=function(){function i(){this.key=null,this.node=0}return i}(),g6=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 n=0;n<t+1;n++)this.nodes[n]=new M2,this.handles[n]=new C2;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,nt(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[r].key,n[s].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[r].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[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,n;if(e=++this.size,e*2>this.max){this.max*=2;var r,s;for(s=this.nodes.length,this.nodes.length=this.max+1,r=s;r<this.nodes.length;r++)this.nodes[r]=new M2;for(s=this.handles.length,this.handles.length=this.max+1,r=s;r<this.handles.length;r++)this.handles[r]=new C2}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,r=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),r},i.prototype.delete=function(t){var e=this.nodes,n=this.handles,r;nt(t>=1&&t<=this.max&&n[t].key!==null),r=n[t].node,e[r].handle=e[this.size].handle,n[e[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[e[r>>1].handle].key,n[e[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},i}(),aw=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}(),P2=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),y6=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new P2,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 n=new P2;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),v6=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,n){var r=t.event,s=e.eUp,o=n.eUp;if(s.Dst===r)return o.Dst===r?Qe.vertLeq(s.Org,o.Org)?Qe.edgeSign(o.Dst,s.Org,o.Org)<=0:Qe.edgeSign(s.Dst,o.Org,s.Org)>=0:Qe.edgeSign(o.Dst,r,o.Org)<=0;if(o.Dst===r)return Qe.edgeSign(s.Dst,r,s.Org)>=0;var a=Qe.edgeEval(s.Dst,r,s.Org),l=Qe.edgeEval(o.Dst,r,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,n){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},i.topLeftRegion=function(t,e){var n=e.eUp.Org,r;do e=i.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(r=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),r===null)return null;i.fixUpperEdge(t,e,r),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,n){var r=new aw;return r.eUp=n,r.nodeUp=t.dict.insertBefore(e.nodeUp,r),r.fixUpperEdge=!1,r.sentinel=!1,r.dirty=!1,n.activeRegion=r,r},i.isWindingInside=function(t,e){switch(t.windingRule){case xt.ODD:return(e&1)!==0;case xt.NONZERO:return e!==0;case xt.POSITIVE:return e>0;case xt.NEGATIVE:return e<0;case xt.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 n=e.eUp,r=n.Lface;r.inside=e.inside,r.anEdge=n,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,n){for(var r,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),r=s.eUp,r.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}r=t.mesh.connect(a.Lprev,r.Sym),i.fixUpperEdge(t,s,r)}a.Onext!==r&&(t.mesh.splice(r.Oprev,r),t.mesh.splice(a,r)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,n,r,s,o){var a,l,u,c,d=!0;u=n;do nt(Qe.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==r);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,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),d=!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,n){t.mesh.splice(e,n)},i.vertexWeights=function(t,e,n){var r=Qe.vertL1dist(e,t),s=Qe.vertL1dist(n,t),o=.5*s/(r+s),a=.5*r/(r+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},i.getIntersectData=function(t,e,n,r,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,n,r),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp;if(Qe.vertLeq(r.Org,s.Org)){if(Qe.edgeSign(s.Dst,r.Org,s.Org)>0)return!1;Qe.vertEq(r.Org,s.Org)?r.Org!==s.Org&&(t.pq.delete(r.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,r)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(r,s.Oprev),e.dirty=n.dirty=!0)}else{if(Qe.edgeSign(r.Dst,s.Org,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Oprev,r)}return!0},i.checkForLeftSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o;if(nt(!Qe.vertEq(r.Dst,s.Dst)),Qe.vertLeq(r.Dst,s.Dst)){if(Qe.edgeSign(r.Dst,s.Dst,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(r),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Qe.edgeSign(s.Dst,r.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(r.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o=r.Org,a=s.Org,l=r.Dst,u=s.Dst,c,d,h=new Sd,f,p;if(nt(!Qe.vertEq(u,l)),nt(Qe.edgeSign(l,t.event,o)<=0),nt(Qe.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(Qe.vertLeq(o,a)){if(Qe.edgeSign(u,o,a)>0)return!1}else if(Qe.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Qe.intersect(l,o,u,a,h),nt(Math.min(o.t,l.t)<=h.t),nt(h.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=h.s),nt(h.s<=Math.max(a.s,o.s)),Qe.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=Qe.vertLeq(o,a)?o:a,Qe.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),Qe.vertEq(h,o)||Qe.vertEq(h,a)?(i.checkForRightSplice(t,e),!1):!Qe.vertEq(l,t.event)&&Qe.edgeSign(l,t.event,h)>=0||!Qe.vertEq(u,t.event)&&Qe.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Sym,r),e=i.topLeftRegion(t,e),r=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),n),i.addRightEdges(t,e,r.Oprev,r,r,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(r.Lnext,s.Oprev),n=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=i.finishLeftRegions(t,n,null),i.addRightEdges(t,e,s.Onext,r.Rprev,p,!0),!0):(Qe.edgeSign(l,t.event,h)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),r.Org.s=t.event.s,r.Org.t=t.event.t),Qe.edgeSign(u,t.event,h)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(r.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,r),r.Org.s=h.s,r.Org.t=h.t,r.Org.pqHandle=t.pq.insert(r.Org),i.getIntersectData(t,r.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var n=i.regionBelow(e),r,s;;){for(;n.dirty;)e=n,n=i.regionBelow(n);if(!e.dirty&&(n=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,r=e.eUp,s=n.eUp,r.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(i.deleteRegion(t,n),t.mesh.delete(s),n=i.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n),r=e.eUp)),r.Org!==s.Org)if(r.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(r.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);r.Org===s.Org&&r.Dst===s.Dst&&(i.addWinding(s,r),i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n))}},i.connectRightVertex=function(t,e,n){var r,s=n.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Qe.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),Qe.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,n.Onext,s,s,!0);return}Qe.vertLeq(l.Org,a.Org)?r=l.Oprev:r=a,r=t.mesh.connect(n.Lprev,r),i.addRightEdges(t,e,r,r.Onext,r.Onext,!1),r.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,n){var r,s,o,a,l;if(r=e.eUp,Qe.vertEq(r.Org,n)){nt(!1),i.spliceMergeVertices(t,r,n.anEdge);return}if(!Qe.vertEq(r.Dst,n)){t.mesh.splitEdge(r.Sym),e.fixUpperEdge&&(t.mesh.delete(r.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,r),i.sweepEvent(t,n);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(n.anEdge,o),Qe.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var n,r,s,o,a,l,u=new aw;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,r=i.regionBelow(n),!!r){if(o=n.eUp,a=r.eUp,Qe.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,n,e);return}if(s=Qe.vertLeq(a.Dst,o.Dst)?n:r,n.inside||s.fixUpperEdge){if(s===n)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,n,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){i.connectLeftVertex(t,e);return}var r=i.topLeftRegion(t,n.activeRegion);nt(r!==null);var s=i.regionBelow(r),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,r,a):i.addRightEdges(t,r,a.Onext,o,o,!0)},i.addSentinel=function(t,e,n,r){var s=new aw,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=r,o.Dst.s=e,o.Dst.t=r,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 y6(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],r=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;i.addSentinel(t,r,s,o),i.addSentinel(t,r,s,a)},i.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++n===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,n,r,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,r=e.Lnext,Qe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,r,e),t.mesh.delete(e),e=r,r=e.Lnext),r.Lnext===e&&(r!==e&&((r===n||r===n.Sym)&&(n=n.next),t.mesh.delete(r)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,n,r,s=0;for(r=t.mesh.vHead,n=r.next;n!==r;n=n.next)s++;for(s+=8,e=t.pq=new g6(s,Qe.vertLeq),r=t.mesh.vHead,n=r.next;n!==r;n=n.next)n.pqHandle=e.insert(n);return n!==r?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var n,r,s;for(n=e.fHead.next;n!==e.fHead;n=r)r=n.next,s=n.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 n,r;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;r=t.pq.min(),!(r===null||!Qe.vertEq(r,n));)r=t.pq.extractMin(),i.spliceMergeVertices(t,n.anEdge,r.anEdge);i.sweepEvent(t,n)}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}(),x6=function(){function i(){this.mesh=new T2,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=xt.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,n,r,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[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,n=p[v],r=f[v],c[0]=n.coords[0]-r.coords[0],c[1]=n.coords[1]-r.coords[1],c[2]=n.coords[2]-r.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-r.coords[0],d[1]=e.coords[1]-r.coords[1],d[2]=e.coords[2]-r.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[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,n=this.mesh.vHead,r,s=0,o=t.next;o!==t;o=o.next)if(r=o.anEdge,!(r.winding<=0))do s+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(s<0){for(e=n.next;e!==n;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],n,r,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),n=this.sUnit,r=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,r);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 n,r;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Qe.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Qe.vertLeq(n.Org,n.Dst);n=n.Lnext);r=n.Lprev;for(var s=void 0;n.Lnext!==r;)if(Qe.vertLeq(n.Dst,r.Org)){for(;r.Lnext!==n&&(Qe.edgeGoesLeft(r.Lnext)||Qe.edgeSign(r.Org,r.Dst,r.Lnext.Dst)<=0);)s=t.connect(r.Lnext,r),r=s.Sym;r=r.Lprev}else{for(;r.Lnext!==n&&(Qe.edgeGoesRight(n.Lprev)||Qe.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(r.Lnext===n)throw"Mono region invalid";for(;r.Lnext.Lnext!==n;)s=t.connect(r.Lnext,r),r=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},i.prototype.setWindingNumber_=function(t,e,n){for(var r,s=t.eHead.next;s!==t.eHead;s=r)r=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?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,n,r){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);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>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===mn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*r,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*r;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],r>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=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[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===mn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var p=l;p<n;++p)this.elements[h++]=-1}}},i.prototype.outputContours_=function(t,e){var n,r,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){r=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==r);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,r=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==r);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new T2),t<2&&(t=2),t>3&&(t=3);for(var n=null,r=0;r<e.length;r+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[r+0],n.Org.coords[1]=e[r+1],t>2?n.Org.coords[2]=e[r+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},i.prototype.tesselate=function(t,e,n,r,s,o){if(t===void 0&&(t=xt.ODD),e===void 0&&(e=mn.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,r<2&&(r=2),r>3&&(r=3),!this.mesh)return!1;this.projectPolygon_(),v6.computeInterior(this,o);var a=this.mesh;return e===mn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===mn.BOUNDARY_CONTOURS?this.outputContours_(a,r):this.outputPolymesh_(a,e,n,r),!0},i}();function as(i){var t=i.windingRule,e=t===void 0?xt.ODD:t,n=i.elementType,r=n===void 0?mn.POLYGONS:n,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,d=i.contours,h=d===void 0?[]:d,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!h&&p)throw new Error("Contours can't be empty");if(!!h){var y=new x6;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,r,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 Nde=xt.ODD,Bde=xt.NONZERO,Fde=xt.POSITIVE,Vde=xt.NEGATIVE,kde=xt.ABS_GEQ_TWO,Ude=mn.POLYGONS,zde=mn.CONNECTED_POLYGONS,Gde=mn.BOUNDARY_CONTOURS;var qy=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*qy.eSize;this.buffer=new ArrayBuffer(n);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*r,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 n=t*qy.eSize,r=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(r,o*s,3*t);o+=3*t;let l=new Float32Array(r,o*s,3*t);o+=3*t;let u=new Float32Array(r,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=r,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 r=this.capacity;for(;e>r;)r*=2;this.realloc(r)}let n=this.size;return this.size=e,n}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)}},$f=qy;$f.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var R2=$o(O2()),ep={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},hw={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},fw={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},dw=(i,t)=>([e,n])=>(n<e&&(n+=t),(i>=e?i:i+t)<=n),ja=class extends Ee{constructor(e,n,r=0,s=12,o=3,a=xt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._curveSegments=s,this._bevelSegmentsInput=o;let u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let D=C.extractShapePointsToFlatArray([],s),P=[];for(let I=D.length-1;I>=1;I-=2){let L=D[I-1],H=D[I-0];P.push(L,H)}return P}),d=[],h=[];for(let C=0;C<u.length;C+=2)h.push([u[C],u[C+1]]);d.push(h);for(let C=0;C<c.length;C++){let D=c[C],P=[];for(let I=0;I<D.length;I+=2)P.push([D[I],D[I+1]]);d.push(P)}let f;e.isText?f=new tu().setFromPoints(e.points.map(D=>D.position)).getSize(new B).length()*.1:d[0].length===0?f=r:f=(0,R2.default)(d).distance,r<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(r,f,n/2),this._bevelSegments=Math.floor(o));let p;try{p=as({windingRule:a,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=ep}let m;try{m=as({windingRule:xt.ODD,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=hw}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 D=m.elements[C],P=C%2===0?p.vertexCount:0;p.elements.push(D+P)}for(let C=0;C<m.vertexIndices.length;C++){let D=m.vertexIndices[C],P=p.vertexCount;p.vertexIndices.push(D+P)}for(let C=0;C<m.vertices.length;C++){let D=m.vertices[C];p.vertices.push(D)}}let y=1/0,v=-1/0,x=1/0,b=-1/0;for(let C=0,D=p.vertexCount;C<D;C++){let P=C*2,I=p.vertices[P+0],L=p.vertices[P+1];I<y&&(y=I),I>v&&(v=I),L<x&&(x=L),L>b&&(b=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=b-x,this._buffer=new $f(this._computeBufferEstimatedSize(p));let w=[],E=[];for(let C=p.elementCount-1;C>=0;C--){let D=C>=g,P=C*2,I=p.elements[P+0],L=p.elements[P+1],H=I+L,k={start:I,count:L,normals:[],continuous:[],concave:[]},G=I,z=H-1,U=I+1,$=this._shape.roundedCurves.length;do{let V=G-I,Z=p.vertices[z*2+0],Q=p.vertices[z*2+1],K=p.vertices[G*2+0],W=p.vertices[G*2+1],ye=p.vertices[U*2+0],fe=p.vertices[U*2+1],ie=K-Z,Ae=W-Q,xe=Math.sqrt(ie*ie+Ae*Ae);ie/=xe,Ae/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,k.normals[V*2+0]=-Ie,k.normals[V*2+1]=Oe,k.concave[V]=ie*Ie-Ae*Oe>0;let Te=p.vertexIndices[G];if(Array.isArray(Te))k.continuous[V]=!1;else{let[Ue,ze]=this._shape.getCurveIndexFromVertexId(Te-1,!0);if(ze>0&&ze<1)k.continuous[V]=!0;else{let R=ze===1?Ue+1:Ue-1;R=(R+$)%$;let O=ze===1?0:1,ne=this._shape.roundedCurves[Ue].getTangent(ze),ue=this._shape.roundedCurves[R].getTangent(O);k.continuous[V]=ne.dot(ue)>.95}}D&&(k.normals[V*2+0]*=-1,k.normals[V*2+1]*=-1),[z,G,U]=[G,U,U+1],U>=H&&(U-=L)}while(U!==I+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,H*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((V,Z)=>[Z,Z]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,H*2)});let j=0;for(let V=1;V<=this._bevelSegments;V++){let Z=V/this._bevelSegments*Math.PI/2,Q=(1-Math.cos(Z))*this._bevel,K=[],W=[],ye=[],fe=[],ie=0;for(let xe=0;xe<L;xe++){let Oe=xe*2,Ie=(xe-1+L)%L*2,Pe=p.vertices[k.start*2+Oe+0],Te=p.vertices[k.start*2+Oe+1],Ue=-k.normals[Ie+0]*Q,ze=-k.normals[Ie+1]*Q,R=-k.normals[Oe+0]*Q,O=-k.normals[Oe+1]*Q;if(k.concave[xe]||!k.concave[xe]&&D){let ne=Math.atan2(ze,Ue),ue=Math.atan2(O,R);ue>ne&&(ue-=Math.PI*2);let me=ue-ne;if(k.continuous[xe]||D){let De=ne+me/2,Me=Math.cos(De)*Q,_e=Math.sin(De)*Q;K[2*ie+0]=Pe+Me*(D?-1:1),K[2*ie+1]=Te+_e*(D?-1:1),fe[ie]=xe,ie++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Me=0;Me<=De;Me++){let _e=ne+me*(Me/De),le=Math.cos(_e)*Q,Ke=Math.sin(_e)*Q;K[2*ie+0]=Pe+le,K[2*ie+1]=Te+Ke,fe[ie]=xe,ie++}}}else K[2*ie+0]=Pe+Ue,K[2*ie+1]=Te+ze,fe[ie]=xe,W[xe]=ie,ie++,K[2*ie+0]=Pe,K[2*ie+1]=Te,fe[ie]=xe,ie++,K[2*ie+0]=Pe+R,K[2*ie+1]=Te+O,fe[ie]=xe,ye[xe]=ie,ie++}let Ae=as({windingRule:xt.POSITIVE,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],Te=fe[(Ie+1)%fe.length];xe.idx=[Pe,Te],xe.Sym.idx=[Te,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!Ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!Ae.vertexCount){let xe=(V-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<Ae.vertexIndices.length;xe++){let[Oe,Ie]=Ae.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie<Oe&&(Pe+=L);for(let Te=Oe;Te<Pe;Te++){let Ue=Te%L,ze=(Te+1)%L;if(!k.continuous[Ue]||!k.continuous[ze]){Ae.vertexIndices[xe]=[Oe,Ue],Ae.vertexIndices.splice(xe+1,0,[ze,Ie]),Ae.vertices.splice((xe+1)*2,0,Ae.vertices[xe*2],Ae.vertices[xe*2+1]);break}}}F.push({bevelI:V,angle:Z,size:Q,boundary:Ae,reverseMap:fe,insetPoints:K})}let X=(V,Z,Q)=>{let K=0,W=V.boundary.vertexIndices.length;for(;K<W&&Q(V.boundary.vertexIndices[Z]);)Z=(Z+1)%W,K++;return K},q=w.length;for(let V=1;V<F.length;V++){let Z=F[V-1],Q=F[V],K=Z.boundary.vertexIndices.length,W=Q.boundary.vertexIndices.length;if(!K||!W)break;let ye=k.concave.length,fe=0,ie=dw(fe,L);for(;!Z.boundary.vertexIndices.filter(ie).length||!Q.boundary.vertexIndices.filter(ie).length;)fe++,ie=dw(fe,L);let Ae=Z.boundary.vertexIndices.findIndex(ie),xe=Q.boundary.vertexIndices.findIndex(ie);do Ae=(Ae+1)%K;while(ie(Z.boundary.vertexIndices[Ae]));do xe=(xe+1)%W;while(ie(Q.boundary.vertexIndices[xe]));fe=(fe+1)%L;let Oe=fe,Ie=0,Pe=this._buildBevelVert(k,Z,(Ae-1+K)%K,void 0,Ie),Te=this._buildBevelVert(k,Q,(xe-1+W)%W,void 0,Ie),Ue=Pe,ze=Te,R,O,ne=!1;do{Ie=(fe||ye)/ye,ie=dw(fe,L);let ue=X(Z,Ae,ie),me=X(Q,xe,ie),De=ne;if(ne=!1,ue&&!me){for(let Me=0;Me<ue;Me++)R=this._buildBevelVert(k,Z,(Ae+Me)%K,Me/(ue-1),Ie),w.push(Ue.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ue.bottomN,ze.bottomN),Ue=R;ne=!0}else if(!ue&&me)for(let Me=0;Me<me;Me++)O=this._buildBevelVert(k,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(ze.topN,Ue.topP,O.topP),l===!1&&w.push(Ue.bottomP,ze.bottomN,O.bottomP),ze=O;else if(ue&&me)if(R=this._buildBevelVert(k,Z,Ae,0,Ie),O=this._buildBevelVert(k,Q,xe,0,Ie),De?(w.push(Ue.topN,O.topP,ze.topN),w.push(Ue.topN,R.topP,O.topP),l===!1&&(w.push(O.bottomP,Ue.bottomN,ze.bottomN),w.push(O.bottomP,R.bottomP,Ue.bottomN))):(w.push(ze.topN,Ue.topN,R.topP),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ue.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP))),Ue=R,ze=O,ue===me)for(let Me=1;Me<ue;Me++)R=this._buildBevelVert(k,Z,(Ae+Me)%K,Me/(ue-1),Ie),O=this._buildBevelVert(k,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(Ue.topN,R.topP,ze.topN),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ue.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP)),Ue=R,ze=O;else if(ue>me){let Me=ue/me,_e=0;for(let le=1;le<ue;le++)R=this._buildBevelVert(k,Z,(Ae+le)%K,le/(ue-1),Ie),w.push(Ue.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ue.bottomN,ze.bottomN),Ue=R,le>(_e+1)*Me&&(_e++,O=this._buildBevelVert(k,Q,(xe+_e)%W,_e/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O)}else{let Me=me/ue,_e=0;for(let le=1;le<me;le++)O=this._buildBevelVert(k,Q,(xe+le)%W,le/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O,le>(_e+1)*Me&&(_e++,R=this._buildBevelVert(k,Z,(Ae+_e)%K,_e/(ue-1),Ie),w.push(Ue.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ue.bottomN,ze.bottomN),Ue=R)}Ae=(Ae+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(F,k,w),D){let V=[];for(let Z=w.length-1;Z>=q+2;Z-=3){let Q=w[Z-2],K=w[Z-1],W=w[Z-0];V.push(W,K,Q)}w.splice(q,w.length-q,...V)}if(D){let V=[];for(let Z=F[F.length-1].boundary.vertices.length-1;Z>=1;Z-=2){let Q=F[F.length-1].boundary.vertices[Z-1],K=F[F.length-1].boundary.vertices[Z-0];V.push(Q,K)}E.push(V)}if(!D){let V=F[F.length-1],Z;try{Z=as({windingRule:F.length>1?xt.POSITIVE:xt.ODD,elementType:mn.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...E]})}catch{Z=fw}if(!Z)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Q=0;Q<Z.elementCount*3;Q+=3){let K=this._buildSurfaceVert(Z,Z.elements[Q+0],j),W=this._buildSurfaceVert(Z,Z.elements[Q+1],j),ye=this._buildSurfaceVert(Z,Z.elements[Q+2],j);w.push(K.top,W.top,ye.top),l===!1&&w.push(ye.bottom,W.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ge(Uint32Array.from(w),1),S=new Ge(this._buffer.positions,3),T=new Ge(this._buffer.normals,3),M=new Ge(this._buffer.uvs,2);S.needsUpdate=!0,T.needsUpdate=!0,M.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",T),this.setAttribute("uv",M),this.setIndex(_)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n,r){let s=n.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[n*2+0],a=e.vertices[n*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),d=c*3,h=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[d+0]=o,this._buffer.positions[d+1]=a,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-r,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[h+0]=l,this._buffer.uvs[h+1]=u,this.forPathBevel===!1&&(this._buffer.positions[d+3]=o,this._buffer.positions[d+4]=a,this._buffer.positions[d+5]=r,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[h+2]=l,this._buffer.uvs[h+3]=u),this.vertexCache[s]=f,f}_buildBevelVert(e,n,r,s=1,o){let a=`${n.bevelI}:${r}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,u]=n.boundary.vertexIndices[r],c,d,h,f;l!==u?(d=l,c=u,f=!1,h=e.continuous[d]&&e.continuous[c]):(c=l,d=(c-1+e.count)%e.count,f=e.concave[c]&&n.bevelI>0,h=e.continuous[c]||f);let p=Math.cos(n.angle),m=Math.sin(n.angle),g=r*2,y=c*2,v=d*2,x=n.boundary.vertices[g+0],b=n.boundary.vertices[g+1],w=(1-m)*this._bevel,E=(x-this._minX)/this._width,_=(b-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(E=o),_=1);let S=e.normals[y+0],T=e.normals[y+1],M=e.normals[v+0],C=e.normals[v+1];if(f){let H=M-S,k=C-T;S=S+H*(1-s),T=T+k*(1-s);let G=Math.sqrt(S*S+T*T);S/=G,T/=G}let D=this.forPathBevel?this._buffer.get(h?1:2):this._buffer.get(h?2:4),P=D*3,I=D*2,L={i:r,fi:c,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:o};return this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=S*p,this._buffer.normals[P+1]=T*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=S*p,this._buffer.normals[P+4]=T*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E),h||(this.forPathBevel?(D+=1,P+=3,I+=2):(D+=2,P+=6,I+=4),L.topP=D+0,L.bottomP=D+1,this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=M*p,this._buffer.normals[P+1]=C*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=M*p,this._buffer.normals[P+4]=C*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E)),this.vertexCache[a]=L,L}clone(){let e=new ja(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var wd=class extends Ee{constructor(e,n=12,r={}){super();this.type="ShapeGeometry";this.windingRule=xt.ODD;this.elementType=mn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:xt.ODD,elementType:mn.POLYGONS,polySize:3,vertexSize:2,strict:!0},r);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;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),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=as({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=ep}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(h*3),3),this._normalAttribute=new Ge(new Float32Array(h*3),3),this._uvAttribute=new Ge(new Float32Array(h*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 b=0,w=h;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1];_<p&&(p=_),_>m&&(m=_),S<g&&(g=S),S>y&&(y=S)}let v=m-p,x=y-g;for(let b=0,w=h;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1],T=(_-p)/v,M=(S-g)/x;this._positionAttribute.setXYZ(b,_,S,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,M)}for(let b=0,w=f;b<w;b++){let E=b*3,_=a.elements[E+0],S=a.elements[E+1],T=a.elements[E+2];this._indexAttribute.setX(E+0,_),this._indexAttribute.setX(E+1,S),this._indexAttribute.setX(E+2,T)}}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 wd(this._shape,this._curveSegments);return e.userData=Io(this.userData),e}};var Ad=class extends ja{constructor(e,n,r=0,s=12,o=3,a=xt.ODD){super(e,n,r,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Ad(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var ri=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:xt.ODD},i.parameters),n=Math.abs(e.width),r=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 Pt?(o.width!==n||o.height!==r)&&o.applySize(n,r):o=new Pt(n,r).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Pt(n,r);return{parameters:Object.assign(e,{width:n,height:r,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:r,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new wd(i.shape,r,{windingRule:o}):a=new Ad(i.shape,t,e,r,n,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var N2=Math.PI*2,_d=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=we.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,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:n,angle:r,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,d=e*.5,h=E6(u,c,d,r*Math.PI/180,n,s);u.isClosed=!0,u.update();let f;return r===0?(f=new Ee,f.setAttribute("position",new be([],3))):f=ri.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function E6(i,t,e,n,r,s){if(n>=N2)return r>30||r%4===0?(T6(i,t,e,s),Math.round(r/4)):L2(i,n,r,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=_2({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return r>30||r%u.length===0?_6(i,o.x,o.y,u,r,t,e,s):L2(i,n,r,t,e,s)}function _6(i,t,e,n,r,s,o,a){let l=Math.round(r/n.length);i.addPoint(Ed(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=i.points[u],f=Ed(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),i.addPoint(f)}return a>0?B2(i,s,o,a):i.addPoint(Ed(0,0)),l}function L2(i,t,e,n,r,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*r;i.addPoint(Ed(u,c))}return t<N2?s>0?B2(i,n,r,s):i.addPoint(Ed(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&F2(i,n,r,s)),1}function T6(i,t,e,n=0,r=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Xy(r-t,s,r-t,s-l,r-t,s+l)),i.addPoint(Xy(r,s+e,r-a,s+e,r+a,s+e)),i.addPoint(Xy(r+t,s,r+t,s+l,r+t,s-l)),i.addPoint(Xy(r,s-e,r+a,s-e,r-a,s-e)),n>0&&F2(i,t,e,n)}function Ed(i,t){return new os(we.generateUUID(),new B(i,t))}function Xy(i,t,e,n,r,s){let o=Ed(i,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(r,s),o}function B2(i,t,e,n){V2(i,t,e,n).forEach(s=>i.addPoint(s))}function F2(i,t,e,n){let r=V2(i,t,e,n),s=new Pt;r.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function V2(i,t,e,n){let r=n*t/100,s=r*(Math.abs(e)/Math.abs(t)),o=new B(r/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=we.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 k2=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),n=Math.abs(e.width),r=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:r,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:n,radius:r,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=i.parameters,h=new tp(!1,t,e,n,r,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...i,type:"HelixGeometry"}})}},pw=new Ms([0,0,0],1),tp=class extends Ee{constructor(t=!0,e=1,n=1,r=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let p=()=>new A,m=new A,g=p(),y=p(),v=p(),x,b,w,E,_,S,T,M,C=p(),D=p(),P=p(),I=p(),L=p(),H=p(),k=p(),G=p(),z=n-2*l+.001,U=z/o,$=Math.ceil(a*o),F=$+1,j=z/$,X=-z/2,q=c+1,V=2*Math.PI/c,Z=Math.PI/2/h,Q=.01,K=Math.min((1-d/100)*l,l-Q),W=l-K,ye=0,fe=2,ie=h*fe+fe,Ae=q*ie/fe,xe=Ae+q*F,Oe=Math.max(0,q*(F+ie)),[Ie,Pe,Te]=[3,3,2].map(Ve=>Array(Oe*Ve).fill(0)),Ue=[],ze=s-l;function R(Ve,Le){let je=Math.PI/2;S=Le*j,M=2*Math.PI*(S%U)/U+je,S+=X,T=Math.sin(M)*ze,_=Math.cos(M)*ze,t?Ve.set(_,T,S):Ve.set(_,S,T)}R(m,-1e-10),R(g,0),C.copy(m),R(m,1);let O=m.distanceTo(g),ne=f?0:W+K,ue=O*$+2*ne,me=K,De=ue-ne;for(let Ve=0;Ve<=$;Ve++){R(y,Ve),G.subVectors(y,C).normalize(),C.copy(y),H.copy(y).setComponent(+t+1,0).normalize(),k.crossVectors(G,H).normalize();let Le=Ve===0,je=Ve===$,Je=Le?3*Math.PI/2:Z,St=Le?me:De,Zt=Le?q:xe,Ln=Le?0:Oe-q,Y=G.clone().multiplyScalar(Le?-W:W).add(y),ce=G.clone().multiplyScalar(Le?-1:1).normalize();for(let ve=0;ve<q;ve++){let ke=ve*V;if(D.addVectors(m.copy(H).multiplyScalar(l*Math.cos(ke)),g.copy(k).multiplyScalar(l*Math.sin(ke))),P.copy(D).normalize(),Le||je){f||(ye=Ln+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=Y.getComponent(Be),Pe[ye*3+Be]=ce.getComponent(Be)}),Te[ye*2]=+je,Te[ye*2+1]=ve/c),g.copy(P).multiplyScalar(K),v.addVectors(y,g);for(let Be=0;Be<h;Be++){let wt=Be*Z+Je;I.addVectors(m.copy(G).multiplyScalar(W*Math.sin(wt)),g.copy(P).multiplyScalar(W*Math.cos(wt))),L.copy(I).normalize(),g.addVectors(v,I),I.normalize(),ye=Zt+Be*q+ve,[0,1,2].forEach(Sn=>{Ie[ye*3+Sn]=g.getComponent(Sn),Pe[ye*3+Sn]=L.getComponent(Sn)});let Nn=+Le+Math.sin(wt);Te[ye*2]=(St+W*Nn)/ue,Te[ye*2+1]=ve/c}}g.addVectors(y,D),ye=Ae+Ve*q+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=g.getComponent(Be),Pe[ye*3+Be]=P.getComponent(Be)}),Te[ye*2]=(ne+Ve*O)/ue,Te[ye*2+1]=ve/c}}let Me=F+2*h+fe,_e=1,[le,Ke]=[+f,Me-1];for(let Ve=le;Ve<=Ke-1;Ve++){let Le=f&&Ve===Ke-1;for(let je=0;je<q-1;je++)x=Ve*q+je,b=x+1,w=(Le?je:x)+q,E=(Le?je+1:b)+q,Ve===0?Ue.push(b,E,w):Ve===Me-2?Ue.push(x,b,w):Ue.push(x,b,w,b,E,w)}this.setIndex(Ue),this.setAttribute("position",new be(Ie,3)),this.setAttribute("normal",new be(Pe,3)),this.setAttribute("uv",new be(Te,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,r=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let h=0;h<t.radialSegments;h++)s=c*n+h,o=s+1,a=(d?h:s)+n,l=(d?h+1:o)+n,r[u++]=s,r[u++]=o,r[u++]=a,r[u++]=o,r[u++]=l,r[u++]=a;return r.length=u,pw.array=r,pw.count=r.length,pw}};var U2=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:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new np(t*.5,s,o):new Wc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},np=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],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,n),this.type=a}static fromJSON(t){return new np(t.radius,t.corner,t.cornerSides)}};var z2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[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:n}=i.parameters,r=new _o;r.moveTo(t[0].x,t[0].y),r.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Uc(r.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Hs=new se,mw=new mt,Ky=new A,Wa=class extends Ht{constructor(){super(),this.uuid=we.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 $t().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];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 Hs.makeRotationX(t),this.applyMatrix4(Hs),this}rotateY(t){return Hs.makeRotationY(t),this.applyMatrix4(Hs),this}rotateZ(t){return Hs.makeRotationZ(t),this.applyMatrix4(Hs),this}translate(t,e,n){return Hs.makeTranslation(t,e,n),this.applyMatrix4(Hs),this}scale(t,e,n){return Hs.makeScale(t,e,n),this.applyMatrix4(Hs),this}lookAt(t){return mw.lookAt(t),mw.updateMatrix(),this.applyMatrix4(mw.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,o=r.normal,a=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Fe().fromBufferAttribute(a,h));function c(h,f,p,m){let g=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,p)],v=new Td(h,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new B().fromBufferAttribute(l,h),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,p)]),u!==void 0&&e.faceVertexUvs[1].push([new B().fromBufferAttribute(u,h),new B().fromBufferAttribute(u,f),new B().fromBufferAttribute(u,p)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+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(Ky).negate(),this.translate(Ky.x,Ky.y,Ky.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new se;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],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 n=0,r=this.vertices.length;n<r;n++)e[n]=new A;if(t){let n=new A,r=new A;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];n.subVectors(c,u),r.subVectors(l,u),n.cross(r),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],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 n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,o=r.vertexNormals.length;s<o;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let t=new Wa;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;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 A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let r=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=r.faceNormals[s],u=r.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,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Tt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ln),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(r=new $t().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let m=a[h].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let p=u[h],m,g,y=p.vertexNormals,v=p.vertexColors,x=new Td(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,w=y.length;b<w;b++)m=y[b].clone(),r!==void 0&&m.applyMatrix3(r).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let b=0,w=v.length;b<w;b++)g=v[b],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let p=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++)v.push(y[x].clone());this.faceVertexUvs[h].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={},n=[],r=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),r[l]=n.length-1):r[l]=r[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=r[c.a],c.b=r[c.b],c.c=r[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+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,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new A(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;r&&r.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(r[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 n=[],r=[],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,b=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,E=m.vertexColors.length>0,_=0;if(_=c(_,0,0),_=c(_,1,g),_=c(_,2,y),_=c(_,3,v),_=c(_,4,x),_=c(_,5,b),_=c(_,6,w),_=c(_,7,E),n.push(_),n.push(m.a,m.b,m.c),n.push(m.materialIndex),v){let S=this.faceVertexUvs[0][p];n.push(f(S[0]),f(S[1]),f(S[2]))}if(x&&n.push(d(m.normal)),b){let S=m.vertexNormals;n.push(d(S[0]),d(S[1]),d(S[2]))}if(w&&n.push(h(m.color)),E){let S=m.vertexColors;n.push(h(S[0]),h(S[1]),h(S[2]))}}function c(p,m,g){return g?p|1<<m:p&~(1<<m)}function d(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=r.length/3,r.push(p.x,p.y,p.z)),s[m]}function h(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=r,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new Wa().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 h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let r=t.faces;for(let h=0,f=r.length;h<f;h++)this.faces.push(r[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let p=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let p={};if(p.name=s[h].name,s[h].vertices!==void 0){p.vertices=[];for(let m=0,g=s[h].vertices.length;m<g;m++)p.vertices.push(s[h].vertices[m].clone())}if(s[h].normals!==void 0){p.normals=[];for(let m=0,g=s[h].normals.length;m<g;m++)p.normals.push(s[h].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let p={};if(o[h].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[h].vertexNormals.length;m<g;m++){let y=o[h].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[h].faceNormals.length;m<g;m++)p.faceNormals.push(o[h].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.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 gw().fromGeometry(this),e=new Ee,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Qy.call(new Ge(n,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);e.setAttribute("normal",Qy.call(new Ge(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);e.setAttribute("color",G2.call(new Ge(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);e.setAttribute("uv",H2.call(new Ge(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",H2.call(new Ge(r,2),t.uvs2))}e.groups=t.groups;for(let r in t.morphTargets){let s=[],o=t.morphTargets[r];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(Qy.call(c,u.data))}e.morphAttributes[r]=s}if(t.skinIndices.length>0){let r=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",j2.call(r,t.skinIndices))}if(t.skinWeights.length>0){let r=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",j2.call(r,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 Ee,n=t.geometry;if(t.isPoints||t.isLine){let r=new be(n.vertices.length*3,3),s=new be(n.colors.length*3,3);if(e.setAttribute("position",Qy.call(r,n.vertices)),e.setAttribute("color",G2.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new be(n.lineDistances.length,1);e.setAttribute("lineDistance",M6.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};Wa.prototype.isGeometry=!0;var gw=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=[],n,r,s,o=t.faces;for(r=0;r<o.length;r++){let a=o[r];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=r*3-n.start,e.push(n)),n={start:r*3,materialIndex:s})}n!==void 0&&(n.count=r*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[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,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,p=t.skinWeights,m=f.length===n.length,g=p.length===n.length;n.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(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][y];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new B,new B,new B))}if(o===!0){let w=r[1][y];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new B,new B,new B))}for(let w=0;w<l;w++){let E=a[w].vertices;u[w].data.push(E[v.a],E[v.b],E[v.c])}for(let w=0;w<d;w++){let E=c[w].vertexNormals[y];h[w].data.push(E.a,E.b,E.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}},Td=class{constructor(t,e,n,r,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new A,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Fe,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,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function M6(i){return this.array.set(i),this}function G2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Fe),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function H2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new B),t[e++]=s.x,t[e++]=s.y}return this}function Qy(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function j2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Xe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var C6=["a","b","c"];function P6(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function yw(i,t,e){let n=Math.min(i,t),r=Math.max(i,t),s=n+"_"+r;return e.get(s)}function vw(i,t,e,n,r,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(r),s[i].edges.push(u),s[t].edges.push(u)}function D6(i,t,e,n){let r,s,o;for(r=0,s=i.length;r<s;r++)e[r]={edges:[]};for(r=0,s=t.length;r<s;r++)o=t[r],vw(o.a,o.b,i,n,o,e),vw(o.b,o.c,i,n,o,e),vw(o.c,o.a,i,n,o,e)}function Zy(i,t,e,n,r){i.push(new Td(t,e,n,void 0,void 0,r))}function Md(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Jy(i,t,e,n){i.push([t.clone(),e.clone(),n.clone()])}var $y=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ee?t=new Wa().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 A,n,r,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;D6(l,u,h,f);let p=[],m,g,y,v,x,b,w;for(let Q of Array.from(f.keys())){for(g=f.get(Q),y=new A,x=3/8,b=1/8,w=g.faces.length,w!=2&&(x=.5,b=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=g.faces[o],a=0;a<3&&(m=l[P6(v,C6[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(b),y.add(e),g.newEdge=p.length,p.push(y)}let E,_,S,T,M,C,D,P=[];for(r=0,s=l.length;r<s;r++){for(C=l[r],M=h[r].edges,n=M.length,n==3?E=3/16:n>3&&(E=3/(8*n)),_=1-n*Number(E),S=E,n<=2&&(n==2?(_=3/4,S=1/8):n==1||n==0),D=C.clone().multiplyScalar(_),e.set(0,0,0),o=0;o<n;o++)T=M[o],m=T.a!==C?T.a:T.b,e.add(m);e.multiplyScalar(Number(S)),D.add(e),P.push(D)}let I=P.concat(p),L=P.length,H,k,G,z=[],U=[],$,F,j,X,q=new B,V=new B,Z=new B;for(r=0,s=u.length;r<s;r++)v=u[r],H=Number(yw(v.a,v.b,f).newEdge)+L,k=Number(yw(v.b,v.c,f).newEdge)+L,G=Number(yw(v.c,v.a,f).newEdge)+L,Zy(z,H,k,G,v.materialIndex),Zy(z,v.a,H,G,v.materialIndex),Zy(z,v.b,k,H,v.materialIndex),Zy(z,v.c,G,k,v.materialIndex),d&&($=c[r],F=$[0],j=$[1],X=$[2],q.set(Md(F.x,j.x),Md(F.y,j.y)),V.set(Md(j.x,X.x),Md(j.y,X.y)),Z.set(Md(F.x,X.x),Md(F.y,X.y)),Jy(U,q,V,Z),Jy(U,F,q,Z),Jy(U,j,V,q),Jy(U,X,Z,V));t.vertices=I,t.faces=z,d&&(t.faceVertexUvs[0]=U)}};var Jn=new A,W2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ee().copy(new sr(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Jn),n={width:Jn.x,height:Jn.y,depth:Jn.z,subdivisions:0}):n=t.parameters;let r={...n,...i.parameters};return{parameters:{width:Math.abs(r.width),height:Math.abs(r.height),depth:Math.abs(r.depth),subdivisions:Math.abs(r.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:n,subdivisions:r}=i.parameters,s=i.geometry??new Ee().copy(new sr(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Jn)):Jn.set(o.width,o.height,o.depth),(t!==Jn.x||e!==Jn.y||n!==Jn.z)&&s.scale(Jn.x===0?1:t/Jn.x,Jn.y===0?1:e/Jn.y,Jn.z===0?1:n/Jn.z);let a=s.originalGeometry;try{r>0?(a===void 0||o?.subdivisions!==r)&&(a===void 0&&(a=s),s=new $y(r).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 $c(e).load(i,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Jn);let o=100/Jn.x;Object.assign(s.parameters,{width:100,height:Jn.y*o,depth:Jn.z*o}),t(this.build(s))})}};var ev=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 Pt?i.shape:new Pt,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:n,cornerRadius:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let m=0;m<n;m++){let g=f*m,y=d+Math.sin(g)*u,v=h+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=r;l.roundness=r,l.update();let p=ri.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var q2=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:n,radialSegments:r,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new bw(t*.5,e,r,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function rp(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function xw(i,t,e,n,r,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===r){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,r/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function I6(i,t,e){let n=i.clone().sub(t),r=e.clone().sub(t);return n.projectOnVector(r),n.add(t)}var bw=class extends Ee{constructor(t=.5,e=1,n=4,r=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),r=Math.floor(r),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,p=Math.PI/n,m=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),b=new A(0,f,0),w=new B(t,-f),E=new B(m,-f),_=new B(0,b.y).sub(E),S=new B(0,b.y).sub(w),T=new B(_.y,-_.x).normalize(),M=new B(S.y,-S.x).normalize(),D=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,D);let P;{let U=new A(T.x,T.y,0),$=new A(Math.cos(g)*U.x,U.y,Math.sin(g)*U.x);P=U.angleTo($)}let I=o/Math.tan((Math.PI-_.angle())/2),L=o/Math.tan((Math.PI-P)/2),H=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let U=h++,$=[],F=w.clone(),j=I/Math.cos(Math.PI/n);F.x-=j;for(let X=0;X<n;X++){let q=X/n*Math.PI*2+p,V=new B(Math.sin(q),Math.cos(q));rp(F,V,H),u.push(H.x,H.y,H.z),c.push(0,-1,0),d.push(0,0),$.push(h++)}for(let X=0;X<$.length;X++)l.push($[X],U,$[(X+1)%$.length])}let k=[];{let U=new A,$=new A,F=new A,j=new A,X=new A,q=new A;for(let V=0;V<n;V++){let Z=V/n*Math.PI*2+p,Q=(V+.5)/n*Math.PI*2+p,K=(V+1)/n*Math.PI*2+p,W=new B(Math.sin(Z),Math.cos(Z)),ye=new B(Math.sin(Q),Math.cos(Q)),fe=new B(Math.sin(K),Math.cos(K));rp(w,W,$),rp(w,fe,F),rp(T,ye,U),xw(b,$,F,L,L,j),u.push(j.x,j.y,j.z),xw($,b,F,L,I,X),u.push(X.x,X.y,X.z),xw(F,$,b,I,L,q),u.push(q.x,q.y,q.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),d.push(0,0),d.push(0,0),d.push(0,0);let ie=h++,Ae=h++,xe=h++;if(l.push(ie,Ae,xe),o>0){{let Pe=$.clone().add(F).multiplyScalar(.5),Te=b.clone().sub(Pe).normalize(),ze=x.clone().sub(Pe).normalize().add(Te).normalize().multiplyScalar(-1),R=q.clone().sub(X);G(Pe,R,ze,_.angle())}let Oe,Ie;{let Pe=new A;rp(M,fe,Pe);let Te=q.clone().add(j).multiplyScalar(.5);Te=I6(Te,F,b);let Ue=q.clone().sub(j);[Oe,Ie]=G(Te,Ue,Pe,P,j.y)}{let Pe=Oe,Te=Pe.clone().setY(0).normalize(),Ue=new A(0,-1,0),ze=Te.clone().cross(Ue);z(Pe,Te,Ue,ze)}k.concat(Ie);{let Pe=_.angle(),Te=Math.PI-Pe,Ue=b.clone();Ue.y-=o/Math.sin(Pe-Math.PI/2);let ze=new A,R=[];for(let ne=0;ne<a;ne++){let ue=[],me=Math.PI/2-Te*ne/a,De=Math.cos(me),Me=Math.sin(me),_e=Q;for(let le=0;le<=ne;le++){let Ke=Math.cos(_e),Ve=Math.sin(_e);U.x=De*Ve,U.y=Me,U.z=De*Ke,ze.copy(Ue).addScaledVector(U,o),u.push(ze.x,ze.y,ze.z),c.push(U.x,U.y,U.z),d.push(0,0),ue.push(h++),_e+=Math.PI*2/ne/n}R.push(ue)}Ie.reverse(),R.push(Ie);let O=R.length-1;for(let ne=0;ne<O;ne++){let ue=R[ne],me=R[ne+1],De=ue.length-1;l.push(me[1],ue[0],me[0]);for(let Me=1;Me<=De;Me++)l.push(ue[Me],ue[Me-1],me[Me]),l.push(me[Me+1],ue[Me],me[Me])}}}}}this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(d,2));function G(U,$,F,j,X){let q=-j/2,V=(Math.PI-j)/2,Z=$.clone().normalize().cross(F);U.addScaledVector(F,-o/Math.sin(V));let Q=new A,K=new A,W=1,ye=h,fe=[];for(let ie=0;ie<=a;ie++){let Ae=q+ie/a*j;K.set(0,0,0),K.addScaledVector(Z,Math.sin(Ae)),K.addScaledVector(F,Math.cos(Ae));for(let xe=0;xe<=W;xe++){let Oe=xe/W-.5;if(Q.copy(U),Q.addScaledVector($,Oe),Q.addScaledVector(K,o),X!=null){let Ie=Math.max(0,Q.y-X);Q.addScaledVector($,-Ie/$.y)}u.push(Q.x,Q.y,Q.z),c.push(K.x,K.y,K.z),d.push(0,0),xe===0&&fe.push(h),h++}}for(let ie=0;ie<a;ie++)for(let Ae=0;Ae<W;Ae++){let xe=ye+Ae+(W+1)*ie,Oe=xe+(W+1),Ie=Oe+1,Pe=xe+1;l.push(xe,Oe,Pe),l.push(Oe,Ie,Pe)}return[U.clone().addScaledVector($,.5),fe]}function z(U,$,F,j){let X=Math.PI/2,q=S.angle()-X,V=[],Z=new A,Q=new A;for(let W=0;W<=a;W++){let ye=[],fe=W/a;for(let ie=0;ie<=W;ie++){let xe=((W?ie/W:0)-.5)*v,Oe=Math.cos(xe),Ie=Math.sin(xe),Pe=Math.atan(Math.tan(q)*Oe),Te=(X+Pe)*fe,Ue=Math.cos(Te),ze=Math.sin(Te);Z.set(0,0,0),Z.addScaledVector($,ze*Oe),Z.addScaledVector(F,Ue),Z.addScaledVector(j,ze*Ie),Q.copy(U).addScaledVector(Z,o),u.push(Q.x,Q.y,Q.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),ye.push(h++)}V.push(ye)}let K=V.length-1;for(let W=0;W<K;W++){let ye=V[W],fe=V[W+1],ie=ye.length-1;l.push(ye[0],fe[1],fe[0]);for(let Ae=1;Ae<=ie;Ae++)l.push(ye[Ae-1],ye[Ae],fe[Ae]),l.push(ye[Ae],fe[Ae+1],fe[Ae])}}}};var tv=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),n=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(i){let t=i.shape,{width:e,height:n,cornerRadius:r,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(b,w,E){return w>e&&E>n?Math.min(b*e/w,b*n/E):w>e?b*e/w:E>n?b*n/E:b}let f=[];f[0]=r[0]===0?0:h(r[0],r[0]+r[3],r[0]+r[1]),f[1]=r[1]===0?0:h(r[1],r[1]+r[2],r[1]+r[0]),f[2]=r[2]===0?0:h(r[2],r[2]+r[1],r[2]+r[3]),f[3]=r[3]===0?0:h(r[3],r[3]+r[0],r[3]+r[2]);let p=c.x,m=d.x,g=d.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 b=0,w=t.points.length;b<w;b++)t.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=ri.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var Y2=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=we.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:n=t,widthSegments:r=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ee,c.setAttribute("position",new be([],3))):c=new Ml(.5*t,r,s,o,a,l,u*we.DEG2RAD),c.scale(1,e/t,n/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var X2=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:n=8,heightSegments:r=8}=i.parameters,s=new Ao(t,e,n,r);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var K2=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:n,angle:r,cornerRadius:s,cornerSegments:o}=i.parameters,a=new Sw(t,e,n,r,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},Sw=class extends Ee{constructor(t=1,e=1,n=1,r=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),r=Math.min(180-c,r),r*=Math.PI/180;let d=[],h=Math.PI/2,f=(Q=0,K=0,W=0)=>new A(Q,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,b=+y,[w,E,_]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],S=(Q,K=!1)=>Math.sin(Q-Math.PI/(1+ +K)),T=(Q,K=!1)=>Math.cos(Q-Math.PI/(1+ +K));_.y=Math.sin(r)*e-g;let M=Math.cos(r)*e-v,C=w.z-c;r<=h?(_.z=Math.min(M,C),_.z==C&&(_.y-=(M-C)/Math.tan(h-r))):E.z=Math.min(E.z-M-v,w.z-c),p.subVectors(w,E),m.subVectors(_,E);let D=Math.min(p.length(),m.length())*s/100,P=D*Math.tan(r/2),I=D/Math.cos(r/2),L=p.clone().normalize().add(m.normalize()).setLength(I).add(E);p.set(0,S(r,!0),T(r,!0)),d.push([_,p.clone()]);let H=(Math.PI-r)/o;for(let Q=0;Q<=o;Q++){let K=h+r+Q*H;p.set(0,Math.sin(K)*P,Math.cos(K)*P),p.add(L),m.set(0,S(K),T(K)),d.push([p.clone(),m.clone()])}d.push([w,f(0,1,0)]);let k=Math.sin(H/2)*P*2,G=d.length-1,z=d[0][0].distanceTo(d[1][0]),U=d[G-1][0].distanceTo(d[G][0]),$=z+k*o+U;d[0].push(1);for(let Q=0;Q<=o;Q++)d[Q+1].push(1-(z+Q*k)/$);d[G].push(0);let[F,j,X]=d[0],q,V,Z;for(let Q=1;Q<d.length;Q++)[q,V,Z]=d[Q],a.push(x,F.y,F.z,x,q.y,q.z,b,F.y,F.z,b,F.y,F.z,x,q.y,q.z,b,q.y,q.z),l.push(0,j.y,j.z,0,V.y,V.z,0,j.y,j.z,0,j.y,j.z,0,V.y,V.z,0,V.y,V.z),u.push(0,X,0,Z,1,X,1,X,0,Z,1,Z),[F,j,X]=[q,V,Z];this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(l,3)),this.setAttribute("uv",new be(u,2))}};var nv=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 Pt?i.shape:new Pt,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:n,spikes:r,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,d=t*.5,h=e*.5,f=0,p=0,m=o*Math.PI/360/r,g=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(r===3&&n===50){m=2*Math.PI/r;for(let b=0;b<r;b++){let w=m*b,E=f+Math.sin(w)*d,_=p+Math.cos(w)*h;c.addPoint(c.createPoint(E,_))}}else for(let b=0;b<r;b++){let w=f+Math.cos(g)*d,E=p+Math.sin(g)*h;c.addPoint(c.createPoint(w,E)),g+=m,w=f+Math.cos(g)*y,E=p+Math.sin(g)*v,b<=r,c.addPoint(c.createPoint(w,E)),g+=m}c.isClosed=!0;for(let b=0,w=c.points.length;b<w;b++)c.points[b].roundness=s;c.roundness=s,c.update();let x=ri.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var Q2=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,n=new Ao(t,e);return Object.assign(n,{userData:{...i,type:"TextFrameGeometry"}})}};var Z2=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),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:r,depth:s})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=O6(t,e,n,t*.5,o,s,0,0,r,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function O6(i,t,e,n,r,s,o,a,l,u,c){[t,e]=[e,t],o=t/2;let d=we.clamp(r/360,0,1);if(d===0){let h=new Ee;return h.setAttribute("position",new be([],3)),h}return d===1&&(u=0),new tp(!0,i,t,e,n,d,s,o,a,l,u,c)}var J2=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:n,radialSegments:r,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new qc(a,e,n,r,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var $2=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 Pt?i.shape:new Pt,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:n,depth:r,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 h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=ri.create({shape:l,parameters:{roundness:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...i,type:"TriangleGeometry"}})}};function eD(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var ww=class{add(t,e,n){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(r){this[r]=this[r]||[],e&&this[r][n?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(n){n.call(e&&e.context?e.context:e,e)})}},Aw=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,n){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,n?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 n={context:this,node:e};return ae.hooks.run(t,n),n.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(n){return n.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=[],n,r;for(;this.index<this.expr.length;)if(n=this.code,n===ae.SEMCOL_CODE||n===ae.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())e.push(r);else if(this.index<this.expr.length){if(n===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,n,r,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),r=[o,s,a];e=this.gobbleBinaryOp();){if(n=ae.binaryPrecedence(e),n===0){this.index-=e.length;break}s={value:e,prec:n,right_a:ae.right_associative.has(e)},u=e;let c=d=>s.right_a&&d.right_a?n>d.prec:n<=d.prec;for(;r.length>2&&c(r[r.length-2]);)a=r.pop(),e=r.pop().value,o=r.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},r.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),r.push(s,t)}for(l=r.length-1,t=r[l];l>1;)t={type:ae.BINARY_EXP,operator:r[l-1].value,left:r[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)r=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),n=e.length;n>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+=n;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,--n)}ae.isIdentifierStart(t)?(r=this.gobbleIdentifier(),ae.literals.hasOwnProperty(r.name)?r={type:ae.LITERAL,value:ae.literals[r.name],raw:r.name}:r.name===ae.this_str&&(r={type:ae.THIS_EXP})):t===ae.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):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 n;if(e===ae.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ae.PERIOD_CODE)break;n=!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||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:ae.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,n;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 n=this.code,ae.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(n===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,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===n){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
3139
3139
  `;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 r||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=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){n=!0,this.index++,t===ae.CPAREN_CODE&&r&&r>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===ae.COMMA_CODE){if(this.index++,r++,r!==e.length){if(t===ae.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ae.CBRACK_CODE)for(let o=e.length;o<r;o++)e.push(null)}}else if(e.length!==r&&r!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===ae.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return n||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)}}},R6=new ww;Object.assign(ae,{hooks:R6,plugins:new Aw(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 ql=i=>new ae(i).parse(),L6=Object.getOwnPropertyNames(ae);L6.forEach(i=>{ql[i]===void 0&&i!=="prototype"&&(ql[i]=ae[i])});ql.Jsep=ae;var N6="ConditionalExpression",B6={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let n=e.node,r=this.gobbleExpression();if(r||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:N6,test:n,consequent:r,alternate:s},n.operator&&i.binary_ops[n.operator]<=.9){let o=n;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=n}}else this.throwError("Expected :")}})}};ql.plugins.register(B6);var F6=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],V6=["0","1","2","3","4","5","6","7","8","9","."],k6=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function U6(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}ql.addBinaryOp("^",11,!0);function rv(i,t,e="number"){let n="";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=fr.getDisplayedValue(u);e==="number"&&fr.isTextValue(u)&&Array.isArray(u.textValue)&&u.textValue.length===1?c=parseFloat(c).toString():e==="boolean"&&fr.isBoolean(u)?c=u?"true":"false":e==="boolean"&&fr.isTextValue(u)&&!Array.isArray(u.textValue)&&(c='"'+c+'"'),n+=c;continue}else if(e==="string"){a.name!=='"'&&a.name!=="+"&&(n+=a.name),a.name==="+"&&n[n.length-1]==="\\"&&(n=n.slice(0,-1)+a.name);continue}if(a.name==="and"){n+="&&";continue}if(a.name==="or"){n+="||";continue}if(a.name==="True"){n+="true";continue}if(a.name==="False"){n+="false";continue}if(e==="boolean"&&!U6(a.name)&&!V6.includes(a.name)&&!F6.includes(a.name)&&!k6.includes(a.name.replace(/\($/g,""))){n+='"'+a.name+'"';continue}n+=a.name}if(e==="string")return n;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let r;try{r=ql(n)}catch(o){console.error(n,o);return}let s;try{s=Mt(r)}catch(o){console.error(n,r,o)}return s}function Mt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(Mt(i.left)===Mt(i.right));case"!=":return Number(Mt(i.left)!==Mt(i.right));case">":return Number(Mt(i.left)>Mt(i.right));case">=":return Number(Mt(i.left)>=Mt(i.right));case"<":return Number(Mt(i.left)<Mt(i.right));case"<=":return Number(Mt(i.left)<=Mt(i.right));case"+":return Mt(i.left)+Mt(i.right);case"-":return Mt(i.left)-Mt(i.right);case"*":return Mt(i.left)*Mt(i.right);case"/":return Mt(i.left)/Mt(i.right);case"%":return Mt(i.left)%Mt(i.right);case"&&":return Mt(i.left)&&Mt(i.right);case"||":return Mt(i.left)||Mt(i.right);case"^":return Math.pow(Mt(i.left),Mt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-Mt(i.argument);case"!":return Number(!Mt(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=Mt(i.arguments[0])}catch(n){console.warn(n)}if(i.arguments.length>=2)try{e=Mt(i.arguments[1])}catch(n){console.warn(n)}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(Mt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var z6=new se,G6=new se;function H6(i,t,e){let n=[new A,new A,new A],r=[new A,new A,new A];return i.extractBasis(n[0],n[1],n[2]),t.extractBasis(r[0],r[1],r[2]),n.forEach((s,o)=>{let a=r[o],l=we.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new se().makeBasis(n[0],n[1],n[2])}var tD=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),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??_d.create({parameters:xS}).userData.shape;return{path:i.path??Hu.defaultData(),parameters:Object.assign(e,{width:n,height:r,depth:s,extrusion:{...xy,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new Ew(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ee,{userData:{...i,type:"PathGeometry"}})}},Ew=class extends Ee{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)||!eD(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:r,offset:s}=this.inputs.parameters.extrusion;r=Math.max(0,Math.min(r,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((r+s)*o):Math.ceil(Math.min(1,r+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let z=0;z<u;z++){let U=this.inputs.path.isClosed?(z+a)%e.length:Math.min(z+a,e.length-1);c.push(e[U].clone()),d.push(n[U].clone())}let h=(z,U,$)=>{c[z]=c[z].clone().lerp(c[U],$),d[z]=H6(d[z],d[U],$)},f=0,p=s*o%1;(!this.inputs.path.isClosed||r<=1)&&(p||s===0)&&(f=p,h(0,1,f));let m=0,g=(s+r)*o%1;if((this.inputs.path.isClosed&&r<=1||!this.inputs.path.isClosed&&s+r<1)&&g&&(m=g,h(c.length-1,c.length-2,1-m)),r===0){let z=c.length-1;c[z].copy(c[0]),d[z].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:w,infos:E,vertices:_}=this._computeShapePoints(b),S=0,T;x==="round"&&(T=new ja(this.inputs.shapeData,2*y,y,b,v,void 0,!0),S=T.getAttribute("position").count);let M=0,C=0;E.sort((z,U)=>z.start-U.start),E.forEach(z=>{z.verticesStart=M,z.verticesCount=z.continuous.reduce((U,$,F)=>U+(F===0||!$?2:1),0),C+=z.verticesCount,M=C});let D=C*u,P,I=0;if(this._isOpenEnded()&&x==="flat"){try{P=as({windingRule:xt.ODD,elementType:mn.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:w})}catch{P=fw}I=P.vertexCount}let L=D+2*I+S*2,H=D+2*I,k={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},G=[];if(E.forEach(z=>{this._extrudeRegion(z,_,d,c,k,G,this._isGeometryClosed()&&!this._isOpenEnded())}),P&&(this._closeEnd(P,D,G,k,d[0],c[0],!1),this._closeEnd(P,D+I,G,k,d[d.length-1],c[c.length-1],!0)),T){k.positions.set(T.getAttribute("position").array,H*3),k.normals.set(T.getAttribute("normal").array,H*3),k.uvs.set(T.getAttribute("uv").array,H*2);let z=G.length;G.push(...T.getIndex().array.map(F=>F+H)),H+=S,k.positions.set(T.getAttribute("position").array,H*3),k.normals.set(T.getAttribute("normal").array,H*3),k.uvs.set(T.getAttribute("uv").array,H*2);let U=G.length;G.push(...T.getIndex().array.map(F=>F+H)),this.setAttribute("position",new Ge(k.positions,3)),this.setAttribute("normal",new Ge(k.normals,3)),this.setAttribute("uv",new Ge(k.uvs,2)),this.setIndex(G);let $=z6;$.copy(d[d.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange($,H,L),$.copy(d[0]).setPosition(c[0]).multiply(G6.makeScale(1,1,-1)),this.applyMatrix4OnRange($,H-S,H),this.reverseIndicesOnRange(z,U)}else this.setAttribute("position",new Ge(k.positions,3)),this.setAttribute("normal",new Ge(k.normals,3)),this.setAttribute("uv",new Ge(k.uvs,2)),this.setIndex(G)}_extractPathPoints(){let n=Gy(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let r=[n[0]];return n.forEach(o=>{r[r.length-1].distanceToSquared(o)>.001&&r.push(o)}),this.inputs.path.isClosed&&r[r.length-1].distanceTo(r[0])<.001&&r.pop(),r}_computeBasisMatrices(e){let n=[],r=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let g=0;g<r;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===r-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let b=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),E=b.clone().add(w).normalize();l.copy(E),g===0&&(E.equals(c)||E.clone().negate().equals(c))&&c.set(0,0,1);let _=c.clone().cross(E).normalize(),S=E.clone().cross(_).normalize();c.copy(S),u.copy(_),g===0&&(o.copy(S),a.copy(E));let T=new se().makeBasis(_,S,E);n.push(T)}let d=s?a:l,h=s?o:new A(0,1,0),f=d.clone().cross(u).normalize(),p=Math.acos(h.dot(f));if(isNaN(p))return n;let m=h.clone().cross(f);d.dot(m)>0&&(p*=-1);for(let g=1;g<n.length;g++){let y=new se().makeRotationZ(p*g/n.length);n[g].multiply(y)}return n}_applyPathModifiers(e,n,r){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new se,d=new se;return e.forEach((h,f)=>{let p=f===0?0:f===s-1?1:(f-n)/(s-(r===0?0:1)-(n+(1-r)));c.makeRotationZ(we.lerp(o,o+a,p)*we.DEG2RAD);let m=we.lerp(l,u,p);d.makeScale(m,m,m),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=xt.ODD){let r=this.inputs.shapeData,s=r.extractShapePointsToFlatArray([],e),o=r.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],b=g[v-0];y.push(x,b)}return y}),a;try{a=as({windingRule:n,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=ep}let l;try{l=as({windingRule:xt.ODD,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=hw}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,d=-1/0,h=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>d&&(d=v),x<h&&(h=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],b=v+x,w={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(w);let E=v,_=b-1,S=v+1,T=r.roundedCurves.length;do{let M=E-v,C=a.vertices[_*2+0],D=a.vertices[_*2+1],P=a.vertices[E*2+0],I=a.vertices[E*2+1],L=a.vertices[S*2+0],H=a.vertices[S*2+1],k=P-C,G=I-D,z=Math.sqrt(k*k+G*G);k/=z,G/=z;let U=P-L,$=I-H,F=Math.sqrt(U*U+$*$);U/=F,$/=F,w.normals[M*2+0]=-$,w.normals[M*2+1]=U;let j=a.vertexIndices[E];if(Array.isArray(j))w.continuous[M]=!1;else{let[X,q]=r.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)w.continuous[M]=!0;else{let V=q===1?X+1:X-1;V=(V+T)%T;let Z=q===1?0:1,Q=r.roundedCurves[X].getTangent(q),K=r.roundedCurves[V].getTangent(Z);w.continuous[M]=Q.dot(K)>.95}}g&&(w.normals[M*2+0]*=-1,w.normals[M*2+1]*=-1),[_,E,S]=[E,S,S+1],S>=b&&(S-=x)}while(S!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,n,r,s,o){let a=n*2,l=n*3;e.positions[l+0]=r.x,e.positions[l+1]=r.y,e.positions[l+2]=r.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,n,r,s,o,a,l){let u=new A,c=new A,d=new A,h=new A,f=new B;r.forEach((m,g)=>{let y=s[g],v=e.verticesStart*r.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let b=(e.start+x)*2;if(u.set(n[b+0],n[b+1],0),d.copy(u).applyMatrix4(m).add(y),e.continuous[x])h.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let w=x===0?(e.start+e.count-1)*2:b-2;c.set(n[w+0],n[w+1],0),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(m).normalize(),f.set(x===0?1:x/e.count,g/(r.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(r.length-1));else{let w=x===e.count-1?e.start*2:b+2;c.set(n[w+0],n[w+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(m).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let p=r.length-1;for(let m=0;m<p;m++){let g=e.verticesStart*r.length+e.verticesCount*m,y=e.verticesStart*r.length+e.verticesCount*(m+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let b=x===e.count-1?0:v+1,w=g+v,E=g+b,_=y+b,S=y+v;e.isHole?a.push(w,_,E,w,S,_):a.push(w,E,_,w,_,S),v++}}}_closeEnd(e,n,r,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),d=new A,h=new B;for(let p=0;p<u;p++){let m=2*p;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+p,d,c,h)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let m=3*p,g=f[m+0]+n,y=f[m+(l?1:2)]+n,v=f[m+(l?2:1)]+n;r.push(g,y,v)}}applyMatrix4OnRange(e,n,r){let s=e.elements,o=new $t().getNormalMatrix(e).elements,a,l,u,c,d=this.attributes.position,h=this.attributes.normal;if(!d||!h)return;let f=d.array,p=h.array,m=d.itemSize;for(let g=n*m,y=r*m;g<y;g+=m){if(g===n)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}d.needsUpdate=!0,h.needsUpdate=!0}reverseIndicesOnRange(e,n){let r=this.index;if(r){for(let s=e;s<n;s+=3){let o=r.getX(s),a=r.getX(s+1),l=r.getX(s+2);r.setXYZ(s,l,a,o)}r.needsUpdate=!0}}};function nD(){let i=new Ee;return i.setAttribute("position",new Ge(new Float32Array([]),3)),i.setIndex(new Ge(new Uint16Array([]),1)),i}var j6=nD().attributes,W6=12,q6=1,Cd=class extends Ee{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,j6),this.userData={parameters:e,type:"TextGeometry"};let r=n.getFont(e.font);r?.isLoaded?(this.font=r,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let r=n.getFont(e);r&&(this.font=r,await r.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=fr.getDisplayedValue(u),h=c===2?d.toUpperCase():c===3?d.toLowerCase():d,f=Y6(e,n,h),{shapes:p,charWidths:m,charCoords:g}=n.generateShapes(f,e),y=(typeof r=="number"?r:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(E=>new Pt().fromShape(E,!0));this.vectorShapes=x;let b=x.map(E=>ri.create({shape:E,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?xt.NONZERO:xt.ODD,subdivisions:this.isLowResolution&&o>0?q6:W6}})),w=b.length?rs(b):nD();w.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([E,_])=>{this.setAttribute(E,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Qr(new Ee,Cd.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,r])=>{this.setAttribute(n,r)}),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 Y6(i,t,e){let n=[""],r="";for(let s of e)r+=s,s===" "||s===`
3140
3140
  `?(n[n.length-1]+=r,r="",s===`
3141
- `&&n.push("")):t.getTextWidth(n[n.length-1]+r,i)>i.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+r,i)>i.width&&(r.length===1?(n[n.length-1]+=r,r=""):(n[n.length-1]+=r.slice(0,-1),r=r[r.length-1],n.push(""))));return n[n.length-1]+=r,n}var iD,Pd=new Promise(i=>{iD=i}),rD=!1;var iv;function sD(){if(rD)return;if(iv)return iv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.494/build",r=import("./process.js"),[s,o]=await Promise.all([r,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});iD(l),rD=!0}return iv=i(),iv}function Yl(i,t,e,n){let r,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 d of u)c=c[d];for(r in c){let d=c[r];fP(d)&&(c[r]=t.getVariable(d,[n.uuid,"geometry",...u,r]))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Pt.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 $c().parse(s);else if(s.type==="SubdivGeometry"){let u=new Pn(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new Cd(s,t);let l;try{l=_w(a)}catch(u){console.error(u)}if(!l){let u=Pt.createFromState(Gu.defaultData(),100,100);a.shape=u,l=_w(a)}return l}var X6=new se;function ip(i,t,e,n){let r=i.position.array,s=i.normal.array,o=X6.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=r.length;c<d;c+=3)r[c]*=t,r[c+1]*=e,r[c+2]*=n,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 sv=new Tt,Dd=new A,et;Pd.then(i=>{et=i});var oD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),aD=new Uint32Array([0,1,2,3]),lD=new Uint8Array([4]),Pn=class extends Ee{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let r=this.data.scaleBaked,s=Ns.div(n,r);this.subdividedGeometry&&ip(this.subdividedGeometry.attributes,...s),this.originalGeometry&&ip(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(Dd.fromArray(s));let a=Dd.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,n,r;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:r}=Pn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new sr(100,100,100),r=0}this.subdivPointer=r,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Pn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ln,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,r=e.boundingSphere.center;sv.setFromBufferAttribute(n),sv.getCenter(r),e.boundingSphere.radius=r.distanceTo(sv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),sv.getSize(Dd);let s={width:Dd.x,height:Dd.y,depth:Dd.z};return this.userData.parameters=s,s}static build(e,n,r,s){let o,a,l,u=e?.phongAngle??35;r===!1&&(u=-1),n&&(et.free_bvh(n),et.free_subdivision_surface(n));try{o=Pn.allocate(e,s)}catch(c){console.error(c,e),o=Pn.allocate({positionWASM:oD,indexWASM:aD,verticesPerFaceWASM:lD},s)}if(et.set_destination_refinement_level(o,0),a=Pn.buildLevel(o,!0,u),e.subdivisions>0)try{et.set_destination_refinement_level(o,e.subdivisions),l=Pn.buildLevel(o,!1,u)}catch{try{et.set_destination_refinement_level(o,e.subdivisions-1),l=Pn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,r){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?n.geometry:Yl(e,r,!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}=Xl(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=Pw(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let r,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(r=oD,s=aD,o=lD);let u=r.length,c=s.length,d=o.length,h=r.length+a.length+l.length,f=s.length+o.length,p=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=h*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=et._malloc(p),v=new Float32Array(et.HEAPF32.buffer,y,h),x=new Uint32Array(et.HEAPU32.buffer,y+m,f);v.set(r,0),v.set(a,r.length),v.set(l,r.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(E=>E!==1)&&(b=new se().makeScale(...e.scaleBaked)),n&&(b?b.premultiply(n):b=n);let w=b?et.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,d,b.elements):et.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return et._free(y),w}static buildLevel(e,n,r,s,o){let a=o?et.get_mesh_data2(e,n?et.Level.CONTROL:et.Level.REFINED,r,o.elements):et.get_mesh_data(e,n?et.Level.CONTROL:et.Level.REFINED,r),l=8,u=et.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=et.HEAPU32[u[d]>>2],f=et.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let p=et.HEAPU32[u[d]>>2],m=et.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let g=et.HEAPU32[u[d]>>2],y=et.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=et.HEAPU32[u[d]>>2],x=et.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let b=new Ee;if(b.setIndex(new Ms(x,1)),b.setAttribute("position",new be(f,3)),b.setAttribute("normal",new be(m,3)),n){b.setAttribute("faceMap",new Ms(y,1));let w=new Float32Array(m.length/3*4).fill(0);b.setAttribute("color",new Ge(w,4))}return et.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,et.free_mesh_data(a)}static freeSubdivPointer(e){et.free_bvh(e),et.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,r){let s=et.get_wireframe_data_for_base_level(e),o=4,a=et.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=et.HEAPU32[a[u]>>2],d=et.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=et.HEAPU32[a[u]>>2],f=et.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let p=new Ee;p.setAttribute("position",new be(d,3));let m=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)m[g++]=r.r,m[g++]=r.g,m[g++]=r.b;return p.setAttribute("color",new Ge(m,3)),p.setIndex(new Ms(f,1)),et.free_wireframe_data_for_base_level(s),p}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,et.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,r){let s=n===0;s||et.set_destination_refinement_level(e,n);let o=r?et.get_topological_data2(e,s?et.Level.CONTROL:et.Level.REFINED,r.elements):et.get_topological_data(e,s?et.Level.CONTROL:et.Level.REFINED),a=6,l=et.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=et.HEAPU32[l[c]>>2],h=new Float32Array(et.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=et.HEAPU32[l[c]>>2],p=new Uint32Array(et.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=et.HEAPU32[l[c]>>2],g=new Uint8Array(et.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return et.free_topological_data(o),{positions:h,indices:p,verticesPerFace:g}}};var cD=["getX","getY","getZ"];function Xl(i,t){let e={},n=t?t.count:i.count,r=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(i[cD[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(i[cD[h]](c));e[d]=r,s.push(r),r++}}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 ov=new A,Tw=new A,Mw=new A,Cw=new A;function Pw(i,t,e,n){let r=[],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 h=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%h===0)}let c=0;for(let h=0;h<l.length;h+=2)c+=(l[h]-l[(h===0?l.length:h)-2])*(l[h+1]+l[(h===0?l.length:h)-1]);i.length=0;let d=0;if(c<0)for(let h=0;h<l.length;h+=2)i.push(l[h],l[h+1],0),r.push(d++);else for(let h=l.length-2;h>=0;h-=2)i.push(l[h],l[h+1],0),r.push(d++);return s.push(d),{indices:r,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]){ov.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),Tw.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),Mw.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),Cw.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),Tw.sub(ov).normalize(),Mw.sub(ov).normalize(),Cw.sub(ov).normalize();let l=Tw.cross(Mw).dot(Cw);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:a>=n[c]&&a<n[c+1])?(r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(r.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,h=0;d<i.length;d+=3,h++)i[d+2]===0&&(l.push(h),c++),i[d+2]===o&&u.push(h);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),r.push(...l,...u),s.push(c,c)}return{indices:r,verticesPerFace:s}}var Fi={};BA(Fi,{calcBoolean:()=>Z6,calcBooleanTopological:()=>Q6,freeMeshSet:()=>t8,getMeshSet:()=>J6,hasOpenEdges:()=>$6,transformMeshSet:()=>e8});var uD,dD=new Promise(i=>{uD=i});var av;function hD(){if(av)return av;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.494/build",r=import("./boolean.js"),[s,o]=await Promise.all([r,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});uD(l)}return av=i(),av}var ht,Id;dD.then(i=>ht=i);function K6(i,t,e){let n,r;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?r=i.getClosedTorusIndicesForBooleanOrSubdiv():r=i.getIndex();let{positions:s,triIndices:o}=Xl(i.getAttribute("position"),r),a;if(t&&e){let{indices:l,verticesPerFace:u}=Pw(s,o,i);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function fD(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,r=Number.isInteger(i[0])?e:n,s=ht._malloc(r);return(Number.isInteger(i[0])?new Uint32Array(ht.HEAPU32.buffer,s,t):new Float32Array(ht.HEAPF32.buffer,s,t)).set(i,0),s}function pD(i){switch(i){case 0:return ht.OP.UNION;case 1:return ht.OP.INTERSECTION;case 2:return ht.OP.A_MINUS_B;case 3:return ht.OP.B_MINUS_A;case 4:return ht.OP.SYMMETRIC_DIFFERENCE;case 5:return ht.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function Q6(i,t){Id===void 0&&(Id=ht.init_csg());let e=fD(i),n=ht.csg_calc_topological(Id,e,i.length,pD(t));ht._free(e);let r=6,s=ht.HEAPU32.subarray(n>>2,(n>>2)+r),o=s.subarray(3,3+3),a=0,l=ht.HEAPU32[s[a]>>2],u=new Float32Array(ht.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ht.HEAPU32[s[a]>>2],d=new Uint32Array(ht.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=ht.HEAPU32[s[a]>>2],f=new Uint8Array(ht.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return ht.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function Z6(i,t,e,n){Id===void 0&&(Id=ht.init_csg());let r=fD(i),s=ht.csg_calc(Id,r,i.length,n,pD(t));ht._free(r);let o=5,a=ht.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ht.HEAPU32[a[u]>>2],d=ht.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=ht.HEAPU32[a[u]>>2],f=ht.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(d,3)),e.setAttribute("normal",new be(f,3));let m=ht.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ln),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ht.free_mesh_data(s),p}function J6(i,t,e){if(ht===void 0)return-1;let n,r,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,n=g.positions,r=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){r[x++]=g.verticesPerFace[y];for(let b=0;b<g.verticesPerFace[y];b++)r[x++]=g.indices[v++]}}else({positions:n,faceIndices:r,nFaces:s}=K6(i,t,e));let o=n.length,a=r.length,l=n.length,u=r.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=ht._malloc(c),p=new Float32Array(ht.HEAPF32.buffer,f,l),m=new Uint32Array(ht.HEAPU32.buffer,f+d,u);return p.set(n,0),m.set(r,0),ht.get_csg_mesh(f,o,f+d,a,s)}function $6(i){return ht.has_open_edges(i)}function e8(i,t){ht.transform_csg_mesh(i,t.elements)}function t8(i){ht.free_csg_mesh(i)}var n8={ConeGeometry:l2,CubeGeometry:c2,CylinderGeometry:Hy,DodecahedronGeometry:u2,EllipseGeometry:_d,HelixGeometry:k2,IcosahedronGeometry:U2,LatheGeometry:z2,NonParametricGeometry:W2,PolygonGeometry:ev,PyramidGeometry:q2,RectangleGeometry:tv,SphereGeometry:Y2,PlaneGeometry:X2,BackdropGeometry:K2,StarGeometry:nv,TextFrameGeometry:Q2,TorusGeometry:Z2,TorusKnotGeometry:J2,TriangleGeometry:$2,PathGeometry:tD,VectorGeometry:ri},_w=i=>n8[i.type].create(i);function Od(i){return i!==null&&"booleanOp"in i}var Rd=class extends yd(kn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new se}updateVisible(){super.updateVisible(),this.visible=!Od(this.parent)&&this.visible,Od(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Fi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Od(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Rd&&(e.freeBooleanPointer(),Od(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,n){let r=super.updateTransformState(e,n);return r&&Od(this.parent)&&this.invalidateDownstreamBooleanData(!0),r}onVariableUpdate(e=!1){super.onVariableUpdate(e),Od(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var lv=new Tt;function sp(i,t=0,e=i.count,n,r){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=i.getX(d),f=i.getY(d),p=i.getZ(d);h<s&&(s=h),f<o&&(o=f),p<a&&(a=p),h>l&&(l=h),f>u&&(u=f),p>c&&(c=p)}lv.min.set(s,o,a),lv.max.set(l,u,c),lv.getCenter(n),lv.getSize(r).multiplyScalar(.5)}var r8=new Ee,i8=new wo,Xt=class extends Rd{constructor(t,e){super(r8,i8),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?sp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var op=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 pr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=we.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,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let r={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),r}build(t,e,n){e=e??this.getType(t,e);let r=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,r,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,n)}updateFrame(t){}generateReadonly(t,e,n,r,s,o){return""}generate(t,e,n,r,s){return""}parse(t,e,n,r){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let r=t.getTypeLength(n);(r>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=r,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof pr&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)e=this.hashProperties[r],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Dw=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}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}},$n=new Dw;var qe=class extends pr{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,r,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=we.generateUUID()),r=e.getUUID(r??this.getUUID(),!o);let a=e.getNodeData(r),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,r)):super.build(e,n,r);if(o)return a.name=a.name||super.build(e,n,r),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,r);r=this.getUUID(!1);let u=this.getTemp(e,r);if(u)return e.format(u,l,n);{u=super.generate(e,n,r,a.output,s);let c=this.generate(e,l,r);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,r)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let r=e.getVars()[n];return r?r.name:void 0}generate(e,n,r,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),r=r??this.uuid,e.getTempVar(r,s??this.getType(e),o,this.getLabel()).name}};var Ut=class extends qe{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,r,s,o,a){r=e.getUUID(r??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,r,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var gn=class extends Ut{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof B?e:new B(e,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}generateReadonly(e,n,r,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var Tr=class extends Ut{constructor(e=0,n,r){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,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}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,r,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var dn=class extends Fe{constructor(e,n,r,s){super(e,n,r);this.isColorA=!0;this.a=s}setRGBA(e,n,r,s){super.setRGB(e,n,r),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,n="srgb"){let r;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(r=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=r[1],a=r[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,n);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,n);break}}return super.setStyle(e,n)}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 ii=class extends Ut{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof dn?e:new dn(e.r,e.g,e.b,e.a)}generateReadonly(e,n,r,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var s8=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,mD=/[a-z_0-9]+/gi,ge=class extends qe{constructor(e,n,r,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,n,r,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,r,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=mD.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&$n.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=$n.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||$n.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+m+u.substring(h.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&$n.contains(m)&&e.include($n.get(m))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,r,s){if(this.src=e||"",this.includes=n??[],this.extensions=r??{},this.keywords=s??{},this.isMethod){let o=s8.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(mD);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 d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var o8=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Iw=class extends qe{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Iw.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,r,s,o){this.src=e||"";let a,l,u="",c=o8.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,n){if(n==="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),n)}generate(e,n,r,s,o){return e.format(this.name,this.getType(e),n)}},Ct=Iw;Ct.PI="PI",Ct.PI2="PI2",Ct.RECIPROCAL_PI="RECIPROCAL_PI",Ct.RECIPROCAL_PI2="RECIPROCAL_PI2",Ct.LOG2="LOG2",Ct.EPSILON="EPSILON";var a8=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+r,i)>i.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+r,i)>i.width&&(r.length===1?(n[n.length-1]+=r,r=""):(n[n.length-1]+=r.slice(0,-1),r=r[r.length-1],n.push(""))));return n[n.length-1]+=r,n}var iD,Pd=new Promise(i=>{iD=i}),rD=!1;var iv;function sD(){if(rD)return;if(iv)return iv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.495/build",r=import("./process.js"),[s,o]=await Promise.all([r,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});iD(l),rD=!0}return iv=i(),iv}function Yl(i,t,e,n){let r,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 d of u)c=c[d];for(r in c){let d=c[r];fP(d)&&(c[r]=t.getVariable(d,[n.uuid,"geometry",...u,r]))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Pt.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 $c().parse(s);else if(s.type==="SubdivGeometry"){let u=new Pn(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new Cd(s,t);let l;try{l=_w(a)}catch(u){console.error(u)}if(!l){let u=Pt.createFromState(Gu.defaultData(),100,100);a.shape=u,l=_w(a)}return l}var X6=new se;function ip(i,t,e,n){let r=i.position.array,s=i.normal.array,o=X6.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=r.length;c<d;c+=3)r[c]*=t,r[c+1]*=e,r[c+2]*=n,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 sv=new Tt,Dd=new A,et;Pd.then(i=>{et=i});var oD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),aD=new Uint32Array([0,1,2,3]),lD=new Uint8Array([4]),Pn=class extends Ee{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let r=this.data.scaleBaked,s=Ns.div(n,r);this.subdividedGeometry&&ip(this.subdividedGeometry.attributes,...s),this.originalGeometry&&ip(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(Dd.fromArray(s));let a=Dd.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,n,r;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:r}=Pn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new sr(100,100,100),r=0}this.subdivPointer=r,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Pn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ln,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,r=e.boundingSphere.center;sv.setFromBufferAttribute(n),sv.getCenter(r),e.boundingSphere.radius=r.distanceTo(sv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),sv.getSize(Dd);let s={width:Dd.x,height:Dd.y,depth:Dd.z};return this.userData.parameters=s,s}static build(e,n,r,s){let o,a,l,u=e?.phongAngle??35;r===!1&&(u=-1),n&&(et.free_bvh(n),et.free_subdivision_surface(n));try{o=Pn.allocate(e,s)}catch(c){console.error(c,e),o=Pn.allocate({positionWASM:oD,indexWASM:aD,verticesPerFaceWASM:lD},s)}if(et.set_destination_refinement_level(o,0),a=Pn.buildLevel(o,!0,u),e.subdivisions>0)try{et.set_destination_refinement_level(o,e.subdivisions),l=Pn.buildLevel(o,!1,u)}catch{try{et.set_destination_refinement_level(o,e.subdivisions-1),l=Pn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,r){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?n.geometry:Yl(e,r,!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}=Xl(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=Pw(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let r,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(r=oD,s=aD,o=lD);let u=r.length,c=s.length,d=o.length,h=r.length+a.length+l.length,f=s.length+o.length,p=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=h*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=et._malloc(p),v=new Float32Array(et.HEAPF32.buffer,y,h),x=new Uint32Array(et.HEAPU32.buffer,y+m,f);v.set(r,0),v.set(a,r.length),v.set(l,r.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(E=>E!==1)&&(b=new se().makeScale(...e.scaleBaked)),n&&(b?b.premultiply(n):b=n);let w=b?et.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,d,b.elements):et.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return et._free(y),w}static buildLevel(e,n,r,s,o){let a=o?et.get_mesh_data2(e,n?et.Level.CONTROL:et.Level.REFINED,r,o.elements):et.get_mesh_data(e,n?et.Level.CONTROL:et.Level.REFINED,r),l=8,u=et.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=et.HEAPU32[u[d]>>2],f=et.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let p=et.HEAPU32[u[d]>>2],m=et.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let g=et.HEAPU32[u[d]>>2],y=et.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=et.HEAPU32[u[d]>>2],x=et.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let b=new Ee;if(b.setIndex(new Ms(x,1)),b.setAttribute("position",new be(f,3)),b.setAttribute("normal",new be(m,3)),n){b.setAttribute("faceMap",new Ms(y,1));let w=new Float32Array(m.length/3*4).fill(0);b.setAttribute("color",new Ge(w,4))}return et.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,et.free_mesh_data(a)}static freeSubdivPointer(e){et.free_bvh(e),et.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,r){let s=et.get_wireframe_data_for_base_level(e),o=4,a=et.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=et.HEAPU32[a[u]>>2],d=et.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=et.HEAPU32[a[u]>>2],f=et.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let p=new Ee;p.setAttribute("position",new be(d,3));let m=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)m[g++]=r.r,m[g++]=r.g,m[g++]=r.b;return p.setAttribute("color",new Ge(m,3)),p.setIndex(new Ms(f,1)),et.free_wireframe_data_for_base_level(s),p}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,et.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,r){let s=n===0;s||et.set_destination_refinement_level(e,n);let o=r?et.get_topological_data2(e,s?et.Level.CONTROL:et.Level.REFINED,r.elements):et.get_topological_data(e,s?et.Level.CONTROL:et.Level.REFINED),a=6,l=et.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=et.HEAPU32[l[c]>>2],h=new Float32Array(et.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=et.HEAPU32[l[c]>>2],p=new Uint32Array(et.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=et.HEAPU32[l[c]>>2],g=new Uint8Array(et.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return et.free_topological_data(o),{positions:h,indices:p,verticesPerFace:g}}};var cD=["getX","getY","getZ"];function Xl(i,t){let e={},n=t?t.count:i.count,r=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(i[cD[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(i[cD[h]](c));e[d]=r,s.push(r),r++}}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 ov=new A,Tw=new A,Mw=new A,Cw=new A;function Pw(i,t,e,n){let r=[],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 h=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%h===0)}let c=0;for(let h=0;h<l.length;h+=2)c+=(l[h]-l[(h===0?l.length:h)-2])*(l[h+1]+l[(h===0?l.length:h)-1]);i.length=0;let d=0;if(c<0)for(let h=0;h<l.length;h+=2)i.push(l[h],l[h+1],0),r.push(d++);else for(let h=l.length-2;h>=0;h-=2)i.push(l[h],l[h+1],0),r.push(d++);return s.push(d),{indices:r,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]){ov.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),Tw.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),Mw.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),Cw.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),Tw.sub(ov).normalize(),Mw.sub(ov).normalize(),Cw.sub(ov).normalize();let l=Tw.cross(Mw).dot(Cw);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:a>=n[c]&&a<n[c+1])?(r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(r.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,h=0;d<i.length;d+=3,h++)i[d+2]===0&&(l.push(h),c++),i[d+2]===o&&u.push(h);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),r.push(...l,...u),s.push(c,c)}return{indices:r,verticesPerFace:s}}var Fi={};BA(Fi,{calcBoolean:()=>Z6,calcBooleanTopological:()=>Q6,freeMeshSet:()=>t8,getMeshSet:()=>J6,hasOpenEdges:()=>$6,transformMeshSet:()=>e8});var uD,dD=new Promise(i=>{uD=i});var av;function hD(){if(av)return av;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.495/build",r=import("./boolean.js"),[s,o]=await Promise.all([r,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});uD(l)}return av=i(),av}var ht,Id;dD.then(i=>ht=i);function K6(i,t,e){let n,r;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?r=i.getClosedTorusIndicesForBooleanOrSubdiv():r=i.getIndex();let{positions:s,triIndices:o}=Xl(i.getAttribute("position"),r),a;if(t&&e){let{indices:l,verticesPerFace:u}=Pw(s,o,i);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function fD(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,r=Number.isInteger(i[0])?e:n,s=ht._malloc(r);return(Number.isInteger(i[0])?new Uint32Array(ht.HEAPU32.buffer,s,t):new Float32Array(ht.HEAPF32.buffer,s,t)).set(i,0),s}function pD(i){switch(i){case 0:return ht.OP.UNION;case 1:return ht.OP.INTERSECTION;case 2:return ht.OP.A_MINUS_B;case 3:return ht.OP.B_MINUS_A;case 4:return ht.OP.SYMMETRIC_DIFFERENCE;case 5:return ht.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function Q6(i,t){Id===void 0&&(Id=ht.init_csg());let e=fD(i),n=ht.csg_calc_topological(Id,e,i.length,pD(t));ht._free(e);let r=6,s=ht.HEAPU32.subarray(n>>2,(n>>2)+r),o=s.subarray(3,3+3),a=0,l=ht.HEAPU32[s[a]>>2],u=new Float32Array(ht.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ht.HEAPU32[s[a]>>2],d=new Uint32Array(ht.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=ht.HEAPU32[s[a]>>2],f=new Uint8Array(ht.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return ht.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function Z6(i,t,e,n){Id===void 0&&(Id=ht.init_csg());let r=fD(i),s=ht.csg_calc(Id,r,i.length,n,pD(t));ht._free(r);let o=5,a=ht.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ht.HEAPU32[a[u]>>2],d=ht.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=ht.HEAPU32[a[u]>>2],f=ht.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(d,3)),e.setAttribute("normal",new be(f,3));let m=ht.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ln),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ht.free_mesh_data(s),p}function J6(i,t,e){if(ht===void 0)return-1;let n,r,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,n=g.positions,r=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){r[x++]=g.verticesPerFace[y];for(let b=0;b<g.verticesPerFace[y];b++)r[x++]=g.indices[v++]}}else({positions:n,faceIndices:r,nFaces:s}=K6(i,t,e));let o=n.length,a=r.length,l=n.length,u=r.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=ht._malloc(c),p=new Float32Array(ht.HEAPF32.buffer,f,l),m=new Uint32Array(ht.HEAPU32.buffer,f+d,u);return p.set(n,0),m.set(r,0),ht.get_csg_mesh(f,o,f+d,a,s)}function $6(i){return ht.has_open_edges(i)}function e8(i,t){ht.transform_csg_mesh(i,t.elements)}function t8(i){ht.free_csg_mesh(i)}var n8={ConeGeometry:l2,CubeGeometry:c2,CylinderGeometry:Hy,DodecahedronGeometry:u2,EllipseGeometry:_d,HelixGeometry:k2,IcosahedronGeometry:U2,LatheGeometry:z2,NonParametricGeometry:W2,PolygonGeometry:ev,PyramidGeometry:q2,RectangleGeometry:tv,SphereGeometry:Y2,PlaneGeometry:X2,BackdropGeometry:K2,StarGeometry:nv,TextFrameGeometry:Q2,TorusGeometry:Z2,TorusKnotGeometry:J2,TriangleGeometry:$2,PathGeometry:tD,VectorGeometry:ri},_w=i=>n8[i.type].create(i);function Od(i){return i!==null&&"booleanOp"in i}var Rd=class extends yd(kn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new se}updateVisible(){super.updateVisible(),this.visible=!Od(this.parent)&&this.visible,Od(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Fi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Od(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Rd&&(e.freeBooleanPointer(),Od(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,n){let r=super.updateTransformState(e,n);return r&&Od(this.parent)&&this.invalidateDownstreamBooleanData(!0),r}onVariableUpdate(e=!1){super.onVariableUpdate(e),Od(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var lv=new Tt;function sp(i,t=0,e=i.count,n,r){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=i.getX(d),f=i.getY(d),p=i.getZ(d);h<s&&(s=h),f<o&&(o=f),p<a&&(a=p),h>l&&(l=h),f>u&&(u=f),p>c&&(c=p)}lv.min.set(s,o,a),lv.max.set(l,u,c),lv.getCenter(n),lv.getSize(r).multiplyScalar(.5)}var r8=new Ee,i8=new wo,Xt=class extends Rd{constructor(t,e){super(r8,i8),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?sp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var op=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 pr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=we.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,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let r={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),r}build(t,e,n){e=e??this.getType(t,e);let r=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,r,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,n)}updateFrame(t){}generateReadonly(t,e,n,r,s,o){return""}generate(t,e,n,r,s){return""}parse(t,e,n,r){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let r=t.getTypeLength(n);(r>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=r,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof pr&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)e=this.hashProperties[r],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Dw=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}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}},$n=new Dw;var qe=class extends pr{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,r,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=we.generateUUID()),r=e.getUUID(r??this.getUUID(),!o);let a=e.getNodeData(r),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,r)):super.build(e,n,r);if(o)return a.name=a.name||super.build(e,n,r),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,r);r=this.getUUID(!1);let u=this.getTemp(e,r);if(u)return e.format(u,l,n);{u=super.generate(e,n,r,a.output,s);let c=this.generate(e,l,r);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,r)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let r=e.getVars()[n];return r?r.name:void 0}generate(e,n,r,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),r=r??this.uuid,e.getTempVar(r,s??this.getType(e),o,this.getLabel()).name}};var Ut=class extends qe{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,r,s,o,a){r=e.getUUID(r??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,r,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var gn=class extends Ut{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof B?e:new B(e,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}generateReadonly(e,n,r,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var Tr=class extends Ut{constructor(e=0,n,r){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,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}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,r,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var dn=class extends Fe{constructor(e,n,r,s){super(e,n,r);this.isColorA=!0;this.a=s}setRGBA(e,n,r,s){super.setRGB(e,n,r),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,n="srgb"){let r;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(r=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=r[1],a=r[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,n);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,n);break}}return super.setStyle(e,n)}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 ii=class extends Ut{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof dn?e:new dn(e.r,e.g,e.b,e.a)}generateReadonly(e,n,r,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var s8=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,mD=/[a-z_0-9]+/gi,ge=class extends qe{constructor(e,n,r,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,n,r,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,r,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=mD.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&$n.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=$n.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||$n.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+m+u.substring(h.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&$n.contains(m)&&e.include($n.get(m))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,r,s){if(this.src=e||"",this.includes=n??[],this.extensions=r??{},this.keywords=s??{},this.isMethod){let o=s8.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(mD);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 d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var o8=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Iw=class extends qe{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Iw.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,r,s,o){this.src=e||"";let a,l,u="",c=o8.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,n){if(n==="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),n)}generate(e,n,r,s,o){return e.format(this.name,this.getType(e),n)}},Ct=Iw;Ct.PI="PI",Ct.PI2="PI2",Ct.RECIPROCAL_PI="RECIPROCAL_PI",Ct.RECIPROCAL_PI2="RECIPROCAL_PI2",Ct.LOG2="LOG2",Ct.EPSILON="EPSILON";var a8=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3142
3142
  )*?)}`,"gim"),l8=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ld=class extends qe{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}generate(e,n,r,s,o){return n==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),n)}parse(e=""){this.src=e,this.inputs=[];let n=a8.exec(e);if(n){let r=n[2],s;for(;s=l8.exec(r);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Nd=class extends qe{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,n){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(s,this.getType(e),n)}};$n.addKeyword("uv",function(){return new Nd});$n.addKeyword("uv2",function(){return new Nd(1)});var Kl=class extends qe{constructor(e,n){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=n??Kl.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case gi:return["Linear"];case $e:return["sRGB"];default:return[]}}generate(e,n){let r=this.input.build(e,"v4"),s=this.getType(e),o=Kl.Nodes[this.method],a=e.include(o);if(a===Kl.LINEAR_TO_LINEAR)return e.format(r,s,n);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+r+", "+l+" )",s,n)}else return e.format(a+"( "+r+" )",s,n)}fromEncoding(e){let n=Kl.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(e){let n=Kl.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}},jr=Kl;jr.Nodes={LinearToLinear:new ge(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3143
3143
  `)),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(`
3144
3144
  `)),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(`
@@ -6236,7 +6236,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
6236
6236
  }
6237
6237
  `,Yv=new ot({vertexShader:H9,fragmentShader:j9,uniforms:{depthContrast:{value:1}}});var nO=new en,Xv=class extends Ab{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new B;this.pipeline=new _p(this);this.dummyCamera=new Kt;this.sceneTransitionDuration=0;this.sceneTransitionTimeRemaining=-1;this.isXRCopyPassSet=!1;this.clear=(e=!0,n=!0,r=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),n&&(o|=s.DEPTH_BUFFER_BIT),r&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.autoClear=!1;let n=this.setPixelRatio.bind(this),r=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=sg,this.dummyCamera.matrixAutoUpdate=!1;let s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio!==o&&(this._pixelRatio=o,n(o))},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,r(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new ut(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Ze,magFilter:Ze,wrapS:Jt,wrapT:Jt,depthBuffer:!1}))}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,n*this._pixelRatio/1)}get hdTransmission(){return He.transmissionLod.value===1}set hdTransmission(e){He.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ut(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:yl,magFilter:Ze,wrapS:Jt,wrapT:Jt,depthBuffer:!1}),this.transmissionDepthTarget=new ut(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Nt,magFilter:Nt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ut(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Nt,magFilter:Nt,type:wr,depthTexture:new Ci(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n,r){this.normalRenderTarget&&(this.setClearColor(0),r.layers.enable(8),r.layers.disable(0),r.layers.disable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),r instanceof Kt?Yv.uniforms.depthContrast.value=(r.far-r.near)/1e4:Yv.uniforms.depthContrast.value=1,n.overrideMaterial=Yv,this.render(n,r),this.setClearColor(n.bgColor,n.bgColor.a),this.setRenderTarget(null),n.overrideMaterial=e.wireframeState?Kv:null,r.layers.enable(0),r.layers.enable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,n,r=1){this.dummyCamera.updateCameraState(n.dataPatched),this.dummyCamera.matrix.copy(n.matrixWorld);let s=n.height,o=n.width,a=this.viewportWidth/this.viewportHeight;o<s?o=s*a:s=o/a,this.dummyCamera.setViewplaneSize(o,s);for(let l=0;l<r;l++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,n,{sceneHelpers:r=void 0,sceneHelpersOnTop:s=void 0,overrideTransmission:o=void 0,overrideNormal:a=void 0}={}){let l=e instanceof $a?e.activePage:e,u=l.visible;l.visible=!0;let c=l.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(n)),this.setClearColor(l.bgColor,l.bgColor.a),l.penumbraSizeArray.forEach((p,m)=>{He.penumbraSize.value[m]=p}),He.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?He.resolution.value.set(this.resolution.x,this.resolution.y):He.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(He.normalRenderTarget.value=a,He.normalRenderTargetDepth.value=nO):c.needsNormal()&&(this.createNormalRenderTarget(),He.normalRenderTarget.value=this.normalRenderTarget.texture,He.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(c,l,n));let d=l.data.ao,h=d.occlusion;h&&(this.createAORenderTarget(),He.aoRenderTarget.value=this.aoRenderTarget.texture),He.aoEnabled.value=h,this.pipeline.setAmbientOcclusionParams(d.occlusion,d.radius,d.bias,l.aoColor,l.fog!==null,l.backupFog.near,l.backupFog.far,d.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let f=!1;if(o!==void 0)He.transmissionRenderTarget.value=o,He.transmissionRenderTargetDepth.value=nO,this.pipeline.setTransmissionPassEnabled(!1);else{let p=c.needsTransmission();p&&(this.transmissionRenderTarget===void 0&&(f=!0),this.createTransmissionRenderTarget(),He.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,He.aspectRatio.value=AD(this.viewportWidth,this.viewportHeight),He.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(p)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=l,this.pipeline.camera=n,f&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==l.postprocessing&&(this.pipeline.updatePostprocessing(l.postprocessing),!r&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.overrideMaterial=c.wireframeState?Kv:null,this.pipeline.render(),He.frameIndex.value=(He.frameIndex.value+1)%16,n instanceof Kt&&n.copyHistory(),l.visible=u}renderFromSceneForSceneTransitionPass(e,n,r){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,n),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=r,this.sceneTransitionTimeRemaining=r,this.pipeline.renderToScreen=!0;let s=this.pipeline.sceneTransitionPass.uniforms;s.uDPR.value=window.devicePixelRatio,s.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var bh=class extends Qs(rg){constructor(e,n=15,r=10066329){super(e,n,r);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,n){Zs(this.object,bh.geometryHelper,e,n)}};var Sh=class extends Qs(ng){constructor(e,n=15,r=6710886){super(e,n,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,n){Zs(this.object,Sh.geometryHelper,e,n)}};var Qv=class extends Qs(tg){constructor(e,n=6710886){super(e,n);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,n){Zs(this.object,Qv.geometryHelper,e,n)}update(){if(this.object!==void 0){let e=Qv._vector,n=this.object.distance?this.object.distance:1e3,r=n*Math.tan(this.object.angle);this.cone.scale.set(r,r,n),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Tp=Qv;Tp._vector=new A;function W9(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var wh=class extends ah(Jm,bh){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.top=1250,s.bottom=-1250,s.right=1250,s.left=-1250,s.near=-1e4,s.far=2500;let o=new pa(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof pa&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let n=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&W9(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),n&&this.update()}};var rO=new A,iO=new A,sO=new Ye,Ah=class extends ah(Qm,Tp){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=we.RAD2DEG*2*this.angle,s.aspect=1,s.near=100,s.far=2500;let o=new pa(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof pa&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),iO.setFromMatrixPosition(this.matrixWorld),sO.setFromRotationMatrix(this.matrixWorld),rO.copy(this.up).applyQuaternion(sO).negate().multiplyScalar(this.distance),this.target.position.copy(iO).add(rO),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var li=class extends yd(Ar){constructor(e,n){super();this.data=n;this.bgColor=new dn(1,1,1,1);this.fog=null;this.backupFog=new Vc(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Fe;this.penumbraSizeArrayCache=null;this.super_Entity(e,n),this.personalCamera=new Kt(Li,{...Ul.defaultData,...n.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Km(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,n){e.color!==void 0&&(this.ambientLight.color=Cr(e.color,n)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Ui)if(Array.isArray(e.material))for(let n of e.material)n.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&tO(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,n){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let r=this.scene;r.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Cr(e.color,n),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,n){e.aoColor!==void 0&&(this.aoColor=Cr(e.aoColor,n))}updateByOp(e,n,r,s){super.updateByOp(e,n,r,s);let o=n;Rr(e.path,["fog"])?this.updateFog(o.fog,r.shared):Rr(e.path,["ao"])?this.updateAo(o.ao,r.shared):Rr(e.path,["ambient"])?this.updateAmbientLight(o.ambient,r.shared):Rr(e.path,["shadow"])&&this.updateShadow(o.shadow)}updateState(e,n){this.updateState_Entity(e,n),e.backgroundColor!==void 0&&this.setBackgroundColor(Cr(e.backgroundColor,n.shared)),e.fog!==void 0&&this.updateFog(e.fog,n.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,n.shared),e.ao!==void 0&&this.updateAo(e.ao,n.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,n){super.raycast(e,n)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,n=0;this.traverseEntity(r=>{if(!r.visible)return!0;r instanceof wh&&r.visible&&e<3&&(this.penumbraSizeArrayCache[e]=r.data.penumbraSize,e+=1),r instanceof Ah&&r.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+n]=r.data.penumbraSize,n+=1)})}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;at.is(o)&&(o.visible||a?.object.data.visible)&&((Lr(o)||wp(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),Mp(o,e,n,!0)),r(o))}};return r(this),n}};var Zv=class extends ah(Zm,Sh){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=90,s.aspect=1,s.near=100,s.far=2500;let o=new A(-s.far+this.position.x,-s.far+this.position.y,-s.far+this.position.z),a=new A(s.far+this.position.x,s.far+this.position.y,s.far+this.position.z),l=new Tt(o,a),u=new ma(l,new Fe(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof ma){let n=this.shadow.camera,r=new A(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new A(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z);e.box.set(r,s),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Jv=class extends jt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?sp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var el=class extends jt{constructor(e,n,r){super(e,n,r);this._shapeId=null;this._context=r}updateState(e,n){super.updateState(e,n),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let s in e)typeof e[s]=="string"&&(e[s]=this._context.shared.getVariable(e[s],[this.uuid,"geometry","extrusion","shape",s]));let n;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let o=this._context.scene.find(s);o?.data&&(o.attachedPaths.add(this),n=o.geometry.userData?.shape),n||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=tv;break;case"Ellipse":s=_d;break;case"Polygon":s=ev;break;case"Star":s=nv;break;default:throw new Error(`Unknown shape type: ${e.type}`)}n=s.create({parameters:e}).userData.shape}let r=this.geometry;n&&r.inputs&&(r.inputs.shapeData=n,r.build(),this.attachedSurfaceCloners.forEach(s=>s.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,n){return super.updateTransformState(e,n)}updateGeometryInteractions(e,n){super.updateGeometryInteractions(e,n),this.updateShape()}updateEntityBoxSize(e,n){let r=this.geometry.getAttribute("position");r!==void 0?sp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,e,n):super.updateEntityBoxSize(e,n)}};var gs=class extends Js(Ts,$s){constructor(e,n,r){super();n.type==="Instance"&&typeof e=="string"&&(n=this.transformAssignData(n,r)),this.super_Entity(e,n),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,n){let r=Ku.getComponentData({scene:n.scene.data,shared:n.shared.data},e.component);if(r){let s,o;for(let a of Fs.rootOverrideProps)e[a]===void 0?(s===void 0&&(s={...e}),s[a]=r.data[a]):(o===void 0&&(o={}),o[a]=e[a],s===void 0&&(s={...e}),s[a]=Ds.apply(r.data[a],e[a]));return this.overrideData=o,s}else return{..._r.defaultData,...e,...Si(_r.defaultData,Fs.rootOverrideProps)}}updateByOp(e,n,r,s){let o;if(this.isInstanceRoot&&!s){if(n=this.transformAssignData(n,r),e.type===0&&e.path.length===0&&this.component)for(let a of Fs.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(o===void 0&&(o={...e,props:{...e.props}}),o.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Fs.rootOverrideProps.includes(e.path[0])){let a=e.path[0];o===void 0&&(o={...e,path:[],props:{[a]:n[a]}})}}super.updateByOp(o??e,n,r,s)}updateState(e,n){this.updateState_Entity(e,n)}expandInstanceChildren(e){let n=this.data;if(this.component===void 0){let r=e.scene.find(n.component)??null,s=!1;if(r!==this.oldComponent){if(this.oldComponent){let o=0;for(let a of this.children)if(at.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),$v(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(r){let o={};aO(e,[this.uuid],n.overrides,this,r,r,0,s,o);for(let a of this.children)if(at.is(a)){let l=a.data;l.type==="Empty"&&l.animations&&a.traverseEntity(u=>{if(u instanceof jt&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let d=c.bones.map(p=>e.scene.find(o[p])),h=c.boneInverses.map(p=>new se().fromArray(p)),f=new ca(d,h);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function $v(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)at.is(e)&&$v(e)}}function oO(i,t,e,n){return i.component===t&&Mf(i.identity,n)?i.overrideData===e?2:1:0}function aO(i,t,e,n,r,s,o,a,l){if(o>50)return!1;if(n.component!==r){if(n.component){let c=n.component.instances.indexOf(n);c>=0&&n.component.instances.splice(c,1)}r.instances.push(n),n.component=r}r instanceof gs&&r.isInstanceRoot&&r.expandInstanceChildren(i);let u=0;for(let c of r.children)if(at.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],h=qu.resolve(e,d,1);if(h!=null&&!(h instanceof Yt)){if(!1)debugger;Object.setPrototypeOf(h,Yt.prototype),console.error("wrong prototype")}let f=null,p;if(!a){let m=n.children[u];if(f=at.is(m)?m:null,f!==null){let g=oO(f,c,h,d);p=g>=1?f.stateSelection:void 0,g!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(d)??null,f!==null)){let g=oO(f,c,h,d);if(p=g>=1?f.stateSelection:void 0,g!==2)f=null;else{let y=f.parent.children.indexOf(f);f.parent.children.splice(y,1),n.children.splice(u,0,f),f.parent===n?(y<=u&&console.error("not possible"),void 0):(f.parent=n,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=h?Ds.apply(c.data,h):c.data;ns.is(m.type)&&(m={...m,type:"Empty"}),f=ss.createEntity(d,m,i),f.overrideData=h,n.add(f),n.children.splice(n.children.length-1,1),n.children.splice(u,0,f),f.updateState(f.data,i),p&&f.changeSelectedState(p,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,aO(i,t,e,f,c,s,o+1,a,l)}if(!a){let c=u;for(;;){let d=n.children[u];if(at.is(d))i.pendingDeletes.add(d);else break;u+=1}n.children.splice(c,u-c)}return!0}var e0=class extends Js(lf,$s){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};function q9(i,t,e){let n;return t.geometry.type==="TextGeometry"?new rh(i,t,e):(t.geometry.type==="SubdivGeometry"?n=new hs(i,t,e):t.geometry.type==="PathGeometry"?n=new el(i,t,e):t.geometry.type==="VectorGeometry"?n=new Jv(i,t,e):t.geometry.type==="BooleanGeometry"?n=new Hi(i,t,e):n=new jt(i,t,e),n)}function t0(i,t,e){return t.type==="Mesh"?q9(i,t,e):t.type==="Empty"?new ps(i,t):t.type==="Bone"?new e0(i,t):t.type==="Page"?new li(i,t):t.type==="PointLight"?new Zv(i,t,e):t.type==="SpotLight"?new Ah(i,t,e):t.type==="DirectionalLight"?new wh(i,t,e):t.type==="Component"||t.type==="Instance"?new gs(i,t,e):ns.is(t.type)?new Kt(i,t):(console.error(t),new ps(i,t))}ss.createEntity=t0;function Y9(i,t,e){let n=t0(i.identity,t,e),r=i.children,s=i.attachedPaths,o=i.parent,a=i.component,l=i.instances,u=i.overrideData,c=i.uuid,d=i.stateSelection;i.dispose();for(let h of Object.keys(i))delete i[h];Object.setPrototypeOf(i,Object.getPrototypeOf(n));for(let h of Object.keys(n))i[h]=n[h];i.children=[...i.children,...r],i.attachedPaths=s,i.parent=o,i.component=a,i.instances=l,i.uuid=c,i.overrideData=u,i.updateState(i.data,e),d&&i.changeSelectedState(d,e),i.resetBBoxNeedsUpdate()}ss.changeEntityProptotype=Y9;ss.Cloner=vr;function lO(i,t,e,n){i.updateByOp(t,e,n,!1)}function cO(i,t){let e=!1,n=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(i.layers.set(8),n.length>0&&i.layers.enable(3),e=!0,th(i),eh(i)),n.length===0&&r.length===0&&i.layers.set(0),i instanceof Ui&&i.needsAO&&i.layers.enable(5),e}function uO(i,t){if(!t.layers)return!1;let e=!1,n=t.getLayersOfType("transmission").filter(s=>s.data.visible),r=t.getLayersOfType("outline").filter(s=>s.data.visible);return n.length>0&&(i.layers.set(3),r.length>0&&i.layers.enable(8),e=!0),n.length===0&&r.length===0&&i.layers.set(0),i.needsAO&&i.layers.enable(5),e}function dO(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Ui)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)cO(e,e.material[n])&&(t=!0);else cO(e,e.material)&&(t=!0)}),t}function hO(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Ui)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)uO(e,e.material[n])&&(t=!0);else uO(e,e.material)&&(t=!0)}),t}var X9=new eu,K9=new se,Q9=new Ji;function Mp(i,t,e,n=!1){let r=i.cloner;if(r)for(let s of r.children){let o=K9.copy(s.matrixWorld).invert(),a=Q9.copy(t.ray).applyMatrix4(o),l=i.matrixWorld;a.applyMatrix4(l);let u=X9;u.set(a.origin,a.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(i,!1);c.length>0&&e.push({...c[0],object:n?s:i})}}var n0=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((n,r)=>{let s=[r,n],o=n;for(;this._constraints.has(o);)o=this._constraints.get(o),e.has(o)||s.push(o);for(let a=s.length-2;a>=0;a--)if(!e.has(s[a])){let l=t.find(s[a]);l?l.applyPathSnapping(t):console.warn(`missing entity ${s[a]}`),e.add(s[a])}})}findDependency(t,e){let n=t;for(;this._constraints.has(n);)if(n=this._constraints.get(n),n===e)return!0;return!1}};var Kv=new wo;Kv.wireframe=!0;var fO=new A,$a=class extends Ar{constructor(e,n){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new n0;this.errorPage=new li("fdasfa",{...Lo.defaultData,name:""});this.invisibleObjects=new ps("jflkdsafjasdifjaslk",{...Ay.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=hO(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=dO(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let n=e.identity.join("-"),r=this.entityIdentityToEntity[n];r&&(e.uuid=r.uuid),this.entityIdentityToEntity[n]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof li&&(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 n=this.find(e);if(n===void 0)return;let r=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);r.splice(0,0,a)}return{entity:n,sortKey:r}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push(s)}return n.sort((r,s)=>hC(r.sortKey,s.sortKey)),n.map(r=>r.entity)}nonExistOrDescendantOf(e,n){let r=this.find(e);if(r===void 0)return!0;for(;r;){if(r.uuid===n)return!0;r=r.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===Li)return this.activePage.personalCamera}if(e===""||e===void 0)return;let n=this.entityByUuid[e];return n===void 0?this.getObjectByProperty("uuid",e):n}debugEnsureEntity(e){let n=this.find(e);if(n){if(Array.isArray(n.identity)&&this.findInstance(n.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(n=>{this.toExpandCloner.add(n)})}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,n){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,n)}updateTreeByOp(e,n){if(e.path.length===0&&e.type===7){let r=e.parent===null?this:this.find(e.parent);if(r===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,r,e.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),Lr(s)&&Nr(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(r),this.markPenumbraSizeDirty(),r.parent.remove(r),Nr(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Lr(r)&&(r.freeBooleanPointer(),s instanceof Hi&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r instanceof el&&r.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),this.pathConstraints.removeDependencies(r.uuid),r.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(r),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Lr(r)&&(r.invalidateUpstreamBooleanData(),Nr(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Hi&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r.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 n of this.children)n instanceof li&&(n.visible=n.uuid===e,n.visible&&(this.activePage=n,this.activePage.onActive(this)))}updateEntityByOp(e,n,r,s){if(n.type===0){if(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),"visible"in n.props&&this.markPenumbraSizeDirty(),n.path.includes("overrides")&&"states"in n.props){let{rest:a}=n.props;n={...n,props:a},this.markNeedsRecomputeInstances()}n.path[0]==="pathSnapping"&&n.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,n.props.pathId)}let o=this.find(e);if(o)try{lO(o,n,r,{scene:this,shared:s}),o instanceof jt&&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,n){let r=Object.entries(n.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:n}),this.add(this.invisibleObjects),this.createChildrenObjects(r,this.invisibleObjects,n),this.createChildrenObjects(e.objects,this,n),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(n,!0),this.traverseEntity(s=>{Nr(s)&&s.recomputeBoolean(),s instanceof Kt&&s.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(n=>{(n.data.type==="Component"||n.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){at.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(n=>{at.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,n,r,s,o,a,l){if(e){let u=s.find(e);u&&u!==s&&o.forInstancesRec(c=>{c.data=Aa(c.data,d=>{let h=d.events.data(l.id),f=c.goUp(a);if(f){let p=[...Bg(f.identity),e].join("-"),m=this.entityIdentityToEntity[p];if(m){let g=m.uuid,y=_n.zoom(h,n);y[r]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,n,r,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof gs&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((n,r)=>{n.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(n.forInstancesRec(a=>{a.data=Aa(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of Ju.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,n,r,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,n,r,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,n,r,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,n,r,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,n,r,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,n,r,s)),this.rewriteActions(s.data.inActions,["inActions"],e,n,r,s),this.rewriteActions(s.data.outActions,["outActions"],e,n,r,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,n,r,s)})}),!0})}expandInstances(e,n,r){let s=new Set;this.traverseEntity(o=>{if(o instanceof gs&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),n||o.resetBBoxNeedsUpdate(),r&&o.traverseEntity(a=>{r.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),$v(o)}recomputeInstances(e,n){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(r=>{r instanceof gs&&r.isInstanceRoot&&(r.component=void 0)}),this.expandInstances(e,!1,n))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(n=>{let r=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[r]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[r]),n.dispose()})}clearScene(){for(let e of this.children)at.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,n){this.init(e,n)}raycast(e){return this.raycast1(e,!1)}raycast1(e,n){let r=[],s=o=>{for(let a of o.children){let l=a.cloner;if(at.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(n===!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 d=a.matrixWorld.clone().invert();c.point.applyMatrix4(d),r.push(c)}}else(Lr(a)||wp(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Mp(a,e,r)),s(a)}};return s(this),r}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;at.is(o)&&(o.visible||a?.object.data.visible)&&((Lr(o)||wp(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),Mp(o,e,n,!0)),r(o))}};return r(this),n}forEachEntity(e){for(let n of this.children)at.is(n)&&e(n)}traverseConcreteEntity(e){for(let n of this.children)at.is(n)&&n.isConcreteEntity&&n.traverseEntity(e)}traverseEntity(e){for(let n of this.children)at.is(n)&&n.traverseEntity(e)}updateFont(e,n){this.traverseEntity(r=>{if(r instanceof jt&&r.data.type==="Mesh"&&r.data.geometry.type==="TextGeometry"&&r.data.geometry.font===e){let s=r.geometry,o=r.data.geometry;s.updateFont(e,n).then(()=>{s.update(o);let a=r.invalidateDownstreamBooleanData();Nr(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let n of this.children)pd.is(n)&&n.traverseObject(e)}traverseVisibleEntity(e){for(let n of this.children)at.is(n)&&n.visible&&n.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,n,r){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,n,s,r),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let n of e.children)this.unregisterObject(n)}createObject(e,n,r,s,o,a){let l={scene:this,shared:a},u=t0(e,n,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),r.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,u,a)),u.updateState(n,l),u instanceof jt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),n.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,n.pathSnapping.pathId)),n.type==="Empty"&&n.animations&&u.traverseEntity(c=>{if(c instanceof jt&&c.isSkinnedMesh){let d=c.dataPatched;if(d.bones&&d.boneInverses){let h=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new se().fromArray(m)),p=new ca(h,f);c.bind(p,c.bindMatrix)}}else c.matrixAutoUpdate=!0}),u}getCenter(e){let n=[];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;n.push(...c.vertices)}let r=new Tt;return r.setFromPoints(n),r.getCenter(fO),fO}copyMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e);r?n.copy(r.matrixWorld):n.identity()}copyParentMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e)?.parent;r?n.copy(r.matrixWorld):n.identity()}traverseMaterial(e){this.traverseEntity(n=>{if(n instanceof Xt)if(Array.isArray(n.material))for(let r=0;r<n.material.length;r++)n.material[r]instanceof oi&&e(n.material[r]);else n.material instanceof oi&&e(n.material)})}updateViewPlaneSize(e,n,r=!1){this.traverseConcreteEntity(s=>{s instanceof Kt&&s.setViewplaneSize(e,n,r)})}};var Cp=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return Math.sqrt(e*e+n*n)},pO=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return Z9(Math.atan2(n,e))},mO=(i,t,e)=>{let n={x:0,y:0};return e=r0(e),n.x=i.x-t*Math.cos(e),n.y=i.y-t*Math.sin(e),n},r0=i=>i*(Math.PI/180),Z9=i=>i*(180/Math.PI),gO=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,P1=new Map,D1=i=>{P1.has(i)&&clearTimeout(P1.get(i)),P1.set(i,setTimeout(i,100))},Eh=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.addEventListener?i.addEventListener(r,e,!1):i.attachEvent&&i.attachEvent(r,e)},I1=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.removeEventListener?i.removeEventListener(r,e):i.detachEvent&&i.detachEvent(r,e)};var i0=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),O1=()=>{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}},s0=(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")},o0=(i,t,e)=>{let n=vO(i);for(let r in n)if(n.hasOwnProperty(r))if(typeof t=="string")n[r]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";n[r]=s.slice(0,-2)}return n},yO=(i,t)=>{let e=vO(i);for(let n in e)e.hasOwnProperty(n)&&(e[n]=t);return e},vO=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(n){t[n+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},a0=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},xO=(i,t)=>{let e={};for(let n in i)i.hasOwnProperty(n)&&t.hasOwnProperty(n)?e[n]=t[n]:i.hasOwnProperty(n)&&(e[n]=i[n]);return e},Pp=(i,t)=>{if(i.length)for(let e=0,n=i.length;e<n;e+=1)t(i[e]);else t(i)},bO=(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"&&(SO="ontouchstart"in window,wO=!!window.PointerEvent,AO=!!window.MSPointerEvent);var SO,wO,AO,Dp={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"}},_h,Ip={};wO?_h=Dp.pointer:AO?_h=Dp.MSPointer:SO?(_h=Dp.touch,Ip=Dp.mouse):_h=Dp.mouse;function cc(){}cc.prototype.on=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]=e._handlers_[r]||[],e._handlers_[r].push(t);return e};cc.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};cc.prototype.trigger=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]&&e._handlers_[r].length&&e._handlers_[r].forEach(function(o){o.call(e,{type:r,target:e},t)})};cc.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=xO(t.options,i))};cc.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.')},Eh(i,_h[t],e._domHandlers_[t]),Ip[t]&&Eh(i,Ip[t],e._domHandlers_[t]),e};cc.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},I1(i,_h[t],e._domHandlers_[t]),Ip[t]&&I1(i,Ip[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Th=cc;function er(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=er.id,er.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}er.prototype=new Th;er.constructor=er;er.id=0;er.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)};er.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=yO("borderRadius","50%"),e=o0("transition","opacity",i),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.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)"},n.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)"},a0(n.el,e),this.options.shape==="circle"&&a0(n.back,t),a0(n.front,t),this.applyStyles(n),this};er.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};er.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};er.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};er.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};er.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};er.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,n={};n.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,n.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,n)}return t};er.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var n=e.options.fadeTime+"ms",r={};r.front=o0("transition",["top","left"],n);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(r),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};er.prototype.restCallback=function(){var i=this,t={};t.front=o0("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};er.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};er.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,n=Math.PI/2,r,s,o;if(t>e&&t<e*3&&!i.lockX?r="up":t>-e&&t<=e&&!i.lockY?r="left":t>-e*3&&t<=-e&&!i.lockX?r="down":i.lockY||(r="right"),i.lockY||(t>-n&&t<n?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:r},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:"+r,i)}else this.resetDirection();return i};var EO=er;function In(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=In.id,In.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 n=getComputedStyle(e.options.zone.parentElement);return n&&n.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}In.prototype=new Th;In.constructor=In;In.id=0;In.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 n=0,r=t.length;n<r;n+=1)if(t[n].identifier===e)return t[n];return!1}};In.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};In.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)}};In.prototype.createNipple=function(i,t){var e=this,n=e.manager.scroll,r={},s=e.options,o={x:e.parentIsFlex?n.x:n.x+e.box.left,y:e.parentIsFlex?n.y:n.y+e.box.top};if(i.x&&i.y)r={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),r=i,i={x:l.left+n.x,y:l.top+n.y}}var u=new EO(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||(s0(u.ui.el,r),s0(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};In.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};In.prototype.bindNipple=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};In.prototype.pressureFn=function(i,t,e){var n=this,r=0;clearInterval(n.pressureIntervals[e]),n.pressureIntervals[e]=setInterval(function(){var s=i.force||i.pressure||i.webkitForce||0;s!==r&&(t.trigger("pressure",s),n.trigger("pressure "+t.identifier+":pressure",s),r=s)}.bind(n),100)};In.prototype.onstart=function(i){var t=this,e=t.options,n=i;i=i0(i),t.updateBox();var r=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(n.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 Pp(i,r),t.manager.bindDocument(),!1};In.prototype.processOnStart=function(i){var t=this,e=t.options,n,r=t.manager.getIdentifier(i),s=i.force||i.pressure||i.webkitForce||0,o={x:i.pageX,y:i.pageY},a=t.getOrCreate(r,o);a.identifier!==r&&t.manager.removeIdentifier(a.identifier),a.identifier=r;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((n=t.idles.indexOf(a))>=0&&t.idles.splice(n,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var u=Cp(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(i);return}}return a};In.prototype.getOrCreate=function(i,t){var e=this,n=e.options,r;return/(semi|static)/.test(n.mode)?(r=e.idles[0],r?(e.idles.splice(0,1),r):n.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(r=e.createNipple(t,i),r)};In.prototype.processOnMove=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.scroll;if(!gO(i)){this.processOnEnd(i);return}if(!r){console.error("Found zombie joystick with ID "+n),t.manager.removeIdentifier(n);return}if(e.dynamicPage){var o=r.el.getBoundingClientRect();r.position={x:s.x+o.left,y:s.y+o.top}}r.identifier=n;var a=r.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=r.position.y),e.lockY&&(l.x=r.position.x);var u=Cp(l,r.position),c=pO(l,r.position),d=r0(c),h=u/a,f={distance:u,position:l},p,m;if(r.options.shape==="circle"?(p=Math.min(u,a),m=mO(r.position,p,c)):(m=bO(l,r.position,a),p=Cp(m,r.position)),e.follow){if(u>a){let x=l.x-m.x,b=l.y-m.y;r.position.x+=x,r.position.y+=b,r.el.style.top=r.position.y-(t.box.top+s.y)+"px",r.el.style.left=r.position.x-(t.box.left+s.x)+"px",u=Cp(l,r.position)}}else l=m,u=p;var g=l.x-r.position.x,y=l.y-r.position.y;r.frontPosition={x:g,y},e.dataOnly||s0(r.ui.front,r.frontPosition);var v={identifier:r.identifier,position:l,force:h,pressure:i.force||i.pressure||i.webkitForce||0,distance:u,angle:{radian:d,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:r,lockX:e.lockX,lockY:e.lockY};v=r.computeDirection(v),v.angle={radian:r0(180-c),degree:180-c},r.trigger("move",v),t.trigger("move "+r.id+":move",v)};In.prototype.processOnEnd=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.removeIdentifier(r.identifier);!r||(e.dataOnly||r.hide(function(){e.mode==="dynamic"&&(r.trigger("removed",r),t.trigger("removed "+r.id+":removed",r),t.manager.trigger("removed "+r.id+":removed",r),r.destroy())}),clearInterval(t.pressureIntervals[r.identifier]),r.resetDirection(),r.trigger("end",r),t.trigger("end "+r.id+":end",r),t.ids.indexOf(r.identifier)>=0&&t.ids.splice(t.ids.indexOf(r.identifier),1),t.actives.indexOf(r)>=0&&t.actives.splice(t.actives.indexOf(r),1),/(semi|static)/.test(e.mode)?t.idles.push(r):t.nipples.indexOf(r)>=0&&t.nipples.splice(t.nipples.indexOf(r),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};In.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()};In.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 _O=In;function xr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=O1(),t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(s){s.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};if(typeof window>"u")return t.collections;Eh(window,"resize",function(){D1(e)});var n=function(){t.scroll=O1()};return Eh(window,"scroll",function(){D1(n)}),t.collections}xr.prototype=new Th;xr.constructor=xr;xr.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(n){return e=n.get(t),!e}),e}};xr.prototype.create=function(i){return this.createCollection(i)};xr.prototype.createCollection=function(i){var t=this,e=new _O(t,i);return t.bindCollection(e),t.collections.push(e),e};xr.prototype.bindCollection=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};xr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};xr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};xr.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]};xr.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};xr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};xr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};xr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};xr.prototype.onAny=function(i,t){var e=this,n,r="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=i0(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[r](a),a._found_=!0)},o=function(a){n=e.getIdentifier(a),Pp(e.collections,s.bind(null,a,n)),a._found_||e.removeIdentifier(n)};return Pp(t,o),!1};xr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.off()};xr.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 TO=xr;var MO=new TO,CO={create:function(i){return MO.create(i)},factory:MO};var PO=new Map,Op=new Map,no=class{constructor(t,e,n,r){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"?r.getAudio(s).src:s.data;this.audioPlayer=new Ho({src:u,volume:o,delay:a,loop:l}),Op.has(n.uuid)?Op.get(n.uuid).push(this):Op.set(n.uuid,[this]),PO.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()}},Mh=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=PO.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=Op.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...Op.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Rp=class{constructor(t,e,n,r,s){this.data=e;this.shared=r;this.condition=s;if(e.interaction==="play")this.interaction=new no(t,e,n,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Mh(e);else throw new Error("Missing property")}dispatchBasic(){if(Rt(this.shared,this.condition)===!1)return!1;this.interaction instanceof no?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Rt(this.shared,this.condition)===!1)return!1;this.interaction instanceof no?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){if(Rt(this.shared,this.condition)===!1)return!1;this.interaction instanceof no&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var J9="text/plain",$9="us-ascii",DO=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),eY=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:n,data:r,hash:s}=e.groups,o=n.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(d=>{let[h,f=""]=d.split("=").map(p=>p.trim());return h==="charset"&&(f=f.toLowerCase(),f===$9)?"":`${h}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==J9)&&c.unshift(l),`data:${c.join(";")},${a?r.trim():r}${s?`#${s}`:""}`};function R1(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 eY(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 r=new URL(i);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(r.pathname);if(!c)break;let d=c[0],h=c.index,f=r.pathname.slice(a,h);l+=f.replace(/\/{2,}/g,"/"),l+=d,a=h+d.length}let u=r.pathname.slice(a,r.pathname.length);l+=u.replace(/\/{2,}/g,"/"),r.pathname=l}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=r.pathname.split("/"),a=o[o.length-1];DO(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),r.pathname=o.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...r.searchParams.keys()])DO(o,t.removeQueryParameters)&&r.searchParams.delete(o);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=i;return i=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var c0=class{constructor({url:t,context:e},n,r,s){this.controlsManager=n;this.shared=r;this.condition=s;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:R1(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){if(Rt(this.shared,this.condition)===!1)return!1;Ng?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(We[0]),pC())}};var Lp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.controlsManager=n;this.shared=r;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 n=this.controlsManager.sharedGameControlGlobals.rapierWorld,r=n?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)r?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.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),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(r||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),n.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),n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;n===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(Rt(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(Rt(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 Np=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.shared=n;this.eventManager=r;this.condition=s;this.shared=n}dispatch(){if(Rt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Ch(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 BO={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},F1={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},tY=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],d0={CSS:{},springs:{}};function ys(i,t,e){return Math.min(Math.max(i,t),e)}function Bp(i,t){return i.indexOf(t)>-1}function L1(i,t){return i.apply(null,t)}var rt={arr:function(i){return Array.isArray(i)},obj:function(i){return Bp(Object.prototype.toString.call(i),"Object")},pth:function(i){return rt.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||rt.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 rt.hex(i)||rt.rgb(i)||rt.hsl(i)},key:function(i){return!BO.hasOwnProperty(i)&&!F1.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function FO(i){var t=/\(([^)]+)\)/.exec(i);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function VO(i,t){var e=FO(i),n=ys(rt.und(e[0])?1:e[0],.1,100),r=ys(rt.und(e[1])?100:e[1],.1,100),s=ys(rt.und(e[2])?10:e[2],.1,100),o=ys(rt.und(e[3])?0:e[3],.1,100),a=Math.sqrt(r/n),l=s/(2*Math.sqrt(r*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*a+-o)/u:-o+a;function h(p){var m=t?t*p/1e3:p;return l<1?m=Math.exp(-m*l*a)*(c*Math.cos(u*m)+d*Math.sin(u*m)):m=(c+d*m)*Math.exp(-m*a),p===0||p===1?p:1-m}function f(){var p=d0.springs[i];if(p)return p;for(var m=1/6,g=0,y=0;;)if(g+=m,h(g)===1){if(y++,y>=16)break}else y=0;var v=g*m*1e3;return d0.springs[i]=v,v}return t?h:f}function nY(i){return i===void 0&&(i=10),function(t){return Math.ceil(ys(t,1e-6,1)*i)*(1/i)}}var rY=function(){var i=11,t=1/(i-1);function e(c,d){return 1-3*d+3*c}function n(c,d){return 3*d-6*c}function r(c){return 3*c}function s(c,d,h){return((e(d,h)*c+n(d,h))*c+r(d))*c}function o(c,d,h){return 3*e(d,h)*c*c+2*n(d,h)*c+r(d)}function a(c,d,h,f,p){var m,g,y=0;do g=d+(h-d)/2,m=s(g,f,p)-c,m>0?h=g:d=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(c,d,h,f){for(var p=0;p<4;++p){var m=o(d,h,f);if(m===0)return d;var g=s(d,h,f)-c;d-=g/m}return d}function u(c,d,h,f){if(!(0<=c&&c<=1&&0<=h&&h<=1))return;var p=new Float32Array(i);if(c!==d||h!==f)for(var m=0;m<i;++m)p[m]=s(m*t,c,h);function g(y){for(var v=0,x=1,b=i-1;x!==b&&p[x]<=y;++x)v+=t;--x;var w=(y-p[x])/(p[x+1]-p[x]),E=v+w*t,_=o(E,c,h);return _>=.001?l(y,E,c,h):_===0?E:a(y,v,v+t,c,h)}return function(y){return c===d&&h===f||y===0||y===1?y:s(g(y),d,f)}}return u}(),kO=function(){var i={linear:function(){return function(n){return n}}},t={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var r,s=4;n<((r=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((r*3-2)/22-n,2)}},Elastic:function(n,r){n===void 0&&(n=1),r===void 0&&(r=.5);var s=ys(n,1,10),o=ys(r,.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(n,r){t[n]=function(){return function(s){return Math.pow(s,r+2)}}}),Object.keys(t).forEach(function(n){var r=t[n];i["easeIn"+n]=r,i["easeOut"+n]=function(s,o){return function(a){return 1-r(s,o)(1-a)}},i["easeInOut"+n]=function(s,o){return function(a){return a<.5?r(s,o)(a*2)/2:1-r(s,o)(a*-2+2)/2}}}),i}();function V1(i,t){if(rt.fnc(i))return i;var e=i.split("(")[0],n=kO[e],r=FO(i);switch(e){case"spring":return VO(i,t);case"cubicBezier":return L1(rY,r);case"steps":return L1(nY,r);default:return L1(n,r)}}function UO(i){try{var t=document.querySelectorAll(i);return t}catch{return}}function h0(i,t){for(var e=i.length,n=arguments.length>=2?arguments[1]:void 0,r=[],s=0;s<e;s++)if(s in i){var o=i[s];t.call(n,o,s,i)&&r.push(o)}return r}function f0(i){return i.reduce(function(t,e){return t.concat(rt.arr(e)?f0(e):e)},[])}function IO(i){return rt.arr(i)?i:(rt.str(i)&&(i=UO(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function k1(i,t){return i.some(function(e){return e===t})}function U1(i){var t={};for(var e in i)t[e]=i[e];return t}function N1(i,t){var e=U1(i);for(var n in i)e[n]=t.hasOwnProperty(n)?t[n]:i[n];return e}function p0(i,t){var e=U1(i);for(var n in t)e[n]=rt.und(i[n])?t[n]:i[n];return e}function iY(i){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return t?"rgba("+t[1]+",1)":i}function sY(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}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),r=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+r+","+s+","+o+",1)"}function oY(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,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100,s=t[4]||1;function o(h,f,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?h+(f-h)*6*p:p<1/2?f:p<2/3?h+(f-h)*(2/3-p)*6:h}var a,l,u;if(n==0)a=l=u=r;else{var c=r<.5?r*(1+n):r+n-r*n,d=2*r-c;a=o(d,c,e+1/3),l=o(d,c,e),u=o(d,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function aY(i){if(rt.rgb(i))return iY(i);if(rt.hex(i))return sY(i);if(rt.hsl(i))return oY(i)}function qo(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 lY(i){if(Bp(i,"translate")||i==="perspective")return"px";if(Bp(i,"rotate")||Bp(i,"skew"))return"deg"}function B1(i,t){return rt.fnc(i)?i(t.target,t.id,t.total):i}function ro(i,t){return i.getAttribute(t)}function z1(i,t,e){var n=qo(t);if(k1([e,"deg","rad","turn"],n))return t;var r=d0.CSS[t+e];if(!rt.und(r))return r;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 d0.CSS[t+e]=u,u}function zO(i,t,e){if(t in i.style){var n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=i.style[t]||getComputedStyle(i).getPropertyValue(n)||"0";return e?z1(i,r,e):r}}function G1(i,t){if(rt.dom(i)&&!rt.inp(i)&&(ro(i,t)||rt.svg(i)&&i[t]))return"attribute";if(rt.dom(i)&&k1(tY,t))return"transform";if(rt.dom(i)&&t!=="transform"&&zO(i,t))return"css";if(i[t]!=null)return"object"}function GO(i){if(!!rt.dom(i)){for(var t=i.style.transform||"",e=/(\w+)\(([^)]*)\)/g,n=new Map,r;r=e.exec(t);)n.set(r[1],r[2]);return n}}function cY(i,t,e,n){var r=Bp(t,"scale")?1:0+lY(t),s=GO(i).get(t)||r;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),n?z1(i,s,n):s}function H1(i,t,e,n){switch(G1(i,t)){case"transform":return cY(i,t,n,e);case"css":return zO(i,t,e);case"attribute":return ro(i,t);default:return i[t]||0}}function j1(i,t){var e=/^(\*=|\+=|-=)/.exec(i);if(!e)return i;var n=qo(i)||0,r=parseFloat(t),s=parseFloat(i.replace(e[0],""));switch(e[0][0]){case"+":return r+s+n;case"-":return r-s+n;case"*":return r*s+n}}function HO(i,t){if(rt.col(i))return aY(i);if(/\s/g.test(i))return i;var e=qo(i),n=e?i.substr(0,i.length-e.length):i;return t?n+t:n}function W1(i,t){return Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))}function uY(i){return Math.PI*2*ro(i,"r")}function dY(i){return ro(i,"width")*2+ro(i,"height")*2}function hY(i){return W1({x:ro(i,"x1"),y:ro(i,"y1")},{x:ro(i,"x2"),y:ro(i,"y2")})}function jO(i){for(var t=i.points,e=0,n,r=0;r<t.numberOfItems;r++){var s=t.getItem(r);r>0&&(e+=W1(n,s)),n=s}return e}function fY(i){var t=i.points;return jO(i)+W1(t.getItem(t.numberOfItems-1),t.getItem(0))}function WO(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return uY(i);case"rect":return dY(i);case"line":return hY(i);case"polyline":return jO(i);case"polygon":return fY(i)}}function pY(i){var t=WO(i);return i.setAttribute("stroke-dasharray",t),t}function mY(i){for(var t=i.parentNode;rt.svg(t)&&rt.svg(t.parentNode);)t=t.parentNode;return t}function qO(i,t){var e=t||{},n=e.el||mY(i),r=n.getBoundingClientRect(),s=ro(n,"viewBox"),o=r.width,a=r.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function gY(i,t){var e=rt.str(i)?UO(i)[0]:i,n=t||100;return function(r){return{property:r,el:e,svg:qO(e),totalLength:WO(e)*(n/100)}}}function yY(i,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return i.el.getPointAtLength(l)}var n=qO(i.el,i.svg),r=e(),s=e(-1),o=e(1);switch(i.property){case"x":return(r.x-n.x)*n.w;case"y":return(r.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function OO(i,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=HO(rt.pth(i)?i.totalLength:i,t)+"";return{original:n,numbers:n.match(e)?n.match(e).map(Number):[0],strings:rt.str(i)||t?n.split(e):[]}}function YO(i){var t=i?f0(rt.arr(i)?i.map(IO):IO(i)):[];return h0(t,function(e,n,r){return r.indexOf(e)===n})}function XO(i){var t=YO(i);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:GO(e)}}})}function vY(i,t){var e=U1(t);if(/^spring/.test(e.easing)&&(e.duration=VO(e.easing)),rt.arr(i)){var n=i.length,r=n===2&&!rt.obj(i[0]);r?i={value:i}:rt.fnc(t.duration)||(e.duration=t.duration/n)}var s=rt.arr(i)?i:[i];return s.map(function(o,a){var l=rt.obj(o)&&!rt.pth(o)?o:{value:o};return rt.und(l.delay)&&(l.delay=a?0:t.delay),rt.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return p0(o,e)})}function xY(i){for(var t=h0(f0(i.map(function(s){return Object.keys(s)})),function(s){return rt.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},n=function(s){var o=t[s];e[o]=i.map(function(a){var l={};for(var u in a)rt.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},r=0;r<t.length;r++)n(r);return e}function bY(i,t){var e=[],n=t.keyframes;n&&(t=p0(xY(n),t));for(var r in t)rt.key(r)&&e.push({name:r,tweens:vY(t[r],i)});return e}function SY(i,t){var e={};for(var n in i){var r=B1(i[n],t);rt.arr(r)&&(r=r.map(function(s){return B1(s,t)}),r.length===1&&(r=r[0])),e[n]=r}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function wY(i,t){var e;return i.tweens.map(function(n){var r=SY(n,t),s=r.value,o=rt.arr(s)?s[1]:s,a=qo(o),l=H1(t.target,i.name,a,t),u=e?e.to.original:l,c=rt.arr(s)?s[0]:u,d=qo(c)||qo(l),h=a||d;return rt.und(o)&&(o=u),r.from=OO(c,h),r.to=OO(j1(o,c),h),r.start=e?e.end:0,r.end=r.start+r.delay+r.duration+r.endDelay,r.easing=V1(r.easing,r.duration),r.isPath=rt.pth(s),r.isColor=rt.col(r.from.original),r.isColor&&(r.round=1),e=r,r})}var KO={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,n,r){if(n.list.set(t,e),t===n.last||r){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function QO(i,t){var e=XO(i);e.forEach(function(n){for(var r in t){var s=B1(t[r],n),o=n.target,a=qo(s),l=H1(o,r,a,n),u=a||qo(l),c=j1(HO(s,u),l),d=G1(o,r);KO[d](o,r,c,n.transforms,!0)}})}function AY(i,t){var e=G1(i.target,t.name);if(e){var n=wY(t,i),r=n[n.length-1];return{type:e,property:t.name,animatable:i,tweens:n,duration:r.end,delay:n[0].delay,endDelay:r.endDelay}}}function EY(i,t){return h0(f0(i.map(function(e){return t.map(function(n){return AY(e,n)})})),function(e){return!rt.und(e)})}function ZO(i,t){var e=i.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},r={};return r.duration=e?Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,r.delay=e?Math.min.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):t.delay,r.endDelay=e?r.duration-Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,r}var RO=0;function _Y(i){var t=N1(BO,i),e=N1(F1,i),n=bY(e,i),r=XO(i.targets),s=EY(r,n),o=ZO(s,e),a=RO;return RO++,p0(t,{id:a,children:[],animatables:r,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Wi=[],LO=[],u0,TY=function(){function i(){u0=requestAnimationFrame(t)}function t(e){var n=Wi.length;if(n){for(var r=0;r<n;){var s=Wi[r];s.paused?(Wi.splice(r,1),n-=1):(s.tick(e),r++)}i()}else u0=cancelAnimationFrame(u0)}return i}();function MY(i){document.hidden?(Wi.forEach(function(t){return t.pause(i.timeStamp)}),LO=Wi.slice(0),On.running=Wi=[]):LO.forEach(function(t){return t.play(i.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",MY);function On(i){i===void 0&&(i={});var t=0,e=0,n=0,r,s,o=0,a=null;function l(_){var S=window.Promise&&new Promise(function(T){return a=T});return _.finished=S,S}var u=_Y(i),c=l(u);function d(){var _=u.direction;_!=="alternate"&&(u.direction=_!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(S){(S.loop===1||S.loop%2===0)&&(S.reversed=u.reversed)})}function h(){u.direction="normal",u.reversed=!1,s.forEach(function(_){return _.reversed=!1})}function f(_){return u.reversed?u.duration-_:_}function p(){t=0,e=f(u.currentTime)*(1/On.speed)}function m(_,S,T=!1){S&&(u.reversed?S.seek(S.duration*S.loop-(_-S.timelineOffset-S.pingPongDelayCorrection),T):S.seek(_-S.timelineOffset-S.startOnceDelay-S.pingPongDelayCorrection,T))}function g(_,S=!1){if(u.reversed)for(var M=o;M--;)m(_,s[M],S);else for(var T=0;T<o;T++)m(_,s[T],S)}function y(_){var S=0,T=u.animations,M=T.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"?_=u.duration-u.delay+u.endDelay-_:_=u.duration+u.delay-u.endDelay-_):w(!1,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)&&(u.parent?.reversed&&u.direction==="alternate"?_=u.duration-u.delay+u.endDelay-_:_=u.duration+u.delay-u.endDelay-_);S<M;){var C=T[S],D=C.animatable,P=C.tweens,I=P.length-1,L=P[I];I&&(L=h0(P,function(W){return _<W.end})[0]||L);let K;u.parent?.reversed&&u.direction==="alternate"?K=ys(_-L.start-L.endDelay,0,L.duration)/L.duration:K=ys(_-L.start-L.delay,0,L.duration)/L.duration;for(var H=isNaN(K)?1:L.easing(K),k=L.to.strings,G=L.round,z=[],U=L.to.numbers.length,$=void 0,F=0;F<U;F++){var j=void 0;let W,ye;u.direction!=="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1?(W=L.to.numbers[F],ye=L.from.numbers[F]||0):(ye=L.to.numbers[F],W=L.from.numbers[F]||0):w(!0,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)?(W=L.to.numbers[F],ye=L.from.numbers[F]||0):(ye=L.to.numbers[F],W=L.from.numbers[F]||0),L.isPath?j=yY(L.value,H*ye):j=W+H*(ye-W),G&&(L.isColor&&F>2||(j=Math.round(j*G)/G)),z.push(j)}var X=k.length;if(!X)$=z[0];else{$=k[0];for(var q=0;q<X;q++){var V=k[q],Z=k[q+1],Q=z[q];isNaN(Q)||(Z?$+=Q+Z:$+=Q+" ")}}KO[C.type](D.target,C.property,$,D.transforms),C.currentValue=$,S++}}function v(_){u[_]&&!u.passThrough&&u[_](u)}function x(){u.remaining&&u.remaining!==!0&&u.remaining--}let b={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function w(_,S,T,M,C){return b[_<<4|S<<3|T<<2|M<<1|C]}function E(_,S=!1){var T=u.duration;let M=u.delay,C=T-u.endDelay;u.parent?.reversed&&u.direction==="alternate"&&(M=u.endDelay,C=T-u.delay);var D=f(_);if(u.progress=ys(D/T*100,0,100),S||(u.reversePlayback=D<u.currentTime),o&&g(D,S),!u.began&&u.currentTime>=0&&(u.began=!0,v("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,v("loopBegin")),(u.reversed||D>=0)&&D<=M&&u.currentTime!==0&&(y(0),v("change")),(D>=C&&u.currentTime!==T+u.pingPongDelayCorrection||!T)&&(y(T),v("change")),D>M&&D<C?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,v("changeBegin")),y(D),v("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):u.began&&D>C&&v("changeComplete"),u.currentTime=ys(D,0,T+u.pingPongDelayCorrection),u.began&&v("update"),_>=T)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/On.speed:t+=u.duration;for(let P of s)P.setStartTime(0),P.remaining=P.loop;v("loopComplete"),u.loopBegan=!1,u.direction==="alternate"?d():o&&h()}}return u.reset=function(){var _=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=_==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var S=o;S--;)u.children[S].reset();y(u.reversed?u.duration:0)},u.setStartTime=function(_){t=_},u.set=function(_,S){return QO(_,S),u},u.tick=function(_){n=_,t||(t=n),E((n+(e-t))*On.speed)},u.seek=function(_,S=!1){E(_-t,S)},u.pause=function(_){u.paused=!0,o&&(r=_??performance.now())},u.play=function(_){!u.paused||(u.completed&&u.reset(),u.paused=!1,Wi.push(u),o&&r!==void 0&&(t+=(_??performance.now())-r),u0||TY())},u.reverse=function(){d(),u.completed=!u.reversed,p()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function NO(i,t){for(var e=t.length;e--;)k1(i,t[e].animatable.target)&&t.splice(e,1)}function CY(i){for(var t=YO(i),e=Wi.length;e--;){var n=Wi[e],r=n.animations,s=n.children;NO(t,r);for(var o=s.length;o--;){var a=s[o],l=a.animations;NO(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!r.length&&!s.length&&n.pause()}}function PY(i,t){t===void 0&&(t={});var e=t.direction||"normal",n=t.easing?V1(t.easing):null,r=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=rt.arr(i),d=parseFloat(c?i[0]:i),h=c?parseFloat(i[1]):0,f=qo(c?i[1]:i)||0,p=t.start||0+(c?d: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 b=0;b<x;b++){if(!r)m.push(Math.abs(o-b));else{var w=l?(r[0]-1)/2:o%r[0],E=l?(r[1]-1)/2:Math.floor(o/r[0]),_=b%r[0],S=Math.floor(b/r[0]),T=w-_,M=E-S,C=Math.sqrt(T*T+M*M);s==="x"&&(C=-T),s==="y"&&(C=-M),m.push(C)}g=Math.max.apply(Math,m)}n&&(m=m.map(function(P){return n(P/g)*g})),e==="reverse"&&(m=m.map(function(P){return s?P<0?P*-1:-P:Math.abs(g-P)}))}var D=c?(h-d)/g:d;return p+D*(Math.round(m[v]*100)/100)+f}}function DY(i){i===void 0&&(i={});var t=On(i);return t.duration=0,t.add=function(e,n){var r=Wi.indexOf(t),s=t.children;r>-1&&Wi.splice(r,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=p0(e,N1(F1,i));l.targets=l.targets||i.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=rt.und(n)?u:j1(n,u),o(t);var c=On(l);o(c),s.push(c),c.parent=t;var d=ZO(s,i);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}On.version="3.2.0";On.speed=1;On.running=Wi;On.remove=CY;On.get=H1;On.set=QO;On.convertPx=z1;On.path=gY;On.setDashoffset=pY;On.stagger=PY;On.timeline=DY;On.easing=V1;On.penner=kO;On.random=function(i,t){return Math.floor(Math.random()*(t-i+1))+i};var m0=On;var JO=new A,$O=new A,eR=new Ye;function tR(i,t,e,n){if(n===0)return e.copy(i);if(n===1)return e.copy(t);let r=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(r>=1)return e.copy(i);let s=1-r*r;if(s<=Number.EPSILON){let c=1-n;return e.w=c*i.w+n*t.w,e.x=c*i.x+n*t.x,e.y=c*i.y+n*t.y,e.z=c*i.z+n*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,r),l=Math.sin((1-n)*a)/o,u=Math.sin(n*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 vs(i,t,e,n,r,s){let o=e[i]?e[i]:void 0,a=n[i];if(a==null)return;let l=o!=null?typeof o=="string"?Number(r.getVariable(o)??0):o:t[i],u=typeof a=="string"?Number(r.getVariable(a)??0):a;if(l!==u)return{update:c=>{let d=we.lerp(l,u,c);s?t[i]=Math.trunc(d):t[i]=d},start:()=>{t[i]=l},end:()=>{t[i]=u}}}function q1(i,t,e,n,r,s){let o=e[i]?e[i]:void 0,a=n[i];if(!a)return;let l=t[i],u=[...o??l].map(d=>typeof d=="string"?Number(r.getVariable(d)??0):d),c=[...a].map(d=>typeof d=="string"?Number(r.getVariable(d)??0):d);if(!(u.length!==c.length||Mf(u,c)))return{update:d=>{u.forEach((h,f)=>{let p=we.lerp(h,c[f],d);t[i][f]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[i],u)},end:()=>{Object.assign(t[i],c)}}}function Fp(i,t,e){return t.forEach((n,r)=>{i.setComponent(r,typeof n=="string"?Number(e.getVariable(n)??0):n)}),i}function Y1(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=s?Fp(new A,s,r):a.clone(),u=Fp(new A,o,r);if(!l.equals(u))return{update:c=>{a.lerpVectors(l,u,c)},start:()=>{a.copy(l)},end:()=>{a.copy(u)}}}function nR(i,t,e,n){let r=e[i]?e[i]:void 0,s=n[i];if(!s)return;let o=t[i],a=r?new se().fromArray(r):o.clone(),l=new A,u=new Ye,c=new A;a.decompose(l,u,c);let d=new se().fromArray(s),h=new A,f=new Ye,p=new A;if(d.decompose(h,f,p),!a.equals(d))return{update:m=>{eR.slerpQuaternions(u,f,m),JO.lerpVectors(l,h,m),$O.lerpVectors(c,p,m),o.compose(JO,eR,$O)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(h,f,p)}}}function rR(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=s?typeof s=="string"?r.getColor(s).clone():new Fe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Fe().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[i]=c,{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function io(i,t,e,n,r){if(typeof t[i]=="number")return vs(i,t,e??{},n,r);if(Array.isArray(t[i]))return q1(i,t,e??{},n,r)}function iR(i,t,e,n){let r=[],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&&r.push({update:u=>{i.zoom=we.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=vs("targetOffset",i,t,e,n);a&&r.push(a)}return r}function IY(i,t,e,n){if(e.scaleBaked===void 0)return;let r=(t.scaleBaked??i.data.geometry.scaleBaked).map(a=>typeof a=="string"?Number(n.getVariable(a)??0):a),s=e.scaleBaked.map(a=>typeof a=="string"?Number(n.getVariable(a)??0):a);if(Ns.isEqual(r,s))return;let o=[];return o.push({update:a=>{i.updateGeometryInteractions({scaleBaked:[we.lerp(r[0],s[0],a),we.lerp(r[1],s[1],a),we.lerp(r[2],s[2],a)]},n),i.invalidateDownstreamBooleanData()},start:()=>{i.updateGeometryInteractions({scaleBaked:r},n),i.invalidateDownstreamBooleanData()},end:()=>{i.updateGeometryInteractions({scaleBaked:s},n),i.invalidateDownstreamBooleanData()}}),o}function OY(i,t,e,n){if(!e.extrusion)return;let r=i.extrusion,s=t.extrusion??{},o=e.extrusion,a=[];return bS.forEach(l=>{let u=io(l,r,s,o,n);u&&a.push(u)}),a}function sR(i,t,e,n){let r=[];if(!("geometry"in e))return r;let s=i.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(i instanceof hs){let l=IY(i,o,a,n);l&&r.push(...l)}else{let l={};if(Object.assign(l,Si(s,SS)),SS.forEach(u=>{let c=io(u,l,o,a,n);c&&r.push(c)}),i instanceof el){Object.assign(l,{extrusion:{...s.extrusion}});let u=OY(l,o,a,n);u&&r.push(...u)}r.length&&r.push({update:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},start:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},end:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()}})}return r}function oR(i,t,e,n){let r=[];if(e.intensity!==void 0){let s=vs("intensity",i,t,e,n);s&&r.push(s)}if(e.color!==void 0){let s=rR("color",i,t,e,n);s&&r.push(s)}return r}function lR(i,t,e,n){let r=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return r;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"||r.push(...aR(a,u,c,n))})}else{if(!("material"in e&&e.material))return r;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return r;r.push(...aR(i.material,s,o,n))}return r}function aR(i,t,e,n){let r=[],s=tc(e,n)||!!t.layers&&tc(t,n);r.push(zY(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=>!yy.some(d=>c.includes(d)));for(let c of u)try{let d=o.getValue(c),h;if(c==="colors")h=kY(o,a,l,c);else if(Array.isArray(d))c==="steps"&&(h=VY(o,a,l,c));else if(typeof d=="number")h=RY(o,a,l,c,n);else{if(typeof d=="boolean")continue;d instanceof B?h=LY(o,a,l,c):d instanceof A?h=NY(o,a,l,c,n):d instanceof dn?h=FY(o,a,l,c,n):d instanceof Fe?h=BY(o,a,l,c,n):"isTexture"in d&&(h=UY(o,a,l,c))}h&&(Array.isArray(h)?r.push(...h):r.push(h))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${c}`,d)}}return r}function RY(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:i.getValue(n),o=e[n],a=typeof s=="string"?Number(r.getVariable(s)??0):s,l=typeof o=="string"?Number(r.getVariable(o)??0):o;if(a!==l)return{update:u=>{i.setValue(n,we.lerp(a,l,u))},start:()=>{i.setValue(n,a)},end:()=>{i.setValue(n,l)}}}function LY(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=i.getValue(n),s=t?new B().fromArray(t[n]):r.clone(),o=new B().fromArray(e[n]);if(!s.equals(o))return{update:a=>{r.lerpVectors(s,o,a)},start:()=>{r.copy(s)},end:()=>{r.copy(o)}}}function NY(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=i.getValue(n),o=t?t[n]:void 0,a=e[n],l=o?Fp(new A,o,r):s.clone(),u=Fp(new A,a,r);if(!l.equals(u))return{update:c=>{s.lerpVectors(l,u,c)},start:()=>{s.copy(l)},end:()=>{s.copy(u)}}}function BY(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Fe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Fe().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return{update:d=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function FY(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Fe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new dn(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return{update:d=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function VY(i,t,e,n="steps"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s,a=e[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&r.push({update:d=>{s[l]=we.lerp(u,c,d)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return r.length?r:void 0}function kY(i,t,e,n="colors"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s.map(l=>l.toArray()),a=e[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];Vf.isEqual(u,c)||r.push({update:d=>{s[l].fromArray(Vf.lerp(u,c,d))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return r.length?r:void 0}function UY(i,t,e,n="texture"){if(!i.hasValue(n)||!(n in e))return;let r=i.getNode("mat");if(!r)return;let s=t?t[n]:r,o=e[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!Vl.isEqual(a,u)||!Vl.isEqual(l,c))return{update:d=>{r.repeat=Vl.lerp(a,u,d),r.offset=Vl.lerp(l,c,d),r.updateMatrix()},start:()=>{r.repeat=[...a],r.offset=[...l],r.updateMatrix()},end:()=>{r.repeat=[...u],r.offset=[...c],r.updateMatrix()}}}function zY(i,t){return{update:()=>{i.transparent=t}}}var X1=new A,cR=new qt;function uR(i,t,e,n,r){let s=[],o,a,l,u,c,d,h={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=vs("slide",h,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,r),c&&s.push(c),d=vs("offset",h,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,r),d&&s.push(d),!c&&!d&&(o=Y1("position",i,t,e,r),o&&s.push(o),a=Y1("scale",i,t,e,r),a&&s.push(a),l=GY(i,t,e,n,r),l&&s.push(l),u=nR("hiddenMatrix",i,t,e),u&&s.push(u)),o||a||l||u||c||d){let f=()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),Lr(i)&&Nr(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,h))};s.push({update:f,start:f,end:f})}return s}function GY(i,t,e,n,r){let s=t?.rotation?t.rotation.map(c=>(typeof c=="string"?Number(r.getVariable(c)??0):c)*we.DEG2RAD):void 0,o=e.rotation?.map(c=>(typeof c=="string"?Number(r.getVariable(c)??0):c)*we.DEG2RAD);if(!o)return;let a=s?new A().fromArray(s):new A().setFromEuler(i.rotation),l=new A().fromArray(o);if(a.equals(l))return;let u=X1.subVectors(l,a);if(n&&u.toArray().every(c=>Math.abs(c)<2*Math.PI)){let c=new Ye().setFromEuler(cR.setFromVector3(a)),d=new Ye().setFromEuler(cR.setFromVector3(l));return{update:h=>{tR(c,d,i.quaternion,h)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}else return{update:c=>{X1.lerpVectors(a,l,c),i.rotation.setFromVector3(X1)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}function dR(i,t,e,n){let r=[];if(!("cloner"in e)||!i.cloner)return r;let s=i.cloner,o="cloner"in t?t.cloner:{},a=e.cloner;dS.forEach(f=>{let p;f==="count"?p=vs("count",s.parameters,o,a,n,!0):p=io(f,s.parameters,o??{},a,n),p&&r.push(p)});let l=HY(s,o,a,n);l?.length&&r.push(...l);let u=jY(s,o,a,n);u?.length&&r.push(...u);let c=WY(s,o,a,n);c?.length&&r.push(...c);let d=qY(s,o,a,n);d?.length&&r.push(...d);let h=YY(s,o,a,n);return h?.length&&r.push(...h),r.length&&r.push({update:()=>{s.update()}}),r}function HY(i,t,e,n){if(i.parameters.type!=="radial")return;let r=t.radial,s=e.radial;if(!s)return;let o=i.parameters.radial,a=[];return hS.forEach(l=>{let u=io(l,o,r??{},s,n);u&&a.push(u)}),a}function jY(i,t,e,n){if(i.parameters.type!=="linear")return;let r=t.linear,s=e.linear;if(!s)return;let o=[],a=i.parameters.linear;return fS.forEach(l=>{let u=io(l,a,r??{},s,n);u&&o.push(u)}),o}function WY(i,t,e,n){if(i.parameters.type!=="grid")return;let r=t.grid,s=e.grid;if(!s)return;let o=[],a=i.parameters.grid;return pS.forEach(l=>{let u;l==="count"?u=q1(l,a,r??{},s,n,!0):u=io(l,a,r??{},s,n),u&&o.push(u)}),o}function qY(i,t,e,n){if(i.parameters.type!=="toObject")return;let r=t.toObject,s=e.toObject;if(!s)return;let o=[],a=i.parameters.toObject;return mS.forEach(l=>{let u;l==="count"?u=vs(l,a,r??{},s,n,!0):u=io(l,a,r??{},s,n),u&&o.push(u)}),o}function YY(i,t,e,n){if(!i.parameters.randomness)return;let r=t.randomnessObject,s=e.randomnessObject;if(!s)return;let o=[],a=i.parameters.randomnessObject;return gS.forEach(l=>{let u=io(l,a,r??{},s,n);u&&o.push(u)}),o}function K1(i,t,e,n,r){let s=[];return i.data.visible&&s.push(...uR(i,t,e,r,n)),i.data.visible&&s.push(...dR(i,t,e,n)),Lr(i)?(i instanceof jt&&i.data.visible&&s.push(...sR(i,t,e,n)),i.data.visible&&s.push(...lR(i,t,e,n))):xI(i)?i.data.visible&&s.push(...oR(i,t,e,n)):vI(i)&&s.push(...iR(i,t,e,n)),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 hR=new A;function Ch(i,t,e=!1){let n=[];i.traverseChildren(r=>{if(e&&(r.rigidBody?.setTranslation(r.position0,!0),r.rigidBody?.setRotation(r.rotation0,!0),r.rigidBody?.setLinvel(hR,!0),r.rigidBody?.setAngvel(hR,!0)),!at.is(r))return;let s=r.uuid,o=r.data;if(delete r.states,r.uuid===Li)return;let a=!1;n.some(l=>i.scene.find(s)?.isDescendantOf(l))?a=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&n.push(s),r.data=o,r.currentState=null,r.reversibleToState=null,r.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),r.states||(r.states={}),r.states[l.id]=No.patch(o,u)}KY(i.scene,r,null,t,o.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),XY(i)})}function XY(i){i.traverseEntity(t=>{for(let e of t.data.events){let n=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":n.push(...e.data.actions);break;case"GameControl":for(let r of Object.values(e.data.gameActions))n.push(...r);break;case"DragDrop":n.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":n.push(...e.data.inActions,...e.data.outActions);break}for(let r of n)if(r.data.type==="Create"&&r.data.hideBase==="Yes"){let s=i.scene.find(r.data.object);s&&(s.visible=!1)}}})}function KY(i,t,e,n,r=!1){if(t instanceof jt&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:i,shared:n},r),t instanceof jt&&t.updateGeometryGroupsIfNeeded(),t instanceof Kt&&t.updateCameraState(t.dataPatched,{scene:i,shared:n}),t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}function Z1(i){let t;if(i.easing===5){let{control1:e,control2:n}=i;t=`cubicBezier(
6238
6238
  ${e[0]}, ${e[1]}, ${n[0]}, ${n[1]}
6239
- )`}else if(i.easing===6){let{mass:e,stiffness:n,damping:r,velocity:s}=i;t=`spring( ${e}, ${n}, ${r}, ${s} )`}else{let e;switch(i.easing){case 0:e=Ro.linear;break;case 1:e=Ro.ease;break;case 2:e=Ro.easeIn;break;case 3:e=Ro.easeOut;break;case 4:e=Ro.easeInOut;break;default:e=Ro.linear}let[n,r,s,o]=e;t=`cubicBezier( ${n}, ${r}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function Q1(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 QY={type:"beginState"},ZY={type:"completeState",isfromEntity:!1},y0=class{constructor(t,e,n,r,s,o){this.object=t;this.data=r;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 Kt&&e.dispatchEvent(QY)})};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 Kt&&e.dispatchEvent(ZY)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=K1(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=g0(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=g0(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=g0(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Q1(r),...Z1(r),change:this.onChange},this.callback=K1(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Vp=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;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=g0(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:n=!1,isRebuild:r=!1}={}){try{let s=Q1(this.data.tweens[0].data);r&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=m0.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(n===!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],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new y0(this.object,d,c.data.state===void 0?this.currentState:c.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l]=h,this.timeline.add(h.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],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new y0(this.object,d,c.data.state===void 0?this.currentState:c.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l-1]=h,this.timeline.add(h.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(Rt(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=Q1(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(n){n instanceof Error&&console.error(n.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(Rt(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 g0(i,t){let e,n;if(typeof t=="string"?(e=t,n=i.states?.[e]):t===null&&(e=null,n=i.data),!(e===void 0||n===void 0))return{id:e,data:n}}var JY={type:"beginState"},fR={type:"completeState",isfromEntity:!1},pR={type:"requestRender"},kp=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new Ye;this.qEnd=new Ye;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 n=this.page.scene.find(this.data.targetCamera);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");let r={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=m0({targets:r,t:1,...Z1(this.data),update:()=>{r.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(n.position),this.qEnd.copy(n.quaternion),this.zoomEnd=n.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(n.uuid)),this.page.activeCamera.dispatchEvent(JY));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,r.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,r.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*r.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(pR),r.t===1&&s.dispatchEvent(fR)}})}switchCamera(e){let n=this.page.scene.find(e);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(n),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:n})}play(){if(Rt(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(Rt(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(fR),this.page.activeCamera.dispatchEvent(pR))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var Up=class extends Ht{constructor(e,n,r,s,o){super();this.page=n;this.animationControls=r;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=n.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(Rt(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 n=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let o=r.split("/")[1];this.threeAnimAction!==s&&o===n&&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=we.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,n=!1){if(Rt(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 r=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===r&&o.isRunning()&&(n?o.fadeOut(.2):o.stop())}),n&&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 zp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.eventManager=n;this.shared=r;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Rt(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(n=>n.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),Ch(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var Gp=class{constructor(t,e,n,r){this.data=t;this.page=e;this.shared=n;this.condition=r;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Rt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=rv(this.data.expression,this.shared,fr.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var Hp=class{constructor(t,e,n,r){this.data=t;this.page=e;this.shared=n;this.condition=r;this.timeoutId=null}dispatchInner(){if(Rt(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 Rt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=rv(t.expression,i,"boolean");return t.negate?!e:!!e}function Qt(i,t,e,n,r,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"?Jr[i.type].includes("Audio")&&o.Audio.push(new Rp(u,c,s,n,l)):c.type==="Video"?Jr[i.type].includes("Video")&&o.Video.push(new jp(u,c,s,n,l)):c.type==="Link"?Jr[i.type].includes("Link")&&o.Link.push(new c0(c,r.controlsManager,n,l)):c.type==="Create"?Jr[i.type].includes("Create")&&o.Create.push(new Wp(c,e,r.controlsManager,n,l)):c.type==="Destroy"?Jr[i.type].includes("Destroy")&&o.Destroy.push(new Lp(c,e,r.controlsManager,n,l)):c.type==="Reset"?Jr[i.type].includes("Reset")&&o.Reset.push(new Np(c,e,n,r,l)):c.type==="Transition"?Jr[i.type].includes("Transition")&&o.Transition.push(new Vp(c,e,n,l)):c.type==="SwitchCamera"?Jr[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new kp(c,e,n,l)):c.type==="SceneTransition"?Jr[i.type].includes("SceneTransition")&&o.SceneTransition.push(new zp(c,e,r,n,l)):c.type==="Animation"?Jr[i.type].includes("Animation")&&o.Animation.push(new Up(c,e,r.animationControls,n,l)):c.type==="SetVariable"?Jr[i.type].includes("SetVariable")&&o.SetVariable.push(new Gp(c,e,n,l)):c.type==="DynamicVariablePlay"?Jr[i.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new Hp(c,e,n,l)):c.type==="Conditional"&&Jr[i.type].includes("Conditional")&&(c.ifActions.forEach(a({expression:c.condition,negate:!1})),c.elseActions.forEach(a({expression:c.condition,negate:!0})))}catch(d){!1&&console.log(d)}};return t.forEach(a()),o}function Gt(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Rp||e instanceof jp||e instanceof Up||e instanceof Vp||e instanceof Wp||e instanceof Lp||e instanceof kp||e instanceof zp||e instanceof Np||e instanceof Gp||e instanceof Hp)&&e.dispose()})})}function mR(i,t){let e;if("material"in i){let n=i.material;Array.isArray(n)?e=i.material[0].layers.find(r=>r.uuid===t):e=i.material.layers.find(r=>r.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var gR=new Map,qp=new Map,Yo=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:r,loop:s,volume:o,delay:a}=e;if(this.object=n,r===void 0)throw new Error("Missing property");let l=mR(n,r);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),qp.has(n.uuid)?qp.get(n.uuid).push(this):qp.set(n.uuid,[this]),gR.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 n=this.videoElement.play();n!==void 0&&n.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Ph=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=gR.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=qp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let t=[...qp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},jp=class{constructor(t,e,n,r,s){this.data=e;this.shared=r;this.condition=s;if(e.interaction==="play")this.interaction=new Yo(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Ph(e);else throw new Error("Missing property")}dispatchBasic(){if(Rt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Rt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var yR=(()=>{let i,t,e,n;function r(a){!i&&!vR()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,n=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,d=u.length,h=0;for(;h<d;){let f=u[h];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(),n()),h++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(h,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)),d--,n())}i=h>0?requestAnimationFrame(s):void 0,e=h>0?a:void 0}function o(){vR()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):r()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),r})();function vR(){return!!document&&document.hidden}var xR=new Ye,$Y=new A,e7=new A,Wp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.controlsManager=n;this.shared=r;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=we.generateUUID();this.dispatch=()=>{if(Rt(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(Rt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Hb(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 un(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem,r=this.page.scene.find(n);r&&(r.updateMatrixWorldSVD(),t.hiddenMatrix.copy(r.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),yR(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof vr)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 un)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof vr)return;t instanceof un?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 n=new A().fromArray(this.data.velocity),r=e.dataPatched;if(!(r.physics.enabled==="visibility"?!r.visible:!r.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($Y,xR,e7),n.applyQuaternion(xR),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(n.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=n)),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");yR(n)}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 tA=200,J1=.02,$1=.3,t7=65,y3e=new A,bR=new A,SR=new A,n7=new A,Xr=new A,ci=new A,tl=new A,eA=new se,wR=new se,r7=new se,v3e=new se,xs=new Ye,Xo=new Ye,so=new qt(0,0,0,"YXZ"),i7=new A(1,0,0),bs=new A(0,1,0),s7=new A(0,0,1),AR=new A(1,1,1),x3e=new ln,o7=1,a7=.025,l7=16e-6,ER=12,c7=20,br=new Xn,qi=new Tt,u7={type:"requestRender"},d7={type:"updateMatrix"},_R=Math.PI/6,v0=class extends Ht{constructor(e,n,r,s,o,a,l,u,c){super();this.object=e;this.domElement=n;this.data=r;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new se;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=tA;this.euler0=new qt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new Ye;this.scale0Cam=new A;this.hiddenMatrix0Cam=new se;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Xn(new A(0,-40,0),new A(0,40,0)),matrix:new se,position:new A,rotation:new Ye};this.euler=new qt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastPosition=new A;this.lastCameraQuaternion=new Ye;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new B;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.nonColliderRotOffset=new se;this.nonColliderPosOffset=new se;this.firstPointerId=-1;this.rot=new A;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 se;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new Ye;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Ye;this.objXZQuatInv=new Ye;this.objXZRotMat=new se;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new Ye;this.colliderWorldQuat=new Ye;this.groundNormal=new A;this.groundTilt=new Ye;this.groundTiltInv=new Ye;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new A;this.quaternion=new Ye;this.scale=new A;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"&&!Qn&&(!jb||Wb>=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 n=e.clientX-this.prevMouse.x,r=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(jb&&Wb<15.5&&!Qn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-r*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=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-r*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?v0.isLocked=!0:v0.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 n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]){this.movementState[n[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]||e.code.slice(3,e.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.copyVRGamePadValues=(e,n)=>{for(let r=2;r<4;r++){let s=e.axes[r];n===0?r===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,r===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 d=this.euler0.clone(),h=d.y;if(this.objectRealQuat.copy(this.quaternion),d.y=0,this.quaternion.setFromEuler(d),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),d.set(0,h,0),this.quaternion.setFromEuler(d),this.rot.setFromEuler(d),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 A(0,0,-1).applyQuaternion(this.camera.quaternion),y=new A().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 b=new qt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof Kt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=r.rotByTouch??"joystick",this.rotBy=r.rotBy??"keys",this.rotationMode=r.rotationMode??"normal",this.moveMode=r.moveMode??"walk",this.collisionEnabled=r.collisionEnabled,this.speedTranslate=(r.speedTranslate??250)*o7,this.speedOrbit=(r.speedRotate??100)*a7,this.mouseOrbitSensitivity=(r.speedRotate??100)*l7,this.keyAssignments=r.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}),r.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/((r.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((r.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((r.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((r.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((r.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((r.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Oa.defaultData.gravity)*ER,this.usePhysics=this.gloabalPhysics.usePhysics??Oa.defaultData.usePhysics,this.jumpPower=r.jumpPower*c7,this.resetYPosition=this.position.y+Math.abs(r.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=r.alignToGround??!1,this.orientMode=r.autoOrientMove?r.orientMode:"none",this.orientWith=r.orientWith??$u.defaultDataThirdPerson.orientWith,this.slopeThresh=t7*Math.PI/180,r.collider.type==="capsule"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=r.collider.height/2-r.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=r.collider.height*J1/this.pixelsPerMeter,this.stepThresh=r.collider.height*$1/this.pixelsPerMeter,this.colliderHeight=r.collider.height):r.collider.type==="sphere"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*r.collider.radius*J1/this.pixelsPerMeter,this.stepThresh=2*r.collider.radius*$1/this.pixelsPerMeter,this.colliderHeight=r.collider.radius*2):(this.offset=r.collider.height*J1/this.pixelsPerMeter,this.stepThresh=r.collider.height*$1/this.pixelsPerMeter,this.colliderHeight=r.collider.height),this.collider.type=r.collider.type;let f=new A().fromArray(r.collider.position),p=new Ye().setFromEuler(new qt().fromArray([...r.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,AR),r.cameraXAxis!==void 0&&(this.cameraXAxis=r.cameraXAxis,this.cameraYAxis=r.cameraYAxis,this.minPolarAngle=r.cameraRotXLimits[0],this.maxPolarAngle=r.cameraRotXLimits[1],this.minAzimuthAngleRel=r.cameraRotYLimits[0],this.maxAzimuthAngleRel=r.cameraRotYLimits[1]),this.forwardDir=r.forwardDirection??"-z",this.runMultiplier=r.runMultiplier??2;let m=r.navmesh.destinationHelperRadius*2;if(m>0){let g=new Re;g.push({fi:0,data:{...hr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...hr.defaultData("color"),color:r.navmesh.destinationHelperColor,alpha:r.navmesh.destinationHelperColor.a},id:"layer2"});let y=new Go({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new kn(Hy.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=r.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 n=new qt().setFromQuaternion(this.quaternion,"YXZ"),r=n.y;this.objectRealQuat.copy(this.quaternion),n.y=0,this.quaternion.setFromEuler(n),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),n.set(0,r,0),this.quaternion.setFromEuler(n),this.rot.setFromEuler(n),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Kt?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,n=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Ju.list.forEach(r=>{this.actions[r]=Qt({...e,disabled:!1,type:"GameControl"},e.gameActions[r],this.page,n,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"),Gt(this.actions.idle),Gt(this.actions.move),Gt(this.actions.run),Gt(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(n=>{n.play()}),this.actions[e].Animation.forEach(n=>{n.play(this.initialAction===!1)}),this.actions[e].Create.forEach(n=>{n.dispatchStart()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(n=>{n.dispatchStop()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Xr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,n,r){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=ci.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*ER),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 d=c.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let h of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(h.rigidBody===d&&h.userData.isFollowingObj!==this.object.uuid){(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(Xr,Xo,ci),this.groundVelocity.subVectors(Xr,h.prevT),this.object.getWorldPosition(ci).add(this.collider.position).sub(Xr),this.groundYRotation=so.setFromQuaternion(Xo).y-h.prevR.y,tl.copy(ci).applyAxisAngle(bs,this.groundYRotation),this.groundVelocity.add(tl.sub(ci)).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=Xr.subVectors(this.path[1],this.position),d=ci.subVectors(this.path[1],this.path[0]);c.dot(d)<0?this.path.shift():(this.directionXZ.x=d.x,this.directionXZ.z=d.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=n7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=ci.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=Xr;this.camera.getWorldDirection(u);let c=tl.copy(bs).multiplyScalar(u.dot(bs));u.sub(c);let d=ci.copy(this.directionXZ);d.x*=-1,this.rot.y=u.angleTo(d)*(u.cross(d).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(so.setFromVector3(this.rot),this.moveMode==="walk"&&(so.x=0),l.applyEuler(so),a&&(Xo.setFromUnitVectors(bs,this.groundNormal),l.applyQuaternion(Xo)),r){let u=so.set(0,this.vrEulerYOffset*_R,0);r.applyEuler(u),l.x+=r.x,l.z+=r.z,this.nonColliderPosOffset.elements[13]+=r.y*s}if(this.usePhysics===!0){let u=ci;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let d=tl.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),h=c.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Xr.copy(l).divideScalar(this.pixelsPerMeter),s,!1);d.multiplyScalar(this.pixelsPerMeter);let f=at.is(c)?c:c.object;if(h!==null&&this.lastHitObj!==f){let p;c instanceof un&&(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(x0));this.lastHitObj=f}if(h!==null){this.pushedVelocity.copy(d),u.copy(h.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(bs,this.euler.y-this.euler0.y);let u=ci.copy(this.objectToCamXZ).normalize(),c=tl.copy(l).multiplyScalar(s);c.y=0;let d=c.sub(Xr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(d,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=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=we.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n?(so.copy(n),so.y=0):(so.copy(this.euler),so.y=0),this.nonColliderRotOffset.makeRotationFromEuler(so)),n&&(this.moveMode==="walk"?(this.rot.y=n.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(n),this.rot.y+=this.vrEulerYOffset*_R),xs.setFromAxisAngle(i7,this.rot.x),Xo.setFromAxisAngle(bs,this.rot.y),Xo.multiply(xs),xs.setFromAxisAngle(s7,this.rot.z),Xo.multiply(xs),this.quaternion.copy(Xo),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=ci.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let d=new A;for(let h=0;h<5;h++){let f=u.length(),p=tl.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),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&&h===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let b of x)if(b.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,E;if(m.cloner){for(let _ of m.cloner.children)if(_.rigidBody===w){E=_;break}}b.dispatch(E),m.dispatchEvent(x0)}}}let g=bR.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=SR.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,d.addScaledVector(p,v)),u.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),b=tl.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let w=x.add(b);w.y+=this.stepThresh;let E=this.sharedGameControlGlobals.rapierWorld.castShape(w,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);E!==null&&E.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),d.add(u);break}}this.position.addScaledVector(d,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Xr.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(xs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let d=0;d<u;d++)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);eA.lookAt(c,u,bs).setPosition(c),eA.decompose(this.targetPos,this.targetQuat,Xr),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=we.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=we.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(d7),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(u7),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=xs.setFromAxisAngle(bs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?we.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 n;this.cameraXAxis==="Limit"?n=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let r=Xr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&r.applyQuaternion(e);let s=Xo.setFromAxisAngle(r,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){bs.angleTo(e)*180/Math.PI<15||bs.angleTo(e)*180/Math.PI>85?xs.identity():xs.setFromUnitVectors(bs,e),this.groundTilt.slerp(xs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let n=SR.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let r=eA.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Xr,xs,ci).compose(Xr,xs,AR);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;qi.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=wR.copy(a).invert(),u=r7.copy(wR).multiply(r);br.copy(this.collider.segment),br.start.applyMatrix4(u),br.end.applyMatrix4(u);let c=bR.copy(this.position).applyMatrix4(l);qi.expandByPoint(br.start),qi.expandByPoint(br.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(d){return d.distanceToPoint(br.end)},intersectsBounds:d=>d.intersectsBox(qi),intersectsTriangle:d=>{let h=Xr,f=ci,p=d.closestPointToSegment(br,h,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(h).normalize(),y=tl.copy(c);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);n.add(v),br.start.addScaledVector(g,m),br.end.addScaledVector(g,m)}}})}),qi.makeEmpty(),br.copy(this.collider.segment),br.start.applyMatrix4(r),br.end.applyMatrix4(r),qi.expandByPoint(br.start),qi.expandByPoint(br.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(br.end)},intersectsBounds:o=>o.intersectsBox(qi),intersectsTriangle:o=>{let a=Xr,l=ci,u=o.closestPointToSegment(br,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,d=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(d),n.addScaledVector(d,c),br.start.addScaledVector(d,c),br.end.addScaledVector(d,c)}}}),this.onObject=Math.abs(n.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.position.add(n)}},Yp=v0;Yp.isLocked=!1;var TR=$o(jS());function Ss(i,t){let e=new Ee;if(!i.getAttribute("position"))return e.setAttribute("position",new be([],3)),e.setIndex([]),e;let{positions:n,triIndices:r}=Xl(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new be(n,3)),e.setIndex(r),t&&e.applyMatrix4(t),e}var h7=new se,f7=new se,oo=[[0,0,0],[0,0,0],[0,0,0]];function nA(i){let t=i.elements;oo[0][0]=t[0],oo[0][1]=t[4],oo[0][2]=t[8],oo[1][0]=t[1],oo[1][1]=t[5],oo[1][2]=t[9],oo[2][0]=t[2],oo[2][1]=t[6],oo[2][2]=t[10];let{u:e,v:n}=(0,TR.SVD)(oo),r=h7.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=f7.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return r.multiply(s.transpose())}var b0=class extends eu{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,n=[]){return t.forEach(r=>{r.visible&&this.intersectObject(r,e,n)}),n}createRaycastLineHelper(){let t=new Pi({color:65280,linewidth:10}),e=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new A().addVectors(e,n.multiplyScalar(r)),o=new Ee;return o.setFromPoints([e,s]),new Sl(o,t)}};var MR=i=>i instanceof ps||i instanceof gs;function p7(i,t){return i.distance-t.distance}function CR(i,t,e){if(!(!Gs(t)||!t.visible)){Lr(t)&&t.raycast(i,e);for(let n of t.children)CR(i,n,e)}}function Dh(i,t,e,n=!1){if(!n&&!e.some(s=>Ih(i,s)!==void 0))return[];let r=[];return t.children.forEach(s=>CR(i,s,r)),r.sort(p7),r}function Xp(i){let t=[];if(i.length){let e=i[0].object;Gs(e)&&t.push(e);let n=e.parent;for(;n;)MR(n)&&t.push(n),n=n.parent}return t}function Ih(i,t){if(Lr(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(MR(t))return PR(i,t)}function PR(i,t){if(!(!Gs(t)||!t.visible)){if(Lr(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let n=PR(i,e);if(n)return n}}}function m7(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 S0=class{constructor(t,e,n,r,s,o,a,l){this.renderer=t;this.publish=e;this.scene=n;this.getCamera=r;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new b0;this.raycasterNeedsUpdate=!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}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:n}=t.touches?.length>0?t.touches[0]:t;this.updateDomRect(),this.raycaster.setFromCamera(m7(e,n,this.domRect),this.getCamera())}};var rA=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))(rA||{}),hn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var iA=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],DR=i=>iA.find(([t,e])=>e===i)?.[0],ao=i=>iA.find(([t])=>t===i)?.[1],g7=(i,t)=>{let e=DR(i);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},w0=class extends hn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[DR(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:r}=this.eventContext;r.dispatchEvent(n)};let{page:n}=this.eventContext;n.traverseEntity(r=>{if(!!r.data?.events.length){for(let[s,o]of iA)if(r.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(r):this.objectsPerEvents.set(s,[r]);let a={id:r.uuid,name:r.name},l=g7(o,a),u=this.splineEvents[s];u?u[r.uuid]=l:this.splineEvents[s]={[r.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var sA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;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=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(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(r=>r.playing)||this.actions.Transition.forEach(r=>{this.alreadyPlayedNonTogglingActions.has(r)===!1&&r.play()}),this.actions.SwitchCamera.some(r=>r.playing)||this.actions.SwitchCamera.forEach(r=>{r.play()}),this.actions.Animation.forEach(r=>{r.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())}},A0=class extends hn{constructor(e,n,r){super(e);this.useForRaycastProperty=r;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:n,page:r}=this.eventContext,s=Dh(n,r,[],!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(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(e),n.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(e),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{We.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:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(r)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.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:d})=>d.type===u&&d.disabled!==!0).forEach(({id:d,data:h})=>{try{let f=new sA(d,h,a,s,o,n);f.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.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(([n,r])=>{r.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(n=>{Object.values(n).forEach(r=>{r.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:r,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!(!o.length&&!this.useForRaycastProperty)){if(n||this.useForRaycastProperty){let a;this.sceneInterects===null?a=Dh(r,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]}),n&&Xp(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}n||o.forEach(a=>{Ih(r,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let n="MousePress",r=this.objectsPerTypes[n],s=[];if(!!r.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=Dh(a,l,r);s=Xp(u)}else r.forEach(u=>{Ih(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatchRelease()})}handleKeyEvent(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(r?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(r)})})}};var y7=new A,v7=new A;var E0=class{constructor(t,e,n,r,s){this.actionsIn=Qt(t,t.inActions,n,r,s,e),this.actionsOut=Qt(t,t.outActions,n,r,s,e)}disconnect(){Gt(this.actionsIn),Gt(this.actionsOut)}};var oA=class extends E0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=y7.setFromMatrixPosition(this.objects[0].matrixWorld),n=v7.setFromMatrixPosition(this.objects[1].matrixWorld),r=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==r){this.stage=r;let s=r==="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}=n.condition;this.distance=l;for(let d of[u,c]){if(!d)throw new Error("Missing property");let h=s.find(d);if(!h)throw new Error("Missing property");this.objects.push(h)}}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)})}},aA=class extends E0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(r=>r.dispatchConditional()),this.actionsOut.Video.forEach(r=>r.dispatchConditional()),this.actionsOut.Link.forEach(r=>r.dispatch()),this.actionsOut.Create.forEach(r=>r.dispatch()),this.actionsOut.Destroy.forEach(r=>r.dispatch()),this.actionsOut.Reset.forEach(r=>r.dispatch()),this.actionsIn.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(r=>r.play()),this.actionsOut.Animation.forEach(r=>r.play()),this.actionsIn.SwitchCamera.forEach(r=>r.pause()),this.actionsOut.SwitchCamera.forEach(r=>r.play()),this.actionsOut.SceneTransition.forEach(r=>r.dispatch()),this.actionsOut.SetVariable.forEach(r=>r.checkConditions()),this.actionsOut.SetVariable.forEach(r=>r.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(r=>r.dispatch()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(r=>r.dispatchConditional()),this.actionsIn.Video.forEach(r=>r.dispatchConditional()),this.actionsIn.Link.forEach(r=>r.dispatch()),this.actionsIn.Create.forEach(r=>r.dispatch()),this.actionsIn.Destroy.forEach(r=>r.dispatch()),this.actionsIn.Reset.forEach(r=>r.dispatch()),this.actionsOut.Transition.forEach(r=>r.pause()),this.actionsOut.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(r=>r.play()),this.actionsIn.Animation.forEach(r=>r.play()),this.actionsOut.SwitchCamera.forEach(r=>r.pause()),this.actionsIn.SwitchCamera.forEach(r=>r.play()),this.actionsIn.SceneTransition.forEach(r=>r.dispatch()),this.actionsIn.SetVariable.forEach(r=>r.checkConditions()),this.actionsIn.SetVariable.forEach(r=>r.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(r=>r.dispatch()))};let{condition:l}=n;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(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length||this.actionsOut.DynamicVariablePlay.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length||this.actionsIn.DynamicVariablePlay.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},_0=class extends hn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:r,sharedAssets:s}=this.eventContext;r.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 oA(a,l,o,r,s,n):l.condition.type==="State"&&(u=new aA(a,l,o,r,s,n))),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(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var Kp=new A,nl=new A,dc=new A,IR=new En,x7=.01,Vt=new A,tr=new A,OR=new A,hc=new Ye,lA=new qt,b7=new se,cA=new $t,Oh=new A,lo=new A,Rh=.2;function uA(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 S7=function(){let i=new se;return(t,e,n)=>{let r=t.obj;i.copy(r.hiddenMatrix),r.parent!==null&&i.premultiply(r.parent.matrixWorld),i.invert(),r.position.copy(e),t.reference==="global"&&uA(r.position,t.limits),r.position.applyMatrix4(i),t.reference==="parent"?uA(r.position,t.limits):t.reference==="local"&&(hc.copy(t.quat0).invert(),r.position.sub(t.position0),r.position.applyQuaternion(hc),uA(r.position,t.limits),hc.invert(),r.position.applyQuaternion(hc),r.position.add(t.position0)),i.multiply(n??r.matrixWorld).decompose(Vt,r.quaternion,tr),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r instanceof Xt&&Nr(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),dA=class{constructor(t,e,n,r,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=Qt(e,e.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=Qt(e,e.dragDropActions.drop,n,r,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new Ye().copy(l.quaternion),snapped:!1,orientationMatrix:new se,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Gt(this.actionsDrag),Gt(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()})}},T0=class extends hn{constructor(e,n){super(e);this.eventManager=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);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||at.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 d=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Vt,hc,tr),lA.setFromQuaternion(hc),d.prevR===void 0?(d.prevR=lA.clone(),d.prevT=Vt.clone()):(d.prevR.copy(lA),d.prevT.copy(Vt)),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(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(We.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||at.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 ps)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||r.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=OR.copy(a.face.normal).applyMatrix3(cA.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"){Vt.copy(l).applyMatrix3(cA.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Vt.x>Rh?tr.x=-u.recursiveBBox.min.x:Vt.x<-Rh&&(tr.x=-u.recursiveBBox.max.x),Vt.y>Rh?tr.y=-u.recursiveBBox.min.y:Vt.y<-Rh&&(tr.y=-u.recursiveBBox.max.y),Vt.z>Rh?tr.z=-u.recursiveBBox.min.z:Vt.z<-Rh&&(tr.z=-u.recursiveBBox.max.z),tr.applyMatrix3(cA.invert())}else tr.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(tr)}this.activeEvent.data.autoOrient&&(Vt.set(0,1,0).cross(l),Vt.length()<1e-4&&Vt.set(-1,0,0).cross(l),tr.crossVectors(OR,Vt),o.orientationMatrix.makeBasis(Vt,tr,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 n=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||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(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(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(r=>r.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let r={};e.page.traverseEntity(s=>{s.component&&(r[s.component.uuid]?r[s.component.uuid].push(s.uuid):r[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 dA(s,o.data,e.page,e.sharedAssets,n,r))})})}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(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,r,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(nl),nl.negate();let l=hc.identity();switch(s==="parent"?b7.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Vt,l,tr):s==="local"&&e.matrixWorld.decompose(Vt,l,tr),r){case"x":Vt.set(1,0,0).applyQuaternion(l),Oh.copy(nl).cross(Vt),lo.copy(Vt).cross(Oh);break;case"y":Vt.set(0,1,0).applyQuaternion(l),Oh.copy(nl).cross(Vt),lo.copy(Vt).cross(Oh);break;case"z":Vt.set(0,0,1).applyQuaternion(l),Oh.copy(nl).cross(Vt),lo.copy(Vt).cross(Oh);break;case"xy":lo.set(0,0,1).applyQuaternion(l);break;case"yz":lo.set(1,0,0).applyQuaternion(l);break;case"xz":lo.set(0,1,0).applyQuaternion(l);break;case"adaptive":nl.angleTo(tr.set(0,1,0))>Math.PI/6?(Vt.crossVectors(tr.set(0,1,0),nl),lo.crossVectors(Vt,tr)):lo.set(0,1,0);break;default:lo.copy(nl);break}dc.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:dc;if(IR.setFromNormalAndCoplanarPoint(lo,u),!!a.ray.intersectPlane(IR,n)&&(r==="x"||r==="y"||r==="z")){let c=tr.subVectors(n,u).dot(Vt);n.copy(u).addScaledVector(Vt,c)}}updateDragItem(e,n=!1){dc.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Kp.subVectors(e.fromPosition,dc).divideScalar(e.currentDampingFactor):e.reset==="original"?(Kp.subVectors(e.obj.userData.worldPosition0,dc).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Kp.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(dc).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Kp.length()<x7:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&S7(e,Kp.add(dc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var Lh=new A,hA=new A,Ko=new A,Qo=new A,RR=new En,w7=.01,A7={type:"requestRender"},E7=function(){let i=new A,t=new A;return(e,n,r)=>r>0?(i.subVectors(e,n),i.length()<=r?e:t.copy(n).add(i.normalize().multiplyScalar(r))):n}(),LR=function(){let i=new se;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 Xt&&Nr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),fA=class{constructor(t,e,n,r,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...ly.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.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=Qt(t,t.actions,n,r,s,e)}},M0=class extends hn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!r.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new fA(o.data,s,r,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,o=this.onTargetChange(r);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let r of this.events)r.paused=!0,r.isReset=!1,Gt(r.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:r,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Ko),e.isReset)Qo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Qo);else{let{getCamera:l,raycaster:u}=this.eventContext;if(r==="custom"?(l().getWorldDirection(hA),hA.negate(),Lh.copy(hA)):r==="xy"?Lh.set(0,0,1):r==="xz"?Lh.set(0,1,0):r==="yz"&&Lh.set(1,0,0),RR.setFromNormalAndCoplanarPoint(Lh,Ko),!u.ray.intersectPlane(RR,Qo))return}if(!e.isReset){if(Qo.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)Qo.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&&(Qo.x=Ko.x),e.data.enabledTranslation[1]===!1&&(Qo.y=Ko.y),e.data.enabledTranslation[2]===!1&&(Qo.z=Ko.z);let a=E7(Ko,Qo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Lh.subVectors(a,Ko).divideScalar(e.currentDampingFactor);Ko.add(l),n&&LR(e.object,Ko),e.paused=l.length()<w7}else LR(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(A7)}};var Qp=new A,C0=new A,Zp=new se,Nh=new Ye,rl=new Ye,Jp=new A,$p=new A,fc=new A,Zo=new A,pA=new En,_7=1e-6,T7={type:"requestRender"},M7={type:"changeRotation"},NR=function(){let i=new se;return function(e,n){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),n.premultiply(nA(i).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof Xt&&Nr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),mA=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Ye;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...cy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},P0=class extends hn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:r})=>{if(!n||!r)return;let s=ao(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(r=>{let s=r.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new mA(s.data,r,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let a=this.onTargetChange(r),l=r.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(r),o=r.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let[r,s]of this.pairOfUserEventListeners)r.removeEventListener("userEvent",s);for(let r of this.events)r.paused=!0,r.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:r,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:d}=this.eventContext,{object:h,target:f}=e;if(h.getWorldPosition(Jp),!e.isReset)if(e.target)e.target.getWorldPosition($p);else{if(o==="custom"?(c().getWorldDirection(C0),C0.negate(),pA.setFromNormalAndCoplanarPoint(C0,Jp)):(o==="xy"?Qp.set(0,0,1):o==="xz"?Qp.set(0,1,0):o==="yz"&&Qp.set(1,0,0),pA.setFromNormalAndCoplanarPoint(Qp,Jp)),!d.ray.intersectPlane(pA,$p))return;s>0&&(o==="custom"||o===void 0)&&$p.addScaledVector(C0,s)}if(e.isReset||(f?n==="target"?fc.copy(f.up).applyMatrix4(Zp.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(r==="x"?(Zo.set(0,0,1),l[2]===!1&&Zo.set(0,1,0)):r==="y"?(Zo.set(1,0,0),l[0]===!1&&Zo.set(0,0,1)):(Zo.set(0,1,0),l[1]===!1&&Zo.set(1,0,0)),fc.copy(Zo).applyQuaternion(e.worldQuaternion0).normalize()):fc.set(0,1,0):o==="custom"?fc.set(0,1,0):fc.copy(Qp)),e.isReset)rl.copy(e.worldQuaternion0);else if(Jp.distanceTo($p)>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)rl.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;C7(Zp,$p,Jp,fc,r,Zo),rl.setFromRotationMatrix(Zp),Nh.setFromUnitVectors(Zo.applyQuaternion(rl),fc),l.some(p=>p===!1)&&n!=="target"&&rl.premultiply(Nh).normalize()}e.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),Nh.setFromRotationMatrix(nA(h.matrixWorld)),Nh.slerp(rl,1/e.currentDampingFactor),NR(h,Zp.makeRotationFromQuaternion(Nh)),e.paused=8*(1-Nh.dot(rl))<_7):(NR(h,Zp.makeRotationFromQuaternion(rl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(T7),h.dispatchEvent(M7)}},Yi=new A,nr=new A,Rn=new A;function C7(i,t,e,n,r,s){let o=i.elements;Rn.subVectors(t,e),Rn.lengthSq()===0&&(Rn.z=1),Rn.normalize(),nr.crossVectors(n,Rn),nr.lengthSq()===0&&(Math.abs(n.z)===1?Rn.x+=1e-4:Rn.z+=1e-4,Rn.normalize(),nr.crossVectors(n,Rn)),nr.normalize(),Yi.crossVectors(Rn,nr),r==="x"?s.z===1?[nr,Yi,Rn]=[Rn,nr,Yi]:(nr.negate(),[nr,Rn]=[Rn,nr]):r==="y"?s.x===1?[nr,Yi,Rn]=[Yi,Rn,nr]:(nr.negate(),[Yi,Rn]=[Rn,Yi]):s.x===1&&(nr.negate(),[nr,Yi]=[Yi,nr]),o[0]=nr.x,o[4]=Yi.x,o[8]=Rn.x,o[1]=nr.y,o[5]=Yi.y,o[9]=Rn.y,o[2]=nr.z,o[6]=Yi.z,o[10]=Rn.z}var gA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(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())}},D0=class extends hn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{We.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(r)))};let{page:r,sharedAssets:s}=this.eventContext;r.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 gA(a,l,o,r,s,n);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(),Qn&&(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(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(r=>{r.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:r,raycaster:s,page:o}=this.eventContext;if(r){let a=Dh(s,o,this.objects);n=Xp(a)}else this.objects.forEach(a=>{Ih(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(r=>{n.includes(r)||(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(r=>{r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var yA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=Qt(e,e.actions,r,s,o,n)}connect(){this.scrollCounter=0}disconnect(){Gt(this.actions)}dispatch(t){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(n)),this.actions.Animation.forEach(r=>r.seek(e)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(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())}},vA=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Qt(e,e.actions,r,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,r=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+r-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(){Gt(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 n=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch())}dispatch(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())}},I0=class extends hn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),r.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))};let{page:r,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;r.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 d=new yA(u,c,l,r,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(d):this.wheelEventsPerObject.set(l,[d])}else{let d=new vA(u,c,l,r,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(d):this.scrollEventsPerObject.set(l,[d])}}}),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,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.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,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var xA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(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.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 no?e.interaction.audioPlayer.play():e.interaction instanceof Mh&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof Yo?e.interaction.play(n==="autoplay"):e.interaction instanceof Ph&&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.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 no?e.interaction.audioPlayer.play():e.interaction instanceof Mh&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Yo?e.interaction.play():e.interaction instanceof Ph&&e.interaction.dispatch()})}},O0=class extends hn{constructor(e,n){super(e);this.eventManager=n;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?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,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.actions.Audio.forEach(s=>{s.interaction instanceof no&&s.interaction.audioPlayer.play()}),r.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Yo&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))}}connect(){let{sharedAssets:e,page:n}=this.eventContext;if(n.traverseEntity(r=>{if(!!r.data?.events.length)for(let{id:s,data:o}of r.data.events){if(o.disabled||o.type!=="Start")continue;let a=new xA(s,o,r,n,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,o=s?document:r;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(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,r=n?document:e;r.removeEventListener("pointerdown",this.onMouseDown),r.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),r.removeEventListener("pointerdown",this.onAny),r.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,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(r=>r.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var R0=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=Qt(e,e.actions,r,s,o,n),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){Gt(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 L0=class extends hn{constructor(e,n,r,s,o){super(e);this.sharedVariables=n;this.eventManager=r;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 n=new Date,r=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:u,property:c,prevValue:d}=this.propertiesToWatch[l],h=this.eventContext.scene.find(u),f=dy.propertyPaths[c];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")h=h.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)h=h[f[p]];d===null?this.propertiesToWatch[l].prevValue=h instanceof A?h.clone():h:(h instanceof A?!h.equals(d):d!==h)&&(s.push({objId:u,property:c}),h instanceof A?this.propertiesToWatch[l].prevValue.copy(h):this.propertiesToWatch[l].prevValue=h)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:u,prevValue:c}=this.variablesToWatch[l],d=this.shared.getVariable(u);d!==c&&(r.push(u),this.variablesToWatch[l].prevValue=d)}for(let l=0;l<this.dynamicVars.length;l++){let{id:u,expectedTime:c,last:d,data:h,timerSeconds:f,startValue:p}=this.dynamicVars[l],m=1e3;if((h.dynamicVariableType==="timer"||h.dynamicVariableType==="stopwatch")&&h.format==="number3decimal"?m=1:h.dynamicVariableType==="counter"?m=h.updateInterval:h.dynamicVariableType==="random"&&(m=h.isStatic?1/0:h.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,h.dynamicVariableType==="counter"&&this.shared.getVariable(u)!==p&&(this.shared.updateVariable(u,p),this.eventManager.requestRender()),(h.dynamicVariableType==="timer"||h.dynamicVariableType==="stopwatch")&&this.dynamicVars[l].timerSeconds!==p&&(this.dynamicVars[l].timerSeconds=p,this.shared.updateVariable(u,$r.getFormattedTimerTime(p,h)),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,h.dynamicVariableType==="random"){let g=h.min+Math.random()*(h.max-h.min),y=h.decimals;g=Math.round(g*Math.pow(10,y))/Math.pow(10,y),this.shared.updateVariable(u,g),r.push(u),this.eventManager.requestRender()}else if(h.dynamicVariableType==="counter"){if(h.increment===0)continue;let g=this.shared.getVariable(u),y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=this.shared.getVariable(u)+h.increment*(y?1:-1);h.hasEnd&&(v=h.increment>0?we.clamp(v,p,h.endValue):we.clamp(v,h.endValue,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),h.repeat?v===h.endValue&&(v=p):(v===p||v===h.endValue)&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==g&&(r.push(u),this.shared.updateVariable(u,v),this.eventManager.requestRender())}else if(h.dynamicVariableType==="time")this.shared.updateVariable(u,$w(n,h)),r.push(u),this.eventManager.requestRender();else{let g=fr.isTextValue(h.endValue)?BR(h.endValue.textValue):h.endValue,y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=f+(e-d)/1e3*(h.dynamicVariableType==="timer"?-1:1)*(y?1:-1);v=Math.max(v,0),h.hasEnd&&(v=h.dynamicVariableType==="stopwatch"?we.clamp(v,p,g):we.clamp(v,g,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),h.repeat?Math.abs(v-g)<(h.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(h.format==="number3decimal"?1e-4:.1)||Math.abs(v-g)<(h.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==f&&(r.push(u),this.dynamicVars[l].timerSeconds=v,this.shared.updateVariable(u,$r.getFormattedTimerTime(v,h)),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=>{(r.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 bA(a.uuid,l.data,a,e.page,e.sharedAssets,r))})}),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(fr.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let d=l.value.textValue;d.length===3?c=d[2]+d[1]*60+d[0]*3600:c=d[1]+d[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,$w(new Date,l)),l.dynamicVariableType==="counter"&&(u=fr.isTextValue(l.value)?BR(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 n=0;n<this.dynamicVars.length;n++)this.dynamicVars[n].last+=e,this.dynamicVars[n].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())}},bA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}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(){Gt(this.actions)}};function BR(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var VR=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.494/build/",P7=!1?VR:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.494/build/",D7=`
6239
+ )`}else if(i.easing===6){let{mass:e,stiffness:n,damping:r,velocity:s}=i;t=`spring( ${e}, ${n}, ${r}, ${s} )`}else{let e;switch(i.easing){case 0:e=Ro.linear;break;case 1:e=Ro.ease;break;case 2:e=Ro.easeIn;break;case 3:e=Ro.easeOut;break;case 4:e=Ro.easeInOut;break;default:e=Ro.linear}let[n,r,s,o]=e;t=`cubicBezier( ${n}, ${r}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function Q1(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 QY={type:"beginState"},ZY={type:"completeState",isfromEntity:!1},y0=class{constructor(t,e,n,r,s,o){this.object=t;this.data=r;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 Kt&&e.dispatchEvent(QY)})};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 Kt&&e.dispatchEvent(ZY)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=K1(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=g0(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=g0(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=g0(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Q1(r),...Z1(r),change:this.onChange},this.callback=K1(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Vp=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;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=g0(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:n=!1,isRebuild:r=!1}={}){try{let s=Q1(this.data.tweens[0].data);r&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=m0.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(n===!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],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new y0(this.object,d,c.data.state===void 0?this.currentState:c.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l]=h,this.timeline.add(h.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],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new y0(this.object,d,c.data.state===void 0?this.currentState:c.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l-1]=h,this.timeline.add(h.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(Rt(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=Q1(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(n){n instanceof Error&&console.error(n.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(Rt(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 g0(i,t){let e,n;if(typeof t=="string"?(e=t,n=i.states?.[e]):t===null&&(e=null,n=i.data),!(e===void 0||n===void 0))return{id:e,data:n}}var JY={type:"beginState"},fR={type:"completeState",isfromEntity:!1},pR={type:"requestRender"},kp=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new Ye;this.qEnd=new Ye;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 n=this.page.scene.find(this.data.targetCamera);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");let r={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=m0({targets:r,t:1,...Z1(this.data),update:()=>{r.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(n.position),this.qEnd.copy(n.quaternion),this.zoomEnd=n.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(n.uuid)),this.page.activeCamera.dispatchEvent(JY));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,r.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,r.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*r.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(pR),r.t===1&&s.dispatchEvent(fR)}})}switchCamera(e){let n=this.page.scene.find(e);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(n),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:n})}play(){if(Rt(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(Rt(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(fR),this.page.activeCamera.dispatchEvent(pR))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var Up=class extends Ht{constructor(e,n,r,s,o){super();this.page=n;this.animationControls=r;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=n.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(Rt(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 n=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let o=r.split("/")[1];this.threeAnimAction!==s&&o===n&&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=we.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,n=!1){if(Rt(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 r=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===r&&o.isRunning()&&(n?o.fadeOut(.2):o.stop())}),n&&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 zp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.eventManager=n;this.shared=r;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Rt(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(n=>n.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),Ch(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var Gp=class{constructor(t,e,n,r){this.data=t;this.page=e;this.shared=n;this.condition=r;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Rt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=rv(this.data.expression,this.shared,fr.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var Hp=class{constructor(t,e,n,r){this.data=t;this.page=e;this.shared=n;this.condition=r;this.timeoutId=null}dispatchInner(){if(Rt(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 Rt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=rv(t.expression,i,"boolean");return t.negate?!e:!!e}function Qt(i,t,e,n,r,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"?Jr[i.type].includes("Audio")&&o.Audio.push(new Rp(u,c,s,n,l)):c.type==="Video"?Jr[i.type].includes("Video")&&o.Video.push(new jp(u,c,s,n,l)):c.type==="Link"?Jr[i.type].includes("Link")&&o.Link.push(new c0(c,r.controlsManager,n,l)):c.type==="Create"?Jr[i.type].includes("Create")&&o.Create.push(new Wp(c,e,r.controlsManager,n,l)):c.type==="Destroy"?Jr[i.type].includes("Destroy")&&o.Destroy.push(new Lp(c,e,r.controlsManager,n,l)):c.type==="Reset"?Jr[i.type].includes("Reset")&&o.Reset.push(new Np(c,e,n,r,l)):c.type==="Transition"?Jr[i.type].includes("Transition")&&o.Transition.push(new Vp(c,e,n,l)):c.type==="SwitchCamera"?Jr[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new kp(c,e,n,l)):c.type==="SceneTransition"?Jr[i.type].includes("SceneTransition")&&o.SceneTransition.push(new zp(c,e,r,n,l)):c.type==="Animation"?Jr[i.type].includes("Animation")&&o.Animation.push(new Up(c,e,r.animationControls,n,l)):c.type==="SetVariable"?Jr[i.type].includes("SetVariable")&&o.SetVariable.push(new Gp(c,e,n,l)):c.type==="DynamicVariablePlay"?Jr[i.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new Hp(c,e,n,l)):c.type==="Conditional"&&Jr[i.type].includes("Conditional")&&(c.ifActions.forEach(a({expression:c.condition,negate:!1})),c.elseActions.forEach(a({expression:c.condition,negate:!0})))}catch(d){!1&&console.log(d)}};return t.forEach(a()),o}function Gt(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Rp||e instanceof jp||e instanceof Up||e instanceof Vp||e instanceof Wp||e instanceof Lp||e instanceof kp||e instanceof zp||e instanceof Np||e instanceof Gp||e instanceof Hp)&&e.dispose()})})}function mR(i,t){let e;if("material"in i){let n=i.material;Array.isArray(n)?e=i.material[0].layers.find(r=>r.uuid===t):e=i.material.layers.find(r=>r.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var gR=new Map,qp=new Map,Yo=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:r,loop:s,volume:o,delay:a}=e;if(this.object=n,r===void 0)throw new Error("Missing property");let l=mR(n,r);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),qp.has(n.uuid)?qp.get(n.uuid).push(this):qp.set(n.uuid,[this]),gR.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 n=this.videoElement.play();n!==void 0&&n.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Ph=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=gR.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=qp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let t=[...qp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},jp=class{constructor(t,e,n,r,s){this.data=e;this.shared=r;this.condition=s;if(e.interaction==="play")this.interaction=new Yo(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Ph(e);else throw new Error("Missing property")}dispatchBasic(){if(Rt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Rt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var yR=(()=>{let i,t,e,n;function r(a){!i&&!vR()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,n=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,d=u.length,h=0;for(;h<d;){let f=u[h];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(),n()),h++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(h,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)),d--,n())}i=h>0?requestAnimationFrame(s):void 0,e=h>0?a:void 0}function o(){vR()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):r()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),r})();function vR(){return!!document&&document.hidden}var xR=new Ye,$Y=new A,e7=new A,Wp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.controlsManager=n;this.shared=r;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=we.generateUUID();this.dispatch=()=>{if(Rt(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(Rt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Hb(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 un(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem,r=this.page.scene.find(n);r&&(r.updateMatrixWorldSVD(),t.hiddenMatrix.copy(r.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),yR(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof vr)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 un)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof vr)return;t instanceof un?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 n=new A().fromArray(this.data.velocity),r=e.dataPatched;if(!(r.physics.enabled==="visibility"?!r.visible:!r.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($Y,xR,e7),n.applyQuaternion(xR),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(n.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=n)),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");yR(n)}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 tA=200,J1=.02,$1=.3,t7=65,y3e=new A,bR=new A,SR=new A,n7=new A,Xr=new A,ci=new A,tl=new A,eA=new se,wR=new se,r7=new se,v3e=new se,xs=new Ye,Xo=new Ye,so=new qt(0,0,0,"YXZ"),i7=new A(1,0,0),bs=new A(0,1,0),s7=new A(0,0,1),AR=new A(1,1,1),x3e=new ln,o7=1,a7=.025,l7=16e-6,ER=12,c7=20,br=new Xn,qi=new Tt,u7={type:"requestRender"},d7={type:"updateMatrix"},_R=Math.PI/6,v0=class extends Ht{constructor(e,n,r,s,o,a,l,u,c){super();this.object=e;this.domElement=n;this.data=r;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new se;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=tA;this.euler0=new qt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new Ye;this.scale0Cam=new A;this.hiddenMatrix0Cam=new se;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Xn(new A(0,-40,0),new A(0,40,0)),matrix:new se,position:new A,rotation:new Ye};this.euler=new qt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastPosition=new A;this.lastCameraQuaternion=new Ye;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new B;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.nonColliderRotOffset=new se;this.nonColliderPosOffset=new se;this.firstPointerId=-1;this.rot=new A;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 se;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new Ye;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Ye;this.objXZQuatInv=new Ye;this.objXZRotMat=new se;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new Ye;this.colliderWorldQuat=new Ye;this.groundNormal=new A;this.groundTilt=new Ye;this.groundTiltInv=new Ye;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new A;this.quaternion=new Ye;this.scale=new A;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"&&!Qn&&(!jb||Wb>=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 n=e.clientX-this.prevMouse.x,r=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(jb&&Wb<15.5&&!Qn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-r*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=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-r*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?v0.isLocked=!0:v0.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 n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]){this.movementState[n[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]||e.code.slice(3,e.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.copyVRGamePadValues=(e,n)=>{for(let r=2;r<4;r++){let s=e.axes[r];n===0?r===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,r===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 d=this.euler0.clone(),h=d.y;if(this.objectRealQuat.copy(this.quaternion),d.y=0,this.quaternion.setFromEuler(d),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),d.set(0,h,0),this.quaternion.setFromEuler(d),this.rot.setFromEuler(d),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 A(0,0,-1).applyQuaternion(this.camera.quaternion),y=new A().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 b=new qt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof Kt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=r.rotByTouch??"joystick",this.rotBy=r.rotBy??"keys",this.rotationMode=r.rotationMode??"normal",this.moveMode=r.moveMode??"walk",this.collisionEnabled=r.collisionEnabled,this.speedTranslate=(r.speedTranslate??250)*o7,this.speedOrbit=(r.speedRotate??100)*a7,this.mouseOrbitSensitivity=(r.speedRotate??100)*l7,this.keyAssignments=r.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}),r.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/((r.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((r.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((r.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((r.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((r.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((r.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Oa.defaultData.gravity)*ER,this.usePhysics=this.gloabalPhysics.usePhysics??Oa.defaultData.usePhysics,this.jumpPower=r.jumpPower*c7,this.resetYPosition=this.position.y+Math.abs(r.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=r.alignToGround??!1,this.orientMode=r.autoOrientMove?r.orientMode:"none",this.orientWith=r.orientWith??$u.defaultDataThirdPerson.orientWith,this.slopeThresh=t7*Math.PI/180,r.collider.type==="capsule"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=r.collider.height/2-r.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=r.collider.height*J1/this.pixelsPerMeter,this.stepThresh=r.collider.height*$1/this.pixelsPerMeter,this.colliderHeight=r.collider.height):r.collider.type==="sphere"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*r.collider.radius*J1/this.pixelsPerMeter,this.stepThresh=2*r.collider.radius*$1/this.pixelsPerMeter,this.colliderHeight=r.collider.radius*2):(this.offset=r.collider.height*J1/this.pixelsPerMeter,this.stepThresh=r.collider.height*$1/this.pixelsPerMeter,this.colliderHeight=r.collider.height),this.collider.type=r.collider.type;let f=new A().fromArray(r.collider.position),p=new Ye().setFromEuler(new qt().fromArray([...r.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,AR),r.cameraXAxis!==void 0&&(this.cameraXAxis=r.cameraXAxis,this.cameraYAxis=r.cameraYAxis,this.minPolarAngle=r.cameraRotXLimits[0],this.maxPolarAngle=r.cameraRotXLimits[1],this.minAzimuthAngleRel=r.cameraRotYLimits[0],this.maxAzimuthAngleRel=r.cameraRotYLimits[1]),this.forwardDir=r.forwardDirection??"-z",this.runMultiplier=r.runMultiplier??2;let m=r.navmesh.destinationHelperRadius*2;if(m>0){let g=new Re;g.push({fi:0,data:{...hr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...hr.defaultData("color"),color:r.navmesh.destinationHelperColor,alpha:r.navmesh.destinationHelperColor.a},id:"layer2"});let y=new Go({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new kn(Hy.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=r.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 n=new qt().setFromQuaternion(this.quaternion,"YXZ"),r=n.y;this.objectRealQuat.copy(this.quaternion),n.y=0,this.quaternion.setFromEuler(n),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),n.set(0,r,0),this.quaternion.setFromEuler(n),this.rot.setFromEuler(n),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Kt?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,n=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Ju.list.forEach(r=>{this.actions[r]=Qt({...e,disabled:!1,type:"GameControl"},e.gameActions[r],this.page,n,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"),Gt(this.actions.idle),Gt(this.actions.move),Gt(this.actions.run),Gt(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(n=>{n.play()}),this.actions[e].Animation.forEach(n=>{n.play(this.initialAction===!1)}),this.actions[e].Create.forEach(n=>{n.dispatchStart()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(n=>{n.dispatchStop()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Xr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,n,r){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=ci.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*ER),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 d=c.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let h of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(h.rigidBody===d&&h.userData.isFollowingObj!==this.object.uuid){(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(Xr,Xo,ci),this.groundVelocity.subVectors(Xr,h.prevT),this.object.getWorldPosition(ci).add(this.collider.position).sub(Xr),this.groundYRotation=so.setFromQuaternion(Xo).y-h.prevR.y,tl.copy(ci).applyAxisAngle(bs,this.groundYRotation),this.groundVelocity.add(tl.sub(ci)).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=Xr.subVectors(this.path[1],this.position),d=ci.subVectors(this.path[1],this.path[0]);c.dot(d)<0?this.path.shift():(this.directionXZ.x=d.x,this.directionXZ.z=d.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=n7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=ci.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=Xr;this.camera.getWorldDirection(u);let c=tl.copy(bs).multiplyScalar(u.dot(bs));u.sub(c);let d=ci.copy(this.directionXZ);d.x*=-1,this.rot.y=u.angleTo(d)*(u.cross(d).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(so.setFromVector3(this.rot),this.moveMode==="walk"&&(so.x=0),l.applyEuler(so),a&&(Xo.setFromUnitVectors(bs,this.groundNormal),l.applyQuaternion(Xo)),r){let u=so.set(0,this.vrEulerYOffset*_R,0);r.applyEuler(u),l.x+=r.x,l.z+=r.z,this.nonColliderPosOffset.elements[13]+=r.y*s}if(this.usePhysics===!0){let u=ci;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let d=tl.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),h=c.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Xr.copy(l).divideScalar(this.pixelsPerMeter),s,!1);d.multiplyScalar(this.pixelsPerMeter);let f=at.is(c)?c:c.object;if(h!==null&&this.lastHitObj!==f){let p;c instanceof un&&(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(x0));this.lastHitObj=f}if(h!==null){this.pushedVelocity.copy(d),u.copy(h.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(bs,this.euler.y-this.euler0.y);let u=ci.copy(this.objectToCamXZ).normalize(),c=tl.copy(l).multiplyScalar(s);c.y=0;let d=c.sub(Xr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(d,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=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=we.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n?(so.copy(n),so.y=0):(so.copy(this.euler),so.y=0),this.nonColliderRotOffset.makeRotationFromEuler(so)),n&&(this.moveMode==="walk"?(this.rot.y=n.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(n),this.rot.y+=this.vrEulerYOffset*_R),xs.setFromAxisAngle(i7,this.rot.x),Xo.setFromAxisAngle(bs,this.rot.y),Xo.multiply(xs),xs.setFromAxisAngle(s7,this.rot.z),Xo.multiply(xs),this.quaternion.copy(Xo),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=ci.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let d=new A;for(let h=0;h<5;h++){let f=u.length(),p=tl.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),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&&h===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let b of x)if(b.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,E;if(m.cloner){for(let _ of m.cloner.children)if(_.rigidBody===w){E=_;break}}b.dispatch(E),m.dispatchEvent(x0)}}}let g=bR.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=SR.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,d.addScaledVector(p,v)),u.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),b=tl.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let w=x.add(b);w.y+=this.stepThresh;let E=this.sharedGameControlGlobals.rapierWorld.castShape(w,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);E!==null&&E.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),d.add(u);break}}this.position.addScaledVector(d,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Xr.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(xs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let d=0;d<u;d++)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);eA.lookAt(c,u,bs).setPosition(c),eA.decompose(this.targetPos,this.targetQuat,Xr),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=we.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=we.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(d7),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(u7),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=xs.setFromAxisAngle(bs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?we.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 n;this.cameraXAxis==="Limit"?n=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let r=Xr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&r.applyQuaternion(e);let s=Xo.setFromAxisAngle(r,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){bs.angleTo(e)*180/Math.PI<15||bs.angleTo(e)*180/Math.PI>85?xs.identity():xs.setFromUnitVectors(bs,e),this.groundTilt.slerp(xs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let n=SR.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let r=eA.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Xr,xs,ci).compose(Xr,xs,AR);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;qi.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=wR.copy(a).invert(),u=r7.copy(wR).multiply(r);br.copy(this.collider.segment),br.start.applyMatrix4(u),br.end.applyMatrix4(u);let c=bR.copy(this.position).applyMatrix4(l);qi.expandByPoint(br.start),qi.expandByPoint(br.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(d){return d.distanceToPoint(br.end)},intersectsBounds:d=>d.intersectsBox(qi),intersectsTriangle:d=>{let h=Xr,f=ci,p=d.closestPointToSegment(br,h,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(h).normalize(),y=tl.copy(c);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);n.add(v),br.start.addScaledVector(g,m),br.end.addScaledVector(g,m)}}})}),qi.makeEmpty(),br.copy(this.collider.segment),br.start.applyMatrix4(r),br.end.applyMatrix4(r),qi.expandByPoint(br.start),qi.expandByPoint(br.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(br.end)},intersectsBounds:o=>o.intersectsBox(qi),intersectsTriangle:o=>{let a=Xr,l=ci,u=o.closestPointToSegment(br,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,d=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(d),n.addScaledVector(d,c),br.start.addScaledVector(d,c),br.end.addScaledVector(d,c)}}}),this.onObject=Math.abs(n.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.position.add(n)}},Yp=v0;Yp.isLocked=!1;var TR=$o(jS());function Ss(i,t){let e=new Ee;if(!i.getAttribute("position"))return e.setAttribute("position",new be([],3)),e.setIndex([]),e;let{positions:n,triIndices:r}=Xl(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new be(n,3)),e.setIndex(r),t&&e.applyMatrix4(t),e}var h7=new se,f7=new se,oo=[[0,0,0],[0,0,0],[0,0,0]];function nA(i){let t=i.elements;oo[0][0]=t[0],oo[0][1]=t[4],oo[0][2]=t[8],oo[1][0]=t[1],oo[1][1]=t[5],oo[1][2]=t[9],oo[2][0]=t[2],oo[2][1]=t[6],oo[2][2]=t[10];let{u:e,v:n}=(0,TR.SVD)(oo),r=h7.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=f7.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return r.multiply(s.transpose())}var b0=class extends eu{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,n=[]){return t.forEach(r=>{r.visible&&this.intersectObject(r,e,n)}),n}createRaycastLineHelper(){let t=new Pi({color:65280,linewidth:10}),e=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new A().addVectors(e,n.multiplyScalar(r)),o=new Ee;return o.setFromPoints([e,s]),new Sl(o,t)}};var MR=i=>i instanceof ps||i instanceof gs;function p7(i,t){return i.distance-t.distance}function CR(i,t,e){if(!(!Gs(t)||!t.visible)){Lr(t)&&t.raycast(i,e);for(let n of t.children)CR(i,n,e)}}function Dh(i,t,e,n=!1){if(!n&&!e.some(s=>Ih(i,s)!==void 0))return[];let r=[];return t.children.forEach(s=>CR(i,s,r)),r.sort(p7),r}function Xp(i){let t=[];if(i.length){let e=i[0].object;Gs(e)&&t.push(e);let n=e.parent;for(;n;)MR(n)&&t.push(n),n=n.parent}return t}function Ih(i,t){if(Lr(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(MR(t))return PR(i,t)}function PR(i,t){if(!(!Gs(t)||!t.visible)){if(Lr(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let n=PR(i,e);if(n)return n}}}function m7(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 S0=class{constructor(t,e,n,r,s,o,a,l){this.renderer=t;this.publish=e;this.scene=n;this.getCamera=r;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new b0;this.raycasterNeedsUpdate=!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}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:n}=t.touches?.length>0?t.touches[0]:t;this.updateDomRect(),this.raycaster.setFromCamera(m7(e,n,this.domRect),this.getCamera())}};var rA=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))(rA||{}),hn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var iA=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],DR=i=>iA.find(([t,e])=>e===i)?.[0],ao=i=>iA.find(([t])=>t===i)?.[1],g7=(i,t)=>{let e=DR(i);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},w0=class extends hn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[DR(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:r}=this.eventContext;r.dispatchEvent(n)};let{page:n}=this.eventContext;n.traverseEntity(r=>{if(!!r.data?.events.length){for(let[s,o]of iA)if(r.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(r):this.objectsPerEvents.set(s,[r]);let a={id:r.uuid,name:r.name},l=g7(o,a),u=this.splineEvents[s];u?u[r.uuid]=l:this.splineEvents[s]={[r.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var sA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;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=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(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(r=>r.playing)||this.actions.Transition.forEach(r=>{this.alreadyPlayedNonTogglingActions.has(r)===!1&&r.play()}),this.actions.SwitchCamera.some(r=>r.playing)||this.actions.SwitchCamera.forEach(r=>{r.play()}),this.actions.Animation.forEach(r=>{r.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())}},A0=class extends hn{constructor(e,n,r){super(e);this.useForRaycastProperty=r;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:n,page:r}=this.eventContext,s=Dh(n,r,[],!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(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(e),n.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(e),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{We.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:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(r)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.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:d})=>d.type===u&&d.disabled!==!0).forEach(({id:d,data:h})=>{try{let f=new sA(d,h,a,s,o,n);f.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.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(([n,r])=>{r.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(n=>{Object.values(n).forEach(r=>{r.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:r,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!(!o.length&&!this.useForRaycastProperty)){if(n||this.useForRaycastProperty){let a;this.sceneInterects===null?a=Dh(r,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]}),n&&Xp(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}n||o.forEach(a=>{Ih(r,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let n="MousePress",r=this.objectsPerTypes[n],s=[];if(!!r.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=Dh(a,l,r);s=Xp(u)}else r.forEach(u=>{Ih(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatchRelease()})}handleKeyEvent(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(r?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(r)})})}};var y7=new A,v7=new A;var E0=class{constructor(t,e,n,r,s){this.actionsIn=Qt(t,t.inActions,n,r,s,e),this.actionsOut=Qt(t,t.outActions,n,r,s,e)}disconnect(){Gt(this.actionsIn),Gt(this.actionsOut)}};var oA=class extends E0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=y7.setFromMatrixPosition(this.objects[0].matrixWorld),n=v7.setFromMatrixPosition(this.objects[1].matrixWorld),r=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==r){this.stage=r;let s=r==="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}=n.condition;this.distance=l;for(let d of[u,c]){if(!d)throw new Error("Missing property");let h=s.find(d);if(!h)throw new Error("Missing property");this.objects.push(h)}}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)})}},aA=class extends E0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(r=>r.dispatchConditional()),this.actionsOut.Video.forEach(r=>r.dispatchConditional()),this.actionsOut.Link.forEach(r=>r.dispatch()),this.actionsOut.Create.forEach(r=>r.dispatch()),this.actionsOut.Destroy.forEach(r=>r.dispatch()),this.actionsOut.Reset.forEach(r=>r.dispatch()),this.actionsIn.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(r=>r.play()),this.actionsOut.Animation.forEach(r=>r.play()),this.actionsIn.SwitchCamera.forEach(r=>r.pause()),this.actionsOut.SwitchCamera.forEach(r=>r.play()),this.actionsOut.SceneTransition.forEach(r=>r.dispatch()),this.actionsOut.SetVariable.forEach(r=>r.checkConditions()),this.actionsOut.SetVariable.forEach(r=>r.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(r=>r.dispatch()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(r=>r.dispatchConditional()),this.actionsIn.Video.forEach(r=>r.dispatchConditional()),this.actionsIn.Link.forEach(r=>r.dispatch()),this.actionsIn.Create.forEach(r=>r.dispatch()),this.actionsIn.Destroy.forEach(r=>r.dispatch()),this.actionsIn.Reset.forEach(r=>r.dispatch()),this.actionsOut.Transition.forEach(r=>r.pause()),this.actionsOut.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(r=>r.play()),this.actionsIn.Animation.forEach(r=>r.play()),this.actionsOut.SwitchCamera.forEach(r=>r.pause()),this.actionsIn.SwitchCamera.forEach(r=>r.play()),this.actionsIn.SceneTransition.forEach(r=>r.dispatch()),this.actionsIn.SetVariable.forEach(r=>r.checkConditions()),this.actionsIn.SetVariable.forEach(r=>r.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(r=>r.dispatch()))};let{condition:l}=n;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(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length||this.actionsOut.DynamicVariablePlay.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length||this.actionsIn.DynamicVariablePlay.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},_0=class extends hn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:r,sharedAssets:s}=this.eventContext;r.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 oA(a,l,o,r,s,n):l.condition.type==="State"&&(u=new aA(a,l,o,r,s,n))),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(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var Kp=new A,nl=new A,dc=new A,IR=new En,x7=.01,Vt=new A,tr=new A,OR=new A,hc=new Ye,lA=new qt,b7=new se,cA=new $t,Oh=new A,lo=new A,Rh=.2;function uA(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 S7=function(){let i=new se;return(t,e,n)=>{let r=t.obj;i.copy(r.hiddenMatrix),r.parent!==null&&i.premultiply(r.parent.matrixWorld),i.invert(),r.position.copy(e),t.reference==="global"&&uA(r.position,t.limits),r.position.applyMatrix4(i),t.reference==="parent"?uA(r.position,t.limits):t.reference==="local"&&(hc.copy(t.quat0).invert(),r.position.sub(t.position0),r.position.applyQuaternion(hc),uA(r.position,t.limits),hc.invert(),r.position.applyQuaternion(hc),r.position.add(t.position0)),i.multiply(n??r.matrixWorld).decompose(Vt,r.quaternion,tr),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r instanceof Xt&&Nr(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),dA=class{constructor(t,e,n,r,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=Qt(e,e.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=Qt(e,e.dragDropActions.drop,n,r,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new Ye().copy(l.quaternion),snapped:!1,orientationMatrix:new se,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Gt(this.actionsDrag),Gt(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()})}},T0=class extends hn{constructor(e,n){super(e);this.eventManager=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);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||at.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 d=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Vt,hc,tr),lA.setFromQuaternion(hc),d.prevR===void 0?(d.prevR=lA.clone(),d.prevT=Vt.clone()):(d.prevR.copy(lA),d.prevT.copy(Vt)),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(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(We.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||at.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 ps)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||r.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=OR.copy(a.face.normal).applyMatrix3(cA.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"){Vt.copy(l).applyMatrix3(cA.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Vt.x>Rh?tr.x=-u.recursiveBBox.min.x:Vt.x<-Rh&&(tr.x=-u.recursiveBBox.max.x),Vt.y>Rh?tr.y=-u.recursiveBBox.min.y:Vt.y<-Rh&&(tr.y=-u.recursiveBBox.max.y),Vt.z>Rh?tr.z=-u.recursiveBBox.min.z:Vt.z<-Rh&&(tr.z=-u.recursiveBBox.max.z),tr.applyMatrix3(cA.invert())}else tr.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(tr)}this.activeEvent.data.autoOrient&&(Vt.set(0,1,0).cross(l),Vt.length()<1e-4&&Vt.set(-1,0,0).cross(l),tr.crossVectors(OR,Vt),o.orientationMatrix.makeBasis(Vt,tr,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 n=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||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(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(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(r=>r.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let r={};e.page.traverseEntity(s=>{s.component&&(r[s.component.uuid]?r[s.component.uuid].push(s.uuid):r[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 dA(s,o.data,e.page,e.sharedAssets,n,r))})})}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(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,r,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(nl),nl.negate();let l=hc.identity();switch(s==="parent"?b7.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Vt,l,tr):s==="local"&&e.matrixWorld.decompose(Vt,l,tr),r){case"x":Vt.set(1,0,0).applyQuaternion(l),Oh.copy(nl).cross(Vt),lo.copy(Vt).cross(Oh);break;case"y":Vt.set(0,1,0).applyQuaternion(l),Oh.copy(nl).cross(Vt),lo.copy(Vt).cross(Oh);break;case"z":Vt.set(0,0,1).applyQuaternion(l),Oh.copy(nl).cross(Vt),lo.copy(Vt).cross(Oh);break;case"xy":lo.set(0,0,1).applyQuaternion(l);break;case"yz":lo.set(1,0,0).applyQuaternion(l);break;case"xz":lo.set(0,1,0).applyQuaternion(l);break;case"adaptive":nl.angleTo(tr.set(0,1,0))>Math.PI/6?(Vt.crossVectors(tr.set(0,1,0),nl),lo.crossVectors(Vt,tr)):lo.set(0,1,0);break;default:lo.copy(nl);break}dc.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:dc;if(IR.setFromNormalAndCoplanarPoint(lo,u),!!a.ray.intersectPlane(IR,n)&&(r==="x"||r==="y"||r==="z")){let c=tr.subVectors(n,u).dot(Vt);n.copy(u).addScaledVector(Vt,c)}}updateDragItem(e,n=!1){dc.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Kp.subVectors(e.fromPosition,dc).divideScalar(e.currentDampingFactor):e.reset==="original"?(Kp.subVectors(e.obj.userData.worldPosition0,dc).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Kp.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(dc).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Kp.length()<x7:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&S7(e,Kp.add(dc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var Lh=new A,hA=new A,Ko=new A,Qo=new A,RR=new En,w7=.01,A7={type:"requestRender"},E7=function(){let i=new A,t=new A;return(e,n,r)=>r>0?(i.subVectors(e,n),i.length()<=r?e:t.copy(n).add(i.normalize().multiplyScalar(r))):n}(),LR=function(){let i=new se;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 Xt&&Nr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),fA=class{constructor(t,e,n,r,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...ly.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.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=Qt(t,t.actions,n,r,s,e)}},M0=class extends hn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!r.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new fA(o.data,s,r,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,o=this.onTargetChange(r);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let r of this.events)r.paused=!0,r.isReset=!1,Gt(r.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:r,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Ko),e.isReset)Qo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Qo);else{let{getCamera:l,raycaster:u}=this.eventContext;if(r==="custom"?(l().getWorldDirection(hA),hA.negate(),Lh.copy(hA)):r==="xy"?Lh.set(0,0,1):r==="xz"?Lh.set(0,1,0):r==="yz"&&Lh.set(1,0,0),RR.setFromNormalAndCoplanarPoint(Lh,Ko),!u.ray.intersectPlane(RR,Qo))return}if(!e.isReset){if(Qo.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)Qo.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&&(Qo.x=Ko.x),e.data.enabledTranslation[1]===!1&&(Qo.y=Ko.y),e.data.enabledTranslation[2]===!1&&(Qo.z=Ko.z);let a=E7(Ko,Qo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Lh.subVectors(a,Ko).divideScalar(e.currentDampingFactor);Ko.add(l),n&&LR(e.object,Ko),e.paused=l.length()<w7}else LR(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(A7)}};var Qp=new A,C0=new A,Zp=new se,Nh=new Ye,rl=new Ye,Jp=new A,$p=new A,fc=new A,Zo=new A,pA=new En,_7=1e-6,T7={type:"requestRender"},M7={type:"changeRotation"},NR=function(){let i=new se;return function(e,n){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),n.premultiply(nA(i).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof Xt&&Nr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),mA=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Ye;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...cy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},P0=class extends hn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:r})=>{if(!n||!r)return;let s=ao(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(r=>{let s=r.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new mA(s.data,r,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let a=this.onTargetChange(r),l=r.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(r),o=r.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let[r,s]of this.pairOfUserEventListeners)r.removeEventListener("userEvent",s);for(let r of this.events)r.paused=!0,r.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:r,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:d}=this.eventContext,{object:h,target:f}=e;if(h.getWorldPosition(Jp),!e.isReset)if(e.target)e.target.getWorldPosition($p);else{if(o==="custom"?(c().getWorldDirection(C0),C0.negate(),pA.setFromNormalAndCoplanarPoint(C0,Jp)):(o==="xy"?Qp.set(0,0,1):o==="xz"?Qp.set(0,1,0):o==="yz"&&Qp.set(1,0,0),pA.setFromNormalAndCoplanarPoint(Qp,Jp)),!d.ray.intersectPlane(pA,$p))return;s>0&&(o==="custom"||o===void 0)&&$p.addScaledVector(C0,s)}if(e.isReset||(f?n==="target"?fc.copy(f.up).applyMatrix4(Zp.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(r==="x"?(Zo.set(0,0,1),l[2]===!1&&Zo.set(0,1,0)):r==="y"?(Zo.set(1,0,0),l[0]===!1&&Zo.set(0,0,1)):(Zo.set(0,1,0),l[1]===!1&&Zo.set(1,0,0)),fc.copy(Zo).applyQuaternion(e.worldQuaternion0).normalize()):fc.set(0,1,0):o==="custom"?fc.set(0,1,0):fc.copy(Qp)),e.isReset)rl.copy(e.worldQuaternion0);else if(Jp.distanceTo($p)>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)rl.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;C7(Zp,$p,Jp,fc,r,Zo),rl.setFromRotationMatrix(Zp),Nh.setFromUnitVectors(Zo.applyQuaternion(rl),fc),l.some(p=>p===!1)&&n!=="target"&&rl.premultiply(Nh).normalize()}e.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),Nh.setFromRotationMatrix(nA(h.matrixWorld)),Nh.slerp(rl,1/e.currentDampingFactor),NR(h,Zp.makeRotationFromQuaternion(Nh)),e.paused=8*(1-Nh.dot(rl))<_7):(NR(h,Zp.makeRotationFromQuaternion(rl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(T7),h.dispatchEvent(M7)}},Yi=new A,nr=new A,Rn=new A;function C7(i,t,e,n,r,s){let o=i.elements;Rn.subVectors(t,e),Rn.lengthSq()===0&&(Rn.z=1),Rn.normalize(),nr.crossVectors(n,Rn),nr.lengthSq()===0&&(Math.abs(n.z)===1?Rn.x+=1e-4:Rn.z+=1e-4,Rn.normalize(),nr.crossVectors(n,Rn)),nr.normalize(),Yi.crossVectors(Rn,nr),r==="x"?s.z===1?[nr,Yi,Rn]=[Rn,nr,Yi]:(nr.negate(),[nr,Rn]=[Rn,nr]):r==="y"?s.x===1?[nr,Yi,Rn]=[Yi,Rn,nr]:(nr.negate(),[Yi,Rn]=[Rn,Yi]):s.x===1&&(nr.negate(),[nr,Yi]=[Yi,nr]),o[0]=nr.x,o[4]=Yi.x,o[8]=Rn.x,o[1]=nr.y,o[5]=Yi.y,o[9]=Rn.y,o[2]=nr.z,o[6]=Yi.z,o[10]=Rn.z}var gA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(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())}},D0=class extends hn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{We.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(r)))};let{page:r,sharedAssets:s}=this.eventContext;r.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 gA(a,l,o,r,s,n);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(),Qn&&(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(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(r=>{r.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:r,raycaster:s,page:o}=this.eventContext;if(r){let a=Dh(s,o,this.objects);n=Xp(a)}else this.objects.forEach(a=>{Ih(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(r=>{n.includes(r)||(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(r=>{r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var yA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=Qt(e,e.actions,r,s,o,n)}connect(){this.scrollCounter=0}disconnect(){Gt(this.actions)}dispatch(t){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(n)),this.actions.Animation.forEach(r=>r.seek(e)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(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())}},vA=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Qt(e,e.actions,r,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,r=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+r-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(){Gt(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 n=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch())}dispatch(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())}},I0=class extends hn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),r.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))};let{page:r,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;r.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 d=new yA(u,c,l,r,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(d):this.wheelEventsPerObject.set(l,[d])}else{let d=new vA(u,c,l,r,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(d):this.scrollEventsPerObject.set(l,[d])}}}),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,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.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,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var xA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(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.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 no?e.interaction.audioPlayer.play():e.interaction instanceof Mh&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof Yo?e.interaction.play(n==="autoplay"):e.interaction instanceof Ph&&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.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 no?e.interaction.audioPlayer.play():e.interaction instanceof Mh&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Yo?e.interaction.play():e.interaction instanceof Ph&&e.interaction.dispatch()})}},O0=class extends hn{constructor(e,n){super(e);this.eventManager=n;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?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,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.actions.Audio.forEach(s=>{s.interaction instanceof no&&s.interaction.audioPlayer.play()}),r.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Yo&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))}}connect(){let{sharedAssets:e,page:n}=this.eventContext;if(n.traverseEntity(r=>{if(!!r.data?.events.length)for(let{id:s,data:o}of r.data.events){if(o.disabled||o.type!=="Start")continue;let a=new xA(s,o,r,n,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,o=s?document:r;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(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,r=n?document:e;r.removeEventListener("pointerdown",this.onMouseDown),r.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),r.removeEventListener("pointerdown",this.onAny),r.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,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(r=>r.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var R0=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=Qt(e,e.actions,r,s,o,n),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){Gt(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 L0=class extends hn{constructor(e,n,r,s,o){super(e);this.sharedVariables=n;this.eventManager=r;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 n=new Date,r=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:u,property:c,prevValue:d}=this.propertiesToWatch[l],h=this.eventContext.scene.find(u),f=dy.propertyPaths[c];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")h=h.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)h=h[f[p]];d===null?this.propertiesToWatch[l].prevValue=h instanceof A?h.clone():h:(h instanceof A?!h.equals(d):d!==h)&&(s.push({objId:u,property:c}),h instanceof A?this.propertiesToWatch[l].prevValue.copy(h):this.propertiesToWatch[l].prevValue=h)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:u,prevValue:c}=this.variablesToWatch[l],d=this.shared.getVariable(u);d!==c&&(r.push(u),this.variablesToWatch[l].prevValue=d)}for(let l=0;l<this.dynamicVars.length;l++){let{id:u,expectedTime:c,last:d,data:h,timerSeconds:f,startValue:p}=this.dynamicVars[l],m=1e3;if((h.dynamicVariableType==="timer"||h.dynamicVariableType==="stopwatch")&&h.format==="number3decimal"?m=1:h.dynamicVariableType==="counter"?m=h.updateInterval:h.dynamicVariableType==="random"&&(m=h.isStatic?1/0:h.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,h.dynamicVariableType==="counter"&&this.shared.getVariable(u)!==p&&(this.shared.updateVariable(u,p),this.eventManager.requestRender()),(h.dynamicVariableType==="timer"||h.dynamicVariableType==="stopwatch")&&this.dynamicVars[l].timerSeconds!==p&&(this.dynamicVars[l].timerSeconds=p,this.shared.updateVariable(u,$r.getFormattedTimerTime(p,h)),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,h.dynamicVariableType==="random"){let g=h.min+Math.random()*(h.max-h.min),y=h.decimals;g=Math.round(g*Math.pow(10,y))/Math.pow(10,y),this.shared.updateVariable(u,g),r.push(u),this.eventManager.requestRender()}else if(h.dynamicVariableType==="counter"){if(h.increment===0)continue;let g=this.shared.getVariable(u),y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=this.shared.getVariable(u)+h.increment*(y?1:-1);h.hasEnd&&(v=h.increment>0?we.clamp(v,p,h.endValue):we.clamp(v,h.endValue,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),h.repeat?v===h.endValue&&(v=p):(v===p||v===h.endValue)&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==g&&(r.push(u),this.shared.updateVariable(u,v),this.eventManager.requestRender())}else if(h.dynamicVariableType==="time")this.shared.updateVariable(u,$w(n,h)),r.push(u),this.eventManager.requestRender();else{let g=fr.isTextValue(h.endValue)?BR(h.endValue.textValue):h.endValue,y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=f+(e-d)/1e3*(h.dynamicVariableType==="timer"?-1:1)*(y?1:-1);v=Math.max(v,0),h.hasEnd&&(v=h.dynamicVariableType==="stopwatch"?we.clamp(v,p,g):we.clamp(v,g,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),h.repeat?Math.abs(v-g)<(h.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(h.format==="number3decimal"?1e-4:.1)||Math.abs(v-g)<(h.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==f&&(r.push(u),this.dynamicVars[l].timerSeconds=v,this.shared.updateVariable(u,$r.getFormattedTimerTime(v,h)),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=>{(r.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 bA(a.uuid,l.data,a,e.page,e.sharedAssets,r))})}),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(fr.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let d=l.value.textValue;d.length===3?c=d[2]+d[1]*60+d[0]*3600:c=d[1]+d[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,$w(new Date,l)),l.dynamicVariableType==="counter"&&(u=fr.isTextValue(l.value)?BR(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 n=0;n<this.dynamicVars.length;n++)this.dynamicVars[n].last+=e,this.dynamicVars[n].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())}},bA=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}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(){Gt(this.actions)}};function BR(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var VR=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.495/build/",P7=!1?VR:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.495/build/",D7=`
6240
6240
  (async function() {
6241
6241
  const [wasmImport, wasmBinary] = await Promise.all([
6242
6242
  import('${VR}' + 'navmesh.js'),
@@ -6302,4 +6302,4 @@ onmessage = function(messageEvent) {
6302
6302
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6303
6303
  </svg>
6304
6304
  `),T.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),T.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,m];return}let _={zone:m,mode:"static",position:b,size:g};v==="hide"&&(_.restOpacity=0);let S=CO.create(_);S.on("move",(T,M)=>{let C=this.gameControl;f==="pos"?M.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-M.angle.radian),C.movementState.movePosX=Math.cos(-M.angle.radian),M.force>1.2?C.movementState.run=1:C.movementState.run=0,M.force<.3?C.moveForce=(M.force-.2)/.1:C.moveForce=1):f==="rot"&&(M.force<.2?C.rotForce=0:(C.movementState.rotPosX=M.vector.y,C.movementState.rotPosY=-M.vector.x,M.force<.3?C.rotForce=(M.force-.2)/.1:C.rotForce=1)),this.requestRender()}),S.on("end",(T,M)=>{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]=[S,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 bt.World(new bt.Vector3(0,this.gravity,0)),this.events=new bt.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof vr)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 un)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 d=em(u),h=!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"){h=!0;let v=new R0(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=bt.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Hn,ws,il),a.position0=Hn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=ws.clone(),Hn.divideScalar(this.pixelsPerMeter),y.setTranslation(Hn.x,Hn.y,Hn.z).setRotation(ws);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=v;let x;c.collider.type==="sphere"?x=bt.ColliderDesc.ball(c.collider.radius/this.pixelsPerMeter):c.collider.type==="capsule"?x=bt.ColliderDesc.capsule((c.collider.height/2-c.collider.radius)/this.pixelsPerMeter,c.collider.radius/this.pixelsPerMeter):x=bt.ColliderDesc.cuboid(c.collider.width/this.pixelsPerMeter/2,c.collider.height/this.pixelsPerMeter/2,c.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(bt.CoefficientCombineRule.Average).setRestitutionCombineRule(bt.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(u.physics.restitution);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,l),Hn.fromArray(c.collider.position).multiply(il.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(Hn);let w=new Ye().setFromEuler(new qt().setFromVector3(new A().fromArray(c.collider.rotation)));b.setRotationWrtParent(w),b.setActiveEvents(bt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else u.physics.rigidBody==="dynamic"||d||m||f||p||h?(this.addRigidBody(a,l,{hasFollow:m,hasTransformAnim:d,hasDrag:p}),this.generateSensorColliderDescs(l,u.physics.fusedBody)):(g&&t.push(Ss(g,a.matrixWorld)),u.physics.fusedBody&&a.traverseObject((y,v)=>{if(v===0)return;let x;if(y instanceof vr)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 un)x=y.object;else if(x=y,x.dataPatched.cloner?.hideBase)return!0;let b=x.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let w=y.geometry;w?.getAttribute("position")!==void 0&&t.push(Ss(w,y.matrixWorld))}),this.generateSensorColliderDescs(l,u.physics.fusedBody,e));if(u.physics?.fusedBody===!0||c)return!0}),t.length===0)return;let n=rs(t);n.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=bt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),o=bt.ColliderDesc.trimesh(n.getAttribute("position").array,n.getIndex().array).setFrictionCombineRule(bt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(bt.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 n=new tm(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new se().compose(As.fromArray(e.data.position),kh.setFromEuler(jR.fromArray(e.data.rotation)),CA);if(e.data.triggerZone==="box"){let s=new Tt;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,n])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,t,n])}}),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,n){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(t,e,n)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(t===0)r=this.stepPhysics()&&r;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&&(r=this.stepPhysics()&&r,this.accumulator-=s,l++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}return r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Hn,ws,il),TA.setFromQuaternion(ws);let n=e;n.prevR===void 0?(n.prevR=TA.clone(),n.prevT=Hn.clone()):(n.prevR.copy(TA),n.prevT.copy(Hn)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(Hn.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(ws))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,n){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(n))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===r){s=o;break}}t.dispatch(s),e.dispatchEvent(x0)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,n){let r=WR.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 tm(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),u;if(a.data.triggerZone==="box"?u=bt.ColliderDesc.cuboid(...a.data.size.map(c=>c/(2*this.pixelsPerMeter))):u=bt.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),u.setDensity(0).setSensor(!0).setActiveEvents(bt.ActiveEvents.COLLISION_EVENTS),As.fromArray(a.data.position),kh.setFromEuler(jR.fromArray(a.data.rotation)),V0.compose(As,kh,CA).premultiply(s.matrixWorld),n?(V0.decompose(As,kh,MA),u.setActiveCollisionTypes(bt.ActiveCollisionTypes.KINEMATIC_FIXED|bt.ActiveCollisionTypes.DYNAMIC_FIXED)):(V0.premultiply(r).decompose(As,kh,MA),t.rigidBody.bodyType()===bt.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===bt.RigidBodyType.Fixed?u.setActiveCollisionTypes(bt.ActiveCollisionTypes.KINEMATIC_FIXED|bt.ActiveCollisionTypes.DYNAMIC_FIXED):u.setActiveCollisionTypes(bt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|bt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),As.divideScalar(this.pixelsPerMeter),u.setTranslation(As.x,As.y,As.z),u.setRotation(kh),n)n.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[n,r,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(at.is(l)?l:l.object)===!1)continue;let u=WR.copy(s.matrixWorld).decompose(As,qR,MA).compose(As,qR,CA).multiply(r),c=V0.copy(l.matrixWorld).invert().multiply(u);n instanceof Tt?t=l.bvhGeometry.boundsTree.intersectsBox(n,c):(PA.radius=n,PA.center.setFromMatrixPosition(c),t=l.bvhGeometry.boundsTree.intersectsSphere(PA)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(j7)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(d=>d!==l)}}}};function XR(i){let t=this._clip.duration,e=this._clip.start??0,n=this.loop,r=this.time+i,s=this._loopCount,o=n===yf;if(i===0)return s===-1?r:o&&(s&1)===1?t-(r-e):r;if(n===yb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction: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)),r>=t||r<e){let a=Math.floor((r-e)/(t-e));r-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(r=i>0?t:e,this.repetitions===1&&(r=t)),this.time=r,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=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-(r-e)}return r}var KR=!1,U0=class{constructor(t,e,n,r){this.scene=t;this.requestRender=e;this.updateDisplayProgress=n;this.animationInspectorState=r;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,n)=>{let r=e[0]+"/";if(Array.isArray(t.identity)?r+=t.identity[0]:r+=t.uuid,this.clipIdToAction[r])return;let s=Qc.parse(JSON.parse(e[2]));t.animations[n]=s;let o=this.mixer.clipAction(s,t);KR===!1&&(Object.getPrototypeOf(o)._updateTime=XR,KR=!0),o.clampWhenFinished=!0,this.clipIdToAction[r]=o})};this.mixer=new eg(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let n=this.scene.find(e);if(!n)return;let r=n.animations.find(o=>o.uuid===t);if(!r)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[t],n.animations=n.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=vb}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,n=this.clipIdToAction[e];if(!!n)return t&&(t.repeat>=0&&(n.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(n.loop=yf)),n.play(),n.paused=!1,this.requestRender(),n}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 n=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(),n&&(this.clipIdToAction[e].paused=!0)}};var DA=new WeakMap,z0=class extends Zc{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,n,r){let s=new Jc(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(r)},n,r)}decodeDracoFile(t,e,n,r){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){let n=JSON.stringify(e);if(DA.has(t)){let l=DA.get(t);if(l.key===n)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 r,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(r=l,new Promise((u,c)=>{r._callbacks[s]={resolve:u,reject:c},r.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),DA.set(t,{key:n,promise:a}),a}_createGeometry(t){let e=new Ee;t.index&&e.setIndex(new Ge(t.index.array,1));for(let n=0;n<t.attributes.length;n++){let r=t.attributes[n],s=r.name,o=r.array,a=r.itemSize;e.setAttribute(s,new Ge(o,a))}return e}_loadLibrary(t,e){let n=new Jc(this.manager);return n.setPath(this.decoderPath),n.setResponseType(e),n.setWithCredentials(this.withCredentials),new Promise((r,s)=>{n.load(t,r,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(n=>{let r=n[0];t||(this.decoderConfig.wasmBinary=n[1]);let s=W7.toString(),o=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
6305
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let o=s.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_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 W7(){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(d){c({draco:d})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let d=c.draco,h=new d.Decoder,f=new d.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(d,h,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{d.destroy(f),d.destroy(h)}});break}};function e(o,a,l,u){let c=u.attributeIDs,d=u.attributeTypes,h,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)h=new o.Mesh,f=a.DecodeBufferToMesh(l,h);else if(p===o.POINT_CLOUD)h=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||h.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[d[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(h,x);else{if(x=a.GetAttributeId(h,o[c[g]]),x===-1)continue;v=a.GetAttribute(h,x)}m.attributes.push(r(o,a,h,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=n(o,a,h)),o.destroy(h),m}function n(o,a,l){let c=l.num_faces()*3,d=c*4,h=o._malloc(d);a.GetTrianglesUInt32Array(l,d,h);let f=new Uint32Array(o.HEAPF32.buffer,h,c).slice();return o._free(h),{array:f,itemSize:1}}function r(o,a,l,u,c,d){let h=d.num_components(),p=l.num_points()*h,m=p*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,d,g,m,y);let v=new c(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:u,array:v,itemSize:h}}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 sl;function q7(){return sl||(sl=new z0,sl.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),sl.decoderPending}async function Y7(i){if(sl){let t={attributeIDs:sl.defaultAttributeIDs,attributeTypes:sl.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await sl.decodeGeometry(new Int8Array(i).buffer,t)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function QR(i,t){let[e,n]=Zb(oy.deserialize(new Uint8Array(i)));Ty(e);let r=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await q7();for(let s of r){let o=await Y7(pn(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),n.result().data}var IA=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.dataEvent=n;this.object=r;this.stage=!1;this.actions=Qt(n,e.actions,s,o,a,r)}disconnect(){Gt(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()})}},G0=class extends hn{constructor(e,n){super(e);this.eventManager=n;this.breakpoints=[];this.resize=(e,n)=>{this.breakpoints.forEach(r=>{let s=uy.deviceToSize(r.data.size),o=r.dataEvent.orientation==="horizontal"?e:n,a;switch(r.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}r.stage!==a&&(r.stage=a,r.stage?r.dispatchIn():r.dispatchOut())}),this.eventContext.updateDomRect()};this.onResizeObserver=new ResizeObserver(e=>{for(let n of e){let{width:r,height:s}=n.contentRect;this.resize(r,s)}})}connect(){let{page:e,sharedAssets:n,domElement:r}=this.eventContext;this.onResizeObserver.observe(r),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 IA(l,a,o,s,e,n,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 ZR=Object.keys(rA).filter(i=>isNaN(Number(i))),H0=class{constructor(t,e,n,r,s){this.publish=t;this.controlsManager=e;this.animationControls=n;this.eventContext=r;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=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:n,pageY:r}=t.touches?.length>0?t.touches[0]:t;return{x:n-(e.left+window.scrollX),y:r-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new w0(this.eventContext),DynamicVariable:new L0(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new _0(this.eventContext,this),["Start"]:new O0(this.eventContext,this),Basic:new A0(this.eventContext,this,this.needsRaycast),["MouseHover"]:new D0(this.eventContext,this),["Scroll"]:new I0(this.eventContext,this),["Follow"]:new M0(this.eventContext,this),["DragDrop"]:new T0(this.eventContext,this),["LookAt"]:new P0(this.eventContext),["Resize"]:new G0(this.eventContext,this)};let{page:t,domElement:e,eventElement:n}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),ZR.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(e.addEventListener(r,this.onResetRaycaster),n.addEventListener(r,this.onResetRaycaster))}),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(n=>n.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender),n.destroyedInAction=!1}),ZR.forEach(n=>{e.removeEventListener(n,this.onResetRaycaster)}),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=n=>{if(n.data.type==="Conditional"&&(n.data.ifActions.forEach(e),n.data.elseActions.forEach(e)),n.data.type==="Conditional"||n.data.type==="SetVariable")for(let r of n.data.type==="Conditional"?n.data.condition:n.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));n.data.type==="DynamicVariablePlay"&&n.data.variableId!==""&&(n.data.mode==="Play"||n.data.mode==="PlayPause"||n.data.mode==="Toggle")&&t.setDynamicVariablePlayState(n.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(n=>{if(!!n.data?.events.length){for(let r of n.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(e);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(e);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(e);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(e);else r.data.type==="LookAt"||r.data.actions.forEach(e)}})}};var j0=class{constructor(t,e,n,r,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new B().copy(n),this._editorSize=new B().copy(r),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,n=this._editorSize.y;this._aspect=t/e,e<=n&&(this._camera.zoom*=n/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,n=this._editorSize.y,r=this._fov;if(t&&e>n){let s=X7(e,1080,2160,1,15)/100;r*=e/n,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(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 X7(i,t,e,n,r){return(i-t)/(e-t)*(r-n)+n}var W0=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new rc(t.shared,e),this.scene=new $a(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 li&&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 jt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var q0=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(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 K7(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 nm(i){return i instanceof hs?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Q7(i,t){let e={};return i.traverseEntity(n=>{if(!n.visible||!(n instanceof Xt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let r=n.parent;for(;r;){if(r instanceof Xt&&n.states&&Object.keys(n.states).length)return;r=r.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!Cn.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!Cn.isMergable(u.material))return;s=Cn.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][nm(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][nm(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][nm(n)].push(u)}),e}function Z7(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(n=>{let r=n.length;r>t&&(t=r)})}),t}function JR(i,t){let e=Q7(t,i),n=Z7(e),r=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,u=0,p.forEach(g=>{g instanceof Xt&&(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&&K7(o[g]);let m=rs(o.slice(0,a),!1);if(m){let g;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new kn(m,l[0].material);break}default:{g=new kn(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Xt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][nm(x)]&&e[x.material.uuid][nm(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),r[s++]=x}}}for(let h=0;h<s;h++)r[h].removeFromParent()}var tL=$o(eL(),1);var $7=new B;function eX(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 OA=class{constructor(t,{renderOnDemand:e,renderMode:n="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=$7.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._requestRenderAutoMode()}};this._debouncedResize=Rl(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new q0({x:10,y:10})),yC(t)}async load(t,e,n){eX(t),this.disposed=!1;let s=await(await fetch(t,n)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:n}={}){if(this.disposed)return;let r=await QR(t);this._data=r,r.version&&(0,tL.default)(r.version,"0.9.494")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([v1(r)&&hD(),$D(r)&&sD(),La.physicsEnabled(r.scene.objects)&&EC(),u1(r)&&YD(),wA(r)&&SC()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new W0(r);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();JR(r,s.scene);let u=performance.now();console.log("Merged geometries in ",u-l," ms")}v1(r)&&this._scene.traverse(l=>{Nr(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof vr&&l.pendingMediaLoad&&l.update()})});let o=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);Promise.all(o).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),u1(r)&&YR(r)&&await Promise.all(o),this._scene.rewriteEventsBeforeGoToPlayMode(),Ch(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new Xv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let a=Object.values(r.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 j0(this._renderer,this._camera,new B(this._viewportWidth,this._viewportHeight),new B(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(a.allowResponsive??!1)&&a.preset==="fullscreen"),e){let l=new S0(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,a);this._scene.updateMatrixWorld(!0),this._controls=new k0(l),this._animationControls=new U0(this._scene,this._requestRenderAutoMode),this._eventManager=new H0(r.scene.publish,this._controls,this._animationControls,l,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),n!==void 0&&this.setVariables(n),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[n,r]of e)this.setVariable(n,r)}}setVariable(t,e){let n=this._getVariableByName(t);if(n&&!("dynamicVariableType"in n.data)){let r=e;typeof n.data.value=="number"?r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof n.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof n.data.value!="string"&&n.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(n.id,s),this.requestRender(),this._requestRenderAutoMode()}else n===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in n.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 n=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(n)}}_getVariableValue(t){return typeof t!="string"&&fr.isTextValue(t)?fr.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(n=>n.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!==Li&&!this._scene.isInvisibleObjects(e)&&!(e instanceof li)){let n=this._createProxyObject(e);n&&t.push(n)}}),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 Vh&&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:n,b:r,a:s}={r:0,g:0,b:0,a:1},o=new dn(e,n,r,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=>{Bb.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(),vC(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 li&&(e=s.name)});let n={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 li||t instanceof $a?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Bb(n,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,r),r}};
6305
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let o=s.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_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 W7(){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(d){c({draco:d})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let d=c.draco,h=new d.Decoder,f=new d.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(d,h,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{d.destroy(f),d.destroy(h)}});break}};function e(o,a,l,u){let c=u.attributeIDs,d=u.attributeTypes,h,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)h=new o.Mesh,f=a.DecodeBufferToMesh(l,h);else if(p===o.POINT_CLOUD)h=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||h.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[d[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(h,x);else{if(x=a.GetAttributeId(h,o[c[g]]),x===-1)continue;v=a.GetAttribute(h,x)}m.attributes.push(r(o,a,h,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=n(o,a,h)),o.destroy(h),m}function n(o,a,l){let c=l.num_faces()*3,d=c*4,h=o._malloc(d);a.GetTrianglesUInt32Array(l,d,h);let f=new Uint32Array(o.HEAPF32.buffer,h,c).slice();return o._free(h),{array:f,itemSize:1}}function r(o,a,l,u,c,d){let h=d.num_components(),p=l.num_points()*h,m=p*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,d,g,m,y);let v=new c(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:u,array:v,itemSize:h}}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 sl;function q7(){return sl||(sl=new z0,sl.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),sl.decoderPending}async function Y7(i){if(sl){let t={attributeIDs:sl.defaultAttributeIDs,attributeTypes:sl.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await sl.decodeGeometry(new Int8Array(i).buffer,t)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function QR(i,t){let[e,n]=Zb(oy.deserialize(new Uint8Array(i)));Ty(e);let r=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await q7();for(let s of r){let o=await Y7(pn(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),n.result().data}var IA=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.dataEvent=n;this.object=r;this.stage=!1;this.actions=Qt(n,e.actions,s,o,a,r)}disconnect(){Gt(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()})}},G0=class extends hn{constructor(e,n){super(e);this.eventManager=n;this.breakpoints=[];this.resize=(e,n)=>{this.breakpoints.forEach(r=>{let s=uy.deviceToSize(r.data.size),o=r.dataEvent.orientation==="horizontal"?e:n,a;switch(r.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}r.stage!==a&&(r.stage=a,r.stage?r.dispatchIn():r.dispatchOut())}),this.eventContext.updateDomRect()};this.onResizeObserver=new ResizeObserver(e=>{for(let n of e){let{width:r,height:s}=n.contentRect;this.resize(r,s)}})}connect(){let{page:e,sharedAssets:n,domElement:r}=this.eventContext;this.onResizeObserver.observe(r),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 IA(l,a,o,s,e,n,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 ZR=Object.keys(rA).filter(i=>isNaN(Number(i))),H0=class{constructor(t,e,n,r,s){this.publish=t;this.controlsManager=e;this.animationControls=n;this.eventContext=r;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=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:n,pageY:r}=t.touches?.length>0?t.touches[0]:t;return{x:n-(e.left+window.scrollX),y:r-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new w0(this.eventContext),DynamicVariable:new L0(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new _0(this.eventContext,this),["Start"]:new O0(this.eventContext,this),Basic:new A0(this.eventContext,this,this.needsRaycast),["MouseHover"]:new D0(this.eventContext,this),["Scroll"]:new I0(this.eventContext,this),["Follow"]:new M0(this.eventContext,this),["DragDrop"]:new T0(this.eventContext,this),["LookAt"]:new P0(this.eventContext),["Resize"]:new G0(this.eventContext,this)};let{page:t,domElement:e,eventElement:n}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),ZR.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(e.addEventListener(r,this.onResetRaycaster),n.addEventListener(r,this.onResetRaycaster))}),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(n=>n.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender),n.destroyedInAction=!1}),ZR.forEach(n=>{e.removeEventListener(n,this.onResetRaycaster)}),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=n=>{if(n.data.type==="Conditional"&&(n.data.ifActions.forEach(e),n.data.elseActions.forEach(e)),n.data.type==="Conditional"||n.data.type==="SetVariable")for(let r of n.data.type==="Conditional"?n.data.condition:n.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));n.data.type==="DynamicVariablePlay"&&n.data.variableId!==""&&(n.data.mode==="Play"||n.data.mode==="PlayPause"||n.data.mode==="Toggle")&&t.setDynamicVariablePlayState(n.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(n=>{if(!!n.data?.events.length){for(let r of n.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(e);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(e);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(e);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(e);else r.data.type==="LookAt"||r.data.actions.forEach(e)}})}};var j0=class{constructor(t,e,n,r,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new B().copy(n),this._editorSize=new B().copy(r),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,n=this._editorSize.y;this._aspect=t/e,e<=n&&(this._camera.zoom*=n/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,n=this._editorSize.y,r=this._fov;if(t&&e>n){let s=X7(e,1080,2160,1,15)/100;r*=e/n,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(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 X7(i,t,e,n,r){return(i-t)/(e-t)*(r-n)+n}var W0=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new rc(t.shared,e),this.scene=new $a(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 li&&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 jt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var q0=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(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 K7(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 nm(i){return i instanceof hs?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Q7(i,t){let e={};return i.traverseEntity(n=>{if(!n.visible||!(n instanceof Xt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let r=n.parent;for(;r;){if(r instanceof Xt&&n.states&&Object.keys(n.states).length)return;r=r.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!Cn.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!Cn.isMergable(u.material))return;s=Cn.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][nm(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][nm(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][nm(n)].push(u)}),e}function Z7(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(n=>{let r=n.length;r>t&&(t=r)})}),t}function JR(i,t){let e=Q7(t,i),n=Z7(e),r=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,u=0,p.forEach(g=>{g instanceof Xt&&(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&&K7(o[g]);let m=rs(o.slice(0,a),!1);if(m){let g;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new kn(m,l[0].material);break}default:{g=new kn(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Xt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][nm(x)]&&e[x.material.uuid][nm(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),r[s++]=x}}}for(let h=0;h<s;h++)r[h].removeFromParent()}var tL=$o(eL(),1);var $7=new B;function eX(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 OA=class{constructor(t,{renderOnDemand:e,renderMode:n="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=$7.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._requestRenderAutoMode()}};this._debouncedResize=Rl(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new q0({x:10,y:10})),yC(t)}async load(t,e,n){eX(t),this.disposed=!1;let s=await(await fetch(t,n)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:n}={}){if(this.disposed)return;let r=await QR(t);this._data=r,r.version&&(0,tL.default)(r.version,"0.9.495")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([v1(r)&&hD(),$D(r)&&sD(),La.physicsEnabled(r.scene.objects)&&EC(),u1(r)&&YD(),wA(r)&&SC()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new W0(r);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();JR(r,s.scene);let u=performance.now();console.log("Merged geometries in ",u-l," ms")}v1(r)&&this._scene.traverse(l=>{Nr(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof vr&&l.pendingMediaLoad&&l.update()})});let o=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);Promise.all(o).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),u1(r)&&YR(r)&&await Promise.all(o),this._scene.rewriteEventsBeforeGoToPlayMode(),Ch(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new Xv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let a=Object.values(r.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 j0(this._renderer,this._camera,new B(this._viewportWidth,this._viewportHeight),new B(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(a.allowResponsive??!1)&&a.preset==="fullscreen"),e){let l=new S0(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,a);this._scene.updateMatrixWorld(!0),this._controls=new k0(l),this._animationControls=new U0(this._scene,this._requestRenderAutoMode),this._eventManager=new H0(r.scene.publish,this._controls,this._animationControls,l,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),n!==void 0&&this.setVariables(n),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[n,r]of e)this.setVariable(n,r)}}setVariable(t,e){let n=this._getVariableByName(t);if(n&&!("dynamicVariableType"in n.data)){let r=e;typeof n.data.value=="number"?r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof n.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof n.data.value!="string"&&n.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(n.id,s),this.requestRender(),this._requestRenderAutoMode()}else n===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in n.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 n=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(n)}}_getVariableValue(t){return typeof t!="string"&&fr.isTextValue(t)?fr.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(n=>n.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!==Li&&!this._scene.isInvisibleObjects(e)&&!(e instanceof li)){let n=this._createProxyObject(e);n&&t.push(n)}}),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 Vh&&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:n,b:r,a:s}={r:0,g:0,b:0,a:1},o=new dn(e,n,r,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=>{Bb.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(),vC(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 li&&(e=s.name)});let n={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 li||t instanceof $a?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Bb(n,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,r),r}};