@splinetool/viewer 0.9.378 → 0.9.380

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3135,9 +3135,9 @@ void main() {
3135
3135
  squared_mean = squared_mean / samples;
3136
3136
  float std_dev = sqrt( squared_mean - mean * mean );
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
- }`;function VD(e,t,i){let r=new Ug,s=new k,n=new k,a=new tt,o=new u_({depthPacking:$b}),l=new kD,h={},d=i.maxTextureSize,c={[rs]:gi,[gi]:rs,[mr]:mr},u=new It({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:jD,fragmentShader:GD}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let g=new He;g.setAttribute("position",new qe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let f=new tr(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ig,this.render=function(w,_,S){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let A=e.getRenderTarget(),b=e.getActiveCubeFace(),E=e.getActiveMipmapLevel(),C=e.state;C.setBlending(ri),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,P=w.length;T<P;T++){let L=w[T],D=L.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",L,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;s.copy(D.mapSize);let j=D.getFrameExtents();if(s.multiply(j),n.copy(D.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(n.x=Math.floor(d/j.x),s.x=n.x*j.x,D.mapSize.x=n.x),s.y>d&&(n.y=Math.floor(d/j.y),s.y=n.y*j.y,D.mapSize.y=n.y)),D.map===null){let q=this.type!==uh?{minFilter:Dt,magFilter:Dt}:{};D.map=new St(s.x,s.y,q),D.map.texture.name=L.name+".shadowMap",D.camera.updateProjectionMatrix()}e.setRenderTarget(D.map),e.clear();let W=D.getViewportCount();for(let q=0;q<W;q++){let z=D.getViewport(q);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),D.updateMatrices(L,q),r=D.getFrustum(),x(_,S,D.camera,L,this.type)}D.isPointLightShadow!==!0&&this.type===uh&&v(D,S),D.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(A,b,E)};function v(w,_){let S=t.update(f);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new St(s.x,s.y)),u.uniforms.shadow_pass.value=w.map.texture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,e.setRenderTarget(w.mapPass),e.clear(),e.renderBufferDirect(_,null,S,u,f,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,e.setRenderTarget(w.map),e.clear(),e.renderBufferDirect(_,null,S,p,f,null)}function y(w,_,S,A,b,E){let C=null,T=S.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(T!==void 0)C=T;else if(C=S.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let P=C.uuid,L=_.uuid,D=h[P];D===void 0&&(D={},h[P]=D);let j=D[L];j===void 0&&(j=C.clone(),D[L]=j),C=j}return C.visible=_.visible,C.wireframe=_.wireframe,E===uh?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:c[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,S.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(S.matrixWorld),C.nearDistance=A,C.farDistance=b),C}function x(w,_,S,A,b){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===uh)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,w.matrixWorld);let C=t.update(w),T=w.material;if(Array.isArray(T)){let P=C.groups;for(let L=0,D=P.length;L<D;L++){let j=P[L],W=T[j.materialIndex];if(W&&W.visible){let q=y(w,W,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,q,w,j)}}}else if(T.visible){let P=y(w,T,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,P,w,null)}}let E=w.children;for(let C=0,T=E.length;C<T;C++)x(E[C],_,S,A,b)}}function HD(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,se=new tt,pe=null,xe=new tt(0,0,0,0);return{setMask:function(ke){pe!==ke&&!Y&&(e.colorMask(ke,ke,ke,ke),pe=ke)},setLocked:function(ke){Y=ke},setClear:function(ke,ft,Ut,Mi,aa){aa===!0&&(ke*=Mi,ft*=Mi,Ut*=Mi),se.set(ke,ft,Ut,Mi),xe.equals(se)===!1&&(e.clearColor(ke,ft,Ut,Mi),xe.copy(se))},reset:function(){Y=!1,pe=null,xe.set(-1,0,0,0)}}}function n(){let Y=!1,se=null,pe=null,xe=null;return{setTest:function(ke){ke?ne(2929):G(2929)},setMask:function(ke){se!==ke&&!Y&&(e.depthMask(ke),se=ke)},setFunc:function(ke){if(pe!==ke){switch(ke){case cE:e.depthFunc(512);break;case dE:e.depthFunc(519);break;case uE:e.depthFunc(513);break;case nm:e.depthFunc(515);break;case pE:e.depthFunc(514);break;case fE:e.depthFunc(518);break;case mE:e.depthFunc(516);break;case gE:e.depthFunc(517);break;default:e.depthFunc(515)}pe=ke}},setLocked:function(ke){Y=ke},setClear:function(ke){xe!==ke&&(e.clearDepth(ke),xe=ke)},reset:function(){Y=!1,se=null,pe=null,xe=null}}}function a(){let Y=!1,se=null,pe=null,xe=null,ke=null,ft=null,Ut=null,Mi=null,aa=null;return{setTest:function(zt){Y||(zt?ne(2960):G(2960))},setMask:function(zt){se!==zt&&!Y&&(e.stencilMask(zt),se=zt)},setFunc:function(zt,js,xr){(pe!==zt||xe!==js||ke!==xr)&&(e.stencilFunc(zt,js,xr),pe=zt,xe=js,ke=xr)},setOp:function(zt,js,xr){(ft!==zt||Ut!==js||Mi!==xr)&&(e.stencilOp(zt,js,xr),ft=zt,Ut=js,Mi=xr)},setLocked:function(zt){Y=zt},setClear:function(zt){aa!==zt&&(e.clearStencil(zt),aa=zt)},reset:function(){Y=!1,se=null,pe=null,xe=null,ke=null,ft=null,Ut=null,Mi=null,aa=null}}}let o=new s,l=new n,h=new a,d=new WeakMap,c=new WeakMap,u={},p={},g=new WeakMap,f=[],m=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,E=!1,C=null,T=null,P=null,L=null,D=null,j=e.getParameter(35661),W=!1,q=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(z)[1]),W=q>=1):z.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),W=q>=2);let V=null,F={},N=e.getParameter(3088),B=e.getParameter(2978),H=new tt().fromArray(N),X=new tt().fromArray(B);function Q(Y,se,pe){let xe=new Uint8Array(4),ke=e.createTexture();e.bindTexture(Y,ke),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let ft=0;ft<pe;ft++)e.texImage2D(se+ft,0,6408,1,1,0,6408,5121,xe);return ke}let U={};U[3553]=Q(3553,3553,1),U[34067]=Q(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ne(2929),l.setFunc(nm),Oe(!1),_e(C0),ne(2884),ue(ri);function ne(Y){u[Y]!==!0&&(e.enable(Y),u[Y]=!0)}function G(Y){u[Y]!==!1&&(e.disable(Y),u[Y]=!1)}function $(Y,se){return p[Y]!==se?(e.bindFramebuffer(Y,se),p[Y]=se,r&&(Y===36009&&(p[36160]=se),Y===36160&&(p[36009]=se)),!0):!1}function Z(Y,se){let pe=f,xe=!1;if(Y)if(pe=g.get(se),pe===void 0&&(pe=[],g.set(se,pe)),Y.isWebGLMultipleRenderTargets){let ke=Y.texture;if(pe.length!==ke.length||pe[0]!==36064){for(let ft=0,Ut=ke.length;ft<Ut;ft++)pe[ft]=36064+ft;pe.length=ke.length,xe=!0}}else pe[0]!==36064&&(pe[0]=36064,xe=!0);else pe[0]!==1029&&(pe[0]=1029,xe=!0);xe&&(i.isWebGL2?e.drawBuffers(pe):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function ve(Y){return m!==Y?(e.useProgram(Y),m=Y,!0):!1}let re={[Po]:32774,[$M]:32778,[eE]:32779};if(r)re[O0]=32775,re[L0]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(re[O0]=Y.MIN_EXT,re[L0]=Y.MAX_EXT)}let oe={[tE]:0,[iE]:1,[rE]:768,[Xb]:770,[hE]:776,[oE]:774,[nE]:772,[sE]:769,[Yb]:771,[lE]:775,[aE]:773};function ue(Y,se,pe,xe,ke,ft,Ut,Mi){if(Y===ri){v===!0&&(G(3042),v=!1);return}if(v===!1&&(ne(3042),v=!0),Y!==JM){if(Y!==y||Mi!==E){if((x!==Po||S!==Po)&&(e.blendEquation(32774),x=Po,S=Po),Mi)switch(Y){case Vo:e.blendFuncSeparate(1,771,1,771);break;case T0:e.blendFunc(1,1);break;case P0:e.blendFuncSeparate(0,769,0,1);break;case D0:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Vo:e.blendFuncSeparate(770,771,1,771);break;case T0:e.blendFunc(770,1);break;case P0:e.blendFuncSeparate(0,769,0,1);break;case D0:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}w=null,_=null,A=null,b=null,y=Y,E=Mi}return}ke=ke||se,ft=ft||pe,Ut=Ut||xe,(se!==x||ke!==S)&&(e.blendEquationSeparate(re[se],re[ke]),x=se,S=ke),(pe!==w||xe!==_||ft!==A||Ut!==b)&&(e.blendFuncSeparate(oe[pe],oe[xe],oe[ft],oe[Ut]),w=pe,_=xe,A=ft,b=Ut),y=Y,E=!1}function be(Y,se){Y.side===mr?G(2884):ne(2884);let pe=Y.side===gi;se&&(pe=!pe),Oe(pe),Y.blending===Vo&&Y.transparent===!1?ue(ri):ue(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),o.setMask(Y.colorWrite);let xe=Y.stencilWrite;h.setTest(xe),xe&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),Ie(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ne(32926):G(32926)}function Oe(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function _e(Y){Y!==ZM?(ne(2884),Y!==T&&(Y===C0?e.cullFace(1029):Y===KM?e.cullFace(1028):e.cullFace(1032))):G(2884),T=Y}function Se(Y){Y!==P&&(W&&e.lineWidth(Y),P=Y)}function Ie(Y,se,pe){Y?(ne(32823),(L!==se||D!==pe)&&(e.polygonOffset(se,pe),L=se,D=pe)):G(32823)}function Xe(Y){Y?ne(3089):G(3089)}function ct(Y){Y===void 0&&(Y=33984+j-1),V!==Y&&(e.activeTexture(Y),V=Y)}function R(Y,se,pe){pe===void 0&&(V===null?pe=33984+j-1:pe=V);let xe=F[pe];xe===void 0&&(xe={type:void 0,texture:void 0},F[pe]=xe),(xe.type!==Y||xe.texture!==se)&&(V!==pe&&(e.activeTexture(pe),V=pe),e.bindTexture(Y,se||U[Y]),xe.type=Y,xe.texture=se)}function O(){let Y=F[V];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ie(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function fe(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ge(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ae(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ye(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Me(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ce(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Te(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Pe(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function We(Y){H.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),H.copy(Y))}function ze(Y){X.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),X.copy(Y))}function dt(Y,se){let pe=c.get(se);pe===void 0&&(pe=new WeakMap,c.set(se,pe));let xe=pe.get(Y);xe===void 0&&(xe=e.getUniformBlockIndex(se,Y.name),pe.set(Y,xe))}function Ot(Y,se){let pe=c.get(se).get(Y);d.get(se)!==pe&&(e.uniformBlockBinding(se,pe,Y.__bindingPointIndex),d.set(se,pe))}function Kt(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),u={},V=null,F={},p={},g=new WeakMap,f=[],m=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,E=!1,C=null,T=null,P=null,L=null,D=null,H.set(0,0,e.canvas.width,e.canvas.height),X.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ne,disable:G,bindFramebuffer:$,drawBuffers:Z,useProgram:ve,setBlending:ue,setMaterial:be,setFlipSided:Oe,setCullFace:_e,setLineWidth:Se,setPolygonOffset:Ie,setScissorTest:Xe,activeTexture:ct,bindTexture:R,unbindTexture:O,compressedTexImage2D:ie,compressedTexImage3D:fe,texImage2D:Le,texImage3D:Pe,updateUBOMapping:dt,uniformBlockBinding:Ot,texStorage2D:ce,texStorage3D:Te,texSubImage2D:ge,texSubImage3D:Ae,compressedTexSubImage2D:Ye,compressedTexSubImage3D:Me,scissor:We,viewport:ze,reset:Kt}}function WD(e,t,i,r,s,n,a){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,d=s.maxTextureSize,c=s.maxSamples,u=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap,f,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,O){return v?new OffscreenCanvas(R,O):kd("canvas")}function x(R,O,ie,fe){let ge=1;if((R.width>fe||R.height>fe)&&(ge=fe/Math.max(R.width,R.height)),ge<1||O===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ae=O?Fd:Math.floor,Ye=Ae(ge*R.width),Me=Ae(ge*R.height);f===void 0&&(f=y(Ye,Me));let ce=ie?y(Ye,Me):f;return ce.width=Ye,ce.height=Me,ce.getContext("2d").drawImage(R,0,0,Ye,Me),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Ye+"x"+Me+")."),ce}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function w(R){return dm(R.width)&&dm(R.height)}function _(R){return o?!1:R.wrapS!==Yt||R.wrapT!==Yt||R.minFilter!==Dt&&R.minFilter!==et}function S(R,O){return R.generateMipmaps&&O&&R.minFilter!==Dt&&R.minFilter!==et}function A(R){e.generateMipmap(R)}function b(R,O,ie,fe,ge=!1){if(o===!1)return O;if(R!==null){if(e[R]!==void 0)return e[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ae=O;return O===6403&&(ie===5126&&(Ae=33326),ie===5131&&(Ae=33325),ie===5121&&(Ae=33321)),O===33319&&(ie===5126&&(Ae=33328),ie===5131&&(Ae=33327),ie===5121&&(Ae=33323)),O===6408&&(ie===5126&&(Ae=34836),ie===5131&&(Ae=34842),ie===5121&&(Ae=fe===Ke&&ge===!1?35907:32856),ie===32819&&(Ae=32854),ie===32820&&(Ae=32855)),(Ae===33325||Ae===33326||Ae===33327||Ae===33328||Ae===34842||Ae===34836)&&t.get("EXT_color_buffer_float"),Ae}function E(R,O,ie){return S(R,ie)===!0||R.isFramebufferTexture&&R.minFilter!==Dt&&R.minFilter!==et?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 C(R){return R===Dt||R===R0||R===mp?9728:9729}function T(R){let O=R.target;O.removeEventListener("dispose",T),L(O),O.isVideoTexture&&g.delete(O)}function P(R){let O=R.target;O.removeEventListener("dispose",P),j(O)}function L(R){let O=r.get(R);if(O.__webglInit===void 0)return;let ie=R.source,fe=m.get(ie);if(fe){let ge=fe[O.__cacheKey];ge.usedTimes--,ge.usedTimes===0&&D(R),Object.keys(fe).length===0&&m.delete(ie)}r.remove(R)}function D(R){let O=r.get(R);e.deleteTexture(O.__webglTexture);let ie=R.source,fe=m.get(ie);delete fe[O.__cacheKey],a.memory.textures--}function j(R){let O=R.texture,ie=r.get(R),fe=r.get(O);if(fe.__webglTexture!==void 0&&(e.deleteTexture(fe.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++)e.deleteFramebuffer(ie.__webglFramebuffer[ge]),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer[ge]);else{if(e.deleteFramebuffer(ie.__webglFramebuffer),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let ge=0;ge<ie.__webglColorRenderbuffer.length;ge++)ie.__webglColorRenderbuffer[ge]&&e.deleteRenderbuffer(ie.__webglColorRenderbuffer[ge]);ie.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ie.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let ge=0,Ae=O.length;ge<Ae;ge++){let Ye=r.get(O[ge]);Ye.__webglTexture&&(e.deleteTexture(Ye.__webglTexture),a.memory.textures--),r.remove(O[ge])}r.remove(O),r.remove(R)}let W=0;function q(){W=0}function z(){let R=W;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),W+=1,R}function V(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 F(R,O){let ie=r.get(R);if(R.isVideoTexture&&Xe(R),R.isRenderTargetTexture===!1&&R.version>0&&ie.__version!==R.version){let fe=R.image;if(fe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(fe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{G(ie,R,O);return}}i.bindTexture(3553,ie.__webglTexture,33984+O)}function N(R,O){let ie=r.get(R);if(R.version>0&&ie.__version!==R.version){G(ie,R,O);return}i.bindTexture(35866,ie.__webglTexture,33984+O)}function B(R,O){let ie=r.get(R);if(R.version>0&&ie.__version!==R.version){G(ie,R,O);return}i.bindTexture(32879,ie.__webglTexture,33984+O)}function H(R,O){let ie=r.get(R);if(R.version>0&&ie.__version!==R.version){$(ie,R,O);return}i.bindTexture(34067,ie.__webglTexture,33984+O)}let X={[ln]:10497,[Yt]:33071,[lm]:33648},Q={[Dt]:9728,[R0]:9984,[mp]:9986,[et]:9729,[AE]:9985,[il]:9987};function U(R,O,ie){if(ie?(e.texParameteri(R,10242,X[O.wrapS]),e.texParameteri(R,10243,X[O.wrapT]),(R===32879||R===35866)&&e.texParameteri(R,32882,X[O.wrapR]),e.texParameteri(R,10240,Q[O.magFilter]),e.texParameteri(R,10241,Q[O.minFilter])):(e.texParameteri(R,10242,33071),e.texParameteri(R,10243,33071),(R===32879||R===35866)&&e.texParameteri(R,32882,33071),(O.wrapS!==Yt||O.wrapT!==Yt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(R,10240,C(O.magFilter)),e.texParameteri(R,10241,C(O.minFilter)),O.minFilter!==Dt&&O.minFilter!==et&&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 fe=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Dt||O.minFilter!==mp&&O.minFilter!==il||O.type===Or&&t.has("OES_texture_float_linear")===!1||o===!1&&O.type===rl&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(e.texParameterf(R,fe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function ne(R,O){let ie=!1;R.__webglInit===void 0&&(R.__webglInit=!0,O.addEventListener("dispose",T));let fe=O.source,ge=m.get(fe);ge===void 0&&(ge={},m.set(fe,ge));let Ae=V(O);if(Ae!==R.__cacheKey){ge[Ae]===void 0&&(ge[Ae]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),ge[Ae].usedTimes++;let Ye=ge[R.__cacheKey];Ye!==void 0&&(ge[R.__cacheKey].usedTimes--,Ye.usedTimes===0&&D(O)),R.__cacheKey=Ae,R.__webglTexture=ge[Ae].texture}return ie}function G(R,O,ie){let fe=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(fe=35866),O.isData3DTexture&&(fe=32879);let ge=ne(R,O),Ae=O.source;i.bindTexture(fe,R.__webglTexture,33984+ie);let Ye=r.get(Ae);if(Ae.version!==Ye.__version||ge===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Me=_(O)&&w(O.image)===!1,ce=x(O.image,Me,!1,d);ce=ct(O,ce);let Te=w(ce)||o,Le=n.convert(O.format,O.encoding),Pe=n.convert(O.type),We=b(O.internalFormat,Le,Pe,O.encoding,O.isVideoTexture);U(fe,O,Te);let ze,dt=O.mipmaps,Ot=o&&O.isVideoTexture!==!0,Kt=Ye.__version===void 0||ge===!0,Y=E(O,ce,Te);if(O.isDepthTexture)We=6402,o?O.type===Or?We=36012:O.type===Gn?We=33190:O.type===Oa?We=35056:We=33189:O.type===Or&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===La&&We===6402&&O.type!==Kb&&O.type!==Gn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Gn,Pe=n.convert(O.type)),O.format===ja&&We===6402&&(We=34041,O.type!==Oa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Oa,Pe=n.convert(O.type))),Kt&&(Ot?i.texStorage2D(3553,1,We,ce.width,ce.height):i.texImage2D(3553,0,We,ce.width,ce.height,0,Le,Pe,null));else if(O.isDataTexture)if(dt.length>0&&Te){Ot&&Kt&&i.texStorage2D(3553,Y,We,dt[0].width,dt[0].height);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],Ot?i.texSubImage2D(3553,se,0,0,ze.width,ze.height,Le,Pe,ze.data):i.texImage2D(3553,se,We,ze.width,ze.height,0,Le,Pe,ze.data);O.generateMipmaps=!1}else Ot?(Kt&&i.texStorage2D(3553,Y,We,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,ce.width,ce.height,Le,Pe,ce.data)):i.texImage2D(3553,0,We,ce.width,ce.height,0,Le,Pe,ce.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ot&&Kt&&i.texStorage3D(35866,Y,We,dt[0].width,dt[0].height,ce.depth);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],O.format!==Kr?Le!==null?Ot?i.compressedTexSubImage3D(35866,se,0,0,0,ze.width,ze.height,ce.depth,Le,ze.data,0,0):i.compressedTexImage3D(35866,se,We,ze.width,ze.height,ce.depth,0,ze.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage3D(35866,se,0,0,0,ze.width,ze.height,ce.depth,Le,Pe,ze.data):i.texImage3D(35866,se,We,ze.width,ze.height,ce.depth,0,Le,Pe,ze.data)}else{Ot&&Kt&&i.texStorage2D(3553,Y,We,dt[0].width,dt[0].height);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],O.format!==Kr?Le!==null?Ot?i.compressedTexSubImage2D(3553,se,0,0,ze.width,ze.height,Le,ze.data):i.compressedTexImage2D(3553,se,We,ze.width,ze.height,0,ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage2D(3553,se,0,0,ze.width,ze.height,Le,Pe,ze.data):i.texImage2D(3553,se,We,ze.width,ze.height,0,Le,Pe,ze.data)}else if(O.isDataArrayTexture)Ot?(Kt&&i.texStorage3D(35866,Y,We,ce.width,ce.height,ce.depth),i.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,Le,Pe,ce.data)):i.texImage3D(35866,0,We,ce.width,ce.height,ce.depth,0,Le,Pe,ce.data);else if(O.isData3DTexture)Ot?(Kt&&i.texStorage3D(32879,Y,We,ce.width,ce.height,ce.depth),i.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,Le,Pe,ce.data)):i.texImage3D(32879,0,We,ce.width,ce.height,ce.depth,0,Le,Pe,ce.data);else if(O.isFramebufferTexture){if(Kt)if(Ot)i.texStorage2D(3553,Y,We,ce.width,ce.height);else{let se=ce.width,pe=ce.height;for(let xe=0;xe<Y;xe++)i.texImage2D(3553,xe,We,se,pe,0,Le,Pe,null),se>>=1,pe>>=1}}else if(dt.length>0&&Te){Ot&&Kt&&i.texStorage2D(3553,Y,We,dt[0].width,dt[0].height);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],Ot?i.texSubImage2D(3553,se,0,0,Le,Pe,ze):i.texImage2D(3553,se,We,Le,Pe,ze);O.generateMipmaps=!1}else Ot?(Kt&&i.texStorage2D(3553,Y,We,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,Le,Pe,ce)):i.texImage2D(3553,0,We,Le,Pe,ce);S(O,Te)&&A(fe),Ye.__version=Ae.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function $(R,O,ie){if(O.image.length!==6)return;let fe=ne(R,O),ge=O.source;i.bindTexture(34067,R.__webglTexture,33984+ie);let Ae=r.get(ge);if(ge.version!==Ae.__version||fe===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Ye=O.isCompressedTexture||O.image[0].isCompressedTexture,Me=O.image[0]&&O.image[0].isDataTexture,ce=[];for(let se=0;se<6;se++)!Ye&&!Me?ce[se]=x(O.image[se],!1,!0,h):ce[se]=Me?O.image[se].image:O.image[se],ce[se]=ct(O,ce[se]);let Te=ce[0],Le=w(Te)||o,Pe=n.convert(O.format,O.encoding),We=n.convert(O.type),ze=b(O.internalFormat,Pe,We,O.encoding),dt=o&&O.isVideoTexture!==!0,Ot=Ae.__version===void 0||fe===!0,Kt=E(O,Te,Le);U(34067,O,Le);let Y;if(Ye){dt&&Ot&&i.texStorage2D(34067,Kt,ze,Te.width,Te.height);for(let se=0;se<6;se++){Y=ce[se].mipmaps;for(let pe=0;pe<Y.length;pe++){let xe=Y[pe];O.format!==Kr?Pe!==null?dt?i.compressedTexSubImage2D(34069+se,pe,0,0,xe.width,xe.height,Pe,xe.data):i.compressedTexImage2D(34069+se,pe,ze,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):dt?i.texSubImage2D(34069+se,pe,0,0,xe.width,xe.height,Pe,We,xe.data):i.texImage2D(34069+se,pe,ze,xe.width,xe.height,0,Pe,We,xe.data)}}}else{Y=O.mipmaps,dt&&Ot&&(Y.length>0&&Kt++,i.texStorage2D(34067,Kt,ze,ce[0].width,ce[0].height));for(let se=0;se<6;se++)if(Me){dt?i.texSubImage2D(34069+se,0,0,0,ce[se].width,ce[se].height,Pe,We,ce[se].data):i.texImage2D(34069+se,0,ze,ce[se].width,ce[se].height,0,Pe,We,ce[se].data);for(let pe=0;pe<Y.length;pe++){let xe=Y[pe].image[se].image;dt?i.texSubImage2D(34069+se,pe+1,0,0,xe.width,xe.height,Pe,We,xe.data):i.texImage2D(34069+se,pe+1,ze,xe.width,xe.height,0,Pe,We,xe.data)}}else{dt?i.texSubImage2D(34069+se,0,0,0,Pe,We,ce[se]):i.texImage2D(34069+se,0,ze,Pe,We,ce[se]);for(let pe=0;pe<Y.length;pe++){let xe=Y[pe];dt?i.texSubImage2D(34069+se,pe+1,0,0,Pe,We,xe.image[se]):i.texImage2D(34069+se,pe+1,ze,Pe,We,xe.image[se])}}}S(O,Le)&&A(34067),Ae.__version=ge.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function Z(R,O,ie,fe,ge){let Ae=n.convert(ie.format,ie.encoding),Ye=n.convert(ie.type),Me=b(ie.internalFormat,Ae,Ye,ie.encoding);r.get(O).__hasExternalTextures||(ge===32879||ge===35866?i.texImage3D(ge,0,Me,O.width,O.height,O.depth,0,Ae,Ye,null):i.texImage2D(ge,0,Me,O.width,O.height,0,Ae,Ye,null)),i.bindFramebuffer(36160,R),Ie(O)?u.framebufferTexture2DMultisampleEXT(36160,fe,ge,r.get(ie).__webglTexture,0,Se(O)):(ge===3553||ge>=34069&&ge<=34074)&&e.framebufferTexture2D(36160,fe,ge,r.get(ie).__webglTexture,0),i.bindFramebuffer(36160,null)}function ve(R,O,ie){if(e.bindRenderbuffer(36161,R),O.depthBuffer&&!O.stencilBuffer){let fe=33189;if(ie||Ie(O)){let ge=O.depthTexture;ge&&ge.isDepthTexture&&(ge.type===Or?fe=36012:ge.type===Gn&&(fe=33190));let Ae=Se(O);Ie(O)?u.renderbufferStorageMultisampleEXT(36161,Ae,fe,O.width,O.height):e.renderbufferStorageMultisample(36161,Ae,fe,O.width,O.height)}else e.renderbufferStorage(36161,fe,O.width,O.height);e.framebufferRenderbuffer(36160,36096,36161,R)}else if(O.depthBuffer&&O.stencilBuffer){let fe=Se(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,fe,35056,O.width,O.height):Ie(O)?u.renderbufferStorageMultisampleEXT(36161,fe,35056,O.width,O.height):e.renderbufferStorage(36161,34041,O.width,O.height),e.framebufferRenderbuffer(36160,33306,36161,R)}else{let fe=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let ge=0;ge<fe.length;ge++){let Ae=fe[ge],Ye=n.convert(Ae.format,Ae.encoding),Me=n.convert(Ae.type),ce=b(Ae.internalFormat,Ye,Me,Ae.encoding),Te=Se(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,Te,ce,O.width,O.height):Ie(O)?u.renderbufferStorageMultisampleEXT(36161,Te,ce,O.width,O.height):e.renderbufferStorage(36161,ce,O.width,O.height)}}e.bindRenderbuffer(36161,null)}function re(R,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,R),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),F(O.depthTexture,0);let ie=r.get(O.depthTexture).__webglTexture,fe=Se(O);if(O.depthTexture.format===La)Ie(O)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,ie,0,fe):e.framebufferTexture2D(36160,36096,3553,ie,0);else if(O.depthTexture.format===ja)Ie(O)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,ie,0,fe):e.framebufferTexture2D(36160,33306,3553,ie,0);else throw new Error("Unknown depthTexture format")}function oe(R){let O=r.get(R),ie=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!O.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");re(O.__webglFramebuffer,R)}else if(ie){O.__webglDepthbuffer=[];for(let fe=0;fe<6;fe++)i.bindFramebuffer(36160,O.__webglFramebuffer[fe]),O.__webglDepthbuffer[fe]=e.createRenderbuffer(),ve(O.__webglDepthbuffer[fe],R,!1)}else i.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=e.createRenderbuffer(),ve(O.__webglDepthbuffer,R,!1);i.bindFramebuffer(36160,null)}function ue(R,O,ie){let fe=r.get(R);O!==void 0&&Z(fe.__webglFramebuffer,R,R.texture,36064,3553),ie!==void 0&&oe(R)}function be(R){let O=R.texture,ie=r.get(R),fe=r.get(O);R.addEventListener("dispose",P),R.isWebGLMultipleRenderTargets!==!0&&(fe.__webglTexture===void 0&&(fe.__webglTexture=e.createTexture()),fe.__version=O.version,a.memory.textures++);let ge=R.isWebGLCubeRenderTarget===!0,Ae=R.isWebGLMultipleRenderTargets===!0,Ye=w(R)||o;if(ge){ie.__webglFramebuffer=[];for(let Me=0;Me<6;Me++)ie.__webglFramebuffer[Me]=e.createFramebuffer()}else{if(ie.__webglFramebuffer=e.createFramebuffer(),Ae)if(s.drawBuffers){let Me=R.texture;for(let ce=0,Te=Me.length;ce<Te;ce++){let Le=r.get(Me[ce]);Le.__webglTexture===void 0&&(Le.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&R.samples>0&&Ie(R)===!1){let Me=Ae?O:[O];ie.__webglMultisampledFramebuffer=e.createFramebuffer(),ie.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ie.__webglMultisampledFramebuffer);for(let ce=0;ce<Me.length;ce++){let Te=Me[ce];ie.__webglColorRenderbuffer[ce]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ie.__webglColorRenderbuffer[ce]);let Le=n.convert(Te.format,Te.encoding),Pe=n.convert(Te.type),We=b(Te.internalFormat,Le,Pe,Te.encoding,R.isXRRenderTarget===!0),ze=Se(R);e.renderbufferStorageMultisample(36161,ze,We,R.width,R.height),e.framebufferRenderbuffer(36160,36064+ce,36161,ie.__webglColorRenderbuffer[ce])}e.bindRenderbuffer(36161,null),R.depthBuffer&&(ie.__webglDepthRenderbuffer=e.createRenderbuffer(),ve(ie.__webglDepthRenderbuffer,R,!0)),i.bindFramebuffer(36160,null)}}if(ge){i.bindTexture(34067,fe.__webglTexture),U(34067,O,Ye);for(let Me=0;Me<6;Me++)Z(ie.__webglFramebuffer[Me],R,O,36064,34069+Me);S(O,Ye)&&A(34067),i.unbindTexture()}else if(Ae){let Me=R.texture;for(let ce=0,Te=Me.length;ce<Te;ce++){let Le=Me[ce],Pe=r.get(Le);i.bindTexture(3553,Pe.__webglTexture),U(3553,Le,Ye),Z(ie.__webglFramebuffer,R,Le,36064+ce,3553),S(Le,Ye)&&A(3553)}i.unbindTexture()}else{let Me=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(o?Me=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Me,fe.__webglTexture),U(Me,O,Ye),Z(ie.__webglFramebuffer,R,O,36064,Me),S(O,Ye)&&A(Me),i.unbindTexture()}R.depthBuffer&&oe(R)}function Oe(R){let O=w(R)||o,ie=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let fe=0,ge=ie.length;fe<ge;fe++){let Ae=ie[fe];if(S(Ae,O)){let Ye=R.isWebGLCubeRenderTarget?34067:3553,Me=r.get(Ae).__webglTexture;i.bindTexture(Ye,Me),A(Ye),i.unbindTexture()}}}function _e(R){if(o&&R.samples>0&&Ie(R)===!1){let O=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ie=R.width,fe=R.height,ge=16384,Ae=[],Ye=R.stencilBuffer?33306:36096,Me=r.get(R),ce=R.isWebGLMultipleRenderTargets===!0;if(ce)for(let Te=0;Te<O.length;Te++)i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Te,36161,null),i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Te,3553,null,0);i.bindFramebuffer(36008,Me.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Me.__webglFramebuffer);for(let Te=0;Te<O.length;Te++){Ae.push(36064+Te),R.depthBuffer&&Ae.push(Ye);let Le=Me.__ignoreDepthValues!==void 0?Me.__ignoreDepthValues:!1;if(Le===!1&&(R.depthBuffer&&(ge|=256),R.stencilBuffer&&(ge|=1024)),ce&&e.framebufferRenderbuffer(36008,36064,36161,Me.__webglColorRenderbuffer[Te]),Le===!0&&(e.invalidateFramebuffer(36008,[Ye]),e.invalidateFramebuffer(36009,[Ye])),ce){let Pe=r.get(O[Te]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Pe,0)}e.blitFramebuffer(0,0,ie,fe,0,0,ie,fe,ge,9728),p&&e.invalidateFramebuffer(36008,Ae)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ce)for(let Te=0;Te<O.length;Te++){i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Te,36161,Me.__webglColorRenderbuffer[Te]);let Le=r.get(O[Te]).__webglTexture;i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Te,3553,Le,0)}i.bindFramebuffer(36009,Me.__webglMultisampledFramebuffer)}}function Se(R){return Math.min(c,R.samples)}function Ie(R){let O=r.get(R);return o&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Xe(R){let O=a.render.frame;g.get(R)!==O&&(g.set(R,O),R.update())}function ct(R,O){let ie=R.encoding,fe=R.format,ge=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===cm||ie!==Rs&&(ie===Ke?o===!1?t.has("EXT_sRGB")===!0&&fe===Kr?(R.format=cm,R.minFilter=et,R.generateMipmaps=!1):O=i_.sRGBToLinear(O):(fe!==Kr||ge!==Bi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ie)),O}this.allocateTextureUnit=z,this.resetTextureUnits=q,this.setTexture2D=F,this.setTexture2DArray=N,this.setTexture3D=B,this.setTextureCube=H,this.rebindTextures=ue,this.setupRenderTarget=be,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=_e,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=Ie}function qD(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Bi)return 5121;if(n===TE)return 32819;if(n===PE)return 32820;if(n===ME)return 5120;if(n===EE)return 5122;if(n===Kb)return 5123;if(n===CE)return 5124;if(n===Gn)return 5125;if(n===Or)return 5126;if(n===rl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===DE)return 6406;if(n===Kr)return 6408;if(n===OE)return 6409;if(n===LE)return 6410;if(n===La)return 6402;if(n===ja)return 34041;if(n===cm)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===RE)return 6403;if(n===IE)return 36244;if(n===Jb)return 33319;if(n===BE)return 33320;if(n===zE)return 36249;if(n===gp||n===vp||n===yp||n===xp)if(a===Ke)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===gp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===vp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===yp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===xp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===gp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===vp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===yp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===xp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===I0||n===B0||n===z0||n===N0)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===I0)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===B0)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===z0)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===N0)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===NE)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===U0||n===F0)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===U0)return a===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===F0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===k0||n===j0||n===G0||n===V0||n===H0||n===W0||n===q0||n===X0||n===Y0||n===Q0||n===Z0||n===K0||n===J0||n===$0)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===k0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===j0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===G0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===V0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===H0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===W0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===q0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===X0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Y0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Q0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Z0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===K0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===J0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===$0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===wp)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===wp)return a===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===UE||n===ey||n===ty||n===iy)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===wp)return o.COMPRESSED_RED_RGTC1_EXT;if(n===ey)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ty)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===iy)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Oa?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[n]!==void 0?e[n]:null}return{convert:s}}var XD=class extends Li{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Bo=class extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}},YD={type:"move"},qp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Bo,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 Bo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Bo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let g of e.hand.values()){let f=t.getJointPose(g,i),m=this._getHandJoint(l,g);f!==null&&(m.matrix.fromArray(f.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=f.radius),m.visible=f!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],c=h.position.distanceTo(d.position),u=.02,p=.005;l.inputState.pinching&&c>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=u-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(YD)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Bo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},nl=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:La,h!==La&&h!==ja)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===La&&(i=Gn),i===void 0&&h===ja&&(i=Oa),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Dt,this.minFilter=o!==void 0?o:Dt,this.flipY=!1,this.generateMipmaps=!1}},QD=class extends Wi{constructor(e,t){super();let i=this,r=null,s=1,n=null,a="local-floor",o=1,l=null,h=null,d=null,c=null,u=null,p=null,g=t.getContextAttributes(),f=null,m=null,v=[],y=[],x=new Set,w=new Map,_=new Li;_.layers.enable(1),_.viewport=new tt;let S=new Li;S.layers.enable(2),S.viewport=new tt;let A=[_,S],b=new XD;b.layers.enable(1),b.layers.enable(2);let E=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(N){let B=v[N];return B===void 0&&(B=new qp,v[N]=B),B.getTargetRaySpace()},this.getControllerGrip=function(N){let B=v[N];return B===void 0&&(B=new qp,v[N]=B),B.getGripSpace()},this.getHand=function(N){let B=v[N];return B===void 0&&(B=new qp,v[N]=B),B.getHandSpace()};function T(N){let B=y.indexOf(N.inputSource);if(B===-1)return;let H=v[B];H!==void 0&&H.dispatchEvent({type:N.type,data:N.inputSource})}function P(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",L);for(let N=0;N<v.length;N++){let B=y[N];B!==null&&(y[N]=null,v[N].disconnect(B))}E=null,C=null,e.setRenderTarget(f),u=null,c=null,d=null,r=null,m=null,F.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(N){s=N,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(N){a=N,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(N){l=N},this.getBaseLayer=function(){return c!==null?c:u},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(N){if(r=N,r!==null){if(f=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",P),r.addEventListener("inputsourceschange",L),g.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let B={antialias:r.renderState.layers===void 0?g.antialias:!0,alpha:g.alpha,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(r,t,B),r.updateRenderState({baseLayer:u}),m=new St(u.framebufferWidth,u.framebufferHeight,{format:Kr,type:Bi,encoding:e.outputEncoding,stencilBuffer:g.stencil})}else{let B=null,H=null,X=null;g.depth&&(X=g.stencil?35056:33190,B=g.stencil?ja:La,H=g.stencil?Oa:Gn);let Q={colorFormat:32856,depthFormat:X,scaleFactor:s};d=new XRWebGLBinding(r,t),c=d.createProjectionLayer(Q),r.updateRenderState({layers:[c]}),m=new St(c.textureWidth,c.textureHeight,{format:Kr,type:Bi,depthTexture:new nl(c.textureWidth,c.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,B),stencilBuffer:g.stencil,encoding:e.outputEncoding,samples:g.antialias?4:0});let U=e.properties.get(m);U.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),F.setContext(r),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function L(N){for(let B=0;B<N.removed.length;B++){let H=N.removed[B],X=y.indexOf(H);X>=0&&(y[X]=null,v[X].disconnect(H))}for(let B=0;B<N.added.length;B++){let H=N.added[B],X=y.indexOf(H);if(X===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(H),X=U;break}else if(y[U]===null){y[U]=H,X=U;break}if(X===-1)break}let Q=v[X];Q&&Q.connect(H)}}let D=new M,j=new M;function W(N,B,H){D.setFromMatrixPosition(B.matrixWorld),j.setFromMatrixPosition(H.matrixWorld);let X=D.distanceTo(j),Q=B.projectionMatrix.elements,U=H.projectionMatrix.elements,ne=Q[14]/(Q[10]-1),G=Q[14]/(Q[10]+1),$=(Q[9]+1)/Q[5],Z=(Q[9]-1)/Q[5],ve=(Q[8]-1)/Q[0],re=(U[8]+1)/U[0],oe=ne*ve,ue=ne*re,be=X/(-ve+re),Oe=be*-ve;B.matrixWorld.decompose(N.position,N.quaternion,N.scale),N.translateX(Oe),N.translateZ(be),N.matrixWorld.compose(N.position,N.quaternion,N.scale),N.matrixWorldInverse.copy(N.matrixWorld).invert();let _e=ne+be,Se=G+be,Ie=oe-Oe,Xe=ue+(X-Oe),ct=$*G/Se*_e,R=Z*G/Se*_e;N.projectionMatrix.makePerspective(Ie,Xe,ct,R,_e,Se)}function q(N,B){B===null?N.matrixWorld.copy(N.matrix):N.matrixWorld.multiplyMatrices(B.matrixWorld,N.matrix),N.matrixWorldInverse.copy(N.matrixWorld).invert()}this.updateCamera=function(N){if(r===null)return;b.near=S.near=_.near=N.near,b.far=S.far=_.far=N.far,(E!==b.near||C!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),E=b.near,C=b.far);let B=N.parent,H=b.cameras;q(b,B);for(let Q=0;Q<H.length;Q++)q(H[Q],B);b.matrixWorld.decompose(b.position,b.quaternion,b.scale),N.matrix.copy(b.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);let X=N.children;for(let Q=0,U=X.length;Q<U;Q++)X[Q].updateMatrixWorld(!0);H.length===2?W(b,_,S):b.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return b},this.getFoveation=function(){if(!(c===null&&u===null))return o},this.setFoveation=function(N){o=N,c!==null&&(c.fixedFoveation=N),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=N)},this.getPlanes=function(){return x};let z=null;function V(N,B){if(h=B.getViewerPose(l||n),p=B,h!==null){let H=h.views;u!==null&&(e.setRenderTargetFramebuffer(m,u.framebuffer),e.setRenderTarget(m));let X=!1;H.length!==b.cameras.length&&(b.cameras.length=0,X=!0);for(let Q=0;Q<H.length;Q++){let U=H[Q],ne=null;if(u!==null)ne=u.getViewport(U);else{let $=d.getViewSubImage(c,U);ne=$.viewport,Q===0&&(e.setRenderTargetTextures(m,$.colorTexture,c.ignoreDepthValues?void 0:$.depthStencilTexture),e.setRenderTarget(m))}let G=A[Q];G===void 0&&(G=new Li,G.layers.enable(Q),G.viewport=new tt,A[Q]=G),G.matrix.fromArray(U.transform.matrix),G.projectionMatrix.fromArray(U.projectionMatrix),G.viewport.set(ne.x,ne.y,ne.width,ne.height),Q===0&&b.matrix.copy(G.matrix),X===!0&&b.cameras.push(G)}}for(let H=0;H<v.length;H++){let X=y[H],Q=v[H];X!==null&&Q!==void 0&&Q.update(X,B,l||n)}if(z&&z(N,B),B.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:B.detectedPlanes});let H=null;for(let X of x)B.detectedPlanes.has(X)||(H===null&&(H=[]),H.push(X));if(H!==null)for(let X of H)x.delete(X),w.delete(X),i.dispatchEvent({type:"planeremoved",data:X});for(let X of B.detectedPlanes)if(!x.has(X))x.add(X),w.set(X,B.lastChangedTime),i.dispatchEvent({type:"planeadded",data:X});else{let Q=w.get(X);X.lastChangedTime>Q&&(w.set(X,X.lastChangedTime),i.dispatchEvent({type:"planechanged",data:X}))}}p=null}let F=new o_;F.setAnimationLoop(V),this.setAnimationLoop=function(N){z=N},this.dispose=function(){}}};function ZD(e,t){function i(f,m){m.color.getRGB(f.fogColor.value,a_(e)),m.isFog?(f.fogNear.value=m.near,f.fogFar.value=m.far):m.isFogExp2&&(f.fogDensity.value=m.density)}function r(f,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(f,m):m.isMeshToonMaterial?(s(f,m),d(f,m)):m.isMeshPhongMaterial?(s(f,m),h(f,m)):m.isMeshStandardMaterial?(s(f,m),c(f,m),m.isMeshPhysicalMaterial&&u(f,m,x)):m.isMeshMatcapMaterial?(s(f,m),p(f,m)):m.isMeshDepthMaterial?s(f,m):m.isMeshDistanceMaterial?(s(f,m),g(f,m)):m.isMeshNormalMaterial?s(f,m):m.isLineBasicMaterial?(n(f,m),m.isLineDashedMaterial&&a(f,m)):m.isPointsMaterial?o(f,m,v,y):m.isSpriteMaterial?l(f,m):m.isShadowMaterial?(f.color.value.copy(m.color),f.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(f,m){f.opacity.value=m.opacity,m.color&&f.diffuse.value.copy(m.color),m.emissive&&f.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(f.map.value=m.map),m.alphaMap&&(f.alphaMap.value=m.alphaMap),m.bumpMap&&(f.bumpMap.value=m.bumpMap,f.bumpScale.value=m.bumpScale,m.side===gi&&(f.bumpScale.value*=-1)),m.displacementMap&&(f.displacementMap.value=m.displacementMap,f.displacementScale.value=m.displacementScale,f.displacementBias.value=m.displacementBias),m.emissiveMap&&(f.emissiveMap.value=m.emissiveMap),m.normalMap&&(f.normalMap.value=m.normalMap,f.normalScale.value.copy(m.normalScale),m.side===gi&&f.normalScale.value.negate()),m.specularMap&&(f.specularMap.value=m.specularMap),m.alphaTest>0&&(f.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(f.envMap.value=v,f.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=m.reflectivity,f.ior.value=m.ior,f.refractionRatio.value=m.refractionRatio),m.lightMap){f.lightMap.value=m.lightMap;let w=e.physicallyCorrectLights!==!0?Math.PI:1;f.lightMapIntensity.value=m.lightMapIntensity*w}m.aoMap&&(f.aoMap.value=m.aoMap,f.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),f.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),f.uv2Transform.value.copy(x.matrix))}function n(f,m){f.diffuse.value.copy(m.color),f.opacity.value=m.opacity}function a(f,m){f.dashSize.value=m.dashSize,f.totalSize.value=m.dashSize+m.gapSize,f.scale.value=m.scale}function o(f,m,v,y){f.diffuse.value.copy(m.color),f.opacity.value=m.opacity,f.size.value=m.size*v,f.scale.value=y*.5,m.map&&(f.map.value=m.map),m.alphaMap&&(f.alphaMap.value=m.alphaMap),m.alphaTest>0&&(f.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),f.uvTransform.value.copy(x.matrix))}function l(f,m){f.diffuse.value.copy(m.color),f.opacity.value=m.opacity,f.rotation.value=m.rotation,m.map&&(f.map.value=m.map),m.alphaMap&&(f.alphaMap.value=m.alphaMap),m.alphaTest>0&&(f.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),f.uvTransform.value.copy(v.matrix))}function h(f,m){f.specular.value.copy(m.specular),f.shininess.value=Math.max(m.shininess,1e-4)}function d(f,m){m.gradientMap&&(f.gradientMap.value=m.gradientMap)}function c(f,m){f.roughness.value=m.roughness,f.metalness.value=m.metalness,m.roughnessMap&&(f.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(f.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(f.envMapIntensity.value=m.envMapIntensity)}function u(f,m,v){f.ior.value=m.ior,m.sheen>0&&(f.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),f.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(f.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(f.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(f.clearcoat.value=m.clearcoat,f.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(f.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(f.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),f.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===gi&&f.clearcoatNormalScale.value.negate())),m.iridescence>0&&(f.iridescence.value=m.iridescence,f.iridescenceIOR.value=m.iridescenceIOR,f.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(f.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(f.transmission.value=m.transmission,f.transmissionSamplerMap.value=v.texture,f.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(f.transmissionMap.value=m.transmissionMap),f.thickness.value=m.thickness,m.thicknessMap&&(f.thicknessMap.value=m.thicknessMap),f.attenuationDistance.value=m.attenuationDistance,f.attenuationColor.value.copy(m.attenuationColor)),f.specularIntensity.value=m.specularIntensity,f.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(f.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(f.specularColorMap.value=m.specularColorMap)}function p(f,m){m.matcap&&(f.matcap.value=m.matcap)}function g(f,m){f.referencePosition.value.copy(m.referencePosition),f.nearDistance.value=m.nearDistance,f.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function KD(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let w=x.program;r.uniformBlockBinding(y,w)}function h(y,x){let w=s[y.id];w===void 0&&(g(y),w=d(y),s[y.id]=w,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let S=t.render.frame;n[y.id]!==S&&(u(y),n[y.id]=S)}function d(y){let x=c();y.__bindingPointIndex=x;let w=e.createBuffer(),_=y.__size,S=y.usage;return e.bindBuffer(35345,w),e.bufferData(35345,_,S),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,w),w}function c(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let x=s[y.id],w=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let S=0,A=w.length;S<A;S++){let b=w[S];if(p(b,S,_)===!0){let E=b.__offset,C=Array.isArray(b.value)?b.value:[b.value],T=0;for(let P=0;P<C.length;P++){let L=C[P],D=f(L);typeof L=="number"?(b.__data[0]=L,e.bufferSubData(35345,E+T,b.__data)):L.isMatrix3?(b.__data[0]=L.elements[0],b.__data[1]=L.elements[1],b.__data[2]=L.elements[2],b.__data[3]=L.elements[0],b.__data[4]=L.elements[3],b.__data[5]=L.elements[4],b.__data[6]=L.elements[5],b.__data[7]=L.elements[0],b.__data[8]=L.elements[6],b.__data[9]=L.elements[7],b.__data[10]=L.elements[8],b.__data[11]=L.elements[0]):(L.toArray(b.__data,T),T+=D.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,E,b.__data)}}e.bindBuffer(35345,null)}function p(y,x,w){let _=y.value;if(w[x]===void 0){if(typeof _=="number")w[x]=_;else{let S=Array.isArray(_)?_:[_],A=[];for(let b=0;b<S.length;b++)A.push(S[b].clone());w[x]=A}return!0}else if(typeof _=="number"){if(w[x]!==_)return w[x]=_,!0}else{let S=Array.isArray(w[x])?w[x]:[w[x]],A=Array.isArray(_)?_:[_];for(let b=0;b<S.length;b++){let E=S[b];if(E.equals(A[b])===!1)return E.copy(A[b]),!0}}return!1}function g(y){let x=y.uniforms,w=0,_=16,S=0;for(let A=0,b=x.length;A<b;A++){let E=x[A],C={boundary:0,storage:0},T=Array.isArray(E.value)?E.value:[E.value];for(let P=0,L=T.length;P<L;P++){let D=T[P],j=f(D);C.boundary+=j.boundary,C.storage+=j.storage}if(E.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=w,A>0){S=w%_;let P=_-S;S!==0&&P-C.boundary<0&&(w+=_-S,E.__offset=w)}w+=C.storage}return S=w%_,S>0&&(w+=_-S),y.__size=w,y.__cache={},this}function f(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){let x=y.target;x.removeEventListener("dispose",m);let w=a.indexOf(x.__bindingPointIndex);a.splice(w,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete n[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function JD(){let e=kd("canvas");return e.style.display="block",e}function p_(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:JD(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,n=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,d;i!==null?d=i.getContextAttributes().alpha:d=e.alpha!==void 0?e.alpha:!1;let c=null,u=null,p=[],g=[];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=Rs,this.physicallyCorrectLights=!1,this.toneMapping=dn,this.toneMappingExposure=1;let f=this,m=!1,v=0,y=0,x=null,w=-1,_=null,S=new tt,A=new tt,b=null,E=t.width,C=t.height,T=1,P=null,L=null,D=new tt(0,0,E,C),j=new tt(0,0,E,C),W=!1,q=new Ug,z=!1,V=!1,F=null,N=new me,B=new k,H=new M,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Q(){return x===null?T:1}let U=i;function ne(I,ee){for(let ae=0;ae<I.length;ae++){let J=I[ae],le=t.getContext(J,ee);if(le!==null)return le}return null}try{let I={alpha:!0,depth:r,stencil:s,antialias:n,premultipliedAlpha:a,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${fl}`),t.addEventListener("webglcontextlost",We,!1),t.addEventListener("webglcontextrestored",ze,!1),t.addEventListener("webglcontextcreationerror",dt,!1),U===null){let ee=["webgl2","webgl","experimental-webgl"];if(f.isWebGL1Renderer===!0&&ee.shift(),U=ne(ee,I),U===null)throw ne(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}U.getShaderPrecisionFormat===void 0&&(U.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(I){throw console.error("THREE.WebGLRenderer: "+I.message),I}let G,$,Z,ve,re,oe,ue,be,Oe,_e,Se,Ie,Xe,ct,R,O,ie,fe,ge,Ae,Ye,Me,ce,Te;function Le(){G=new dP(U),$=new nP(U,G,e),G.init($),Me=new qD(U,G,$),Z=new HD(U,G,$),ve=new fP,re=new OD,oe=new WD(U,G,Z,re,$,Me,ve),ue=new oP(f),be=new cP(f),Oe=new SC(U,$),ce=new rP(U,G,Oe,$),_e=new uP(U,Oe,ve,ce),Se=new yP(U,_e,Oe,ve),ge=new vP(U,$,oe),O=new aP(re),Ie=new DD(f,ue,be,G,$,ce,O),Xe=new ZD(f,re),ct=new RD,R=new FD(G,$),fe=new iP(f,ue,be,Z,Se,d,a),ie=new VD(f,Se,$),Te=new KD(U,ve,$,Z),Ae=new sP(U,G,ve,$),Ye=new pP(U,G,ve,$),ve.programs=Ie.programs,f.capabilities=$,f.extensions=G,f.properties=re,f.renderLists=ct,f.shadowMap=ie,f.state=Z,f.info=ve}Le();let Pe=new QD(f,U);this.xr=Pe,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let I=G.get("WEBGL_lose_context");I&&I.loseContext()},this.forceContextRestore=function(){let I=G.get("WEBGL_lose_context");I&&I.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(I){I!==void 0&&(T=I,this.setSize(E,C,!1))},this.getSize=function(I){return I.set(E,C)},this.setSize=function(I,ee,ae){if(Pe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=I,C=ee,t.width=Math.floor(I*T),t.height=Math.floor(ee*T),ae!==!1&&(t.style.width=I+"px",t.style.height=ee+"px"),this.setViewport(0,0,I,ee)},this.getDrawingBufferSize=function(I){return I.set(E*T,C*T).floor()},this.setDrawingBufferSize=function(I,ee,ae){E=I,C=ee,T=ae,t.width=Math.floor(I*ae),t.height=Math.floor(ee*ae),this.setViewport(0,0,I,ee)},this.getCurrentViewport=function(I){return I.copy(S)},this.getViewport=function(I){return I.copy(D)},this.setViewport=function(I,ee,ae,J){I.isVector4?D.set(I.x,I.y,I.z,I.w):D.set(I,ee,ae,J),Z.viewport(S.copy(D).multiplyScalar(T).floor())},this.getScissor=function(I){return I.copy(j)},this.setScissor=function(I,ee,ae,J){I.isVector4?j.set(I.x,I.y,I.z,I.w):j.set(I,ee,ae,J),Z.scissor(A.copy(j).multiplyScalar(T).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(I){Z.setScissorTest(W=I)},this.setOpaqueSort=function(I){P=I},this.setTransparentSort=function(I){L=I},this.getClearColor=function(I){return I.copy(fe.getClearColor())},this.setClearColor=function(){fe.setClearColor.apply(fe,arguments)},this.getClearAlpha=function(){return fe.getClearAlpha()},this.setClearAlpha=function(){fe.setClearAlpha.apply(fe,arguments)},this.clear=function(I=!0,ee=!0,ae=!0){let J=0;I&&(J|=16384),ee&&(J|=256),ae&&(J|=1024),U.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",We,!1),t.removeEventListener("webglcontextrestored",ze,!1),t.removeEventListener("webglcontextcreationerror",dt,!1),ct.dispose(),R.dispose(),re.dispose(),ue.dispose(),be.dispose(),Se.dispose(),ce.dispose(),Te.dispose(),Ie.dispose(),Pe.dispose(),Pe.removeEventListener("sessionstart",xe),Pe.removeEventListener("sessionend",ke),F&&(F.dispose(),F=null),ft.stop()};function We(I){I.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function ze(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let I=ve.autoReset,ee=ie.enabled,ae=ie.autoUpdate,J=ie.needsUpdate,le=ie.type;Le(),ve.autoReset=I,ie.enabled=ee,ie.autoUpdate=ae,ie.needsUpdate=J,ie.type=le}function dt(I){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function Ot(I){let ee=I.target;ee.removeEventListener("dispose",Ot),Kt(ee)}function Kt(I){Y(I),re.remove(I)}function Y(I){let ee=re.get(I).programs;ee!==void 0&&(ee.forEach(function(ae){Ie.releaseProgram(ae)}),I.isShaderMaterial&&Ie.releaseShaderCache(I))}this.renderBufferDirect=function(I,ee,ae,J,le,Re){ee===null&&(ee=X);let $e=le.isMesh&&le.matrixWorld.determinant()<0,nt=DM(I,ee,ae,J,le);Z.setMaterial(J,$e);let lt=ae.index,Ct=1;J.wireframe===!0&&(lt=_e.getWireframeAttribute(ae),Ct=2);let mt=ae.drawRange,ut=ae.attributes.position,Ei=mt.start*Ct,lr=(mt.start+mt.count)*Ct;Re!==null&&(Ei=Math.max(Ei,Re.start*Ct),lr=Math.min(lr,(Re.start+Re.count)*Ct)),lt!==null?(Ei=Math.max(Ei,0),lr=Math.min(lr,lt.count)):ut!=null&&(Ei=Math.max(Ei,0),lr=Math.min(lr,ut.count));let Gs=lr-Ei;if(Gs<0||Gs===1/0)return;ce.setup(le,J,nt,ae,lt);let oa,Jt=Ae;if(lt!==null&&(oa=Oe.get(lt),Jt=Ye,Jt.setIndex(oa)),le.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*Q()),Jt.setMode(1)):Jt.setMode(4);else if(le.isLine){let pt=J.linewidth;pt===void 0&&(pt=1),Z.setLineWidth(pt*Q()),le.isLineSegments?Jt.setMode(1):le.isLineLoop?Jt.setMode(2):Jt.setMode(3)}else le.isPoints?Jt.setMode(0):le.isSprite&&Jt.setMode(4);if(le.isInstancedMesh)Jt.renderInstances(Ei,Gs,le.count);else if(ae.isInstancedBufferGeometry){let pt=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,cp=Math.min(ae.instanceCount,pt);Jt.renderInstances(Ei,Gs,cp)}else Jt.render(Ei,Gs)},this.compile=function(I,ee){function ae(J,le,Re){J.transparent===!0&&J.side===mr&&J.forceSinglePass===!1?(J.side=gi,J.needsUpdate=!0,xr(J,le,Re),J.side=rs,J.needsUpdate=!0,xr(J,le,Re),J.side=mr):xr(J,le,Re)}u=R.get(I),u.init(),g.push(u),I.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(u.pushLight(J),J.castShadow&&u.pushShadow(J))}),u.setupLights(f.physicallyCorrectLights),I.traverse(function(J){let le=J.material;if(le)if(Array.isArray(le))for(let Re=0;Re<le.length;Re++){let $e=le[Re];ae($e,I,J)}else ae(le,I,J)}),g.pop(),u=null};let se=null;function pe(I){se&&se(I)}function xe(){ft.stop()}function ke(){ft.start()}let ft=new o_;ft.setAnimationLoop(pe),typeof self<"u"&&ft.setContext(self),this.setAnimationLoop=function(I){se=I,Pe.setAnimationLoop(I),I===null?ft.stop():ft.start()},Pe.addEventListener("sessionstart",xe),Pe.addEventListener("sessionend",ke),this.render=function(I,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Pe.enabled===!0&&Pe.isPresenting===!0&&(Pe.cameraAutoUpdate===!0&&Pe.updateCamera(ee),ee=Pe.getCamera()),I.isScene===!0&&I.onBeforeRender(f,I,ee,x),u=R.get(I,g.length),u.init(),g.push(u),N.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),q.setFromProjectionMatrix(N),V=this.localClippingEnabled,z=O.init(this.clippingPlanes,V),c=ct.get(I,p.length),c.init(),p.push(c),Ut(I,ee,0,f.sortObjects),c.finish(),f.sortObjects===!0&&c.sort(P,L),z===!0&&O.beginShadows();let ae=u.state.shadowsArray;if(ie.render(ae,I,ee),z===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),fe.render(c,I),u.setupLights(f.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let le=0,Re=J.length;le<Re;le++){let $e=J[le];Mi(c,I,$e,$e.viewport)}}else Mi(c,I,ee);x!==null&&(oe.updateMultisampleRenderTarget(x),oe.updateRenderTargetMipmap(x)),I.isScene===!0&&I.onAfterRender(f,I,ee),ce.resetDefaultState(),w=-1,_=null,g.pop(),g.length>0?u=g[g.length-1]:u=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function Ut(I,ee,ae,J){if(I.visible===!1)return;if(I.layers.test(ee.layers)){if(I.isGroup)ae=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update(ee);else if(I.isLight)u.pushLight(I),I.castShadow&&u.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||q.intersectsSprite(I)){J&&H.setFromMatrixPosition(I.matrixWorld).applyMatrix4(N);let Re=Se.update(I),$e=I.material;$e.visible&&c.push(I,Re,$e,ae,H.z,null)}}else if((I.isMesh||I.isLine||I.isPoints)&&(I.isSkinnedMesh&&I.skeleton.frame!==ve.render.frame&&(I.skeleton.update(),I.skeleton.frame=ve.render.frame),!I.frustumCulled||q.intersectsObject(I))){J&&H.setFromMatrixPosition(I.matrixWorld).applyMatrix4(N);let Re=Se.update(I),$e=I.material;if(Array.isArray($e)){let nt=Re.groups;for(let lt=0,Ct=nt.length;lt<Ct;lt++){let mt=nt[lt],ut=$e[mt.materialIndex];ut&&ut.visible&&c.push(I,Re,ut,ae,H.z,mt)}}else $e.visible&&c.push(I,Re,$e,ae,H.z,null)}}let le=I.children;for(let Re=0,$e=le.length;Re<$e;Re++)Ut(le[Re],ee,ae,J)}function Mi(I,ee,ae,J){let le=I.opaque,Re=I.transmissive,$e=I.transparent;u.setupLightsView(ae),z===!0&&O.setGlobalState(f.clippingPlanes,ae),Re.length>0&&aa(le,ee,ae),J&&Z.viewport(S.copy(J)),le.length>0&&zt(le,ee,ae),Re.length>0&&zt(Re,ee,ae),$e.length>0&&zt($e,ee,ae),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function aa(I,ee,ae){let J=$.isWebGL2;F===null&&(F=new St(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?rl:Bi,minFilter:il,samples:J&&n===!0?4:0})),f.getDrawingBufferSize(B),J?F.setSize(B.x,B.y):F.setSize(Fd(B.x),Fd(B.y));let le=f.getRenderTarget();f.setRenderTarget(F),f.clear();let Re=f.toneMapping;f.toneMapping=dn,zt(I,ee,ae),f.toneMapping=Re,oe.updateMultisampleRenderTarget(F),oe.updateRenderTargetMipmap(F),f.setRenderTarget(le)}function zt(I,ee,ae){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let le=0,Re=I.length;le<Re;le++){let $e=I[le],nt=$e.object,lt=$e.geometry,Ct=J===null?$e.material:J,mt=$e.group;nt.layers.test(ae.layers)&&js(nt,ee,ae,lt,Ct,mt)}}function js(I,ee,ae,J,le,Re){I.onBeforeRender(f,ee,ae,J,le,Re),I.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),le.onBeforeRender(f,ee,ae,J,I,Re),le.transparent===!0&&le.side===mr&&le.forceSinglePass===!1?(le.side=gi,le.needsUpdate=!0,f.renderBufferDirect(ae,ee,J,le,I,Re),le.side=rs,le.needsUpdate=!0,f.renderBufferDirect(ae,ee,J,le,I,Re),le.side=mr):f.renderBufferDirect(ae,ee,J,le,I,Re),I.onAfterRender(f,ee,ae,J,le,Re)}function xr(I,ee,ae){ee.isScene!==!0&&(ee=X);let J=re.get(I),le=u.state.lights,Re=u.state.shadowsArray,$e=le.state.version,nt=Ie.getParameters(I,le.state,Re,ee,ae),lt=Ie.getProgramCacheKey(nt),Ct=J.programs;J.environment=I.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(I.isMeshStandardMaterial?be:ue).get(I.envMap||J.environment),Ct===void 0&&(I.addEventListener("dispose",Ot),Ct=new Map,J.programs=Ct);let mt=Ct.get(lt);if(mt!==void 0){if(J.currentProgram===mt&&J.lightsStateVersion===$e)return _0(I,nt),mt}else nt.uniforms=Ie.getUniforms(I),I.onBuild(ae,nt,f),I.onBeforeCompile(nt,f),mt=Ie.acquireProgram(nt,lt),Ct.set(lt,mt),J.uniforms=nt.uniforms;let ut=J.uniforms;(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)&&(ut.clippingPlanes=O.uniform),_0(I,nt),J.needsLights=LM(I),J.lightsStateVersion=$e,J.needsLights&&(ut.ambientLightColor.value=le.state.ambient,ut.lightProbe.value=le.state.probe,ut.directionalLights.value=le.state.directional,ut.directionalLightShadows.value=le.state.directionalShadow,ut.spotLights.value=le.state.spot,ut.spotLightShadows.value=le.state.spotShadow,ut.rectAreaLights.value=le.state.rectArea,ut.ltc_1.value=le.state.rectAreaLTC1,ut.ltc_2.value=le.state.rectAreaLTC2,ut.pointLights.value=le.state.point,ut.pointLightShadows.value=le.state.pointShadow,ut.hemisphereLights.value=le.state.hemi,ut.directionalShadowMap.value=le.state.directionalShadowMap,ut.directionalShadowMatrix.value=le.state.directionalShadowMatrix,ut.spotShadowMap.value=le.state.spotShadowMap,ut.spotLightMatrix.value=le.state.spotLightMatrix,ut.spotLightMap.value=le.state.spotLightMap,ut.pointShadowMap.value=le.state.pointShadowMap,ut.pointShadowMatrix.value=le.state.pointShadowMatrix);let Ei=mt.getUniforms(),lr=Ed.seqWithValue(Ei.seq,ut);return J.currentProgram=mt,J.uniformsList=lr,mt}function _0(I,ee){let ae=re.get(I);ae.outputEncoding=ee.outputEncoding,ae.instancing=ee.instancing,ae.skinning=ee.skinning,ae.morphTargets=ee.morphTargets,ae.morphNormals=ee.morphNormals,ae.morphColors=ee.morphColors,ae.morphTargetsCount=ee.morphTargetsCount,ae.numClippingPlanes=ee.numClippingPlanes,ae.numIntersection=ee.numClipIntersection,ae.vertexAlphas=ee.vertexAlphas,ae.vertexTangents=ee.vertexTangents,ae.toneMapping=ee.toneMapping}function DM(I,ee,ae,J,le){ee.isScene!==!0&&(ee=X),oe.resetTextureUnits();let Re=ee.fog,$e=J.isMeshStandardMaterial?ee.environment:null,nt=x===null?f.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Rs,lt=(J.isMeshStandardMaterial?be:ue).get(J.envMap||$e),Ct=J.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,mt=!!J.normalMap&&!!ae.attributes.tangent,ut=!!ae.morphAttributes.position,Ei=!!ae.morphAttributes.normal,lr=!!ae.morphAttributes.color,Gs=J.toneMapped?f.toneMapping:dn,oa=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Jt=oa!==void 0?oa.length:0,pt=re.get(J),cp=u.state.lights;if(z===!0&&(V===!0||I!==_)){let hr=I===_&&J.id===w;O.setState(J,I,hr)}let dp=!1;J.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==cp.state.version||pt.outputEncoding!==nt||le.isInstancedMesh&&pt.instancing===!1||!le.isInstancedMesh&&pt.instancing===!0||le.isSkinnedMesh&&pt.skinning===!1||!le.isSkinnedMesh&&pt.skinning===!0||pt.envMap!==lt||J.fog===!0&&pt.fog!==Re||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==O.numPlanes||pt.numIntersection!==O.numIntersection)||pt.vertexAlphas!==Ct||pt.vertexTangents!==mt||pt.morphTargets!==ut||pt.morphNormals!==Ei||pt.morphColors!==lr||pt.toneMapping!==Gs||$.isWebGL2===!0&&pt.morphTargetsCount!==Jt)&&(dp=!0):(dp=!0,pt.__version=J.version);let la=pt.currentProgram;dp===!0&&(la=xr(J,ee,le));let S0=!1,Rl=!1,up=!1,xi=la.getUniforms(),ha=pt.uniforms;if(Z.useProgram(la.program)&&(S0=!0,Rl=!0,up=!0),J.id!==w&&(w=J.id,Rl=!0),S0||_!==I){if(xi.setValue(U,"projectionMatrix",I.projectionMatrix),$.logarithmicDepthBuffer&&xi.setValue(U,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2)),_!==I&&(_=I,Rl=!0,up=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let hr=xi.map.cameraPosition;hr!==void 0&&hr.setValue(U,H.setFromMatrixPosition(I.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&xi.setValue(U,"isOrthographic",I.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||le.isSkinnedMesh)&&xi.setValue(U,"viewMatrix",I.matrixWorldInverse)}if(le.isSkinnedMesh){xi.setOptional(U,le,"bindMatrix"),xi.setOptional(U,le,"bindMatrixInverse");let hr=le.skeleton;hr&&($.floatVertexTextures?(hr.boneTexture===null&&hr.computeBoneTexture(),xi.setValue(U,"boneTexture",hr.boneTexture,oe),xi.setValue(U,"boneTextureSize",hr.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 pp=ae.morphAttributes;if((pp.position!==void 0||pp.normal!==void 0||pp.color!==void 0&&$.isWebGL2===!0)&&ge.update(le,ae,J,la),(Rl||pt.receiveShadow!==le.receiveShadow)&&(pt.receiveShadow=le.receiveShadow,xi.setValue(U,"receiveShadow",le.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(ha.envMap.value=lt,ha.flipEnvMap.value=lt.isCubeTexture&&lt.isRenderTargetTexture===!1?-1:1),Rl&&(xi.setValue(U,"toneMappingExposure",f.toneMappingExposure),pt.needsLights&&OM(ha,up),Re&&J.fog===!0&&Xe.refreshFogUniforms(ha,Re),Xe.refreshMaterialUniforms(ha,J,T,C,F),Ed.upload(U,pt.uniformsList,ha,oe)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Ed.upload(U,pt.uniformsList,ha,oe),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&xi.setValue(U,"center",le.center),xi.setValue(U,"modelViewMatrix",le.modelViewMatrix),xi.setValue(U,"normalMatrix",le.normalMatrix),xi.setValue(U,"modelMatrix",le.matrixWorld),le.previousModelViewMatrix&&xi.setValue(U,"previousModelViewMatrix",le.previousModelViewMatrix),I.previousProjectionMatrix&&xi.setValue(U,"previousProjectionMatrix",I.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let hr=J.uniformsGroups;for(let fp=0,RM=hr.length;fp<RM;fp++)if($.isWebGL2){let A0=hr[fp];Te.update(A0,la),Te.bind(A0,la)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return la}function OM(I,ee){I.ambientLightColor.needsUpdate=ee,I.lightProbe.needsUpdate=ee,I.directionalLights.needsUpdate=ee,I.directionalLightShadows.needsUpdate=ee,I.pointLights.needsUpdate=ee,I.pointLightShadows.needsUpdate=ee,I.spotLights.needsUpdate=ee,I.spotLightShadows.needsUpdate=ee,I.rectAreaLights.needsUpdate=ee,I.hemisphereLights.needsUpdate=ee}function LM(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(I,ee,ae){re.get(I.texture).__webglTexture=ee,re.get(I.depthTexture).__webglTexture=ae;let J=re.get(I);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=ae===void 0,J.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(I,ee){let ae=re.get(I);ae.__webglFramebuffer=ee,ae.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(I,ee=0,ae=0){x=I,v=ee,y=ae;let J=!0,le=null,Re=!1,$e=!1;if(I){let nt=re.get(I);nt.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):nt.__webglFramebuffer===void 0?oe.setupRenderTarget(I):nt.__hasExternalTextures&&oe.rebindTextures(I,re.get(I.texture).__webglTexture,re.get(I.depthTexture).__webglTexture);let lt=I.texture;(lt.isData3DTexture||lt.isDataArrayTexture||lt.isCompressedArrayTexture)&&($e=!0);let Ct=re.get(I).__webglFramebuffer;I.isWebGLCubeRenderTarget?(le=Ct[ee],Re=!0):$.isWebGL2&&I.samples>0&&oe.useMultisampledRTT(I)===!1?le=re.get(I).__webglMultisampledFramebuffer:le=Ct,S.copy(I.viewport),A.copy(I.scissor),b=I.scissorTest}else S.copy(D).multiplyScalar(T).floor(),A.copy(j).multiplyScalar(T).floor(),b=W;if(Z.bindFramebuffer(36160,le)&&$.drawBuffers&&J&&Z.drawBuffers(I,le),Z.viewport(S),Z.scissor(A),Z.setScissorTest(b),Re){let nt=re.get(I.texture);U.framebufferTexture2D(36160,36064,34069+ee,nt.__webglTexture,ae)}else if($e){let nt=re.get(I.texture),lt=ee||0;U.framebufferTextureLayer(36160,36064,nt.__webglTexture,ae||0,lt)}w=-1},this.readRenderTargetPixels=function(I,ee,ae,J,le,Re,$e){if(!(I&&I.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let nt=re.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&$e!==void 0&&(nt=nt[$e]),nt){Z.bindFramebuffer(36160,nt);try{let lt=I.texture,Ct=lt.format,mt=lt.type;if(Ct!==Kr&&Me.convert(Ct)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ut=mt===rl&&(G.has("EXT_color_buffer_half_float")||$.isWebGL2&&G.has("EXT_color_buffer_float"));if(mt!==Bi&&Me.convert(mt)!==U.getParameter(35738)&&!(mt===Or&&($.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!ut){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=I.width-J&&ae>=0&&ae<=I.height-le&&U.readPixels(ee,ae,J,le,Me.convert(Ct),Me.convert(mt),Re)}finally{let lt=x!==null?re.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,lt)}}},this.copyFramebufferToTexture=function(I,ee,ae=0){let J=Math.pow(2,-ae),le=Math.floor(ee.image.width*J),Re=Math.floor(ee.image.height*J);oe.setTexture2D(ee,0),U.copyTexSubImage2D(3553,ae,0,0,I.x,I.y,le,Re),Z.unbindTexture()},this.copyTextureToTexture=function(I,ee,ae,J=0){let le=ee.image.width,Re=ee.image.height,$e=Me.convert(ae.format),nt=Me.convert(ae.type);oe.setTexture2D(ae,0),U.pixelStorei(37440,ae.flipY),U.pixelStorei(37441,ae.premultiplyAlpha),U.pixelStorei(3317,ae.unpackAlignment),ee.isDataTexture?U.texSubImage2D(3553,J,I.x,I.y,le,Re,$e,nt,ee.image.data):ee.isCompressedTexture?U.compressedTexSubImage2D(3553,J,I.x,I.y,ee.mipmaps[0].width,ee.mipmaps[0].height,$e,ee.mipmaps[0].data):U.texSubImage2D(3553,J,I.x,I.y,$e,nt,ee.image),J===0&&ae.generateMipmaps&&U.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(I,ee,ae,J,le=0){if(f.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Re=I.max.x-I.min.x+1,$e=I.max.y-I.min.y+1,nt=I.max.z-I.min.z+1,lt=Me.convert(J.format),Ct=Me.convert(J.type),mt;if(J.isData3DTexture)oe.setTexture3D(J,0),mt=32879;else if(J.isDataArrayTexture)oe.setTexture2DArray(J,0),mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,J.flipY),U.pixelStorei(37441,J.premultiplyAlpha),U.pixelStorei(3317,J.unpackAlignment);let ut=U.getParameter(3314),Ei=U.getParameter(32878),lr=U.getParameter(3316),Gs=U.getParameter(3315),oa=U.getParameter(32877),Jt=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;U.pixelStorei(3314,Jt.width),U.pixelStorei(32878,Jt.height),U.pixelStorei(3316,I.min.x),U.pixelStorei(3315,I.min.y),U.pixelStorei(32877,I.min.z),ae.isDataTexture||ae.isData3DTexture?U.texSubImage3D(mt,le,ee.x,ee.y,ee.z,Re,$e,nt,lt,Ct,Jt.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(mt,le,ee.x,ee.y,ee.z,Re,$e,nt,lt,Jt.data)):U.texSubImage3D(mt,le,ee.x,ee.y,ee.z,Re,$e,nt,lt,Ct,Jt),U.pixelStorei(3314,ut),U.pixelStorei(32878,Ei),U.pixelStorei(3316,lr),U.pixelStorei(3315,Gs),U.pixelStorei(32877,oa),le===0&&J.generateMipmaps&&U.generateMipmap(mt),Z.unbindTexture()},this.initTexture=function(I){I.isCubeTexture?oe.setTextureCube(I,0):I.isData3DTexture?oe.setTexture3D(I,0):I.isDataArrayTexture||I.isCompressedArrayTexture?oe.setTexture2DArray(I,0):oe.setTexture2D(I,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var $D=class extends p_{};$D.prototype.isWebGL1Renderer=!0;var f_=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Fe(e),this.near=t,this.far=i}clone(){return new f_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Ia=class extends Et{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},eO=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=hm,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ds()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ds()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ds()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ni=new M,pm=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ni.fromBufferAttribute(this,t),Ni.applyMatrix4(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ni.fromBufferAttribute(this,t),Ni.applyNormalMatrix(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ni.fromBufferAttribute(this,t),Ni.transformDirection(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}setX(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=hn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=hn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=hn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=hn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array),s=Tt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new qe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new pm(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},fm=class extends ci{constructor(e=null,t=1,i=1,r,s,n,a,o,l=Dt,h=Dt,d,c){super(null,n,a,o,l,h,r,s,d,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tO=class extends qe{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},ta=class extends tc{constructor(e){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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},ky=new M,jy=new M,Gy=new me,Xp=new ml,Nc=new Nr,Gd=class extends Et{constructor(e=new He,t=new ta){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)ky.fromBufferAttribute(t,r-1),jy.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=ky.distanceTo(jy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,n=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Nc.copy(i.boundingSphere),Nc.applyMatrix4(r),Nc.radius+=s,e.ray.intersectsSphere(Nc)===!1)return;Gy.copy(r).invert(),Xp.copy(e.ray).applyMatrix4(Gy);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new M,h=new M,d=new M,c=new M,u=this.isLineSegments?2:1,p=i.index,g=i.attributes.position;if(p!==null){let f=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=f,y=m-1;v<y;v+=u){let x=p.getX(v),w=p.getX(v+1);if(l.fromBufferAttribute(g,x),h.fromBufferAttribute(g,w),Xp.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(c);_<e.near||_>e.far||t.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let f=Math.max(0,n.start),m=Math.min(g.count,n.start+n.count);for(let v=f,y=m-1;v<y;v+=u){if(l.fromBufferAttribute(g,v),h.fromBufferAttribute(g,v+1),Xp.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}},Vy=new M,Hy=new M,ic=class extends Gd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Vy.fromBufferAttribute(t,r),Hy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Vy.distanceTo(Hy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},iO=class extends ci{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isVideoTexture=!0,this.minFilter=n!==void 0?n:et,this.magFilter=s!==void 0?s:et,this.generateMipmaps=!1;let h=this;function d(){h.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Fs=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],d=i[r+1]-h,c=(n-h)/d;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new k:new M);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new M,r=[],s=[],n=[],a=new M,o=new me;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new M)}s[0]=new M,n[0]=new M;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),c<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),n[u]=n[u-1].clone(),a.crossVectors(r[u-1],r[u]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(hi(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(o.makeRotationAxis(a,p))}n[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(hi(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(u=-u);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Iu=class extends Fs{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t){let i=t||new k,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),c=o-this.aX,u=l-this.aY;o=c*h-u*d+this.aX,l=c*d+u*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},rO=class extends Iu{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function kg(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,d,c){let u=(a-n)/h-(o-n)/(h+d)+(o-a)/d,p=(o-a)/d-(l-a)/(d+c)+(l-o)/c;u*=d,p*=d,s(a,o,u,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var Uc=new M,Yp=new kg,Qp=new kg,Zp=new kg,sO=class extends Fs{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new M){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(Uc.subVectors(r[0],r[1]).add(r[0]),l=Uc);let d=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(Uc.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Uc),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),u),g=Math.pow(d.distanceToSquared(c),u),f=Math.pow(c.distanceToSquared(h),u);g<1e-4&&(g=1),p<1e-4&&(p=g),f<1e-4&&(f=g),Yp.initNonuniformCatmullRom(l.x,d.x,c.x,h.x,p,g,f),Qp.initNonuniformCatmullRom(l.y,d.y,c.y,h.y,p,g,f),Zp.initNonuniformCatmullRom(l.z,d.z,c.z,h.z,p,g,f)}else this.curveType==="catmullrom"&&(Yp.initCatmullRom(l.x,d.x,c.x,h.x,this.tension),Qp.initCatmullRom(l.y,d.y,c.y,h.y,this.tension),Zp.initCatmullRom(l.z,d.z,c.z,h.z,this.tension));return i.set(Yp.calc(o),Qp.calc(o),Zp.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new M().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Wy(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function nO(e,t){let i=1-e;return i*i*t}function aO(e,t){return 2*(1-e)*e*t}function oO(e,t){return e*e*t}function Sh(e,t,i,r){return nO(e,t)+aO(e,i)+oO(e,r)}function lO(e,t){let i=1-e;return i*i*i*t}function hO(e,t){let i=1-e;return 3*i*i*e*t}function cO(e,t){return 3*(1-e)*e*e*t}function dO(e,t){return e*e*e*t}function Ah(e,t,i,r,s){return lO(e,t)+hO(e,i)+cO(e,r)+dO(e,s)}var Jr=class extends Fs{constructor(e=new k,t=new k,i=new k,r=new k){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(Ah(e,r.x,s.x,n.x,a.x),Ah(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Cd=class extends Fs{constructor(e=new M,t=new M,i=new M,r=new M){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(Ah(e,r.x,s.x,n.x,a.x),Ah(e,r.y,s.y,n.y,a.y),Ah(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},is=class extends Fs{constructor(e=new k,t=new k){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new k){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new k;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},m_=class extends Fs{constructor(e=new M,t=new M){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new M){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Jn=class extends Fs{constructor(e=new k,t=new k,i=new k){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Sh(e,r.x,s.x,n.x),Sh(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},uO=class extends Fs{constructor(e=new M,t=new M,i=new M){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Sh(e,r.x,s.x,n.x),Sh(e,r.y,s.y,n.y),Sh(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},jg=class extends Fs{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new k){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],d=r[n>r.length-3?r.length-1:n+2];return i.set(Wy(a,o.x,l.x,h.x,d.x),Wy(a,o.y,l.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new k().fromArray(r))}return this}},pO=Object.freeze({__proto__:null,ArcCurve:rO,CatmullRomCurve3:sO,CubicBezierCurve:Jr,CubicBezierCurve3:Cd,EllipseCurve:Iu,LineCurve:is,LineCurve3:m_,QuadraticBezierCurve:Jn,QuadraticBezierCurve3:uO,SplineCurve:jg}),g_=class extends Fs{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new is(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new pO[r.type]().fromJSON(r))}return this}},Vd=class extends g_{constructor(e){super(),this.type="Path",this.currentPoint=new k,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new is(this.currentPoint.clone(),new k(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Jn(this.currentPoint.clone(),new k(e,t),new k(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new Jr(this.currentPoint.clone(),new k(e,t),new k(i,r),new k(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new jg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new Iu(e,t,i,r,s,n,a,o);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},v_=class extends He{constructor(e=[new k(0,-.5),new k(.5,0),new k(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=hi(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,d=new M,c=new k,u=new M,p=new M,g=new M,f=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:f=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-f,u.z=m*0,g.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(g.x,g.y,g.z);break;default:f=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-f,u.z=m*0,p.copy(u),u.x+=g.x,u.y+=g.y,u.z+=g.z,u.normalize(),o.push(u.x,u.y,u.z),g.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),w=Math.cos(y);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*x,d.y=e[_].y,d.z=e[_].x*w,n.push(d.x,d.y,d.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let S=o[3*_+0]*x,A=o[3*_+1],b=o[3*_+0]*w;l.push(S,A,b)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,w=x,_=x+e.length,S=x+e.length+1,A=x+1;s.push(w,_,A),s.push(S,A,_)}this.setIndex(s),this.setAttribute("position",new De(n,3)),this.setAttribute("uv",new De(a,2)),this.setAttribute("normal",new De(l,3))}static fromJSON(e){return new v_(e.points,e.segments,e.phiStart,e.phiLength)}},Gg=class extends He{constructor(e=1,t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],d=[],c=[],u=[],p=0,g=[],f=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function v(){let x=new M,w=new M,_=0,S=(t-e)/i;for(let A=0;A<=s;A++){let b=[],E=A/s,C=E*(t-e)+e;for(let T=0;T<=r;T++){let P=T/r,L=P*o+a,D=Math.sin(L),j=Math.cos(L);w.x=C*D,w.y=-E*i+f,w.z=C*j,d.push(w.x,w.y,w.z),x.set(D,S,j).normalize(),c.push(x.x,x.y,x.z),u.push(P,1-E),b.push(p++)}g.push(b)}for(let A=0;A<r;A++)for(let b=0;b<s;b++){let E=g[b][A],C=g[b+1][A],T=g[b+1][A+1],P=g[b][A+1];h.push(E,C,P),h.push(C,T,P),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let w=p,_=new k,S=new M,A=0,b=x===!0?e:t,E=x===!0?1:-1;for(let T=1;T<=r;T++)d.push(0,f*E,0),c.push(0,E,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let P=T/r*o+a,L=Math.cos(P),D=Math.sin(P);S.x=b*D,S.y=f*E,S.z=b*L,d.push(S.x,S.y,S.z),c.push(0,E,0),_.x=L*.5+.5,_.y=D*.5*E+.5,u.push(_.x,_.y),p++}for(let T=0;T<r;T++){let P=w+T,L=C+T;x===!0?h.push(L,L+1,P):h.push(L+1,L,P),A+=3}l.addGroup(m,A,x===!0?1:2),m+=A}}static fromJSON(e){return new Gg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},y_=class extends Gg{constructor(e=1,t=1,i=32,r=1,s=!1,n=0,a=Math.PI*2){super(0,e,t,i,r,s,n,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:n,thetaLength:a}}static fromJSON(e){return new y_(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Vg=class extends He{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],n=[];a(r),l(i),h(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new M,x=new M,w=new M;for(let _=0;_<t.length;_+=3)u(t[_+0],y),u(t[_+1],x),u(t[_+2],w),o(y,x,w,v)}function o(v,y,x,w){let _=w+1,S=[];for(let A=0;A<=_;A++){S[A]=[];let b=v.clone().lerp(x,A/_),E=y.clone().lerp(x,A/_),C=_-A;for(let T=0;T<=C;T++)T===0&&A===_?S[A][T]=b:S[A][T]=b.clone().lerp(E,T/C)}for(let A=0;A<_;A++)for(let b=0;b<2*(_-A)-1;b++){let E=Math.floor(b/2);b%2===0?(c(S[A][E+1]),c(S[A+1][E]),c(S[A][E])):(c(S[A][E+1]),c(S[A+1][E+1]),c(S[A+1][E]))}}function l(v){let y=new M;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new M;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=f(v)/2/Math.PI+.5,w=m(v)/Math.PI+.5;n.push(x,1-w)}p(),d()}function d(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],w=n[v+4],_=Math.max(y,x,w),S=Math.min(y,x,w);_>.9&&S<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),w<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function u(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new M,y=new M,x=new M,w=new M,_=new k,S=new k,A=new k;for(let b=0,E=0;b<s.length;b+=9,E+=6){v.set(s[b+0],s[b+1],s[b+2]),y.set(s[b+3],s[b+4],s[b+5]),x.set(s[b+6],s[b+7],s[b+8]),_.set(n[E+0],n[E+1]),S.set(n[E+2],n[E+3]),A.set(n[E+4],n[E+5]),w.copy(v).add(y).add(x).divideScalar(3);let C=f(w);g(_,E+0,v,C),g(S,E+2,y,C),g(A,E+4,x,C)}}function g(v,y,x,w){w<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=w/2/Math.PI+.5)}function f(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Vg(e.vertices,e.indices,e.radius,e.details)}},x_=class extends Vg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,n,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new x_(e.radius,e.detail)}},Hd=class extends Vd{constructor(e){super(e),this.uuid=Ds(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Vd().fromJSON(r))}return this}},fO={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=w_(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,d,c,u,p;if(r&&(n=xO(e,t,n,i)),e.length>80*i){o=h=e[0],l=d=e[1];for(let g=i;g<s;g+=i)c=e[g],u=e[g+1],c<o&&(o=c),u<l&&(l=u),c>h&&(h=c),u>d&&(d=u);p=Math.max(h-o,d-l),p=p!==0?32767/p:0}return zh(n,a,i,o,l,p,0),a}};function w_(e,t,i,r,s){let n,a;if(s===DO(e,t,i,r)>0)for(n=t;n<i;n+=r)a=qy(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=qy(n,e[n],e[n+1],a);return a&&Bu(a,a.next)&&(Uh(a),a=a.next),a}function Ga(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Bu(i,i.next)||Ft(i.prev,i,i.next)===0)){if(Uh(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function zh(e,t,i,r,s,n,a){if(!e)return;!a&&n&&AO(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?gO(e,r,s,n):mO(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Uh(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=vO(Ga(e),t,i),zh(e,t,i,r,s,n,2)):a===2&&yO(e,t,i,r,s,n):zh(Ga(e),t,i,r,s,n,1);break}}}function mO(e){let t=e.prev,i=e,r=e.next;if(Ft(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,d=s<n?s<a?s:a:n<a?n:a,c=o<l?o<h?o:h:l<h?l:h,u=s>n?s>a?s:a:n>a?n:a,p=o>l?o>h?o:h:l>h?l:h,g=r.next;for(;g!==t;){if(g.x>=d&&g.x<=u&&g.y>=c&&g.y<=p&&zo(s,o,n,l,a,h,g.x,g.y)&&Ft(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function gO(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Ft(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,d=s.y,c=n.y,u=a.y,p=o<l?o<h?o:h:l<h?l:h,g=d<c?d<u?d:u:c<u?c:u,f=o>l?o>h?o:h:l>h?l:h,m=d>c?d>u?d:u:c>u?c:u,v=mm(p,g,t,i,r),y=mm(f,m,t,i,r),x=e.prevZ,w=e.nextZ;for(;x&&x.z>=v&&w&&w.z<=y;){if(x.x>=p&&x.x<=f&&x.y>=g&&x.y<=m&&x!==s&&x!==a&&zo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=p&&w.x<=f&&w.y>=g&&w.y<=m&&w!==s&&w!==a&&zo(o,d,l,c,h,u,w.x,w.y)&&Ft(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=f&&x.y>=g&&x.y<=m&&x!==s&&x!==a&&zo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=y;){if(w.x>=p&&w.x<=f&&w.y>=g&&w.y<=m&&w!==s&&w!==a&&zo(o,d,l,c,h,u,w.x,w.y)&&Ft(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function vO(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!Bu(s,n)&&b_(s,r,r.next,n)&&Nh(s,n)&&Nh(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),Uh(r),Uh(r.next),r=e=n),r=r.next}while(r!==e);return Ga(r)}function yO(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&CO(a,o)){let l=__(a,o);a=Ga(a,a.next),l=Ga(l,l.next),zh(a,t,i,r,s,n,0),zh(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function xO(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=w_(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(EO(h));for(s.sort(wO),n=0;n<s.length;n++)i=bO(s[n],i);return i}function wO(e,t){return e.x-t.x}function bO(e,t){let i=_O(e,t);if(!i)return t;let r=__(i,e);return Ga(r,r.next),Ga(i,i.next)}function _O(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let u=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=n&&u>r&&(r=u,s=i.x<i.next.x?i:i.next,u===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,d=1/0,c;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&zo(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(c=Math.abs(a-i.y)/(n-i.x),Nh(i,e)&&(c<d||c===d&&(i.x>s.x||i.x===s.x&&SO(s,i)))&&(s=i,d=c)),i=i.next;while(i!==o);return s}function SO(e,t){return Ft(e.prev,e,t.prev)<0&&Ft(t.next,e,e.next)<0}function AO(e,t,i,r){let s=e;do s.z===0&&(s.z=mm(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,MO(s)}function MO(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function mm(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function EO(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function zo(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function CO(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!TO(e,t)&&(Nh(e,t)&&Nh(t,e)&&PO(e,t)&&(Ft(e.prev,e,t.prev)||Ft(e,t.prev,t))||Bu(e,t)&&Ft(e.prev,e,e.next)>0&&Ft(t.prev,t,t.next)>0)}function Ft(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Bu(e,t){return e.x===t.x&&e.y===t.y}function b_(e,t,i,r){let s=kc(Ft(e,t,i)),n=kc(Ft(e,t,r)),a=kc(Ft(i,r,e)),o=kc(Ft(i,r,t));return!!(s!==n&&a!==o||s===0&&Fc(e,i,t)||n===0&&Fc(e,r,t)||a===0&&Fc(i,e,r)||o===0&&Fc(i,t,r))}function Fc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function kc(e){return e>0?1:e<0?-1:0}function TO(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&b_(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Nh(e,t){return Ft(e.prev,e,e.next)<0?Ft(e,t,e.next)>=0&&Ft(e,e.prev,t)>=0:Ft(e,t,e.prev)<0||Ft(e,e.next,t)<0}function PO(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function __(e,t){let i=new gm(e.i,e.x,e.y),r=new gm(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function qy(e,t,i,r){let s=new gm(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Uh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function gm(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function DO(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var S_=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return S_.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Xy(e),Yy(i,e);let n=e.length;t.forEach(Xy);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,Yy(i,t[o]);let a=fO.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function Xy(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Yy(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var A_=class extends Vg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new A_(e.radius,e.detail)}},Hg=class extends He{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:n,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(n+a,Math.PI),l=0,h=[],d=new M,c=new M,u=[],p=[],g=[],f=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&n==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let w=0;w<=t;w++){let _=w/t;d.x=-e*Math.cos(r+_*s)*Math.sin(n+y*a),d.y=e*Math.cos(n+y*a),d.z=e*Math.sin(r+_*s)*Math.sin(n+y*a),p.push(d.x,d.y,d.z),c.copy(d).normalize(),g.push(c.x,c.y,c.z),f.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],w=h[m+1][v],_=h[m+1][v+1];(m!==0||n>0)&&u.push(y,x,_),(m!==i-1||o<Math.PI)&&u.push(x,w,_)}this.setIndex(u),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(g,3)),this.setAttribute("uv",new De(f,2))}static fromJSON(e){return new Hg(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},M_=class extends He{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:n},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],h=[],d=new M,c=new M,u=new M,p=new M,g=new M,f=new M,m=new M;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,n,e,u),v(x+.01,s,n,e,p),f.subVectors(p,u),m.addVectors(p,u),g.crossVectors(f,m),m.crossVectors(g,f),g.normalize(),m.normalize();for(let w=0;w<=r;++w){let _=w/r*Math.PI*2,S=-t*Math.cos(_),A=t*Math.sin(_);d.x=u.x+(S*m.x+A*g.x),d.y=u.y+(S*m.y+A*g.y),d.z=u.z+(S*m.z+A*g.z),o.push(d.x,d.y,d.z),c.subVectors(d,u).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(w/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let w=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),S=(r+1)*y+x,A=(r+1)*(y-1)+x;a.push(w,_,A),a.push(_,S,A)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(h,2));function v(y,x,w,_,S){let A=Math.cos(y),b=Math.sin(y),E=w/x*y,C=Math.cos(E);S.x=_*(2+C)*.5*A,S.y=_*(2+C)*b*.5,S.z=_*Math.sin(E)*.5}}static fromJSON(e){return new M_(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Mn(e,t,i){return E_(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function jc(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function E_(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var zu=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];i:{e:{let n;t:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break e}n=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break e}n=i,i=0;break t}break i}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},OO=class extends zu{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ry,endingEnd:ry}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case sy:s=e,a=2*t-i;break;case ny:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case sy:n=e,o=2*i-t;break;case ny:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,d=this._offsetNext,c=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),g=p*p,f=g*p,m=-c*f+2*c*g-c*p,v=(1+c)*f+(-1.5-2*c)*g+(-.5+c)*p+1,y=(-1-u)*f+(1.5+u)*g+.5*p,x=u*f-u*g;for(let w=0;w!==a;++w)s[w]=m*n[h+w]+v*n[l+w]+y*n[o+w]+x*n[d+w];return s}},LO=class extends zu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),d=1-h;for(let c=0;c!==a;++c)s[c]=n[l+c]*d+n[o+c]*h;return s}},RO=class extends zu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},vn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=jc(t,this.TimeBufferType),this.values=jc(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:jc(e.times,Array),values:jc(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new RO(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new LO(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new OO(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case zd:t=this.InterpolantFactoryMethodDiscrete;break;case Nd:t=this.InterpolantFactoryMethodLinear;break;case bp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return zd;case this.InterpolantFactoryMethodLinear:return Nd;case this.InterpolantFactoryMethodSmooth:return bp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=Mn(i,s,n),this.values=Mn(this.values,s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&E_(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=Mn(this.times),t=Mn(this.values),i=this.getValueSize(),r=this.getInterpolation()===bp,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let d=a*i,c=d-i,u=d+i;for(let p=0;p!==i;++p){let g=t[d+p];if(g!==t[c+p]||g!==t[u+p]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let d=a*i,c=n*i;for(let u=0;u!==i;++u)t[c+u]=t[d+u]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=Mn(e,0,n),this.values=Mn(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=Mn(this.times,0),t=Mn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=Nd;var rc=class extends vn{};rc.prototype.ValueTypeName="bool";rc.prototype.ValueBufferType=Array;rc.prototype.DefaultInterpolation=zd;rc.prototype.InterpolantFactoryMethodLinear=void 0;rc.prototype.InterpolantFactoryMethodSmooth=void 0;var IO=class extends vn{};IO.prototype.ValueTypeName="color";var BO=class extends vn{};BO.prototype.ValueTypeName="number";var zO=class extends zu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)rt.slerpFlat(s,0,n,l-a,n,l,o);return s}},Wg=class extends vn{InterpolantFactoryMethodLinear(e){return new zO(this.times,this.values,this.getValueSize(),e)}};Wg.prototype.ValueTypeName="quaternion";Wg.prototype.DefaultInterpolation=Nd;Wg.prototype.InterpolantFactoryMethodSmooth=void 0;var sc=class extends vn{};sc.prototype.ValueTypeName="string";sc.prototype.ValueBufferType=Array;sc.prototype.DefaultInterpolation=zd;sc.prototype.InterpolantFactoryMethodLinear=void 0;sc.prototype.InterpolantFactoryMethodSmooth=void 0;var NO=class extends vn{};NO.prototype.ValueTypeName="vector";var Qy={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},C_=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,c=l.length;d<c;d+=2){let u=l[d],p=l[d+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},UO=new C_,qg=class{constructor(e){this.manager=e!==void 0?e:UO,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Ys={},FO=class extends Error{constructor(e,t){super(e),this.response=t}},vm=class extends qg{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=Qy.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ys[e]!==void 0){Ys[e].push({onLoad:t,onProgress:i,onError:r});return}Ys[e]=[],Ys[e].push({onLoad:t,onProgress:i,onError:r});let n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Ys[e],d=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=c?parseInt(c):0,p=u!==0,g=0,f=new ReadableStream({start(m){v();function v(){d.read().then(({done:y,value:x})=>{if(y)m.close();else{g+=x.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:g,total:u});for(let _=0,S=h.length;_<S;_++){let A=h[_];A.onProgress&&A.onProgress(w)}m.enqueue(x),v()}})}}});return new Response(f)}else throw new FO(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(d);return l.arrayBuffer().then(u=>c.decode(u))}}}).then(l=>{Qy.add(e,l);let h=Ys[e];delete Ys[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=Ys[e];if(h===void 0)throw this.manager.itemError(e),l;delete Ys[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onError&&u.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},nc=class extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Fe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},kO=class extends nc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Fe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Kp=new me,Zy=new M,Ky=new M,Xg=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new me,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ug,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;Zy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Zy),Ky.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ky),t.updateMatrixWorld(),Kp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Kp),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Kp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},jO=class extends Xg{constructor(){super(new Li(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Bh*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},GO=class extends nc{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new jO}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Jy=new me,Vl=new M,Jp=new M,VO=class extends Xg{constructor(){super(new Li(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new tt(2,1,1,1),new tt(0,1,1,1),new tt(3,1,1,1),new tt(1,1,1,1),new tt(3,0,1,1),new tt(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Vl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Vl),Jp.copy(i.position),Jp.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Jp),i.updateMatrixWorld(),r.makeTranslation(-Vl.x,-Vl.y,-Vl.z),Jy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Jy)}},HO=class extends nc{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new VO}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},WO=class extends Xg{constructor(){super(new jd(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},qO=class extends nc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new WO}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},XO=class extends He{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},T_=class extends qg{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new vm(s.manager);n.setPath(s.path),n.setRequestHeader(s.requestHeader),n.setWithCredentials(s.withCredentials),n.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,u){if(t[u]!==void 0)return t[u];let p=c.interleavedBuffers[u],g=s(c,p.buffer),f=yc(p.type,g),m=new eO(f,p.stride);return m.uuid=p.uuid,t[u]=m,m}function s(c,u){if(i[u]!==void 0)return i[u];let p=c.arrayBuffers[u],g=new Uint32Array(p).buffer;return i[u]=g,g}let n=e.isInstancedBufferGeometry?new XO:new He,a=e.data.index;if(a!==void 0){let c=yc(a.type,a.array);n.setIndex(new qe(c,1))}let o=e.data.attributes;for(let c in o){let u=o[c],p;if(u.isInterleavedBufferAttribute){let g=r(e.data,u.data);p=new pm(g,u.itemSize,u.offset,u.normalized)}else{let g=yc(u.type,u.array),f=u.isInstancedBufferAttribute?tO:qe;p=new f(g,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),n.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let u=l[c],p=[];for(let g=0,f=u.length;g<f;g++){let m=u[g],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new pm(y,m.itemSize,m.offset,m.normalized)}else{let y=yc(m.type,m.array);v=new qe(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),p.push(v)}n.morphAttributes[c]=p}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,u=h.length;c!==u;++c){let p=h[c];n.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let c=new M;d.center!==void 0&&c.fromArray(d.center),n.boundingSphere=new Nr(c,d.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},YO=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=$y(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=$y();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function $y(){return(typeof performance>"u"?Date:performance).now()}var Yg="\\[\\]\\.:\\/",QO=new RegExp("["+Yg+"]","g"),Qg="[^"+Yg+"]",ZO="[^"+Yg.replace("\\.","")+"]",KO=/((?:WC+[\/:])*)/.source.replace("WC",Qg),JO=/(WCOD+)?/.source.replace("WCOD",ZO),$O=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qg),eL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qg),tL=new RegExp("^"+KO+JO+$O+eL+"$"),iL=["material","materials","bones","map"],rL=class{constructor(e,t,i){let r=i||Pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Pt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Pt.parseTrackName(t),this.node=Pt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Pt.Composite(e,t,i):new Pt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(QO,"")}static parseTrackName(e){let t=tL.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);iL.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let n=0;n<s.length;n++){let a=s[n];if(a.name===t||a.uuid===t)return a;let o=i(a.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Pt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let n=e[r];if(n===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=s}else n.fromArray!==void 0&&n.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Pt.Composite=rL;Pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Pt.prototype.GetterByBindingType=[Pt.prototype._getValue_direct,Pt.prototype._getValue_array,Pt.prototype._getValue_arrayElement,Pt.prototype._getValue_toArray];Pt.prototype.SetterByBindingTypeAndVersioning=[[Pt.prototype._setValue_direct,Pt.prototype._setValue_direct_setNeedsUpdate,Pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_array,Pt.prototype._setValue_array_setNeedsUpdate,Pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_arrayElement,Pt.prototype._setValue_arrayElement_setNeedsUpdate,Pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_fromArray,Pt.prototype._setValue_fromArray_setNeedsUpdate,Pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var dW=new Float32Array(1),de=class{constructor(e){this.value=e}clone(){return new de(this.value.clone===void 0?this.value:this.value.clone())}},P_=class{constructor(e,t,i=0,r=1/0){this.ray=new ml(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new zg,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return ym(e,this,i,t),i.sort(e1),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)ym(e[r],this,i,t);return i.sort(e1),i}};function e1(e,t){return e.distance-t.distance}function ym(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let n=0,a=s.length;n<a;n++)ym(s[n],t,i,!0)}}var t1=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(hi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},i1=new k,sL=class{constructor(e=new k(1/0,1/0),t=new k(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=i1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return i1.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},r1=new M,Gc=new M,Rr=class{constructor(e=new M,t=new M){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){r1.subVectors(e,this.start),Gc.subVectors(this.end,this.start);let i=Gc.dot(Gc),r=Gc.dot(r1)/i;return t&&(r=hi(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},s1=new M,nL=class extends Et{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new He,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let n=0,a=1,o=32;n<o;n++,a++){let l=n/o*Math.PI*2,h=a/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new De(r,3));let s=new ta({fog:!1,toneMapped:!1});this.cone=new ic(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),s1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(s1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},aL=class extends tr{constructor(e,t,i){let r=new Hg(t,4,2),s=new gl({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},n1=new M,Vc=new M,a1=new M,oL=class extends Et{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new He;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new ta({fog:!1,toneMapped:!1});this.lightPlane=new Gd(r,s),this.add(this.lightPlane),r=new He,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Gd(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),n1.setFromMatrixPosition(this.light.matrixWorld),Vc.setFromMatrixPosition(this.light.target.matrixWorld),a1.subVectors(Vc,n1),this.lightPlane.lookAt(Vc),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(Vc),this.targetLine.scale.z=a1.length()}},Hc=new M,kt=new yl,Wd=class extends ic{constructor(e){let t=new He,i=new ta({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,g){o(p),o(g)}function o(p){r.push(0,0,0),s.push(0,0,0),n[p]===void 0&&(n[p]=[]),n[p].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();let l=new Fe(16755200),h=new Fe(16711680),d=new Fe(43775),c=new Fe(16777215),u=new Fe(3355443);this.setColors(l,h,d,c,u)}setColors(e,t,i,r,s){let n=this.geometry.getAttribute("color");n.setXYZ(0,e.r,e.g,e.b),n.setXYZ(1,e.r,e.g,e.b),n.setXYZ(2,e.r,e.g,e.b),n.setXYZ(3,e.r,e.g,e.b),n.setXYZ(4,e.r,e.g,e.b),n.setXYZ(5,e.r,e.g,e.b),n.setXYZ(6,e.r,e.g,e.b),n.setXYZ(7,e.r,e.g,e.b),n.setXYZ(8,e.r,e.g,e.b),n.setXYZ(9,e.r,e.g,e.b),n.setXYZ(10,e.r,e.g,e.b),n.setXYZ(11,e.r,e.g,e.b),n.setXYZ(12,e.r,e.g,e.b),n.setXYZ(13,e.r,e.g,e.b),n.setXYZ(14,e.r,e.g,e.b),n.setXYZ(15,e.r,e.g,e.b),n.setXYZ(16,e.r,e.g,e.b),n.setXYZ(17,e.r,e.g,e.b),n.setXYZ(18,e.r,e.g,e.b),n.setXYZ(19,e.r,e.g,e.b),n.setXYZ(20,e.r,e.g,e.b),n.setXYZ(21,e.r,e.g,e.b),n.setXYZ(22,e.r,e.g,e.b),n.setXYZ(23,e.r,e.g,e.b),n.setXYZ(24,t.r,t.g,t.b),n.setXYZ(25,t.r,t.g,t.b),n.setXYZ(26,t.r,t.g,t.b),n.setXYZ(27,t.r,t.g,t.b),n.setXYZ(28,t.r,t.g,t.b),n.setXYZ(29,t.r,t.g,t.b),n.setXYZ(30,t.r,t.g,t.b),n.setXYZ(31,t.r,t.g,t.b),n.setXYZ(32,i.r,i.g,i.b),n.setXYZ(33,i.r,i.g,i.b),n.setXYZ(34,i.r,i.g,i.b),n.setXYZ(35,i.r,i.g,i.b),n.setXYZ(36,i.r,i.g,i.b),n.setXYZ(37,i.r,i.g,i.b),n.setXYZ(38,r.r,r.g,r.b),n.setXYZ(39,r.r,r.g,r.b),n.setXYZ(40,s.r,s.g,s.b),n.setXYZ(41,s.r,s.g,s.b),n.setXYZ(42,s.r,s.g,s.b),n.setXYZ(43,s.r,s.g,s.b),n.setXYZ(44,s.r,s.g,s.b),n.setXYZ(45,s.r,s.g,s.b),n.setXYZ(46,s.r,s.g,s.b),n.setXYZ(47,s.r,s.g,s.b),n.setXYZ(48,s.r,s.g,s.b),n.setXYZ(49,s.r,s.g,s.b),n.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Ht("c",t,e,kt,0,0,-1),Ht("t",t,e,kt,0,0,1),Ht("n1",t,e,kt,-i,-r,-1),Ht("n2",t,e,kt,i,-r,-1),Ht("n3",t,e,kt,-i,r,-1),Ht("n4",t,e,kt,i,r,-1),Ht("f1",t,e,kt,-i,-r,1),Ht("f2",t,e,kt,i,-r,1),Ht("f3",t,e,kt,-i,r,1),Ht("f4",t,e,kt,i,r,1),Ht("u1",t,e,kt,i*.7,r*1.1,-1),Ht("u2",t,e,kt,-i*.7,r*1.1,-1),Ht("u3",t,e,kt,0,r*2,-1),Ht("cf1",t,e,kt,-i,0,1),Ht("cf2",t,e,kt,i,0,1),Ht("cf3",t,e,kt,0,-r,1),Ht("cf4",t,e,kt,0,r,1),Ht("cn1",t,e,kt,-i,0,-1),Ht("cn2",t,e,kt,i,0,-1),Ht("cn3",t,e,kt,0,-r,-1),Ht("cn4",t,e,kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ht(e,t,i,r,s,n,a){Hc.set(s,n,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,d=o.length;h<d;h++)l.setXYZ(o[h],Hc.x,Hc.y,Hc.z)}}var qd=class extends ic{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new He;s.setIndex(new qe(i,1)),s.setAttribute("position",new De(r,3)),super(s,new ta({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},lL=class extends ic{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new He;r.setAttribute("position",new De(t,3)),r.setAttribute("color",new De(i,3));let s=new ta({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Fe,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:fl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=fl);var Hl=".",Zg=Symbol("target"),D_=Symbol("unsubscribe");function xm(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function hL(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var As=Array.isArray;function Kg(e){return typeof e=="symbol"}var cL={after:(e,t)=>As(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>As(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Hl),Kg(t)?e+t.toString():e+t):e,initial:e=>{if(As(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Hl);return t===-1?"":e.slice(0,t)},last:e=>{if(As(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Hl);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(As(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Hl);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(Hl,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Cr=cL;function dL(e){return typeof e=="object"&&typeof e.next=="function"}function uL(e,t,i,r,s){let n=e.next;if(t.name==="entries")e.next=function(){let a=n.call(this);return a.done===!1&&(a.value[0]=s(a.value[0],t,a.value[0],r),a.value[1]=s(a.value[1],t,a.value[0],r)),a};else if(t.name==="values"){let a=i[Zg].keys();e.next=function(){let o=n.call(this);return o.done===!1&&(o.value=s(o.value,t,a.next().value,r)),o}}else e.next=function(){let a=n.call(this);return a.done===!1&&(a.value=s(a.value,t,a.value,r)),a};return e}function o1(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Kg(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var pL=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],n=s||e;this._pathCache.set(n,t);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(e,i):e,this._proxyCache.set(n,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Cr.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&"set"in n?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function wm(e){return toString.call(e)==="[object Object]"}function Wc(){return!0}function go(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var O_=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),fL=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),L_={push:Wc,pop:Wc,shift:Wc,unshift:Wc,copyWithin:go,reverse:go,sort:go,splice:go,flat:go,fill:go},mL=new Set([...O_,...fL,...Object.keys(L_)]);function qc(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var R_=["keys","values","entries"],I_=new Set(["has","toString"]),B_={add:qc,clear:qc,delete:qc,forEach:qc},gL=new Set([...I_,...Object.keys(B_),...R_]);function Xc(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var vL=new Set([...I_,"get"]),z_={set:Xc,clear:Xc,delete:Xc,forEach:Xc},yL=new Set([...vL,...Object.keys(z_),...R_]),$n=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return O_.has(e)}_shallowClone(e){let t=e;if(wm(e))t={...e};else if(As(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(As(r)?this._onIsChanged=L_[t]:r instanceof Set?this._onIsChanged=B_[t]:r instanceof Map&&(this._onIsChanged=z_[t]),r):i}update(e,t,i){let r=Cr.after(e,this._path);if(t!=="length"){let s=this.clone;Cr.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],Cr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},l1=class extends $n{static isHandledMethod(e){return mL.has(e)}},xL=class extends $n{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},h1=class extends $n{static isHandledMethod(e){return gL.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},c1=class extends $n{static isHandledMethod(e){return yL.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},wL=class extends $n{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},bL=class extends $n{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Do=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return wm(e)||As(e)||xm(e)}static isHandledMethod(e,t){return wm(e)?$n.isHandledMethod(t):As(e)?l1.isHandledMethod(t):e instanceof Set?h1.isHandledMethod(t):e instanceof Map?c1.isHandledMethod(t):xm(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=$n;As(e)?r=l1:e instanceof Date?r=xL:e instanceof Set?r=h1:e instanceof Map?r=c1:e instanceof WeakSet?r=wL:e instanceof WeakMap&&(r=bL),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=Do.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},_L={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Jg=(e,t,i={})=>{i={..._L,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new pL(s),h=typeof i.onValidate=="function",d=new Do(h),c=(y,x,w,_,S)=>!h||d.isCloning||i.onValidate(Cr.concat(l.getPath(y),x),w,_,S)===!0,u=(y,x,w,_)=>{!o1(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,w,_)},p=(y,x,w,_,S)=>{d.isCloning?d.update(y,x,_):t(Cr.concat(y,x),w,_,S)},g=y=>y&&(y[r]||y),f=(y,x,w,_)=>hL(y)||w==="constructor"||n&&!Do.isHandledMethod(x,w)||o1(l,i,w)||l.isGetInvariant(x,w)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,Cr.concat(_,w),m,r)),m={get(y,x,w){if(Kg(x)){if(x===r||x===Zg)return y;if(x===D_&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=xm(y)?Reflect.get(y,x):Reflect.get(y,x,w);return f(_,y,x)},set(y,x,w,_){w=g(w);let S=y[r]||y,A=S[x];if(s(A,w)&&x in y)return!0;let b=c(y,x,w,A);return b&&l.setProperty(S,x,w,_,A)?(u(y,x,y[x],A),!0):!b},defineProperty(y,x,w){if(!l.isSameDescriptor(w,y,x)){let _=y[x];c(y,x,w.value,_)&&l.defineProperty(y,x,w,_)&&u(y,x,w.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let w=Reflect.get(y,x),_=c(y,x,void 0,w);return _&&l.deleteProperty(y,x,w)?(u(y,x,void 0,w),!0):!_},apply(y,x,w){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,w);if((o===!1||o!==!0&&!o.includes(y.name))&&Do.isHandledType(_)){let S=Cr.initial(l.getPath(y)),A=Do.isHandledMethod(_,y.name);d.start(_,S,w);let b=Reflect.apply(y,d.preferredThisArg(y,x,_),A?w.map(T=>g(T)):w),E=d.isChanged(_,s),C=d.stop();if(Do.isHandledType(b)&&A&&(x instanceof Map&&y.name==="get"&&(S=Cr.concat(S,w[0])),b=l.getProxy(b,S,m)),E){let T={name:y.name,args:w,result:b},P=d.isCloning?Cr.initial(S):S,L=d.isCloning?Cr.last(S):"";c(Cr.get(e,P),L,_,C,T)?p(P,L,_,C,T):d.undo(_)}return(x instanceof Map||x instanceof Set)&&dL(b)?uL(b,y,x,S,f):b}return Reflect.apply(y,x,w)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};Jg.target=e=>e&&e[Zg]||e;Jg.unsubscribe=e=>e[D_]||e;var d1=Jg,SL=typeof global=="object"&&global&&global.Object===Object&&global,N_=SL,AL=typeof self=="object"&&self&&self.Object===Object&&self,ML=N_||AL||Function("return this")(),as=ML,EL=as.Symbol,Ur=EL,U_=Object.prototype,CL=U_.hasOwnProperty,TL=U_.toString,Wl=Ur?Ur.toStringTag:void 0;function PL(e){var t=CL.call(e,Wl),i=e[Wl];try{e[Wl]=void 0;var r=!0}catch{}var s=TL.call(e);return r&&(t?e[Wl]=i:delete e[Wl]),s}var DL=PL,OL=Object.prototype,LL=OL.toString;function RL(e){return LL.call(e)}var IL=RL,BL="[object Null]",zL="[object Undefined]",u1=Ur?Ur.toStringTag:void 0;function NL(e){return e==null?e===void 0?zL:BL:u1&&u1 in Object(e)?DL(e):IL(e)}var qa=NL;function UL(e){return e!=null&&typeof e=="object"}var fn=UL,FL="[object Symbol]";function kL(e){return typeof e=="symbol"||fn(e)&&qa(e)==FL}var Nu=kL;function jL(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var F_=jL,GL=Array.isArray,Bs=GL,VL=1/0,p1=Ur?Ur.prototype:void 0,f1=p1?p1.toString:void 0;function k_(e){if(typeof e=="string")return e;if(Bs(e))return F_(e,k_)+"";if(Nu(e))return f1?f1.call(e):"";var t=e+"";return t=="0"&&1/e==-VL?"-0":t}var HL=k_,WL=/\s/;function qL(e){for(var t=e.length;t--&&WL.test(e.charAt(t)););return t}var XL=qL,YL=/^\s+/;function QL(e){return e&&e.slice(0,XL(e)+1).replace(YL,"")}var ZL=QL;function KL(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ss=KL,m1=0/0,JL=/^[-+]0x[0-9a-f]+$/i,$L=/^0b[01]+$/i,e4=/^0o[0-7]+$/i,t4=parseInt;function i4(e){if(typeof e=="number")return e;if(Nu(e))return m1;if(ss(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ss(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=ZL(e);var i=$L.test(e);return i||e4.test(e)?t4(e.slice(2),i?2:8):JL.test(e)?m1:+e}var g1=i4;function r4(e){return e}var s4=r4,n4="[object AsyncFunction]",a4="[object Function]",o4="[object GeneratorFunction]",l4="[object Proxy]";function h4(e){if(!ss(e))return!1;var t=qa(e);return t==a4||t==o4||t==n4||t==l4}var j_=h4,c4=as["__core-js_shared__"],$p=c4,v1=function(){var e=/[^.]+$/.exec($p&&$p.keys&&$p.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function d4(e){return!!v1&&v1 in e}var u4=d4,p4=Function.prototype,f4=p4.toString;function m4(e){if(e!=null){try{return f4.call(e)}catch{}try{return e+""}catch{}}return""}var Xa=m4,g4=/[\\^$.*+?()[\]{}|]/g,v4=/^\[object .+?Constructor\]$/,y4=Function.prototype,x4=Object.prototype,w4=y4.toString,b4=x4.hasOwnProperty,_4=RegExp("^"+w4.call(b4).replace(g4,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function S4(e){if(!ss(e)||u4(e))return!1;var t=j_(e)?_4:v4;return t.test(Xa(e))}var A4=S4;function M4(e,t){return e?.[t]}var E4=M4;function C4(e,t){var i=E4(e,t);return A4(i)?i:void 0}var Ya=C4,T4=Ya(as,"WeakMap"),bm=T4,y1=Object.create,P4=function(){function e(){}return function(t){if(!ss(t))return{};if(y1)return y1(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),D4=P4;function O4(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var L4=O4;function R4(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var I4=R4,B4=800,z4=16,N4=Date.now;function U4(e){var t=0,i=0;return function(){var r=N4(),s=z4-(r-i);if(i=r,s>0){if(++t>=B4)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var F4=U4;function k4(e){return function(){return e}}var j4=k4,G4=function(){try{var e=Ya(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Xd=G4,V4=Xd?function(e,t){return Xd(e,"toString",{configurable:!0,enumerable:!1,value:j4(t),writable:!0})}:s4,H4=V4,W4=F4(H4),q4=W4;function X4(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var Y4=X4,Q4=9007199254740991,Z4=/^(?:0|[1-9]\d*)$/;function K4(e,t){var i=typeof e;return t=t??Q4,!!t&&(i=="number"||i!="symbol"&&Z4.test(e))&&e>-1&&e%1==0&&e<t}var $g=K4;function J4(e,t,i){t=="__proto__"&&Xd?Xd(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var G_=J4;function $4(e,t){return e===t||e!==e&&t!==t}var ev=$4,eR=Object.prototype,tR=eR.hasOwnProperty;function iR(e,t,i){var r=e[t];(!(tR.call(e,t)&&ev(r,i))||i===void 0&&!(t in e))&&G_(e,t,i)}var tv=iR;function rR(e,t,i,r){var s=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?G_(i,o,l):tv(i,o,l)}return i}var ac=rR,x1=Math.max;function sR(e,t,i){return t=x1(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=x1(r.length-t,0),a=Array(n);++s<n;)a[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(a),L4(e,this,o)}}var nR=sR,aR=9007199254740991;function oR(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=aR}var iv=oR;function lR(e){return e!=null&&iv(e.length)&&!j_(e)}var V_=lR,hR=Object.prototype;function cR(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||hR;return e===i}var rv=cR;function dR(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var uR=dR,pR="[object Arguments]";function fR(e){return fn(e)&&qa(e)==pR}var w1=fR,H_=Object.prototype,mR=H_.hasOwnProperty,gR=H_.propertyIsEnumerable,vR=w1(function(){return arguments}())?w1:function(e){return fn(e)&&mR.call(e,"callee")&&!gR.call(e,"callee")},sv=vR;function yR(){return!1}var xR=yR,W_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,b1=W_&&typeof module=="object"&&module&&!module.nodeType&&module,wR=b1&&b1.exports===W_,_1=wR?as.Buffer:void 0,bR=_1?_1.isBuffer:void 0,_R=bR||xR,Yd=_R,SR="[object Arguments]",AR="[object Array]",MR="[object Boolean]",ER="[object Date]",CR="[object Error]",TR="[object Function]",PR="[object Map]",DR="[object Number]",OR="[object Object]",LR="[object RegExp]",RR="[object Set]",IR="[object String]",BR="[object WeakMap]",zR="[object ArrayBuffer]",NR="[object DataView]",UR="[object Float32Array]",FR="[object Float64Array]",kR="[object Int8Array]",jR="[object Int16Array]",GR="[object Int32Array]",VR="[object Uint8Array]",HR="[object Uint8ClampedArray]",WR="[object Uint16Array]",qR="[object Uint32Array]",Bt={};Bt[UR]=Bt[FR]=Bt[kR]=Bt[jR]=Bt[GR]=Bt[VR]=Bt[HR]=Bt[WR]=Bt[qR]=!0;Bt[SR]=Bt[AR]=Bt[zR]=Bt[MR]=Bt[NR]=Bt[ER]=Bt[CR]=Bt[TR]=Bt[PR]=Bt[DR]=Bt[OR]=Bt[LR]=Bt[RR]=Bt[IR]=Bt[BR]=!1;function XR(e){return fn(e)&&iv(e.length)&&!!Bt[qa(e)]}var YR=XR;function QR(e){return function(t){return e(t)}}var nv=QR,q_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mh=q_&&typeof module=="object"&&module&&!module.nodeType&&module,ZR=Mh&&Mh.exports===q_,ef=ZR&&N_.process,KR=function(){try{var e=Mh&&Mh.require&&Mh.require("util").types;return e||ef&&ef.binding&&ef.binding("util")}catch{}}(),al=KR,S1=al&&al.isTypedArray,JR=S1?nv(S1):YR,X_=JR,$R=Object.prototype,eI=$R.hasOwnProperty;function tI(e,t){var i=Bs(e),r=!i&&sv(e),s=!i&&!r&&Yd(e),n=!i&&!r&&!s&&X_(e),a=i||r||s||n,o=a?uR(e.length,String):[],l=o.length;for(var h in e)(t||eI.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||$g(h,l)))&&o.push(h);return o}var Y_=tI;function iI(e,t){return function(i){return e(t(i))}}var Q_=iI,rI=Q_(Object.keys,Object),sI=rI,nI=Object.prototype,aI=nI.hasOwnProperty;function oI(e){if(!rv(e))return sI(e);var t=[];for(var i in Object(e))aI.call(e,i)&&i!="constructor"&&t.push(i);return t}var lI=oI;function hI(e){return V_(e)?Y_(e):lI(e)}var av=hI;function cI(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var dI=cI,uI=Object.prototype,pI=uI.hasOwnProperty;function fI(e){if(!ss(e))return dI(e);var t=rv(e),i=[];for(var r in e)r=="constructor"&&(t||!pI.call(e,r))||i.push(r);return i}var mI=fI;function gI(e){return V_(e)?Y_(e,!0):mI(e)}var ov=gI,vI=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yI=/^\w*$/;function xI(e,t){if(Bs(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Nu(e)?!0:yI.test(e)||!vI.test(e)||t!=null&&e in Object(t)}var wI=xI,bI=Ya(Object,"create"),Fh=bI;function _I(){this.__data__=Fh?Fh(null):{},this.size=0}var SI=_I;function AI(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var MI=AI,EI="__lodash_hash_undefined__",CI=Object.prototype,TI=CI.hasOwnProperty;function PI(e){var t=this.__data__;if(Fh){var i=t[e];return i===EI?void 0:i}return TI.call(t,e)?t[e]:void 0}var DI=PI,OI=Object.prototype,LI=OI.hasOwnProperty;function RI(e){var t=this.__data__;return Fh?t[e]!==void 0:LI.call(t,e)}var II=RI,BI="__lodash_hash_undefined__";function zI(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Fh&&t===void 0?BI:t,this}var NI=zI;function wl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}wl.prototype.clear=SI;wl.prototype.delete=MI;wl.prototype.get=DI;wl.prototype.has=II;wl.prototype.set=NI;var A1=wl;function UI(){this.__data__=[],this.size=0}var FI=UI;function kI(e,t){for(var i=e.length;i--;)if(ev(e[i][0],t))return i;return-1}var Uu=kI,jI=Array.prototype,GI=jI.splice;function VI(e){var t=this.__data__,i=Uu(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():GI.call(t,i,1),--this.size,!0}var HI=VI;function WI(e){var t=this.__data__,i=Uu(t,e);return i<0?void 0:t[i][1]}var qI=WI;function XI(e){return Uu(this.__data__,e)>-1}var YI=XI;function QI(e,t){var i=this.__data__,r=Uu(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var ZI=QI;function bl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}bl.prototype.clear=FI;bl.prototype.delete=HI;bl.prototype.get=qI;bl.prototype.has=YI;bl.prototype.set=ZI;var Fu=bl,KI=Ya(as,"Map"),kh=KI;function JI(){this.size=0,this.__data__={hash:new A1,map:new(kh||Fu),string:new A1}}var $I=JI;function eB(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var tB=eB;function iB(e,t){var i=e.__data__;return tB(t)?i[typeof t=="string"?"string":"hash"]:i.map}var ku=iB;function rB(e){var t=ku(this,e).delete(e);return this.size-=t?1:0,t}var sB=rB;function nB(e){return ku(this,e).get(e)}var aB=nB;function oB(e){return ku(this,e).has(e)}var lB=oB;function hB(e,t){var i=ku(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var cB=hB;function _l(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}_l.prototype.clear=$I;_l.prototype.delete=sB;_l.prototype.get=aB;_l.prototype.has=lB;_l.prototype.set=cB;var ju=_l,dB="Expected a function";function lv(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(dB);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],n=i.cache;if(n.has(s))return n.get(s);var a=e.apply(this,r);return i.cache=n.set(s,a)||n,a};return i.cache=new(lv.Cache||ju),i}lv.Cache=ju;var uB=lv,pB=500;function fB(e){var t=uB(e,function(r){return i.size===pB&&i.clear(),r}),i=t.cache;return t}var mB=fB,gB=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vB=/\\(\\)?/g,yB=mB(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(gB,function(i,r,s,n){t.push(s?n.replace(vB,"$1"):r||i)}),t}),xB=yB;function wB(e){return e==null?"":HL(e)}var bB=wB;function _B(e,t){return Bs(e)?e:wI(e,t)?[e]:xB(bB(e))}var Sl=_B,SB=1/0;function AB(e){if(typeof e=="string"||Nu(e))return e;var t=e+"";return t=="0"&&1/e==-SB?"-0":t}var Gu=AB;function MB(e,t){t=Sl(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Gu(t[i++])];return i&&i==r?e:void 0}var Z_=MB;function EB(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var hv=EB,M1=Ur?Ur.isConcatSpreadable:void 0;function CB(e){return Bs(e)||sv(e)||!!(M1&&e&&e[M1])}var TB=CB;function K_(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=TB),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?K_(o,t-1,i,r,s):hv(s,o):r||(s[s.length]=o)}return s}var PB=K_;function DB(e){var t=e==null?0:e.length;return t?PB(e,1):[]}var OB=DB;function LB(e){return q4(nR(e,void 0,OB),e+"")}var J_=LB,RB=Q_(Object.getPrototypeOf,Object),cv=RB,IB="[object Object]",BB=Function.prototype,zB=Object.prototype,$_=BB.toString,NB=zB.hasOwnProperty,UB=$_.call(Object);function FB(e){if(!fn(e)||qa(e)!=IB)return!1;var t=cv(e);if(t===null)return!0;var i=NB.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&$_.call(i)==UB}var kB=FB;function jB(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var n=Array(s);++r<s;)n[r]=e[r+t];return n}var GB=jB;function VB(){this.__data__=new Fu,this.size=0}var HB=VB;function WB(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var qB=WB;function XB(e){return this.__data__.get(e)}var YB=XB;function QB(e){return this.__data__.has(e)}var ZB=QB,KB=200;function JB(e,t){var i=this.__data__;if(i instanceof Fu){var r=i.__data__;if(!kh||r.length<KB-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new ju(r)}return i.set(e,t),this.size=i.size,this}var $B=JB;function Al(e){var t=this.__data__=new Fu(e);this.size=t.size}Al.prototype.clear=HB;Al.prototype.delete=qB;Al.prototype.get=YB;Al.prototype.has=ZB;Al.prototype.set=$B;var Td=Al;function ez(e,t){return e&&ac(t,av(t),e)}var tz=ez;function iz(e,t){return e&&ac(t,ov(t),e)}var rz=iz,eS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,E1=eS&&typeof module=="object"&&module&&!module.nodeType&&module,sz=E1&&E1.exports===eS,C1=sz?as.Buffer:void 0,T1=C1?C1.allocUnsafe:void 0;function nz(e,t){if(t)return e.slice();var i=e.length,r=T1?T1(i):new e.constructor(i);return e.copy(r),r}var az=nz;function oz(e,t){for(var i=-1,r=e==null?0:e.length,s=0,n=[];++i<r;){var a=e[i];t(a,i,e)&&(n[s++]=a)}return n}var lz=oz;function hz(){return[]}var tS=hz,cz=Object.prototype,dz=cz.propertyIsEnumerable,P1=Object.getOwnPropertySymbols,uz=P1?function(e){return e==null?[]:(e=Object(e),lz(P1(e),function(t){return dz.call(e,t)}))}:tS,dv=uz;function pz(e,t){return ac(e,dv(e),t)}var fz=pz,mz=Object.getOwnPropertySymbols,gz=mz?function(e){for(var t=[];e;)hv(t,dv(e)),e=cv(e);return t}:tS,iS=gz;function vz(e,t){return ac(e,iS(e),t)}var yz=vz;function xz(e,t,i){var r=t(e);return Bs(e)?r:hv(r,i(e))}var rS=xz;function wz(e){return rS(e,av,dv)}var _m=wz;function bz(e){return rS(e,ov,iS)}var sS=bz,_z=Ya(as,"DataView"),Sm=_z,Sz=Ya(as,"Promise"),Am=Sz,Az=Ya(as,"Set"),Mm=Az,D1="[object Map]",Mz="[object Object]",O1="[object Promise]",L1="[object Set]",R1="[object WeakMap]",I1="[object DataView]",Ez=Xa(Sm),Cz=Xa(kh),Tz=Xa(Am),Pz=Xa(Mm),Dz=Xa(bm),xa=qa;(Sm&&xa(new Sm(new ArrayBuffer(1)))!=I1||kh&&xa(new kh)!=D1||Am&&xa(Am.resolve())!=O1||Mm&&xa(new Mm)!=L1||bm&&xa(new bm)!=R1)&&(xa=function(e){var t=qa(e),i=t==Mz?e.constructor:void 0,r=i?Xa(i):"";if(r)switch(r){case Ez:return I1;case Cz:return D1;case Tz:return O1;case Pz:return L1;case Dz:return R1}return t});var jh=xa,Oz=Object.prototype,Lz=Oz.hasOwnProperty;function Rz(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&Lz.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var Iz=Rz,Bz=as.Uint8Array,Qd=Bz;function zz(e){var t=new e.constructor(e.byteLength);return new Qd(t).set(new Qd(e)),t}var uv=zz;function Nz(e,t){var i=t?uv(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var Uz=Nz,Fz=/\w*$/;function kz(e){var t=new e.constructor(e.source,Fz.exec(e));return t.lastIndex=e.lastIndex,t}var jz=kz,B1=Ur?Ur.prototype:void 0,z1=B1?B1.valueOf:void 0;function Gz(e){return z1?Object(z1.call(e)):{}}var Vz=Gz;function Hz(e,t){var i=t?uv(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var Wz=Hz,qz="[object Boolean]",Xz="[object Date]",Yz="[object Map]",Qz="[object Number]",Zz="[object RegExp]",Kz="[object Set]",Jz="[object String]",$z="[object Symbol]",e5="[object ArrayBuffer]",t5="[object DataView]",i5="[object Float32Array]",r5="[object Float64Array]",s5="[object Int8Array]",n5="[object Int16Array]",a5="[object Int32Array]",o5="[object Uint8Array]",l5="[object Uint8ClampedArray]",h5="[object Uint16Array]",c5="[object Uint32Array]";function d5(e,t,i){var r=e.constructor;switch(t){case e5:return uv(e);case qz:case Xz:return new r(+e);case t5:return Uz(e,i);case i5:case r5:case s5:case n5:case a5:case o5:case l5:case h5:case c5:return Wz(e,i);case Yz:return new r;case Qz:case Jz:return new r(e);case Zz:return jz(e);case Kz:return new r;case $z:return Vz(e)}}var u5=d5;function p5(e){return typeof e.constructor=="function"&&!rv(e)?D4(cv(e)):{}}var f5=p5,m5="[object Map]";function g5(e){return fn(e)&&jh(e)==m5}var v5=g5,N1=al&&al.isMap,y5=N1?nv(N1):v5,x5=y5,w5="[object Set]";function b5(e){return fn(e)&&jh(e)==w5}var _5=b5,U1=al&&al.isSet,S5=U1?nv(U1):_5,A5=S5,M5=1,E5=2,C5=4,nS="[object Arguments]",T5="[object Array]",P5="[object Boolean]",D5="[object Date]",O5="[object Error]",aS="[object Function]",L5="[object GeneratorFunction]",R5="[object Map]",I5="[object Number]",oS="[object Object]",B5="[object RegExp]",z5="[object Set]",N5="[object String]",U5="[object Symbol]",F5="[object WeakMap]",k5="[object ArrayBuffer]",j5="[object DataView]",G5="[object Float32Array]",V5="[object Float64Array]",H5="[object Int8Array]",W5="[object Int16Array]",q5="[object Int32Array]",X5="[object Uint8Array]",Y5="[object Uint8ClampedArray]",Q5="[object Uint16Array]",Z5="[object Uint32Array]",Lt={};Lt[nS]=Lt[T5]=Lt[k5]=Lt[j5]=Lt[P5]=Lt[D5]=Lt[G5]=Lt[V5]=Lt[H5]=Lt[W5]=Lt[q5]=Lt[R5]=Lt[I5]=Lt[oS]=Lt[B5]=Lt[z5]=Lt[N5]=Lt[U5]=Lt[X5]=Lt[Y5]=Lt[Q5]=Lt[Z5]=!0;Lt[O5]=Lt[aS]=Lt[F5]=!1;function Pd(e,t,i,r,s,n){var a,o=t&M5,l=t&E5,h=t&C5;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!ss(e))return e;var d=Bs(e);if(d){if(a=Iz(e),!o)return I4(e,a)}else{var c=jh(e),u=c==aS||c==L5;if(Yd(e))return az(e,o);if(c==oS||c==nS||u&&!s){if(a=l||u?{}:f5(e),!o)return l?yz(e,rz(a,e)):fz(e,tz(a,e))}else{if(!Lt[c])return s?e:{};a=u5(e,c,o)}}n||(n=new Td);var p=n.get(e);if(p)return p;n.set(e,a),A5(e)?e.forEach(function(m){a.add(Pd(m,t,i,m,e,n))}):x5(e)&&e.forEach(function(m,v){a.set(v,Pd(m,t,i,v,e,n))});var g=h?l?sS:_m:l?ov:av,f=d?void 0:g(e);return Y4(f||e,function(m,v){f&&(v=m,m=e[v]),tv(a,v,Pd(m,t,i,v,e,n))}),a}var lS=Pd,K5=1,J5=4;function $5(e){return lS(e,K5|J5)}var Vu=$5,eN="__lodash_hash_undefined__";function tN(e){return this.__data__.set(e,eN),this}var iN=tN;function rN(e){return this.__data__.has(e)}var sN=rN;function Zd(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new ju;++t<i;)this.add(e[t])}Zd.prototype.add=Zd.prototype.push=iN;Zd.prototype.has=sN;var nN=Zd;function aN(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var oN=aN;function lN(e,t){return e.has(t)}var hN=lN,cN=1,dN=2;function uN(e,t,i,r,s,n){var a=i&cN,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var h=n.get(e),d=n.get(t);if(h&&d)return h==t&&d==e;var c=-1,u=!0,p=i&dN?new nN:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var g=e[c],f=t[c];if(r)var m=a?r(f,g,c,t,e,n):r(g,f,c,e,t,n);if(m!==void 0){if(m)continue;u=!1;break}if(p){if(!oN(t,function(v,y){if(!hN(p,y)&&(g===v||s(g,v,i,r,n)))return p.push(y)})){u=!1;break}}else if(!(g===f||s(g,f,i,r,n))){u=!1;break}}return n.delete(e),n.delete(t),u}var hS=uN;function pN(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var fN=pN;function mN(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var gN=mN,vN=1,yN=2,xN="[object Boolean]",wN="[object Date]",bN="[object Error]",_N="[object Map]",SN="[object Number]",AN="[object RegExp]",MN="[object Set]",EN="[object String]",CN="[object Symbol]",TN="[object ArrayBuffer]",PN="[object DataView]",F1=Ur?Ur.prototype:void 0,tf=F1?F1.valueOf:void 0;function DN(e,t,i,r,s,n,a){switch(i){case PN:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case TN:return!(e.byteLength!=t.byteLength||!n(new Qd(e),new Qd(t)));case xN:case wN:case SN:return ev(+e,+t);case bN:return e.name==t.name&&e.message==t.message;case AN:case EN:return e==t+"";case _N:var o=fN;case MN:var l=r&vN;if(o||(o=gN),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=yN,a.set(e,t);var d=hS(o(e),o(t),r,s,n,a);return a.delete(e),d;case CN:if(tf)return tf.call(e)==tf.call(t)}return!1}var ON=DN,LN=1,RN=Object.prototype,IN=RN.hasOwnProperty;function BN(e,t,i,r,s,n){var a=i&LN,o=_m(e),l=o.length,h=_m(t),d=h.length;if(l!=d&&!a)return!1;for(var c=l;c--;){var u=o[c];if(!(a?u in t:IN.call(t,u)))return!1}var p=n.get(e),g=n.get(t);if(p&&g)return p==t&&g==e;var f=!0;n.set(e,t),n.set(t,e);for(var m=a;++c<l;){u=o[c];var v=e[u],y=t[u];if(r)var x=a?r(y,v,u,t,e,n):r(v,y,u,e,t,n);if(!(x===void 0?v===y||s(v,y,i,r,n):x)){f=!1;break}m||(m=u=="constructor")}if(f&&!m){var w=e.constructor,_=t.constructor;w!=_&&"constructor"in e&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof _=="function"&&_ instanceof _)&&(f=!1)}return n.delete(e),n.delete(t),f}var zN=BN,NN=1,k1="[object Arguments]",j1="[object Array]",Yc="[object Object]",UN=Object.prototype,G1=UN.hasOwnProperty;function FN(e,t,i,r,s,n){var a=Bs(e),o=Bs(t),l=a?j1:jh(e),h=o?j1:jh(t);l=l==k1?Yc:l,h=h==k1?Yc:h;var d=l==Yc,c=h==Yc,u=l==h;if(u&&Yd(e)){if(!Yd(t))return!1;a=!0,d=!1}if(u&&!d)return n||(n=new Td),a||X_(e)?hS(e,t,i,r,s,n):ON(e,t,l,i,r,s,n);if(!(i&NN)){var p=d&&G1.call(e,"__wrapped__"),g=c&&G1.call(t,"__wrapped__");if(p||g){var f=p?e.value():e,m=g?t.value():t;return n||(n=new Td),s(f,m,i,r,n)}}return u?(n||(n=new Td),zN(e,t,i,r,s,n)):!1}var kN=FN;function cS(e,t,i,r,s){return e===t?!0:e==null||t==null||!fn(e)&&!fn(t)?e!==e&&t!==t:kN(e,t,i,r,cS,s)}var jN=cS;function GN(e,t){return e!=null&&t in Object(e)}var VN=GN;function HN(e,t,i){t=Sl(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=Gu(t[r]);if(!(n=e!=null&&i(e,a)))break;e=e[a]}return n||++r!=s?n:(s=e==null?0:e.length,!!s&&iv(s)&&$g(a,s)&&(Bs(e)||sv(e)))}var WN=HN;function qN(e,t){return e!=null&&WN(e,t,VN)}var XN=qN,YN=function(){return as.Date.now()},rf=YN,QN="Expected a function",ZN=Math.max,KN=Math.min;function JN(e,t,i){var r,s,n,a,o,l,h=0,d=!1,c=!1,u=!0;if(typeof e!="function")throw new TypeError(QN);t=g1(t)||0,ss(i)&&(d=!!i.leading,c="maxWait"in i,n=c?ZN(g1(i.maxWait)||0,t):n,u="trailing"in i?!!i.trailing:u);function p(S){var A=r,b=s;return r=s=void 0,h=S,a=e.apply(b,A),a}function g(S){return h=S,o=setTimeout(v,t),d?p(S):a}function f(S){var A=S-l,b=S-h,E=t-A;return c?KN(E,n-b):E}function m(S){var A=S-l,b=S-h;return l===void 0||A>=t||A<0||c&&b>=n}function v(){var S=rf();if(m(S))return y(S);o=setTimeout(v,f(S))}function y(S){return o=void 0,u&&r?p(S):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function w(){return o===void 0?a:y(rf())}function _(){var S=rf(),A=m(S);if(r=arguments,s=this,l=S,A){if(o===void 0)return g(l);if(c)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),a}return _.cancel=x,_.flush=w,_}var pv=JN;function $N(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var eU=$N;function tU(e,t){return t.length<2?e:Z_(e,GB(t,0,-1))}var iU=tU;function rU(e,t){return jN(e,t)}var fv=rU;function sU(e,t){return t=Sl(t,e),e=iU(e,t),e==null||delete e[Gu(eU(t))]}var nU=sU;function aU(e){return kB(e)?void 0:e}var oU=aU,lU=1,hU=2,cU=4,dU=J_(function(e,t){var i={};if(e==null)return i;var r=!1;t=F_(t,function(n){return n=Sl(n,e),r||(r=n.length>1),n}),ac(e,sS(e),i),r&&(i=lS(i,lU|hU|cU,oU));for(var s=t.length;s--;)nU(i,t[s]);return i}),Em=dU;function uU(e,t,i,r){if(!ss(e))return e;t=Sl(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=Gu(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=a){var d=o[l];h=r?r(d,l,o):void 0,h===void 0&&(h=ss(d)?d:$g(t[s+1])?[]:{})}tv(o,l,h),o=o[l]}return e}var pU=uU;function fU(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=Z_(e,a);i(o,a)&&pU(n,Sl(a,e),o)}return n}var mU=fU;function gU(e,t){return mU(e,t,function(i,r){return XN(e,r)})}var vU=gU,yU=J_(function(e,t){return e==null?{}:vU(e,t)}),Gh=yU,xU="Expected a function";function wU(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(xU);return ss(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),pv(e,t,{leading:r,maxWait:t,trailing:s})}var bU=wU;function _U(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Va(e,t){return Object.setPrototypeOf(e,t),e}var SU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),AU=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),MU=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Hu&&"ontouchend"in document,EU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,CU=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,TU=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},PU=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},uW=SU(),Hu=AU(),dS=MU(),DU=EU(),gr=CU(),V1=TU(),H1=Number(PU());function uS(e){return Array.isArray(e)?e:[e]}function OU(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Qc(e){return Hu?e.metaKey:e.ctrlKey}var je=[],Kd={},fh={},Dd={};function pS(e){je.includes(e)||je.push(e)}function Wo(e){delete Kd[e.pointerId];for(let t=0;t<je.length;t++)if(je[t].pointerId===e.pointerId){je.splice(t,1);break}}function LU(){je.splice(0,je.length)}function Jd(e){if(e.pointerType!=="touch")return;let t=Kd[e.pointerId];t===void 0&&(t={x:0,y:0},Kd[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function sf(e){let t=e.pointerId===je[0].pointerId?je[1]:je[0];return Kd[t.pointerId]}function fS(e){fh[e.key]=!0,Dd[e.key]=Dd[e.key]===void 0?1:Dd[e.key]+1}function mS(e){if(Hu&&fh.Meta)for(let t in fh)fh[t]=!1;else fh[e.key]=!1;Dd={}}function RU(e){e.addEventListener("pointerdown",pS,!0),e.addEventListener("pointerdown",Jd,!0),e.addEventListener("pointermove",Jd,!0),e.addEventListener("pointerup",Wo,!0),e.addEventListener("pointercancel",Wo,!0),e.addEventListener("pointerleave",Wo,!0),window.addEventListener("keydown",fS,!0),window.addEventListener("keyup",mS,!0)}function IU(e){e.removeEventListener("pointerdown",pS,!0),e.removeEventListener("pointerdown",Jd,!0),e.removeEventListener("pointermove",Jd,!0),e.removeEventListener("pointerup",Wo,!0),e.removeEventListener("pointercancel",Wo,!0),e.removeEventListener("pointerleave",Wo,!0),window.removeEventListener("keydown",fS,!0),window.removeEventListener("keyup",mS,!0)}var gS,BU=new Promise(e=>{gS=e}),W1=!1;async function zU(){if(W1)return;let e="https://unpkg.com/@splinetool/navmesh-wasm@0.9.378/build",[t,i]=await Promise.all([import("./navmesh.js"),fetch(`${e}/navmesh.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});gS(s),W1=!0}var vS,NU=new Promise(e=>{vS=e}),q1=!1;async function UU(){if(q1)return;let e=await import("./physics.js");await e.init(),vS(e),q1=!0}var ti=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,ti.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:n}=e,a={...t,[s]:n};return Object.setPrototypeOf(a,ti.prototype),{data:a,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,ti.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function mv(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&mv(r)}return Object.freeze(e)}function FU(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var yS=class extends Error{};function nf(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Vn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let n=e;e=t,t=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=e+(t-e)*(n+.75+Math.random()*.5)*s;r.push(a)}return r}function gv(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function kU(){return typeof process<"u"}function xS(e,t){for(let i of e)t(i.id,i.data)!==!0&&xS(i.children,t)}function wS(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)wS(i,t)}var sr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,sr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)mv(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&wS(i,t)}}traverse(e){xS(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);if(s<0)throw new Error("not expected");let n=r[s];return r=[...r],r[s]={...n,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let n=r,a=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===a);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:n}}Object.setPrototypeOf(r,sr.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,d)=>h.fi-d.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===t);e.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...n,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new yS("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(c=>c.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=t,a=h.childrenArray(s);let d=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:e,reverse:{type:9,parent:n,fi:d,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>FU(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Vn(0,i,i);{let s=r[0].fi;return Vn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Vn(a,a+i,i)}else return Vn(s.fi,n.fi,i)}}},$d;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,n={},a=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");n[l]=a[h],a[h]=s[l],o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let s=r.props,n={},a={...i},o=!1;if(s)for(let l of Object.keys(s)){n[l]=a[l];let h=s[l];h===void 0?delete a[l]:a[l]=h,o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}}e.runOp=t})($d||($d={}));var it=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,it.prototype)}deepFreeze(){let e=0;for(;e<this.length;)mv(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,it.prototype);let t=e;return kU()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,n={fi:t,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(n=>n.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:t};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:n,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Vn(0,t,t);{let r=i[0].fi;return Vn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Vn(n,n+t,t)}else return Vn(r.fi,s.fi,t)}}};function ol(e){return e&&typeof e=="object"&&e instanceof Si}var Si=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!ol(i))return null;r+=1}i=i?nf(i):new Si;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=nf(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=nf(o);l[e.path[r-1]]=i,i=l}else{let l=new Si;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,Si.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},Ba;(e=>{function t(s,n){return Vh(s,n)??s}e.apply=t;function i(s,n){return yv(s,n)}e.merge=i;function r(s,n){let a=0,o=n.path,l=s;for(;a<o.length&&l!==void 0;){if(l=Os.zoomOnce(l,o[a]),l===void 0)return n;if(!ol(l))return;a+=1}if(l===void 0)return n;if(ol(l))if(n.type===0){let h={...n.props};for(let d of Object.keys(l))delete h[d];return{...n,props:h}}else if(n.type===1||n.type===4||n.type===7){let h=vv([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(Ba||(Ba={}));function vv(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Vh(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=vv(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}else return{...s,id:n,data:a}});if(i)return r}function jU(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Vh(s.data,t[n]);return i=i||a!==void 0,a===void 0&&(a=s.data),{...s,id:n,data:a}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function Vh(e,t){if(!ol(t))return t;if(e instanceof sr){let i=vv(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof it)return jU(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=Vh(s,t[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Si)return yv(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=Vh(n,t[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function yv(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!ol(t))return t;if(!ol(e))return Ba.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new Si;for(let s of i){let n=yv(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function GU(e,t){let i={cur:[],result:[],len:0};return e=Hh(e,t,i)??e,[e,i.result]}function eu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function tu(e){e&&(e.len-=1)}function VU(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function bS(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Hh(n.data,t,eu(i,a));tu(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=bS(n.children,t,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function HU(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Hh(n.data,t,eu(i,a));return tu(i),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function Hh(e,t,i){if(e instanceof sr){let r=bS(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof it)return HU(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=Hh(n,t,eu(i,a));return tu(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!gv(e)){let r={},s=!1;for(let[n,a]of Object.entries(e))if(n!=="name"&&n!=="text"){let o=t[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=Hh(a,t,eu(i,n));tu(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];if(r!==void 0){if(e.length!==36)throw new Error("for now you should only call this method when the key is a uuid");VU(i)}return r}else return}}var Cm;(e=>{function t(i,r){let s=Os.zoom(r,i.path);if(typeof s=="object"){let n={};for(let a of Object.keys(i.props))n[a]=s[a];return{...i,props:n}}else return{...i,props:{}}}e.replaceProps=t})(Cm||(Cm={}));var vr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let d=h.path;for(var c=[];;){let u;if(l instanceof Si&&h.type===0&&(u=l.runOp({...h,path:d.slice(c.length)}),u===null&&(u=void 0)),u===void 0&&c.length===d.length&&(l instanceof sr||l instanceof it||l instanceof ti?u=l.runOp(h):u=$d.runOp(l,h)),u!==void 0)if(u!==null){let f=u.data;for(let m=c.length-1;m>=0;m--){let v=d[m],y=c[m];if(y instanceof sr){if(typeof v=="number")throw new Error("illegal arg");f=y.modifyById(v,f)}else if(y instanceof it){if(typeof v=="number")throw new Error("illegal arg");f=y.modifyById(v,f)}else if(y instanceof ti){if(typeof v=="number")throw new Error("illegal arg");f=y.modifyById(v,f)}else if(y instanceof Si){let x={...y,[v]:f};f=Object.setPrototypeOf(x,Si.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let x=f;f=[...y],f[v]=x}else f={...y,[v]:f};else return null}return{data:f,actual:{...u.actual,path:d},reverse:{...u.reverse,path:d}}}else return null;let p=d[c.length],g;if(l instanceof sr){if(typeof p=="number")throw new Error("");g=l.get(p)?.data}else if(l instanceof it){if(typeof p=="number")throw new Error("");g=l.get(p)?.data}else l!==null&&(g=l[p]);if(g!==void 0)c.push(l),l=g;else return null}}e.apply=r;function s(l,h){for(let d=0;d<l.length&&d<h.length;d++)if(l[d]!==h[d])return!0;return!1}e.pathDisjoint=s;function n(l,h){if(l.length!==h.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==h[d])return!1;return!0}e.pathEq=n;function a(l,h){return s(l.path,h.path)}e.commutative=a;function o(l,h){return l.type===0&&h.type===0&&n(l.path,h.path)?Object.keys(l.props).every(d=>h.props[d]!==void 0):!1}e.subsumed=o})(vr||(vr={}));var X1;(e=>{function t(){return[]}e.empty=t;function i(h,d){let c=[];for(let u of h){let[p,...g]=u.path;p===d&&c.push({...u,path:g})}return c}e.removePrefix=i;function r(h,d){return h.map(c=>({...c,path:[d,...c.path]}))}e.addPrefix=r;function s(h,d){return[...h,...d]}e.concat=s;function n(h,d){return[...h.filter(c=>!d.some(u=>vr.subsumed(c,u))),...d]}e.compress=n;function a(h,d){return h.every(c=>d.every(u=>vr.commutative(c,u)))}e.commutative=a;function o(h,d){for(let c of d){let u=l(h,c);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,d){var c=h;let u=[],p=[];for(let g of d)try{if(g.type===3){let f=Os.zoom(c,[...g.path,g.id]),m=vr.apply(c,{...g,type:2});if(m!==null){c=m.data;let[v,y]=GU(c,{[g.id]:f});c=v;for(let x of y){let w=x[x.length-1];x.splice(x.length-1,1),u.push({type:0,path:x,props:{[w]:f}}),p.push({type:0,path:x,props:{[w]:g.id}})}p.push(m.reverse),u.push(m.actual)}}else{let f=vr.apply(c,g);f!==null&&(u.push(f.actual),c=f.data,p.push(f.reverse))}}catch(f){if(f instanceof yS)return null;throw f}return{data:c,actual:u,reverse:p.reverse()}}e.apply=l})(X1||(X1={}));var _S=Symbol(),WU=Symbol(),Wu=Symbol(),oc=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof AS);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Wu];i&&i(),delete this._children[e]}}}},qU=class extends oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,$d.runOp(this._current,e),e.path)}},XU=class extends oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,ti.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},SS={get(e,t){if(t===Wu)return()=>{e._parent=null};if(t===_S)return e._current;if(t===WU)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let n=i[t],a=qu(e,t,n);return a!==n?(r===void 0&&(r={},e._children=r),r[t]=a,a):n},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},YU={...SS,set(e,t,i){let r={type:0,props:{[t]:Ii(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},QU={...SS,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},xv=class extends oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Wu]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=qu(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},wv=class extends oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Wu]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=qu(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function af(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Os.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var AS=class extends oc{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){af(this.ts,t,e),af(this.actual,i,e),af(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function qu(e,t,i){return i instanceof sr?new xv(e,t,i):i instanceof it?new wv(e,t,i):i instanceof ti?new Proxy(new XU(e,t,i),QU):i!==null&&typeof i=="object"?gv(i)?i:new Proxy(new qU(e,t,i),YU):i}function MS(e){let t=new AS(e);return[qu(t,"",e),t]}function iu(e,t){let[i,r]=MS(e);return t(i),r.result()}function Ii(e){return e instanceof xv||e instanceof wv?e._current:e!==null&&typeof e=="object"?e[_S]:e}var Os;(e=>{function t(n,a){if(a.length===n.length)for(var o=0;o<n.length;){if(n[o]!==a[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(n,a,o){let l=s(o,n);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...a};return Object.keys(l).forEach(d=>{delete h[d]}),h}else return a}e.removeOverridden=i;function r(n,a){if((n instanceof sr||n instanceof xv)&&typeof a=="string"||(n instanceof it||n instanceof wv)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n)||typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}e.zoomOnce=r;function s(n,a,o=0){for(;o<a.length&&n!==void 0;)n=r(n,a[o]),o+=1;return n}e.zoom=s})(Os||(Os={}));function ZU(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Fn(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var ES=class{},Y1=class extends ES{constructor(e){super(),this.id=e}},Q1=class extends ES{constructor(e){super(),this.data=e}},Tm;try{Tm=new TextDecoder}catch{}var Ee,Qn,K=0,CS=[],Pm=CS,Dm=0,$i={},gt,Hn,Tr=0,Ms=0,ur,un,Hi=[],yt,Z1={useRecords:!1,mapsAsObjects:!0},TS=class{},PS=new TS;PS.name="MessagePack 0xC1";var ll=!1,ru=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Ee)return BS(()=>(Lm(),this?this.unpack(e,t):ru.prototype.unpack.call(Z1,e,t)));Qn=t>-1?t:e.length,K=0,Dm=0,Ms=0,Hn=null,Pm=CS,ur=null,Ee=e;try{yt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ee=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof ru){if($i=this,this.structures)return gt=this.structures,Zc();(!gt||gt.length>0)&&(gt=[])}else $i=Z1,(!gt||gt.length>0)&&(gt=[]);return Zc()}unpackMultiple(e,t){let i,r=0;try{ll=!0;let s=e.length,n=this?this.unpack(e,s):Yu.unpack(e,s);if(t){for(t(n);K<s;)if(r=K,t(Zc())===!1)return}else{for(i=[n];K<s;)r=K,i.push(Zc());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{ll=!1,Lm()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Zc(){try{if(!$i.trusted&&!ll){let t=gt.sharedLength||0;t<gt.length&&(gt.length=t)}let e=jt();if(K==Qn)gt.restoreStructures&&K1(),gt=null,Ee=null,un&&(un=null);else if(K>Qn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!ll)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw gt.restoreStructures&&K1(),Lm(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function K1(){for(let e in gt.restoreStructures)gt[e]=gt.restoreStructures[e];gt.restoreStructures=null}function jt(){let e=Ee[K++];if(e<160)if(e<128){if(e<64)return e;{let t=gt[e&63]||$i.getStructures&&DS()[e&63];return t?(t.read||(t.read=bv(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,$i.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[LS()]=jt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(jt(),jt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=jt();return t}else if(e<192){let t=e-160;if(Ms>=K)return Hn.slice(K-Tr,(K+=t)-Tr);if(Ms==0&&Qn<140){let i=t<16?_v(t):OS(t);if(i!=null)return i}return Om(t)}else{let t;switch(e){case 192:return null;case 193:return ur?(t=jt(),t>0?ur[1].slice(ur.position1,ur.position1+=t):ur[0].slice(ur.position0,ur.position0-=t)):PS;case 194:return!1;case 195:return!0;case 196:return of(Ee[K++]);case 197:return t=yt.getUint16(K),K+=2,of(t);case 198:return t=yt.getUint32(K),K+=4,of(t);case 199:return pa(Ee[K++]);case 200:return t=yt.getUint16(K),K+=2,pa(t);case 201:return t=yt.getUint32(K),K+=4,pa(t);case 202:if(t=yt.getFloat32(K),$i.useFloat32>2){let i=Sv[(Ee[K]&127)<<1|Ee[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=yt.getFloat64(K),K+=8,t;case 204:return Ee[K++];case 205:return t=yt.getUint16(K),K+=2,t;case 206:return t=yt.getUint32(K),K+=4,t;case 207:return $i.int64AsNumber?(t=yt.getUint32(K)*4294967296,t+=yt.getUint32(K+4)):t=yt.getBigUint64(K),K+=8,t;case 208:return yt.getInt8(K++);case 209:return t=yt.getInt16(K),K+=2,t;case 210:return t=yt.getInt32(K),K+=4,t;case 211:return $i.int64AsNumber?(t=yt.getInt32(K)*4294967296,t+=yt.getUint32(K+4)):t=yt.getBigInt64(K),K+=8,t;case 212:if(t=Ee[K++],t==114)return ix(Ee[K++]&63);{let i=Hi[t];if(i)return i.read?(K++,i.read(jt())):i.noBuffer?(K++,i()):i(Ee.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Ee[K],t==114?(K++,ix(Ee[K++]&63,Ee[K++])):pa(2);case 214:return pa(4);case 215:return pa(8);case 216:return pa(16);case 217:return t=Ee[K++],Ms>=K?Hn.slice(K-Tr,(K+=t)-Tr):JU(t);case 218:return t=yt.getUint16(K),K+=2,Ms>=K?Hn.slice(K-Tr,(K+=t)-Tr):$U(t);case 219:return t=yt.getUint32(K),K+=4,Ms>=K?Hn.slice(K-Tr,(K+=t)-Tr):eF(t);case 220:return t=yt.getUint16(K),K+=2,$1(t);case 221:return t=yt.getUint32(K),K+=4,$1(t);case 222:return t=yt.getUint16(K),K+=2,ex(t);case 223:return t=yt.getUint32(K),K+=4,ex(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var KU=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function bv(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>KU.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(jt);return e.highByte===0&&(e.read=J1(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=jt()}return r}return i.count=0,e.highByte===0?J1(t,i):i}var J1=(e,t)=>function(){let i=Ee[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=gt[r]||DS()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=bv(s,e)),s.read()};function DS(){let e=BS(()=>(Ee=null,$i.getStructures()));return gt=$i._mergeStructures(e,gt)}var Om=Xu,JU=Xu,$U=Xu,eF=Xu;function Xu(e){let t;if(e<16&&(t=_v(e)))return t;if(e>64&&Tm)return Tm.decode(Ee.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Ee[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Ee[K++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Ee[K++]&63,a=Ee[K++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Ee[K++]&63,a=Ee[K++]&63,o=Ee[K++]&63,l=(s&7)<<18|n<<12|a<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=mi.apply(String,r),r.length=0)}return r.length>0&&(t+=mi.apply(String,r)),t}function $1(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=jt();return t}function ex(e){if($i.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[LS()]=jt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(jt(),jt());return t}}var mi=String.fromCharCode;function OS(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Ee[K++];if((s&128)>0){K=t;return}i[r]=s}return mi.apply(String,i)}function _v(e){if(e<4)if(e<2){if(e===0)return"";{let t=Ee[K++];if((t&128)>1){K-=1;return}return mi(t)}}else{let t=Ee[K++],i=Ee[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return mi(t,i);let r=Ee[K++];if((r&128)>0){K-=3;return}return mi(t,i,r)}else{let t=Ee[K++],i=Ee[K++],r=Ee[K++],s=Ee[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return mi(t,i,r,s);{let n=Ee[K++];if((n&128)>0){K-=5;return}return mi(t,i,r,s,n)}}else if(e<8){let n=Ee[K++],a=Ee[K++];if((n&128)>0||(a&128)>0){K-=6;return}if(e<7)return mi(t,i,r,s,n,a);let o=Ee[K++];if((o&128)>0){K-=7;return}return mi(t,i,r,s,n,a,o)}else{let n=Ee[K++],a=Ee[K++],o=Ee[K++],l=Ee[K++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return mi(t,i,r,s,n,a,o,l);{let h=Ee[K++];if((h&128)>0){K-=9;return}return mi(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Ee[K++],d=Ee[K++];if((h&128)>0||(d&128)>0){K-=10;return}if(e<11)return mi(t,i,r,s,n,a,o,l,h,d);let c=Ee[K++];if((c&128)>0){K-=11;return}return mi(t,i,r,s,n,a,o,l,h,d,c)}else{let h=Ee[K++],d=Ee[K++],c=Ee[K++],u=Ee[K++];if((h&128)>0||(d&128)>0||(c&128)>0||(u&128)>0){K-=12;return}if(e<14){if(e===12)return mi(t,i,r,s,n,a,o,l,h,d,c,u);{let p=Ee[K++];if((p&128)>0){K-=13;return}return mi(t,i,r,s,n,a,o,l,h,d,c,u,p)}}else{let p=Ee[K++],g=Ee[K++];if((p&128)>0||(g&128)>0){K-=14;return}if(e<15)return mi(t,i,r,s,n,a,o,l,h,d,c,u,p,g);let f=Ee[K++];if((f&128)>0){K-=15;return}return mi(t,i,r,s,n,a,o,l,h,d,c,u,p,g,f)}}}}}function of(e){return $i.copyBuffers?Uint8Array.prototype.slice.call(Ee,K,K+=e):Ee.subarray(K,K+=e)}function pa(e){let t=Ee[K++];if(Hi[t])return Hi[t](Ee.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var tx=new Array(4096);function LS(){let e=Ee[K++];if(e>=160&&e<192){if(e=e-160,Ms>=K)return Hn.slice(K-Tr,(K+=e)-Tr);if(!(Ms==0&&Qn<180))return Om(e)}else return K--,jt();let t=(e<<5^(e>1?yt.getUint16(K):e>0?Ee[K]:0))&4095,i=tx[t],r=K,s=K+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=yt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Ee[r++],n!=i[a++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],tx[t]=i,i.bytes=e;r<s;)n=yt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Ee[r++],i.push(n);let o=e<16?_v(e):OS(e);return o!=null?i.string=o:i.string=Om(e)}var ix=(e,t)=>{var i=jt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=gt[e];return s&&s.isShared&&((gt.restoreStructures||(gt.restoreStructures=[]))[e]=s),gt[e]=i,i.read=bv(i,r),i.read()},RS=typeof self=="object"?self:global;Hi[0]=()=>{};Hi[0].noBuffer=!0;Hi[101]=()=>{let e=jt();return(RS[e[0]]||Error)(e[1])};Hi[105]=e=>{let t=yt.getUint32(K-4);un||(un=new Map);let i=Ee[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};un.set(t,s);let n=jt();return s.used?Object.assign(r,n):(s.target=n,n)};Hi[112]=e=>{let t=yt.getUint32(K-4),i=un.get(t);return i.used=!0,i.target};Hi[115]=()=>new Set(jt());var IS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Hi[116]=e=>{let t=e[0],i=IS[t];if(!i)throw new Error("Could not find typed array for code "+t);return new RS[i](Uint8Array.prototype.slice.call(e,1).buffer)};Hi[120]=()=>{let e=jt();return new RegExp(e[0],e[1])};Hi[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,ur=[jt(),jt()],ur.position0=0,ur.position1=0;let r=K;K=i;try{return jt()}finally{K=r}};Hi[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function BS(e){let t=Qn,i=K,r=Dm,s=Tr,n=Ms,a=Hn,o=Pm,l=un,h=ur,d=new Uint8Array(Ee.slice(0,Qn)),c=gt,u=gt.slice(0,gt.length),p=$i,g=ll,f=e();return Qn=t,K=i,Dm=r,Tr=s,Ms=n,Hn=a,Pm=o,un=l,ur=h,Ee=d,ll=g,gt=c,gt.splice(0,gt.length,...u),$i=p,yt=new DataView(Ee.buffer,Ee.byteOffset,Ee.byteLength),f}function Lm(){Ee=null,un=null,gt=null}function tF(e){e.unpack?Hi[e.type]=e.unpack:Hi[e.type]=e}var Sv=new Array(147);for(let e=0;e<256;e++)Sv[e]=+("1e"+Math.floor(45.15-e*.30103));var Yu=new ru({useRecords:!1}),pW=Yu.unpack,fW=Yu.unpackMultiple,mW=Yu.unpack,iF={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},rF=new Float32Array(1),gW=new Uint8Array(rF.buffer,0,4),Od;try{Od=new TextEncoder}catch{}var su,Av,Qu=typeof Buffer<"u",lf=Qu?Buffer.allocUnsafeSlow:Uint8Array,zS=Qu?Buffer:Uint8Array,rx=Qu?4294967296:2144337920,he,Wt,te=0,hs,cs=null,sF=/[\u0080-\uFFFF]/,ql=Symbol("record-id"),NS=class extends ru{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=zS.prototype.utf8Write?function(A,b,E){return he.utf8Write(A,b,E)}:Od&&Od.encodeInto?function(A,b){return Od.encodeInto(A,he.subarray(b)).written}:!1,h=this;e||(e={});let d=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),d&&!e.saveStructures&&(this.structures=[]);let g=u>32||p+u>64,f=u+64,m=u+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(A,b){if(he||(he=new lf(8192),Wt=new DataView(he.buffer,0,8192),te=0),hs=he.length-10,hs-te<2048?(he=new lf(he.length),Wt=new DataView(he.buffer,0,he.length),hs=he.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(cs=["",""],he[te++]=214,he[te++]=98,cs.position=te-i,te+=4):cs=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let E=r.sharedLength||0;if(E>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<E;C++){let T=r[C];if(!T)continue;let P,L=r.transitions;for(let D=0,j=T.length;D<j;D++){let W=T[D];P=L[W],P||(P=L[W]=Object.create(null)),L=P}L[ql]=C+64}o=E}d||(r.nextId=E+64)}s&&(s=!1),n=r||[];try{if(w(A),cs){Wt.setUint32(cs.position+i,te-cs.position-i);let E=cs;cs=null,w(E[0]),w(E[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>hs&&S(te),h.offset=te;let E=aF(he.subarray(i,te),a.idsToInsert);return a=null,E}return b&oF?(he.start=i,he.end=te,he):he.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let E=0,C=v.length;E<C;E++)v[E][ql]=0;v=[]}if(s&&h.saveStructures){let E=r.sharedLength||u;r.length>E&&(r=r.slice(0,E));let C=he.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(A)):(o=E,C)}}b&lF&&(te=i)}};let w=A=>{te>hs&&(he=S(te));var b=typeof A,E;if(b==="string"){let C=A.length;if(cs&&C>=8&&C<4096){let L=sF.test(A);cs[L?0:1]+=A,he[te++]=193,w(L?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let P=C*3;if(te+P>hs&&(he=S(te+P)),C<64||!l){let L,D,j,W=te+T;for(L=0;L<C;L++)D=A.charCodeAt(L),D<128?he[W++]=D:D<2048?(he[W++]=D>>6|192,he[W++]=D&63|128):(D&64512)===55296&&((j=A.charCodeAt(L+1))&64512)===56320?(D=65536+((D&1023)<<10)+(j&1023),L++,he[W++]=D>>18|240,he[W++]=D>>12&63|128,he[W++]=D>>6&63|128,he[W++]=D&63|128):(he[W++]=D>>12|224,he[W++]=D>>6&63|128,he[W++]=D&63|128);E=W-te-T}else E=l(A,te+T,P);E<32?he[te++]=160|E:E<256?(T<2&&he.copyWithin(te+2,te+1,te+1+E),he[te++]=217,he[te++]=E):E<65536?(T<3&&he.copyWithin(te+3,te+2,te+2+E),he[te++]=218,he[te++]=E>>8,he[te++]=E&255):(T<5&&he.copyWithin(te+5,te+3,te+3+E),he[te++]=219,Wt.setUint32(te,E),te+=4),te+=E}else if(b==="number")if(A>>>0===A)A<64?he[te++]=A:A<256?(he[te++]=204,he[te++]=A):A<65536?(he[te++]=205,he[te++]=A>>8,he[te++]=A&255):(he[te++]=206,Wt.setUint32(te,A),te+=4);else if(A>>0===A)A>=-32?he[te++]=256+A:A>=-128?(he[te++]=208,he[te++]=A+256):A>=-32768?(he[te++]=209,Wt.setInt16(te,A),te+=2):(he[te++]=210,Wt.setInt32(te,A),te+=4);else{let C;if((C=this.useFloat32)>0&&A<4294967296&&A>=-2147483648){he[te++]=202,Wt.setFloat32(te,A);let T;if(C<4||(T=A*Sv[(he[te]&127)<<1|he[te+1]>>7])>>0===T){te+=4;return}else te--}he[te++]=203,Wt.setFloat64(te,A),te+=8}else if(b==="object")if(!A)he[te++]=192;else{if(a){let T=a.get(A);if(T){if(!T.id){let P=a.idsToInsert||(a.idsToInsert=[]);T.id=P.push(T)}he[te++]=214,he[te++]=112,Wt.setUint32(te,T.id),te+=4;return}else a.set(A,{offset:te-i})}let C=A.constructor;if(C===Object)_(A,!0);else if(C===Array){E=A.length,E<16?he[te++]=144|E:E<65536?(he[te++]=220,he[te++]=E>>8,he[te++]=E&255):(he[te++]=221,Wt.setUint32(te,E),te+=4);for(let T=0;T<E;T++)w(A[T])}else if(C===Map){E=A.size,E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,Wt.setUint32(te,E),te+=4);for(let[T,P]of A)w(T),w(P)}else{for(let T=0,P=su.length;T<P;T++){let L=Av[T];if(A instanceof L){let D=su[T];if(D.write){D.type&&(he[te++]=212,he[te++]=D.type,he[te++]=0),w(D.write.call(this,A));return}let j=he,W=Wt,q=te;he=null;let z;try{z=D.pack.call(this,A,V=>(he=j,j=null,te+=V,te>hs&&S(te),{target:he,targetView:Wt,position:te-V}),w)}finally{j&&(he=j,Wt=W,te=q,hs=he.length-10)}z&&(z.length+te>hs&&S(z.length+te),te=nF(z,he,te,D.type));return}}_(A,!A.hasOwnProperty)}}else if(b==="boolean")he[te++]=A?195:194;else if(b==="bigint"){if(A<BigInt(1)<<BigInt(63)&&A>=-(BigInt(1)<<BigInt(63)))he[te++]=211,Wt.setBigInt64(te,A);else if(A<BigInt(1)<<BigInt(64)&&A>0)he[te++]=207,Wt.setBigUint64(te,A);else if(this.largeBigIntToFloat)he[te++]=203,Wt.setFloat64(te,Number(A));else throw new RangeError(A+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(b==="undefined")this.encodeUndefinedAsNil?he[te++]=192:(he[te++]=212,he[te++]=0,he[te++]=0);else if(b==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+b)},_=this.useRecords===!1?this.variableMapSize?A=>{let b=Object.keys(A),E=b.length;E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,Wt.setUint32(te,E),te+=4);let C;for(let T=0;T<E;T++)w(C=b[T]),w(A[C])}:(A,b)=>{he[te++]=222;let E=te-i;te+=2;let C=0;for(let T in A)(b||A.hasOwnProperty(T))&&(w(T),w(A[T]),C++);he[E+++i]=C>>8,he[E+i]=C&255}:A=>{let b=Object.keys(A),E,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let L=0,D=b.length;L<D;L++){let j=b[L];E=C[j],E||(E=C[j]=Object.create(null),T++),C=E}let P=C[ql];if(P)P>=96&&g?(he[te++]=((P-=96)&31)+96,he[te++]=P>>5):he[te++]=P;else{P=n.nextId,P||(P=64),P<f&&this.shouldShareStructure&&!this.shouldShareStructure(b)?(P=n.nextOwnId,P<m||(P=f),n.nextOwnId=P+1):(P>=m&&(P=f),n.nextId=P+1);let L=b.highByte=P>=96&&g?P-96>>5:-1;C[ql]=P,n[P-64]=b,P<f?(b.isShared=!0,n.sharedLength=P-63,s=!0,L>=0?(he[te++]=(P&31)+96,he[te++]=L):he[te++]=P):(L>=0?(he[te++]=213,he[te++]=114,he[te++]=(P&31)+96,he[te++]=L):(he[te++]=212,he[te++]=114,he[te++]=P),T&&(y+=x*T),v.length>=p&&(v.shift()[ql]=0),v.push(C),w(b))}for(let L=0,D=b.length;L<D;L++)w(A[b[L]])},S=A=>{let b;if(A>16777216){if(A-i>rx)throw new Error("Packed buffer would be larger than maximum buffer size");b=Math.min(rx,Math.round(Math.max((A-i)*(A>67108864?1.25:2),4194304)/4096)*4096)}else b=(Math.max(A-i<<2,he.length-1)>>12)+1<<12;let E=new lf(b);return Wt=new DataView(E.buffer,0,b),he.copy?he.copy(E,0,i,A):E.set(he.slice(i,A)),te-=i,i=0,hs=E.length-10,he=E}}useBuffer(e){he=e,Wt=new DataView(he.buffer,he.byteOffset,he.byteLength),te=0}};Av=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,TS];su=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:n,position:a}=t(6);s[a++]=214,s[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:s,targetView:n,position:a}=t(10);s[a++]=215,s[a++]=255,n.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:n,position:a}=t(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:n,position:a}=t(15);s[a++]=199,s[a++]=12,s[a++]=255,n.setUint32(a,e.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(s[n++]=212,s[n++]=115,s[n++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?sx(e,16,t):nx(Qu?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==zS&&this.structuredClone?sx(e,IS.indexOf(i.name),t):nx(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function sx(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:n,position:a}=i(4+s);n[a++]=199,n[a++]=s+1}else if(s+1<65536){var{target:n,position:a}=i(5+s);n[a++]=200,n[a++]=s+1>>8,n[a++]=s+1&255}else{var{target:n,position:a,targetView:o}=i(7+s);n[a++]=201,o.setUint32(a,s+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function nx(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:n}=t(i+5);r[s++]=198,n.setUint32(s,i),s+=4}r.set(e,s)}function nF(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function aF(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);i=t.pop();){let n=i.offset,a=i.id;e.copyWithin(n+r,n,s),r-=6;let o=n+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,s=n}return e}function Ml(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");Av.unshift(e.Class),su.unshift(e)}tF(e)}var US=new NS({useRecords:!1}),vW=US.pack,yW=US.pack,{NEVER:xW,ALWAYS:wW,DECIMAL_ROUND:bW,DECIMAL_FIT:_W}=iF,oF=512,lF=1024,ax=new NS({structuredClone:!0});Ml({Class:ti.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ti.prototype),e}});Ml({Class:it.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,it.prototype),e}});Ml({Class:sr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,sr.prototype),e}});Ml({Class:Y1.prototype.constructor,type:4,write(e){return e.id},read(e){return new Y1(e)}});Ml({Class:Q1.prototype.constructor,type:5,write(e){return e.data},read(e){return new Q1(e)}});Ml({Class:Si.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Si.prototype),e}});function hF(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function Rm(e){if(gv(e))return e;if(Array.isArray(e))return e.map(Rm);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Rm(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Im;(e=>{function t(s){return ax.pack(s)}e.serialize=t;function i(s){return ax.unpack(s)}e.deserialize=i;function r(s){return hF(t(Rm(s))).toString()}e.checksum=r})(Im||(Im={}));var En={LookAt:[],Follow:["Create"],DragDrop:["Transition","Audio","Create"],MouseHover:["Transition","Create","Destroy","SwitchCamera"],Scroll:["Transition","Create"],Start:["Transition","Audio","Video","Create","Destroy","SwitchCamera"],Conditional:["Transition","Audio","Video","Create","Destroy","SwitchCamera","Reset"],MouseDown:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],MouseUp:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],MousePress:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],KeyDown:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],KeyUp:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],KeyPress:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],GameControl:["Transition","Audio","Video","Create"],Collision:["Transition","Audio","Video","Create","Destroy","Reset"]},ox;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,toggle:!1,actions:new it}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new it}}e.defaultData=i})(ox||(ox={}));var nu;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(nu||(nu={}));var Bm;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:nu.propertyDefaultData(s),rOperand:{...nu.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,n){return{type:"State",object:s??null,state:n??null}}e.stateDefaultData=r})(Bm||(Bm={}));var lx;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new it,outActions:new it,condition:Bm.distanceDefaultData(r)}}e.defaultData=i})(lx||(lx={}));var hx;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new it,drop:new it}})(hx||(hx={}));var zm;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new it})(zm||(zm={}));var Nm;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Nm||(Nm={}));var cx;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new it}}e.defaultData=i})(cx||(cx={}));var dx;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new it}}e.defaultData=i})(dx||(dx={}));var ux;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new it}}e.defaultData=i})(ux||(ux={}));var px;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new it}}e.defaultData=i})(px||(px={}));var No;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n]}e.lerp=i})(No||(No={}));var za;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function n(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=n;function a(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=a;function o(l,h,d){return[l[0]+(h[0]-l[0])*d,l[1]+(h[1]-l[1])*d,l[2]+(h[2]-l[2])*d]}e.lerp=o})(za||(za={}));var au;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]}e.lerp=i})(au||(au={}));var hl;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,n){for(let a=0;a<16;a++)if(s[a]!==n[a])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,n){let a=n.slice(0);for(var o=0,l=n.length;o<l;o+=3){let h=s[3]*n[o]+s[7]*n[o+1]+s[11]*n[o+2]+s[15];a[o]=(s[0]*n[o]+s[4]*n[o+1]+s[8]*n[o+2]+s[12])/h,a[o+1]=(s[1]*n[o]+s[5]*n[o+1]+s[9]*n[o+2]+s[13])/h,a[o+2]=(s[2]*n[o]+s[6]*n[o+1]+s[10]*n[o+2]+s[14])/h}return a}e.applyMatrix4=r})(hl||(hl={}));var Oi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function n(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=n;function a(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=a;function o(l,h,d){return{r:l.r+(h.r-l.r)*d,g:l.g+(h.g-l.g)*d,b:l.b+(h.b-l.b)*d}}e.lerp=o})(Oi||(Oi={}));var Lr;(e=>{e.white={...Oi.white,a:1},e.transparent={...Oi.white,a:0};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}e.from0to1=t;function i(a,o){return{...Oi.fromHex(a),a:o}}e.fromHexAndA=i;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}e.toRgb255a1=r;function s(a,o){return Oi.equals(a,o)&&a.a===o.a}e.equals=s;function n(a,o,l){return{r:a.r+(o.r-a.r)*l,g:a.g+(o.g-a.g)*l,b:a.b+(o.b-a.b)*l,a:a.a+(o.a-a.a)*l}}e.lerp=n})(Lr||(Lr={}));var Um;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Um||(Um={}));var fx;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(fx||(fx={}));var mx;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(mx||(mx={}));var zn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(zn||(zn={}));var Ha;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Ha||(Ha={}));var Wh;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Wh||(Wh={}));var Wn;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(n=>n*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let n={...r};if(FS.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;kS.forEach(l=>{Object.assign(n.radial,{[l]:o[l]??a[l]})})}if(n.linear={...r.linear},s.linear){let a=r.linear,o=s.linear;jS.forEach(l=>{Object.assign(n.linear,{[l]:o[l]??a[l]})})}if(n.grid={...r.grid},s.grid){let a=r.grid,o=s.grid;GS.forEach(l=>{Object.assign(n.grid,{[l]:o[l]??a[l]})})}if(n.toObject={...r.toObject},s.toObject){let a=r.toObject,o=s.toObject;VS.forEach(l=>{Object.assign(n.toObject,{[l]:o[l]??a[l]})})}if(n.randomnessObject={...r.randomnessObject},s.randomnessObject){let a=r.randomnessObject,o=s.randomnessObject;HS.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(Wn||(Wn={}));var Fm;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of t){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}e.toOps=i})(Fm||(Fm={}));var FS=["count"],kS=["radius","start","end","position","scale","rotation"],jS=["position","scale","rotation"],GS=["count","size"],VS=["count","position","scale","rotation"],HS=["strength","scale","rotation","position","movement","seed","freqScale"],qh;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(qh||(qh={}));var km;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(km||(km={}));var jm;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Lr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(r==="SpotLight")return{type:r,color:Lr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Lr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(jm||(jm={}));var Gm;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Gm||(Gm={}));var Vm;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Vm||(Vm={}));var Hm;(e=>e.defaultData={...Vm.defaultData,...Gm.defaultData})(Hm||(Hm={}));var ou;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ou||(ou={}));var gx;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(gx||(gx={}));function cF(e){return e.type!=="displace"}var vx;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(vx||(vx={}));var WS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],dF=["wrapping","image","video"],Pr;(e=>{function t(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let h=n.texture;h&&Object.assign(h,o)}}e.patch=t;function i(n,a){return n==="light"&&a?r(a):s(n)}e.defaultData=i;function r(n){let a={mode:0,isMask:!1,visible:!0};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ou.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:Oi.fromHex(5526619)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Oi.fromHex(6710886),a:1},colorB:{...Oi.fromHex(6710886),a:1},colorC:{...Oi.fromHex(16777215),a:1},colorD:{...Oi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Lr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Lr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Lr.fromHexAndA(0,1),contourColor:Lr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Oi.fromHex(0),a:1},colorB:{...Oi.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}}}})(Pr||(Pr={}));var yr;(e=>{function t(h){return!h.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}e.isMergable=t;function i(h){let d="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([u,p])=>{d+=`${u}${p}`,Array.isArray(p)?p.forEach(g=>d+=`${g}`):typeof p=="object"?Object.values(p).forEach(g=>{typeof g=="number"?d+=`${g.toFixed(4)}`:d+=`${g}`}):d+=`${p}`})}),d}e.getHash=i;function r(){return{layers:new it}}e.defaultEmptyData=r;function s(h="layer1",d="layer2"){return a("phong",h,d)}e.defaultData=s;function n(h,d){return{...h,name:d}}e.withName=n;function a(h,d="layer1",c="layer2"){let u=new it;return u.push({fi:0,data:Pr.defaultData("light",h),id:d}),u.push({fi:1,data:Pr.defaultData("color"),id:c}),{layers:u}}e.defaultTwoLayerData=a;function o(h,d="phong",c="layer1",u="layer2"){let p=Pr.defaultData("texture");Object.assign(p.texture,{image:h});let g=new it;return g.push({fi:0,data:p,id:c}),g.push({fi:1,data:Pr.defaultData("light",d),id:u}),{layers:g}}e.defaultTwoLayerTextureData=o;function l(h,d="phong",c="layer1",u="layer2"){let p=Pr.defaultData("video");Object.assign(p.texture,{video:h});let g=new it;return g.push({fi:0,data:p,id:c}),g.push({fi:1,data:Pr.defaultData("light",d),id:u}),{layers:g}}e.defaultTwoLayerVideoTextureData=l})(yr||(yr={}));var lu;(e=>{function t(){return{points:new it,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(lu||(lu={}));var hu;(e=>{function t(){return{points:new it,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(hu||(hu={}));var qS={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0},Wm;(e=>{function t(i,r){let s={...i};return YS.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(Wm||(Wm={}));var XS={shape:qS,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},YS=["depth","offset","angle","twist","startScale","endScale"],cu;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(cu||(cu={}));var qm;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,Wm.merge(s.extrusion,r.extrusion))),s}e.merge=t})(qm||(qm={}));var qo;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:hu.defaultData(),extrusion:XS};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:lu.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}e.defaultData=t})(qo||(qo={}));var yx=["width","height","depth"],xx;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(xx||(xx={}));var cl;(e=>{e.identity={...Um.identity,hiddenMatrix:hl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,n){return{position:n?.position||s.position,rotation:n?.rotation||s.rotation,scale:n?.scale||s.scale,hiddenMatrix:n?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,n){return _U({position:za.isEqual(s.position,n.position)?void 0:n.position,rotation:za.isEqual(s.rotation,n.rotation)?void 0:n.rotation,scale:za.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:hl.isEqual(s.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})}e.diff=r})(cl||(cl={}));var wx;(e=>e.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(wx||(wx={}));var Ir;(e=>e.defaultData={states:new it,events:new it,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...cl.identity,cloner:null})(Ir||(Ir={}));var bx;(e=>e.defaultData={type:"Empty",...Ir.defaultData})(bx||(bx={}));var _x;(e=>e.defaultData={type:"Component",...Ir.defaultData})(_x||(_x={}));var Xo;(e=>e.defaultData={type:"Mesh",...Ir.defaultData,...Hm.defaultData})(Xo||(Xo={}));var du;(e=>e.defaultData={...Ir.defaultData,...cl.identity,...Wh.defaultData})(du||(du={}));var Xm;(e=>{function t(i){return{...Ir.defaultData,...jm.defaultData(i)}}e.defaultData=t})(Xm||(Xm={}));var uu;(e=>{function t(r,s,n=0){for(;n<s.length;){let a=r?r[s[n]]:void 0;if(s.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=t;function i(r,s,n=0){let a=t(r,s,n);if(a){let o=Object.keys(a);if(o.length===1&&o[0]==="descendants")return}return a}e.resolve=i})(uu||(uu={}));var dl;(e=>{e.rootOverrideProps=["physics"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Ir.defaultData,...s,component:r,overrides:new Si,physics:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=cl.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(dl||(dl={}));var Ym;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:hl.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new it,events:new it,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Wh.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Ir.defaultData,...Xo.defaultData,geometry:qo.defaultData("RectangleGeometry"),material:yr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Ir.defaultData,...Xo.defaultData,geometry:qo.defaultData("BooleanGeometry"),material:yr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Ir.defaultData,...Xo.defaultData,geometry:qo.defaultData("TextGeometry"),material:yr.defaultTwoLayerData("phong","layer1","layer2")}))(Ym||(Ym={}));var Ca;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new Si}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new Si})))):Ha.is(n.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(n,a){if(a===void 0)return n;let o={...n};return"material"in o&&"material"in a&&a.material&&(o.material=iu(o.material,l=>{if(typeof l!="string")for(let[h,d]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&Pr.patch(c,d)}}).data),o.materials&&a.materials&&(o.materials=iu(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let d=a.materials[h];if(typeof d!="string")for(let[c,u]of Object.entries(d.layers)){let p=l[h]?.layers?.data(c);p&&Pr.patch(p,u)}}}).data),o}function r(n,a){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function d(c,u){for(let[p,g]of Object.entries(u.layers)){let{texture:f,...m}=g;if(f!==void 0&&Object.keys(f).length>0){let v={path:[...c,"layers",p,"texture"],props:f,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,u]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...Fm.toOps(u,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:u.slide,offset:u.offset},type:0});else if(c==="material")d(["material"],u);else if(c==="materials")for(let[p,g]of Object.entries(u))d(["materials",p],g);else if(h[c]===0){if(c==="geometry"&&u.extrusion!==void 0){let p={path:[c,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[c],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=u;return l}e.toOps=r;function s(n,a){if(a===void 0)return n;let o={...n};if(Object.assign(o,cl.merge(o,a)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:a.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Ha.is(n.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=a;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(o,{geometry:qm.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Wn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Wn.merge(o.cloner,a.cloner)});else if(km.is(n.type)){let l=a;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Oi.clone(l.color))}return o}e.patch=s})(Ca||(Ca={}));var pu;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Oi.white,near:.1,far:2e3})(pu||(pu={}));var fu;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(fu||(fu={}));var ul;(e=>e.defaultData={orbitControls:fu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio: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,joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),gameControlObject:null,hdTransmission:!1})(ul||(ul={}));var Qm;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Qm||(Qm={}));var Zm;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Zm||(Zm={}));var Xh;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Qm.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Zm.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Xh||(Xh={}));var fr;(e=>e.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low",occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(fr||(fr={}));var Sx;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=new sr,a=Ym.defaultMeshObject;return s.withLight===!0&&n.push({fi:-1,data:{...Xm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]}),n}e.defaultData={backgroundColor:Lr.fromHexAndA(2960946,1),postprocessing:qh.defaultData,fog:pu.defaultData,objects:t(),environment:fr.defaultData,publish:ul.defaultData,styles:Xh.defaultData()},e.emptyData=function(s){return{backgroundColor:Lr.fromHexAndA(2960946,1),postprocessing:qh.defaultData,fog:pu.defaultData,objects:s?t(s):new sr,environment:fr.defaultData,publish:ul.defaultData,styles:Xh.defaultData()}};function i(s){return{...e.defaultData,objects:Va(s,sr.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(Sx||(Sx={}));var mu;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(mu||(mu={}));var Km;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Va(s,ti.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...mu.emptyImage,name:"AI generated image"}),Va(n,ti.prototype)}e.defaultImages=i;function r(){return{materials:new ti,images:new ti,videos:new ti,colors:new ti,audios:new ti,fonts:new ti,penumbraSize:[2,2,2]}}e.emptyData=r})(Km||(Km={}));var gu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new it,move:new it,jump:new it},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Lr.fromHexAndA(3728051,1)}}))(gu||(gu={}));function Ax(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...Gh(Ii(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Ii(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Uo(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Fo(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach(s=>{typeof s!="string"&&t(s)}):"material"in r&&typeof r.material!="string"&&t(r.material)})}function uF(e){Object.assign(e.scene.publish,{orbitControls:{...fu.defaultData,...Ii(e.scene.publish.orbitControls)}})}function pF(e){Object.assign(e.scene.publish.settings,{video:{...ul.defaultData.settings.video,...Ii(e.scene.publish.settings.video)}})}function fF(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,n]of Object.entries(r))if((WS.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(dF.includes(a)||typeof o=="boolean")&&delete n[a]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let n=s;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function mF(e){e.scene.publish.withBackground=!0}function gF(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function vF(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function yF(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function xF(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=Ii(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Ii(i).booleanExclude!==!0)}})}function wF(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function bF(e){function t(r){Object.setPrototypeOf(r,Si.prototype),r.texture&&Object.setPrototypeOf(r.texture,Si.prototype)}function i(r){Object.setPrototypeOf(r,Si.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(n=>{let a=n;if(a.material){let o=Ii(a.material).layers;i(o),a.material.layers=o}if(a.materials)for(let o=0;o<a.materials.length;o++){let l=a.materials[o],h=Ii(l).layers;i(h),l.layers=h}})})}function Mx(e){e.layers===void 0&&Object.assign(e,yr.defaultTwoLayerData("lambert"))}function hf(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...Ii(t),colors:i,steps:r};Object.assign(t,s)}})}function _F(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function Ex(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&hf(r)}):"material"in i&&typeof i.material!="string"&&hf(i.material)}),Object.values(e.shared.materials).forEach(t=>hf(t))}function SF(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function AF(e){e.shared.audios=Va({},ti.prototype)}function MF(e){e.shared.videos=Va({},ti.prototype)}function EF(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function CF(e){Object.entries(Ii(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Ii(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function TF(e){e.scene.publish.settings.web.preload=!1}function Cx(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function Tx(e){e.layers&&e.layers.forEach(t=>{cF(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 PF(e){e.shared.fonts=Va({},ti.prototype)}function DF(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function OF(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=yr.defaultTwoLayerData("phong"),a=typeof s.color=="string"?e.shared.colors[s.color]:s.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=s.alpha;let o=DF(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Ir.defaultData,...Xo.defaultData,flatShading:!1,wireframe:!1,geometry:{...qo.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:Ii(s.states),events:Ii(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Ii(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function LF(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new it,move:new it,jump:new it}});else{let n=new it;Object.assign(s,{actions:n}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&n.push({fi:0,id:st.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((a,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},d={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(d,Gh(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(d,{control1:{...a.control1},control2:{...a.control2}});let c={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},u={state:a.state,...c,...d},p={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new it({fi:0,id:st.generateUUID(),data:h},{fi:1,id:st.generateUUID(),data:u})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function RF(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new it,o=[];if(i.events.forEach((l,h,d)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...Gh(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...Gh(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&a.push({fi:d,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),a.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):i.events.insertBefore(null,[{id:st.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Px(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Pr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Dx(e){Uo(e,Px),Fo(e,Px)}function IF(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function BF(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function zF(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=yr.defaultTwoLayerData("phong"))})}function NF(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function UF(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function FF(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function kF(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function jF(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function GF(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function VF(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=gu.defaultDataThirdPerson.navmesh)})})}function HF(e){e.scene.styles||(e.scene.styles=Xh.defaultData())}function Ox(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function WF(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Fo(e,Ox),Uo(e,Ox)}var Lx=41;function qF(e){let t=e.schema??0;t!==Lx&&(console.warn("updating from ",t,"to ",Lx),t<1&&(Fo(e,Ax),Uo(e,Ax),e.schema=1),t<2&&(uF(e),e.schema=2),t<3&&(fF(e),e.schema=3),t<4&&(mF(e),e.schema=4),t<5&&(gF(e),e.schema=5),t<6&&(vF(e),e.schema=6),t<7&&(yF(e),e.schema=7),t<8&&(e.schema=8),t<9&&(Ex(e),e.schema=9),t<10&&(_F(e),e.schema=10),t<11&&(SF(e),e.schema=11),t<12&&(Ex(e),e.schema=12),t<13&&(AF(e),e.schema=13),t<14&&(EF(e),e.schema=14),t<15&&(CF(e),e.schema=15),t<16&&(TF(e),e.schema=16),t<17&&(Fo(e,Cx),Uo(e,Cx),e.schema=17),t<18&&(Fo(e,Mx),Uo(e,Mx),e.schema=18),t<19&&(pF(e),e.schema=19),t<20&&(PF(e),OF(e),e.schema=20),t<21&&(LF(e),RF(e),e.schema=21),t<22&&(Dx(e),e.schema=22),t<23&&(IF(e),e.schema=23),t<24&&(BF(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(MF(e),t<25&&(e.schema=25)),t<26&&(xF(e),e.schema=26),t<27&&(wF(e),e.schema=27),t<28&&(Dx(e),e.schema=28),t<29&&(bF(e),e.schema=29),t<30&&(zF(e),e.schema=30),t<31&&(NF(e),e.schema=31),t<33&&(UF(e),e.schema=33),t<34&&(FF(e),e.schema=34),t<35&&(kF(e),e.schema=35),t<36&&(jF(e),e.schema=36),t<37&&(GF(e),e.schema=37),t<38&&(Fo(e,Tx),Uo(e,Tx),e.schema=38),t<39&&(VF(e),e.schema=39),t<40&&(HF(e),e.schema=40),t<41&&(WF(e),e.schema=41))}function Ta(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),n={},a={},o=e[0].morphTargetsRelative,l=new He,h=0;for(let d=0;d<e.length;++d){let c=e[d],u=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,d),h+=p}}if(i){let d=0,c=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let g=0;g<p.count;++g)c.push(p.getX(g)+d);d+=e[u].attributes.position.count}l.setIndex(c)}for(let d in n){let c=Rx(n[d]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,c)}for(let d in a){let c=a[d][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let u=0;u<c;++u){let p=[];for(let f=0;f<a[d].length;++f)p.push(a[d][f][u]);let g=Rx(p);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(g)}}return l}function Rx(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let n=new t(s),a=0;for(let o=0;o<e.length;++o)n.set(e[o].array,a),a+=e[o].array.length;return new qe(n,i,r)}var XF=Math.pow(2,-24),Kc=class{constructor(){}};function Es(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function Ix(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function Bx(e,t){t.set(e)}function zx(e,t,i){let r,s;for(let n=0;n<3;n++){let a=n+3;r=e[n],s=t[n],i[n]=r<s?r:s,r=e[a],s=t[a],i[a]=r>s?r:s}}function Jc(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],n=t[e+2*r+1],a=s-n,o=s+n;a<i[r]&&(i[r]=a),o>i[r+3]&&(i[r+3]=o)}}function Xl(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function YF(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new qe(s,1));for(let n=0;n<i;n++)s[n]=n}}function QF(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,n)=>s-n);for(let s=0;s<r.length-1;s++){let n=r[s],a=r[s+1];t.push({offset:n/3,count:(a-n)/3})}return t}function cf(e,t,i,r,s=null){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0,c=1/0,u=1/0,p=1/0,g=-1/0,f=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let w=e[y+0],_=e[y+1],S=w-_,A=w+_;S<n&&(n=S),A>l&&(l=A),v&&w<c&&(c=w),v&&w>g&&(g=w);let b=e[y+2],E=e[y+3],C=b-E,T=b+E;C<a&&(a=C),T>h&&(h=T),v&&b<u&&(u=b),v&&b>f&&(f=b);let P=e[y+4],L=e[y+5],D=P-L,j=P+L;D<o&&(o=D),j>d&&(d=j),v&&P<p&&(p=P),v&&P>m&&(m=P)}r[0]=n,r[1]=a,r[2]=o,r[3]=l,r[4]=h,r[5]=d,v&&(s[0]=c,s[1]=u,s[2]=p,s[3]=g,s[4]=f,s[5]=m)}function ZF(e,t,i,r){let s=1/0,n=1/0,a=1/0,o=-1/0,l=-1/0,h=-1/0;for(let d=t*6,c=(t+i)*6;d<c;d+=6){let u=e[d+0];u<s&&(s=u),u>o&&(o=u);let p=e[d+2];p<n&&(n=p),p>l&&(l=p);let g=e[d+4];g<a&&(a=g),g>h&&(h=g)}r[0]=s,r[1]=n,r[2]=a,r[3]=o,r[4]=l,r[5]=h}function KF(e,t,i,r,s){let n=i,a=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;n<=a&&t[n*6+l]<o;)n++;for(;n<=a&&t[a*6+l]>=o;)a--;if(n<a){for(let h=0;h<3;h++){let d=e[n*3+h];e[n*3+h]=e[a*3+h],e[a*3+h]=d;let c=t[n*6+h*2+0];t[n*6+h*2+0]=t[a*6+h*2+0],t[a*6+h*2+0]=c;let u=t[n*6+h*2+1];t[n*6+h*2+1]=t[a*6+h*2+1],t[a*6+h*2+1]=u}n++,a--}else return n}}var en=32,JF=(e,t)=>e.candidate-t.candidate,Cn=new Array(en).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),$c=new Float32Array(6);function $F(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=Ix(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=Ix(e),a!==-1&&(o=e6(i,r,s,a));else if(n===2){let l=Xl(e),h=1.25*s,d=r*6,c=(r+s)*6;for(let u=0;u<3;u++){let p=t[u],g=(t[u+3]-p)/en;if(s<en/4){let f=[...Cn];f.length=s;let m=0;for(let y=d;y<c;y+=6,m++){let x=f[m];x.candidate=i[y+2*u],x.count=0;let{bounds:w,leftCacheBounds:_,rightCacheBounds:S}=x;for(let A=0;A<3;A++)S[A]=1/0,S[A+3]=-1/0,_[A]=1/0,_[A+3]=-1/0,w[A]=1/0,w[A+3]=-1/0;Jc(y,i,w)}f.sort(JF);let v=s;for(let y=0;y<v;y++){let x=f[y];for(;y+1<v&&f[y+1].candidate===x.candidate;)f.splice(y+1,1),v--}for(let y=d;y<c;y+=6){let x=i[y+2*u];for(let w=0;w<v;w++){let _=f[w];x>=_.candidate?Jc(y,i,_.rightCacheBounds):(Jc(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=f[y],w=x.count,_=s-x.count,S=x.leftCacheBounds,A=x.rightCacheBounds,b=0;w!==0&&(b=Xl(S)/l);let E=0;_!==0&&(E=Xl(A)/l);let C=1+1.25*(b*w+E*_);C<h&&(a=u,h=C,o=x.candidate)}}else{for(let v=0;v<en;v++){let y=Cn[v];y.count=0,y.candidate=p+g+v*g;let x=y.bounds;for(let w=0;w<3;w++)x[w]=1/0,x[w+3]=-1/0}for(let v=d;v<c;v+=6){let y=~~((i[v+2*u]-p)/g);y>=en&&(y=en-1);let x=Cn[y];x.count++,Jc(v,i,x.bounds)}let f=Cn[en-1];Bx(f.bounds,f.rightCacheBounds);for(let v=en-2;v>=0;v--){let y=Cn[v],x=Cn[v+1];zx(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<en-1;v++){let y=Cn[v],x=y.count,w=y.bounds,_=Cn[v+1].rightCacheBounds;x!==0&&(m===0?Bx(w,$c):zx(w,$c,$c)),m+=x;let S=0,A=0;m!==0&&(S=Xl($c)/l);let b=s-m;b!==0&&(A=Xl(_)/l);let E=1+1.25*(S*m+A*b);E<h&&(a=u,h=E,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function e6(e,t,i,r){let s=0;for(let n=t,a=t+i;n<a;n++)s+=e[n*6+r*2];return s/i}function t6(e,t){let i=e.attributes.position,r=i.array,s=e.index.array,n=s.length/3,a=new Float32Array(n*6),o=i.offset||0,l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);for(let h=0;h<n;h++){let d=h*3,c=h*6,u=s[d+0]*l+o,p=s[d+1]*l+o,g=s[d+2]*l+o;for(let f=0;f<3;f++){let m=r[u+f],v=r[p+f],y=r[g+f],x=m;v<x&&(x=v),y<x&&(x=y);let w=m;v>w&&(w=v),y>w&&(w=y);let _=(w-x)/2,S=f*2;a[c+S+0]=x+_,a[c+S+1]=_+(Math.abs(x)+_)*XF,x<t[f]&&(t[f]=x),w>t[f+3]&&(t[f+3]=w)}}return a}function i6(e,t){function i(v){u&&u(v/p)}function r(v,y,x,w=null,_=0){if(!g&&_>=l&&(g=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=d||_>=l)return i(y+x),v.offset=y,v.count=x,v;let S=$F(v.boundingData,w,a,y,x,c);if(S.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let A=KF(o,a,y,x,S);if(A===y||A===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=S.axis;let b=new Kc,E=y,C=A-y;v.left=b,b.boundingData=new Float32Array(6),cf(a,E,C,b.boundingData,n),r(b,E,C,n,_+1);let T=new Kc,P=A,L=x-C;v.right=T,T.boundingData=new Float32Array(6),cf(a,P,L,T.boundingData,n),r(T,P,L,n,_+1)}return v}YF(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=t6(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,d=t.maxLeafTris,c=t.strategy,u=t.onProgress,p=e.index.count/3,g=!1,f=[],m=QF(e);if(m.length===1){let v=m[0],y=new Kc;y.boundingData=s,ZF(a,v.offset,v.count,n),r(y,v.offset,v.count,n),f.push(y)}else for(let v of m){let y=new Kc;y.boundingData=new Float32Array(6),cf(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),f.push(y)}return f}function r6(e,t){let i=i6(e,t),r,s,n,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let d=0;d<i.length;d++){let c=i[d],u=l(c),p=new o(32*u);r=new Float32Array(p),s=new Uint32Array(p),n=new Uint16Array(p),h(0,c),a.push(p)}return a;function l(d){return d.count?1:1+l(d.left)+l(d.right)}function h(d,c){let u=d/4,p=d/2,g=!!c.count,f=c.boundingData;for(let m=0;m<6;m++)r[u+m]=f[m];if(g){let m=c.offset,v=c.count;return s[u+6]=m,n[p+14]=v,n[p+15]=65535,d+32}else{let m=c.left,v=c.right,y=c.splitAxis,x;if(x=h(d+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=x/4,x=h(x,v),s[u+7]=y,x}}}var zs=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,n=e.length;s<n;s++){let a=e[s][t];i=a<i?a:i,r=a>r?a:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,n=t.length;s<n;s++){let a=t[s],o=e.dot(a);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};zs.prototype.setFromBox=function(){let e=new M;return function(t,i){let r=i.min,s=i.max,n=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let d=t.dot(e);n=Math.min(d,n),a=Math.max(d,a)}this.min=n,this.max=a}}();var SW=function(){let e=new zs;return function(t,i){let r=t.points,s=t.satAxes,n=t.satBounds,a=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let d=n[h],c=s[h];if(e.setFromPoints(c,a),d.isSeparated(e))return!1}for(let h=0;h<3;h++){let d=l[h],c=o[h];if(e.setFromPoints(c,r),d.isSeparated(e))return!1}}}(),s6=function(){let e=new M,t=new M,i=new M;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,s.start),t.subVectors(s.end,s.start);let d=i.dot(h),c=h.dot(o),u=h.dot(h),p=i.dot(o),g=o.dot(o)*u-c*c,f,m;g!==0?f=(d*c-p*u)/g:f=0,m=(d+f*c)/u,n.x=f,n.y=m}}(),Mv=function(){let e=new k,t=new M,i=new M;return function(r,s,n,a){s6(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,n),s.at(l,a);return}else if(o>=0&&o<=1){l<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,n);return}else if(l>=0&&l<=1){o<0?r.at(0,n):r.at(1,n),s.closestPointToPoint(n,!0,a);return}else{let h;o<0?h=r.start:h=r.end;let d;l<0?d=s.start:d=s.end;let c=t,u=i;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(d)<=u.distanceToSquared(h)){n.copy(c),a.copy(d);return}else{n.copy(h),a.copy(u);return}}}}(),n6=function(){let e=new M,t=new M,i=new pr,r=new Rr;return function(s,n){let{radius:a,center:o}=s,{a:l,b:h,c:d}=n;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a||(r.start=l,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a)||(r.start=h,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a))return!0;let c=n.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=a){let u=c.projectPoint(o,t);if(n.containsPoint(u))return!0}return!1}}(),a6=1e-15;function vo(e){return Math.abs(e)<a6}var mn=class extends Ji{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M),this.satBounds=new Array(4).fill().map(()=>new zs),this.points=[this.a,this.b,this.c],this.sphere=new Nr,this.plane=new pr,this.needsUpdate=!0}intersectsSphere(e){return n6(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,n=this.satBounds,a=s[0],o=n[0];this.getNormal(a),o.setFromPoints(a,r);let l=s[1],h=n[1];l.subVectors(e,t),h.setFromPoints(l,r);let d=s[2],c=n[2];d.subVectors(t,i),c.setFromPoints(d,r);let u=s[3],p=n[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};mn.prototype.closestPointToSegment=function(){let e=new M,t=new M,i=new Rr;return function(r,s=null,n=null){let{start:a,end:o}=r,l=this.points,h,d=1/0;for(let c=0;c<3;c++){let u=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[u]),Mv(i,r,e,t),h=e.distanceToSquared(t),h<d&&(d=h,s&&s.copy(e),n&&n.copy(t))}return this.closestPointToPoint(a,e),h=a.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),n&&n.copy(a)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),n&&n.copy(o)),Math.sqrt(d)}}();mn.prototype.intersectsTriangle=function(){let e=new mn,t=new Array(3),i=new Array(3),r=new zs,s=new zs,n=new M,a=new M,o=new M,l=new M,h=new Rr,d=new Rr,c=new Rr;return function(u,p=null){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let g=this.plane,f=u.plane;if(Math.abs(g.normal.dot(f.normal))>1-1e-10){let m=this.satBounds,v=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let w=0;w<4;w++){let _=m[w],S=v[w];if(r.setFromPoints(S,i),_.isSeparated(r))return!1}let y=u.satBounds,x=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let _=y[w],S=x[w];if(r.setFromPoints(S,t),_.isSeparated(r))return!1}for(let w=0;w<4;w++){let _=v[w];for(let S=0;S<4;S++){let A=x[S];if(n.crossVectors(_,A),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let m=this.points,v=!1,y=0;for(let P=0;P<3;P++){let L=m[P],D=m[(P+1)%3];h.start.copy(L),h.end.copy(D),h.delta(a);let j=v?d.start:d.end,W=vo(f.distanceToPoint(L));if(vo(f.normal.dot(a))&&W){d.copy(h),y=2;break}if((f.intersectLine(h,j)||W)&&!vo(j.distanceTo(D))){if(y++,v)break;v=!0}}if(y===1&&this.containsPoint(d.start))return p&&(p.start.copy(d.start),p.end.copy(d.start)),!0;if(y!==2)return!1;let x=u.points,w=!1,_=0;for(let P=0;P<3;P++){let L=x[P],D=x[(P+1)%3];h.start.copy(L),h.end.copy(D),h.delta(o);let j=w?c.start:c.end,W=vo(g.distanceToPoint(L));if(vo(g.normal.dot(o))&&W){c.copy(h),_=2;break}if((g.intersectLine(h,j)||W)&&!vo(j.distanceTo(D))){if(_++,w)break;w=!0}}if(_===1&&this.containsPoint(c.start))return p&&(p.start.copy(c.start),p.end.copy(c.start)),!0;if(_!==2)return!1;if(d.delta(a),c.delta(o),a.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let S=d.start.dot(a),A=d.end.dot(a),b=c.start.dot(a),E=c.end.dot(a),C=A<b,T=S<E;return S!==E&&b!==A&&C===T?!1:(p&&(l.subVectors(d.start,c.start),l.dot(a)>0?p.start.copy(d.start):p.start.copy(c.start),l.subVectors(d.end,c.end),l.dot(a)<0?p.end.copy(d.end):p.end.copy(c.end)),!0)}}}();mn.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();mn.prototype.distanceToTriangle=function(){let e=new M,t=new M,i=["a","b","c"],r=new Rr,s=new Rr;return function(n,a=null,o=null){let l=a||o?r:null;if(this.intersectsTriangle(n,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let d=0;d<3;d++){let c,u=i[d],p=n[u];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,a&&a.copy(e),o&&o.copy(p));let g=this[u];n.closestPointToPoint(g,e),c=g.distanceToSquared(e),c<h&&(h=c,a&&a.copy(g),o&&o.copy(e))}for(let d=0;d<3;d++){let c=i[d],u=i[(d+1)%3];r.set(this[c],this[u]);for(let p=0;p<3;p++){let g=i[p],f=i[(p+1)%3];s.set(n[g],n[f]),Mv(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Ns=class extends si{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new me,this.invMatrix=new me,this.points=new Array(8).fill().map(()=>new M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new zs),this.alignedSatBounds=new Array(3).fill().map(()=>new zs),this.needsUpdate=!1}set(e,t,i){super.set(e,t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Ns.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){let c=1*l|2*h|4*d,u=r[c];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=d?i.z:t.z,u.applyMatrix4(e)}let s=this.satBounds,n=this.satAxes,a=r[0];for(let l=0;l<3;l++){let h=n[l],d=s[l],c=1<<l,u=r[c];h.subVectors(a,u),d.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Ns.prototype.intersectsBox=function(){let e=new zs;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,n=this.satAxes,a=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,a[0].isSeparated(e)||(e.min=i.y,e.max=r.y,a[1].isSeparated(e))||(e.min=i.z,e.max=r.z,a[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=n[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Ns.prototype.intersectsTriangle=function(){let e=new mn,t=new Array(3),i=new zs,r=new zs,s=new M;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);let a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let c=0;c<3;c++){let u=a[c],p=o[c];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=n.satBounds,h=n.satAxes,d=this.points;for(let c=0;c<3;c++){let u=l[c],p=h[c];if(i.setFromPoints(p,d),u.isSeparated(i))return!1}for(let c=0;c<3;c++){let u=o[c];for(let p=0;p<4;p++){let g=h[p];if(s.crossVectors(u,g),i.setFromPoints(s,t),r.setFromPoints(s,d),i.isSeparated(r))return!1}}return!0}}();Ns.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Ns.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ns.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Rr),i=new Array(12).fill().map(()=>new Rr),r=new M,s=new M;return function(n,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(s),this.closestPointToPoint(s,r),n.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=a*a,d=n.min,c=n.max,u=this.points,p=1/0;for(let f=0;f<8;f++){let m=u[f];s.copy(m).clamp(d,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let g=0;for(let f=0;f<3;f++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(f+1)%3,x=(f+2)%3,w=m<<y|v<<x,_=1<<f|m<<y|v<<x,S=u[w],A=u[_];t[g].set(S,A);let b=e[f],E=e[y],C=e[x],T=i[g],P=T.start,L=T.end;P[b]=d[b],P[E]=m?d[E]:c[E],P[C]=v?d[C]:c[E],L[b]=c[b],L[E]=m?d[E]:c[E],L[C]=v?d[C]:c[E],g++}for(let f=0;f<=1;f++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=f?c.x:d.x,s.y=m?c.y:d.y,s.z=v?c.z:d.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let f=0;f<12;f++){let m=t[f];for(let v=0;v<12;v++){let y=i[v];Mv(m,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var ed=new M,td=new M,id=new M,Nx=new k,Ux=new k,Fx=new k,kx=new M;function o6(e,t,i,r,s,n){let a;return n===gi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==mr,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function l6(e,t,i,r,s,n,a){ed.fromBufferAttribute(t,r),td.fromBufferAttribute(t,s),id.fromBufferAttribute(t,n);let o=o6(e,ed,td,id,kx,a);if(o){i&&(Nx.fromBufferAttribute(i,r),Ux.fromBufferAttribute(i,s),Fx.fromBufferAttribute(i,n),o.uv=Ji.getUV(kx,ed,td,id,Nx,Ux,Fx,new k));let l={a:r,b:s,c:n,normal:new M,materialIndex:0};Ji.getNormal(ed,td,id,l.normal),o.face=l,o.faceIndex=r}return o}function QS(e,t,i,r,s){let n=r*3,a=e.index.getX(n),o=e.index.getX(n+1),l=e.index.getX(n+2),h=l6(i,e.attributes.position,e.attributes.uv,a,o,l,t);return h?(h.faceIndex=r,s&&s.push(h),h):null}function h6(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)QS(e,t,i,a,n)}function c6(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=QS(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function ZS(e,t,i){return e===null||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far)?null:e}function Ss(e,t,i,r){let s=e.a,n=e.b,a=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),n.x=r.getX(l),n.y=r.getY(l),n.z=r.getZ(l),a.x=r.getX(h),a.y=r.getY(h),a.z=r.getZ(h)}function jx(e,t,i,r,s,n,a){let o=i.index,l=i.attributes.position;for(let h=e,d=t+e;h<d;h++)if(Ss(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var KS=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function kn(e,t){return t[e+15]===65535}function Yo(e,t){return t[e+6]}function Yh(e,t){return t[e+14]}function Qh(e){return e+8}function Zh(e,t){return t[e+6]}function d6(e,t){return t[e+7]}var ko=new si,vu=new M,u6=["x","y","z"];function Jm(e,t,i,r,s){let n=e*2,a=El,o=Zn,l=Kn;if(kn(n,o)){let h=Yo(e,l),d=Yh(n,o);h6(t,i,r,h,d,s)}else{let h=Qh(e);yu(h,a,r,vu)&&Jm(h,t,i,r,s);let d=Zh(e,l);yu(d,a,r,vu)&&Jm(d,t,i,r,s)}}function $m(e,t,i,r){let s=e*2,n=El,a=Zn,o=Kn;if(kn(s,a)){let l=Yo(e,o),h=Yh(s,a);return c6(t,i,r,l,h)}else{let l=d6(e,o),h=u6[l],d=r.direction[h]>=0,c,u;d?(c=Qh(e),u=Zh(e,o)):(c=Zh(e,o),u=Qh(e));let p=yu(c,n,r,vu)?$m(c,t,i,r):null;if(p){let f=p.point[h];if(d?f<=n[u+l]:f>=n[u+l+3])return p}let g=yu(u,n,r,vu)?$m(u,t,i,r):null;return p&&g?p.distance<=g.distance?p:g:p||g||null}}var p6=function(){let e,t,i=[],r=new KS(()=>new si);return function(...n){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let a=s(...n);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),a};function s(n,a,o,l,h=null,d=0,c=0){function u(y){let x=y*2,w=Zn,_=Kn;for(;!kn(x,w);)y=Qh(y),x=y*2;return Yo(y,_)}function p(y){let x=y*2,w=Zn,_=Kn;for(;!kn(x,w);)y=Zh(y,_),x=y*2;return Yo(y,_)+Yh(x,w)}let g=n*2,f=El,m=Zn,v=Kn;if(kn(g,m)){let y=Yo(n,v),x=Yh(g,m);return Es(n,f,e),l(y,x,!1,c,d+n,e)}else{let y=Qh(n),x=Zh(n,v),w=y,_=x,S,A,b,E;if(h&&(b=e,E=t,Es(w,f,b),Es(_,f,E),S=h(b),A=h(E),A<S)){w=x,_=y;let W=S;S=A,A=W,b=E}b||(b=e,Es(w,f,b));let C=kn(w*2,m),T=o(b,C,S,c+1,d+w),P;if(T===2){let W=u(w),q=p(w)-W;P=l(W,q,!0,c+1,d+w,b)}else P=T&&s(w,a,o,l,h,d,c+1);if(P)return!0;E=t,Es(_,f,E);let L=kn(_*2,m),D=o(E,L,A,c+1,d+_),j;if(D===2){let W=u(_),q=p(_)-W;j=l(W,q,!0,c+1,d+_,E)}else j=D&&s(_,a,o,l,h,d,c+1);return!!j}}}(),f6=function(){let e=new mn,t=new mn,i=new me,r=new Ns,s=new Ns;return function n(a,o,l,h,d=null){let c=a*2,u=El,p=Zn,g=Kn;if(d===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),d=r),kn(c,p)){let f=o,m=f.index,v=f.attributes.position,y=l.index,x=l.attributes.position,w=Yo(a,g),_=Yh(c,p);if(i.copy(h).invert(),l.boundsTree)return Es(a,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>s.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(h),S.b.applyMatrix4(h),S.c.applyMatrix4(h),S.needsUpdate=!0;for(let A=w*3,b=(_+w)*3;A<b;A+=3)if(Ss(t,A,m,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let S=w*3,A=_+w*3;S<A;S+=3){Ss(e,S,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let b=0,E=y.count;b<E;b+=3)if(Ss(t,b,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let f=a+8,m=g[a+6];return Es(f,u,ko),!!(d.intersectsBox(ko)&&n(f,o,l,h,d)||(Es(m,u,ko),d.intersectsBox(ko)&&n(m,o,l,h,d)))}}}();function yu(e,t,i,r){return Es(e,t,ko),i.intersectBox(ko,r)}var eg=[],Ld,El,Zn,Kn;function mh(e){Ld&&eg.push(Ld),Ld=e,El=new Float32Array(e),Zn=new Uint16Array(e),Kn=new Uint32Array(e)}function rd(){Ld=null,El=null,Zn=null,Kn=null,eg.length&&mh(eg.pop())}var df=Symbol("skip tree generation"),uf=new si,pf=new si,yo=new me,fa=new Ns,Yl=new Ns,Ql=new M,sd=new M,m6=new M,g6=new M,v6=new M,Gx=new si,ds=new KS(()=>new mn),Ai=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ai.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),n;return t.cloneBuffers?n={roots:r.map(a=>a.slice()),index:s.array.slice()}:n={roots:r,index:s.array},n}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ai.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,n=new Ai(t,{...i,[df]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new qe(e.index,1,!1);t.setIndex(o)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return n}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[df]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[df]||(this._roots=r6(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new si))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s=r.array,n=r.offset||0,a=3;r.isInterleavedBufferAttribute&&(a=r.data.stride);let o,l,h,d,c=0,u=this._roots;for(let g=0,f=u.length;g<f;g++)o=u[g],l=new Uint32Array(o),h=new Uint16Array(o),d=new Float32Array(o),p(0,c),c+=o.byteLength;function p(g,f,m=!1){let v=g*2;if(h[v+15]===65535){let y=l[g+6],x=h[v+14],w=1/0,_=1/0,S=1/0,A=-1/0,b=-1/0,E=-1/0;for(let C=3*y,T=3*(y+x);C<T;C++){let P=i[C]*a+n,L=s[P+0],D=s[P+1],j=s[P+2];L<w&&(w=L),L>A&&(A=L),D<_&&(_=D),D>b&&(b=D),j<S&&(S=j),j>E&&(E=j)}return d[g+0]!==w||d[g+1]!==_||d[g+2]!==S||d[g+3]!==A||d[g+4]!==b||d[g+5]!==E?(d[g+0]=w,d[g+1]=_,d[g+2]=S,d[g+3]=A,d[g+4]=b,d[g+5]=E,!0):!1}else{let y=g+8,x=l[g+6],w=y+f,_=x+f,S=m,A=!1,b=!1;e?S||(A=e.has(w),b=e.has(_),S=!A&&!b):(A=!0,b=!0);let E=S||A,C=S||b,T=!1;E&&(T=p(y,f,S));let P=!1;C&&(P=p(x,f,S));let L=T||P;if(L)for(let D=0;D<3;D++){let j=y+D,W=x+D,q=d[j],z=d[j+3],V=d[W],F=d[W+3];d[g+D]=q<V?q:V,d[g+D+3]=z>F?z:F}return L}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);n(0);function n(a,o=0){let l=a*2,h=s[l+15]===65535;if(h){let d=r[a+6],c=s[l+14];e(o,h,new Float32Array(i,a*4,6),d,c)}else{let d=a+8,c=r[a+6],u=r[a+7];e(o,h,new Float32Array(i,a*4,6),u)||(n(d,o+1),n(c,o+1))}}}raycast(e,t=rs){let i=this._roots,r=this.geometry,s=[],n=t.isMaterial,a=Array.isArray(t),o=r.groups,l=n?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=a?t[o[h].materialIndex].side:l,u=s.length;if(mh(i[h]),Jm(0,r,c,e,s),rd(),a){let p=o[h].materialIndex;for(let g=u,f=s.length;g<f;g++)s[g].face.materialIndex=p}}return s}raycastFirst(e,t=rs){let i=this._roots,r=this.geometry,s=t.isMaterial,n=Array.isArray(t),a=null,o=r.groups,l=s?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=n?t[o[h].materialIndex].side:l;mh(i[h]);let u=$m(0,r,c,e);rd(),u!=null&&(a==null||u.distance<a.distance)&&(a=u,n&&(u.face.materialIndex=o[h].materialIndex))}return a}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(mh(s),r=f6(0,i,e,t),rd(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(u,p,g,f)=>{let m=p*3;return c(u,m,m+1,m+2,g,f)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=ds.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(u,p,g,f,m)=>c(u,p,g,f,m)?!0:jx(u,p,r,l,g,f,s)}else o||(l?o=(c,u,p,g)=>jx(c,u,r,l,p,g,s):o=(c,u,p)=>p);let h=!1,d=0;for(let c of this._roots){if(mh(c),h=p6(0,r,a,o,n,d),rd(),h)break;d+=c.byteLength}return ds.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,n=this.geometry.index,a=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;yo.copy(t).invert();let h=ds.getPrimitive(),d=ds.getPrimitive();if(s){let u=function(p,g,f,m,v,y,x,w){for(let _=f,S=f+m;_<S;_++){Ss(d,_*3,o,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=p,b=p+g;A<b;A++)if(Ss(h,A*3,n,a),h.needsUpdate=!0,s(h,d,A,_,v,y,x,w))return!0}return!1};if(r){let p=r;r=function(g,f,m,v,y,x,w,_){return p(g,f,m,v,y,x,w,_)?!0:u(g,f,m,v,y,x,w,_)}}else r=u}e.getBoundingBox(pf),pf.applyMatrix4(t);let c=this.shapecast({intersectsBounds:u=>pf.intersectsBox(u),intersectsRange:(u,p,g,f,m,v)=>(uf.copy(v),uf.applyMatrix4(yo),e.shapecast({intersectsBounds:y=>uf.intersectsBox(y),intersectsRange:(y,x,w,_,S)=>r(u,p,y,x,f,m,_,S)}))});return ds.releasePrimitive(h),ds.releasePrimitive(d),c}intersectsBox(e,t){return fa.set(e.min,e.max,t),fa.needsUpdate=!0,this.shapecast({intersectsBounds:i=>fa.intersectsBox(i),intersectsTriangle:i=>fa.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,n=1/0){e.boundingBox||e.computeBoundingBox(),fa.set(e.boundingBox.min,e.boundingBox.max,t),fa.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,d=e.index,c=ds.getPrimitive(),u=ds.getPrimitive(),p=sd,g=m6,f=null,m=null;r&&(f=g6,m=v6);let v=1/0,y=null,x=null;return yo.copy(t).invert(),Yl.matrix.copy(yo),this.shapecast({boundsTraverseOrder:w=>fa.distanceToBox(w),intersectsBounds:(w,_,S)=>S<v&&S<n?(_&&(Yl.min.copy(w.min),Yl.max.copy(w.max),Yl.needsUpdate=!0),!0):!1,intersectsRange:(w,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>Yl.distanceToBox(S),intersectsBounds:(S,A,b)=>b<v&&b<n,intersectsRange:(S,A)=>{for(let b=S*3,E=(S+A)*3;b<E;b+=3){Ss(u,b,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=w*3,T=(w+_)*3;C<T;C+=3){Ss(c,C,l,o),c.needsUpdate=!0;let P=c.distanceToTriangle(u,p,f);if(P<v&&(g.copy(p),m&&m.copy(f),v=P,y=C/3,x=b/3),P<s)return!0}}}});{let S=d?d.count:h.count;for(let A=0,b=S;A<b;A+=3){Ss(u,A,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let E=w*3,C=(w+_)*3;E<C;E+=3){Ss(c,E,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(u,p,f);if(T<v&&(g.copy(p),m&&m.copy(f),v=T,y=E/3,x=A/3),T<s)return!0}}}}}),ds.releasePrimitive(c),ds.releasePrimitive(u),v===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(yo),g.applyMatrix4(yo),r.distance=g.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,n=r*r,a=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Ql.copy(e).clamp(h.min,h.max),Ql.distanceToSquared(e)),intersectsBounds:(h,d,c)=>c<a&&c<n,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Ql);let c=e.distanceToSquared(Ql);return c<a&&(sd.copy(Ql),a=c,o=d),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(sd):t.point=sd.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Es(0,new Float32Array(t),Gx),e.union(Gx)}),e}},Vx=Ai.prototype.raycast;Ai.prototype.raycast=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,i,r,s]=e;return Vx.call(this,r,t.material).forEach(n=>{n=ZS(n,t,i),n&&s.push(n)}),s}else return Vx.apply(this,e)};var Hx=Ai.prototype.raycastFirst;Ai.prototype.raycastFirst=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,i,r]=e;return ZS(Hx.call(this,r,t.material),t,i)}else return Hx.apply(this,e)};var Wx=Ai.prototype.closestPointToPoint;Ai.prototype.closestPointToPoint=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),e.unshift();let t=e[1],i={};return e[1]=i,Wx.apply(this,e),t&&t.copy(i.point),i.distance}else return Wx.apply(this,e)};var qx=Ai.prototype.closestPointToGeometry;Ai.prototype.closestPointToGeometry=function(...e){let t=e[2],i=e[3];if(t&&t.isVector3||i&&i.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let r={},s={},n=e[1];return e[2]=r,e[3]=s,qx.apply(this,e),t&&t.copy(r.point),i&&i.copy(s.point).applyMatrix4(n),r.distance}else return qx.apply(this,e)};var Xx=Ai.prototype.refit;Ai.prototype.refit=function(...e){let t=e[0],i=e[1];if(i&&(i instanceof Set||Array.isArray(i))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let r=new Set;i.forEach(s=>r.add(s)),t&&t.forEach(s=>r.add(s)),Xx.call(this,r)}else Xx.apply(this,e)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(e=>{let t=Ai.prototype[e];Ai.prototype[e]=function(...i){return(i[0]===null||i[0].isMesh)&&(i.shift(),console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,i)}});var Zl=$h(XM()),y6=.5*(Math.sqrt(3)-1),Kl=(3-Math.sqrt(3))/6,x6=1/3,us=1/6,AW=(Math.sqrt(5)-1)/4,MW=(5-Math.sqrt(5))/20,Eh=e=>Math.floor(e)|0,Yx=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]),ff=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 mf(e=Math.random){let t=JS(e),i=new Float64Array(t).map(s=>Yx[s%12*2]),r=new Float64Array(t).map(s=>Yx[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*y6,d=Eh(s+h),c=Eh(n+h),u=(d+c)*Kl,p=d-u,g=c-u,f=s-p,m=n-g,v,y;f>m?(v=1,y=0):(v=0,y=1);let x=f-v+Kl,w=m-y+Kl,_=f-1+2*Kl,S=m-1+2*Kl,A=d&255,b=c&255,E=.5-f*f-m*m;if(E>=0){let P=A+t[b],L=i[P],D=r[P];E*=E,a=E*E*(L*f+D*m)}let C=.5-x*x-w*w;if(C>=0){let P=A+v+t[b+y],L=i[P],D=r[P];C*=C,o=C*C*(L*x+D*w)}let T=.5-_*_-S*S;if(T>=0){let P=A+1+t[b+1],L=i[P],D=r[P];T*=T,l=T*T*(L*_+D*S)}return 70*(a+o+l)}}function w6(e=Math.random){let t=JS(e),i=new Float64Array(t).map(n=>ff[n%12*3]),r=new Float64Array(t).map(n=>ff[n%12*3+1]),s=new Float64Array(t).map(n=>ff[n%12*3+2]);return function(n,a,o){let l,h,d,c,u=(n+a+o)*x6,p=Eh(n+u),g=Eh(a+u),f=Eh(o+u),m=(p+g+f)*us,v=p-m,y=g-m,x=f-m,w=n-v,_=a-y,S=o-x,A,b,E,C,T,P;w>=_?_>=S?(A=1,b=0,E=0,C=1,T=1,P=0):w>=S?(A=1,b=0,E=0,C=1,T=0,P=1):(A=0,b=0,E=1,C=1,T=0,P=1):_<S?(A=0,b=0,E=1,C=0,T=1,P=1):w<S?(A=0,b=1,E=0,C=0,T=1,P=1):(A=0,b=1,E=0,C=1,T=1,P=0);let L=w-A+us,D=_-b+us,j=S-E+us,W=w-C+2*us,q=_-T+2*us,z=S-P+2*us,V=w-1+3*us,F=_-1+3*us,N=S-1+3*us,B=p&255,H=g&255,X=f&255,Q=.6-w*w-_*_-S*S;if(Q<0)l=0;else{let $=B+t[H+t[X]];Q*=Q,l=Q*Q*(i[$]*w+r[$]*_+s[$]*S)}let U=.6-L*L-D*D-j*j;if(U<0)h=0;else{let $=B+A+t[H+b+t[X+E]];U*=U,h=U*U*(i[$]*L+r[$]*D+s[$]*j)}let ne=.6-W*W-q*q-z*z;if(ne<0)d=0;else{let $=B+C+t[H+T+t[X+P]];ne*=ne,d=ne*ne*(i[$]*W+r[$]*q+s[$]*z)}let G=.6-V*V-F*F-N*N;if(G<0)c=0;else{let $=B+1+t[H+1+t[X+1]];G*=G,c=G*G*(i[$]*V+r[$]*F+s[$]*N)}return 32*(l+h+d+c)}}function JS(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Wr=new Ji,b6=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Wr.a.fromBufferAttribute(e,r),Wr.b.fromBufferAttribute(e,r+1),Wr.c.fromBufferAttribute(e,r+2),s*=Wr.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||t[n-1]<=e&&t[n]>e){s=n;break}else e<t[n]?r=n-1:i=n+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Wr.a.fromBufferAttribute(this.positionAttribute,e*3),Wr.b.fromBufferAttribute(this.positionAttribute,e*3+1),Wr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Wr.a,r).addScaledVector(Wr.b,s).addScaledVector(Wr.c,1-(r+s)),Wr.getNormal(i),this}},_6=$h(Wb()),S6=new me,A6=new me,M6=new me,xu;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(xu||(xu={}));var Ev=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new me,this.copyPreviousMatrix=!0,this.hiddenMatrix=new me,this.matrixWorldRigid=new me,this.shearScale=new me,this.shearScaleInv=new me}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Et&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)xu.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:n}=(0,_6.SVD)(i),a=S6.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=A6.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=M6.copy(o).transpose();this.shearScale.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,l).copyPosition(this.matrixWorld),n.every(h=>Math.abs(n[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof me?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},E6=class extends Ev(Et){},C6=e=>e.type==="Mesh",Gi=class extends E6{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Gi(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return C6(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}},Sa=new M,Aa=new M,Qo=new me,$S=[new M(-1,1,1),new M(-1,-1,1),new M(1,-1,1),new M(1,1,1),new M(-1,1,-1),new M(-1,-1,-1),new M(1,-1,-1),new M(1,1,-1)],T6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],P6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Qx=(e,t,i)=>{e.updateEntityBoxSize(Sa,Aa),Qo.copy(t).multiply(e.matrixWorld),Aa.x===0&&Aa.y===0&&Aa.z===0?i.push(new M(Sa.x,Sa.y,Sa.z).applyMatrix4(Qo)):$S.forEach(r=>{i.push(r.clone().multiply(Aa).add(Sa).applyMatrix4(Qo))})},Zx=class extends si{constructor(){super(...arguments),this.matrix=new me,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new me().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new M);return}Qx(s,t,r)}}):Qx(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Qo.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Aa).multiplyScalar(.5),this.getCenter(Sa),Qo.copy(this.matrix).setPosition(Sa),this.vertices=$S.map(e=>e.clone().multiply(Aa).applyMatrix4(Qo))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=T6.map(([e,t])=>new Rr(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new M))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=P6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},qn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},D6=class extends g_{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(e*l/s),d=o.getPoints(h);for(let c=0;c<d.length;c++){let u=d[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},tg=.001;function ig(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=tg}function gf(e,t){let i=new M(...e.position),r=new M(...e.controlNext.position),s=new M(...t.controlPrevious.position),n=new M(...t.position);return ig(i,r,n)&&ig(i,s,n)}function e2(e){let t=e.points.map(d=>new M(...d.data.position)),i=[e.points[0]],r=new M(...i[0].data.position);for(let d=0;d<e.points.length-1;d++)ig(r,t[d],t[d+1])||(i.push(e.points[d]),r=t[d]);i.push(e.points[e.points.length-1]);let s=e.isClosed,n=i.length-(s?0:1),a=i.length,o=[];for(let d=0;d<a;d++){let c=i[d].data,u=new M(...c.position),p=new M(...c.controlPrevious.position),g=new M(...c.controlNext.position),f={position:u,baseRoundness:c.roundness,controlPrevious:p,controlNext:g};if(c.roundness===0||!e.isClosed&&(d===0||d===a-1)){o[d]={...f,removedLength:0};continue}let m=s&&d==0?a-1:d-1,v=s&&d==a-1?0:d+1,y=i[m].data,x=i[v].data,w=new M(...y.position),_=new M(...x.position),S=w.clone().sub(u).normalize(),A=_.clone().sub(u).normalize();Object.assign(f,{prevDir:S,nextDir:A});let b=gf(y,c),E=gf(c,x);if(!b||!E)o[d]={...f,removedLength:0};else{let C=S.clone().add(A).normalize(),T=C.clone().cross(S).length()/S.dot(C);o[d]={...f,tan:T,removedLength:c.roundness/T}}}for(let d=0;d<n;d++){let c=d,u=s&&d===a-1?0:d+1,p=o[c],g=o[u];if(p.removedLength!==0||g.removedLength!==0){let f=p.position.distanceTo(g.position);p.removedLength=Math.min(p.removedLength,f/2),g.removedLength=Math.min(g.removedLength,f/2)}}let l=[];for(let d=0;d<n;d++){let c=d,u=s&&d===a-1?0:d+1,p=o[c],g=o[u],f=null;if(!gf(i[c].data,i[u].data))p.position.distanceTo(g.position)>tg&&(f=new Cd(p.position,p.controlNext,g.controlPrevious,g.position));else{let m=p.position.clone(),v=g.position.clone();(p.removedLength!==0||g.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),g.prevDir&&v.add(g.prevDir.clone().setLength(g.removedLength))),m.distanceTo(v)>tg&&(f=new Cd(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*d+1]=f}for(let d=0;d<a;d++){let c=o[d];if(c.removedLength===0){l[2*d]=null;continue}let u=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(u),g=c.nextDir.clone().multiplyScalar(c.removedLength).add(u),f=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(g,.5),y=p.distanceTo(g)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(f,2)-Math.pow(y,2))).add(v),w=m.clone().multiplyScalar(-f).add(x),_=u.distanceTo(w)/u.distanceTo(v),S=c.prevDir.clone().multiplyScalar(_*u.distanceTo(p)).add(u),A=S.clone().lerp(w,2),b=p.clone().lerp(S,4/3),E=g.clone().lerp(A,4/3);l[2*d]=new Cd(p,b,E,g)}let h=new D6;return l.forEach(d=>{d&&h.add(d)}),h}var bt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(bt||(bt={}));var jn=e=>bt.is(e),O6={type:"completeState",isfromEntity:!0},t2=e=>class extends Ev(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new Zx,this._recursiveBBox=new Zx,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(bt.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(bt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)Ca.toOps(this.data,s.data).forEach(n=>{let a=Cm.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Ca.patch(this.data,s),Ca.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{jn(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(bt.is(i[r]))return i[r];if(bt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&bt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)jn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{bt.is(i)&&t(i)})}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)jn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)jn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>jn(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Em(i,t)}updateTransformState(t){let i=!1;return t.position&&(this.position.fromArray(t.position),i=!0),t.rotation&&(this.rotation.fromArray(t.rotation),i=!0),t.scale&&(i=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??hl.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)bt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{bt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Em(i,t)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=Fn(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let c=Os.zoom(d,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(h[u]=c[u])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:d,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:d,...c}=l;l=c}let h=Os.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Ca.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Fn(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let d of Object.keys(t.props)){l[l.length-1]=d;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[d],c.updateState(Ba.apply(c.component.data,c.overrideData),r))}}else{let d=r.scene.findInstance([this.uuid,...l]);if(d){let c=Os.zoom(d.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(c)for(let[p,g]of Object.entries(t.props))g===void 0&&(u===t.props&&(u={...t.props}),u[p]=c[p]);t={...t,props:u}}d.overrideData=uu.resolve(i.overrides,l),d.updateByOp(t,vr.applySimple(d.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let d of dl.rootOverrideProps)d in t.props&&(h===void 0&&(h={}),h[d]=t.props[d]);h&&(l={...t,props:h})}else for(let h of dl.rootOverrideProps)if(Fn(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Ba.filterOp(h.overrideData,l);d&&h.updateByOp(d,vr.applySimple(h.data,d),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Ba.filterOp(h.overrideData,t);if(d){let c;n===h.data&&t===d?c=i:c=vr.applySimple(h.data,d),h.updateByOp(d,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ha.is(t.props.type)&&qn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){qn.changeEntityProptotype(this,i,r);for(let s of this.children)bt.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Fn(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Fn(t.path,["cloner"])!==null){let s=vr.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=a.data,l=e2(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let d=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new me;a.updateMatrixWorld();let u=new me().multiplyMatrices(c.clone().invert(),a.matrixWorld);d.applyMatrix4(u);let p={position:d.toArray(),rotation:o.rotation};if(n==="tangential"){let g=new me().extractRotation(a.matrixWorld),f=l.getTangentAt(h).applyMatrix4(g).add(d),m=new me().lookAt(d,f,new M(0,1,0)),v=new bi().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(O6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof qn.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new qn.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}},i2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters),r=i.width/2,s=i.radiusTop??r,n=i.radiusBottom??r;return s===n?(s=r,n=r):s>n?(s=r,n=n*r/s):(s=s*r/n,n=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:n})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:u,hollow:p}=e.parameters,g;return c||p?g=new r2(h,d,r,s,n,a,o,l*Math.PI/180,c,c,u,p):g=new Gg(h,d,r,s,n,a,o,l*Math.PI/180),g.scale(1,1,i/t),Object.assign(g,{userData:{...e,type:"CylinderGeometry"}})}};function Tn(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Kx(e){return new k(e.y,-e.x)}var r2=class extends He{constructor(e,t,i,r,s,n,a,o,l,h,d,c,u=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,o=o!==void 0?o:Math.PI*2,n&&(l=0,h=0);let p=[],g=[],f=[],m=[],v=0,y=i/2,x=new M,w=new M;u&&e==0&&(e=l),u&&t==0&&(t=h);let _=new k(e,y),S=new k(t,-y),A=null,b=null,E=null,C=null,T=_.clone().sub(S),P=0,L=0,D=0;c>0&&(P=Math.min(e,t)*(1-c),L=e-P,D=t-P);let j=_.clone();j.x-=P;let W=Math.PI-T.angle(),q=T.angle(),z=Math.tan(q/2),V=Math.tan(W/2),F=z+V,N=c?F:V,B=c?F:z;if(l=Math.min(l,(e-L)/N,T.length()/F),h=Math.min(h,(t-D)/B,T.length()/F),l>0){let G=l/z;A=_.clone().sub(new k(G,l)),c&&(E=A.clone(),E.x-=P-F*l),_.sub(T.clone().setLength(G))}if(h>0){let G=h/V;b=S.clone().sub(new k(G,-h)),S.add(T.clone().setLength(G)),c&&(C=b.clone(),C.x-=P-F*h,j.sub(T.clone().setLength(G)))}T=_.clone().sub(S);let H=T.length()<.5,X=[];for(let G=0;G<=r;G++){let $=[],Z=G/r,ve=Z*o+a,re=new k(Math.sin(ve),Math.cos(ve));C&&b?(Q($,Z,re,W,h,C,-1,!0),Q($,Z,re,q,h,b,-1,!1)):b?(U($,re,b.x,0,-1),Q($,Z,re,q,h,b,-1,!1)):n||U($,re,t,D,-1);let oe=Kx(T).normalize();if(Tn(oe,re,x),!H)for(let ue=0;ue<=s;ue++){let be=ue/s,Oe=T.clone().multiplyScalar(be).add(S);Tn(Oe,re,w),g.push(w.x,w.y,w.z),f.push(x.x,x.y,x.z),m.push(Z,.5+w.y/i),$.push(v++)}if(E&&A?(Q($,Z,re,W,l,A,1,!1),Q($,Z,re,q,l,E,1,!0)):A?(Q($,Z,re,W,l,A,1,!1),U($,re,A.x,0,1)):n||U($,re,e,L,1),c&&!H){let ue=Kx(T).multiplyScalar(-1).normalize();Tn(ue,re,x);for(let be=0;be<=s;be++){let Oe=be/s,_e=T.clone().multiplyScalar(-Oe).add(j);Tn(_e,re,w),g.push(w.x,w.y,w.z),f.push(x.x,x.y,x.z),m.push(Z,.5+w.y/i),$.push(v++)}}c&&!n&&$.push($[0]),X.push($)}for(let G=0;G<X.length-1;G++)for(let $=0;$<X[0].length-1;$++){if(n&&c&&$==s)continue;let Z=X[G][$],ve=X[G+1][$],re=X[G+1][$+1],oe=X[G][$+1],ue=g[re*3+0],be=g[re*3+2];p.push(Z,ve,oe),(ue!=0||be!=0)&&p.push(ve,re,oe)}o<Math.PI*2&&(ne(-1,X[0],a),ne(1,X[X.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new De(g,3)),this.setAttribute("normal",new De(f,3)),this.setAttribute("uv",new De(m,2));function Q(G,$,Z,ve,re,oe,ue,be){for(let Oe=0;Oe<d+1;Oe++){let _e=Oe/d,Se=ue<0?_e:1-_e;be&&(Se-=1),Se*=ve;let Ie=new k(Math.sin(Se),Math.cos(Se)*ue),Xe=Ie.clone().multiplyScalar(re).add(oe);Tn(Xe,Z,w),g.push(w.x,w.y,w.z),Tn(Ie,Z,x),f.push(x.x,x.y,x.z),m.push($,.5+w.y/i),G.push(v++)}}function U(G,$,Z,ve,re){let oe=new M,ue=new k,be=[Z,ve];re<0&&be.reverse();for(let Oe of be)ue.set(Oe,y*re),Tn(ue,$,oe),g.push(oe.x,oe.y,oe.z),f.push(0,re,0),m.push(.5,.5),G.push(v++)}function ne(G,$,Z){let ve=new k(Math.sin(Z),Math.cos(Z)),re=new k(-Math.cos(Z),Math.sin(Z)),oe=new M,ue=G<0?(_e,Se,Ie)=>p.push(_e,Se,Ie):(_e,Se,Ie)=>p.push(_e,Ie,Se),be=new k((e+t+L+D)/4,0);Tn(be,ve,oe),g.push(oe.x,oe.y,oe.z),f.push(re.x,0,re.y),m.push(.5,.5);let Oe=v++;for(let _e of $){let Se=g.slice(_e*3,_e*3+3);g.push(...Se),f.push(re.x,0,re.y);let Ie=m.slice(_e*2,_e*2+2);m.push(...Ie),v++}for(let _e=Oe+1;_e<v-1;_e++)ue(Oe,_e,_e+1);ue(Oe,v-1,Oe+1)}}},L6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=e.parameters,u;return h>0||d>0||l<360?u=new r2(0,t/2,r,s,n,a,o,l*Math.PI/180,h,d,c,0,!0):u=new y_(t/2,r,s,n,a),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},R6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Is(t,i,r,s,n,a):h=new I6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},vf=Math.PI/2,I6=class extends He{constructor(e=1,t=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o),a=Math.min(a,e/2,t/2,i/2);let h=[],d=[],c=[],u=[],p=0,g=0;f("z","y","x",-1,-1,i,t,e,n,s,0),f("z","y","x",1,-1,i,t,-e,n,s,1),f("x","z","y",1,1,e,i,t,r,n,2),f("x","z","y",1,-1,e,i,-t,r,n,3),f("x","y","z",1,-1,e,t,i,r,s,4),f("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("y","x","z",-1,1,-1,t,e,i,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function f(y,x,w,_,S,A,b,E,C,T,P){let L=(A-2*a)/C,D=(b-2*a)/T,j=A/2-a,W=b/2-a,q=E/2,z=C+1,V=T+1,F=0,N=0,B=new M;for(let H=0;H<V;H++){let X=H*D-W;for(let Q=0;Q<z;Q++){let U=Q*L-j;B[y]=U*_,B[x]=X*S,B[w]=q,d.push(B.x,B.y,B.z),B[y]=0,B[x]=0,B[w]=E>0?1:-1,c.push(B.x,B.y,B.z),u.push(Q/C),u.push(1-H/T),F+=1}}for(let H=0;H<T;H++)for(let X=0;X<C;X++){let Q=p+X+z*H,U=p+X+z*(H+1),ne=p+(X+1)+z*(H+1),G=p+(X+1)+z*H;h.push(Q,U,G),h.push(U,ne,G),N+=6}l.addGroup(g,N,P),g+=N,p+=F}function m(y,x,w,_,S,A,b,E,C,T,P){let L=(b-2*a)/T,D=b/2-a,j=E/2-a,W=C/2,q=T+1,z=0,V=0,F=new M,N=new M;for(let B=0;B<o+1;B++){let H=B/o*vf,X=Math.sin(H)*a,Q=(1-Math.cos(H))*a,U=Math.sin(H),ne=Math.cos(H);F[x]=(j+X)*S,F[w]=(W-Q)*A,N[y]=0,N[x]=U*Math.sign(F[x]),N[w]=ne*Math.sign(F[w]);for(let G=0;G<q;G++){let $=G*L-D;F[y]=$*_,d.push(F.x,F.y,F.z),c.push(N.x,N.y,N.z),u.push(G/T),u.push(0),z+=1}}for(let B=0;B<o;B++)for(let H=0;H<T;H++){let X=p+H+q*B,Q=p+H+q*(B+1),U=p+(H+1)+q*(B+1),ne=p+(H+1)+q*B;h.push(X,Q,ne),h.push(Q,U,ne),V+=6}l.addGroup(g,V,P),g+=V,p+=z}function v(y,x,w){let _=new M,S=new M(e/2,t/2,i/2);S.subScalar(a);let A=[],b=y*x*w>0?(C,T,P)=>h.push(C,T,P):(C,T,P)=>h.push(C,P,T);for(let C=0;C<=o;C++){let T=[],P=vf*(1-C/o),L=Math.cos(P),D=Math.sin(P),j=0;for(let W=0;W<=C;W++){let q=Math.cos(j),z=Math.sin(j);_.x=L*q,_.y=D,_.z=L*z;let V=S.clone().addScaledVector(_,a);d.push(y*V.x,x*V.y,w*V.z),c.push(y*_.x,x*_.y,w*_.z),u.push(0,0),T.push(p++),j+=vf/C}A.push(T)}let E=A.length-1;for(let C=0;C<E;C++){let T=A[C],P=A[C+1],L=T.length-1;b(T[0],P[1],P[0]);for(let D=1;D<=L;D++)b(T[D-1],T[D],P[D]),b(T[D],P[D+1],P[D])}}}},Cv=class extends He{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),d(),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(n=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new M,p=u.clone(),g=new Ji,f=s*r,m=r-f,v=n+1,y=new M,x=(q,z)=>y.subVectors(q,z).normalize(),w=(q,z)=>Array(q).fill(void 0).map(z),_=w(e.length/3,(q,z)=>new M().fromArray(e,z*3).setLength(r)),S=[],A=1e6;for(let q=0;q<_.length;q++){let z=_[q],V=[],F,N,B,H=1e10,X=-1;for(;(X=t.indexOf(q,X+1))!=-1;){let G=X-X%3;F=t[G+(X+1)%3],N=t[G+(X+2)%3],B=z.distanceToSquared(_[F]),H=Math.min(H,B),V.push([F,N,B])}H+=1e-6;let Q=[],U=0,ne=V.length;for(let G=0;G<ne;G++){[F,N,B]=V[U];let $=S[F]?.includes(q)==!0;B<=H&&Q.push(F+ +$*A),U=V.findIndex(Z=>Z[0]==N)}S.push(Q)}let b=[];{let q=0,z=0,V,F,N=c==3;for(let B=0;B<=n;B++){V=B*(B+1)/2,F=(B+1)*(B+2)/2;for(let H=0;H<n-B;H++)[q,z]=[V+H+B+2,F+H+B+3],b.push(V,F,...N?[z,V]:[q,F],z,q),[V,F]=[q,z];b.push(V,F,V+n+2)}}let E=u.clone(),C=u.clone(),T=u.clone(),P=u.clone(),L=u.clone(),D=[],j=w(_.length,()=>w(c,()=>u.clone()));for(let q=0;q<_.length;q++){u.copy(_[q]).normalize(),E.copy(u).multiplyScalar(m);let z=S[q];for(let Q=0;Q<z.length;Q++){let U=z[Q],ne=z[(Q+1)%c];g.setFromPointsAndIndices(_,q,U%A,ne%A),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(E,j[q][Q])}let V=[],F=[],N=[],B=new M;n==0&&[...j[q]].reduce((Q,U)=>Q.add(U),B).multiplyScalar(1/c);for(let Q=0;Q<c;Q++){let U=[],ne=(Q-1+c)%c,G=j[q][ne],$=j[q][Q];u.copy(G).sub(E),p.copy($).sub(E);let Z=E.angleTo(u),ve=u.angleTo(p),re=Math.cos(Z)*f;n==0?C.copy(B):C.copy(E).setLength(m+re),F.push(re);let oe=[C,G,$];for(let ue=0;ue<2;ue++){let be=oe[ue],Oe=oe[ue+1];P.subVectors(be,E),L.subVectors(Oe,E),T.crossVectors(P,L).normalize();for(let _e=0;_e<v;_e++){let Se=[Z,ve][ue]*_e/v;u.copy(P).applyAxisAngle(T,Se).add(E),V.push(u.clone()),ue&&(x(u,E),U.push([_e==0?be:u.clone(),y.clone()]))}ue&&(x(Oe,E),U.push([Oe,y.clone()]))}N.push(U)}D.push(N);let H=2*v,X=2;for(let Q=0;Q<c;Q++){let U=H*Q,ne=H*((Q+1)%c),G=[V[U]];for(let Z=1;Z<v;Z++){P=V[U+Z],L=V[ne+Z],G.push(P);for(let ve=1,re=Z-X+1;ve<=re;ve++)u.lerpVectors(P,L,ve/(re+1)),u.sub(E).setLength(F[Q]).add(E),G.push(u.clone());G.push(L)}for(let Z=0;Z<v;Z++)G.push(V[Z+v+U]);G.push(V[ne+v]);let $=b.map(Z=>G[Z]);a.push(...$.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...$.map(Z=>(x(Z,E),[y.x,y.y,y.z])).flat())}}let W=[];for(let q=0;q<S.length;q++)for(let z=0;z<c;z++){let V=S[q][z];if(V<A){let F=S[V].findIndex(H=>H%A==q),N=D[q][z],B=D[V][F];for(let H=0;H<v;H++){let X=N[H],Q=B[v-H],U=N[H+1],ne=B[v-(H+1)];[X,Q,U,U,Q,ne].forEach(G=>{a.push(G[0].x,G[0].y,G[0].z),l.push(G[1].x,G[1].y,G[1].z)})}W.push(N[0][0],B[v][0],N[v][0],B[0][0])}}for(;W.length;){let q,z,V,F;[q,z]=W.splice(0,2);let N=[q];for(;q!=z;)N.push(z),V=W.indexOf(z),F=V%2,z=W.splice(V-F,2)[1-F];y.subVectors(N[0],N[1]).cross(u.subVectors(N[0],N[2])).normalize();let B=y.dot(N[0])<0;B&&y.negate();for(let H=1;H<=N.length-2;H++)[N[H+ +B],N[H+1-+B],N[0]].forEach(X=>{a.push(X.x,X.y,X.z),l.push(y.x,y.y,y.z)})}}function d(){let c=new M;for(let S=0;S<a.length;S+=3){c.x=a[S+0],c.y=a[S+1],c.z=a[S+2];let A=w(c)/2/Math.PI+.5,b=_(c)/Math.PI+.5;o.push(A,1-b)}let u=new M,p=new M,g=new M,f=new M,m=new k,v=new k,y=new k,x=(S,A,b,E)=>{E<0&&S.x===1&&(o[A]=S.x-1),b.x===0&&b.z===0&&(o[A]=E/2/Math.PI+.5)};for(let S=0,A=0;S<a.length;S+=9,A+=6){u.set(a[S+0],a[S+1],a[S+2]),p.set(a[S+3],a[S+4],a[S+5]),g.set(a[S+6],a[S+7],a[S+8]),m.set(o[A+0],o[A+1]),v.set(o[A+2],o[A+3]),y.set(o[A+4],o[A+5]),f.copy(u).add(p).add(g).divideScalar(3);let b=w(f);x(m,A+0,u,b),x(v,A+2,p,b),x(y,A+4,g,b)}for(let S=0;S<o.length;S+=6){let A=o[S+0],b=o[S+2],E=o[S+4],C=Math.max(A,b,E),T=Math.min(A,b,E);C>.9&&T<.1&&(A<.2&&(o[S+0]+=1),b<.2&&(o[S+2]+=1),E<.2&&(o[S+4]+=1))}function w(S){return Math.atan2(S.z,-S.x)}function _(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}}static fromJSON(e){return new Cv(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},B6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new s2(t*.5,n,a):new x_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},s2=class extends Cv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(n,a,o,e,t,i),this.type=o}static fromJSON(e){return new s2(e.radius,e.corner,e.cornerSides)}},Jl=1e-12,Tv=class{constructor(e){this.position=new k,this.startPosition=new k,this.uuid=st.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Tv(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},rg=class extends Tv{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new rg(this.parent).copy(this)}},Zo=class extends Tv{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new rg(this),new rg(this))}static create(e,t){let i=new Zo(e,new k(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Zo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new k,t=new k){let[i,r]=this.computeTangents();return i&&r&&(Jx(i,e),Jx(r,t)),[e,t]}computeTangent(e=new k){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new k){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Jx(e,t=new k){let i=e.length();return t.set(-e.y/i,e.x/i)}var Pv=e=>e,Cl=new k,Zu=new k,z6=new k,N6=new k,U6=new k,F6=new k,n2=new M,a2=new M;function k6(e){let t=new k;t.addVectors(e.v0,Cl.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new k;return i.addVectors(e.v2,Zu.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Jr(e.v0,t,i,e.v2)}function gh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function j6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function G6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function o2(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function V6(e,t,i){return ew(e,t)&&ew(t,i)&&sg(e.position,t.position,i.position)}function sg(e,t,i){return Cl.copy(t).sub(e).cross(Zu.copy(i).sub(e))===0}function H6(e,t,i,r,s){let n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.y-t.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.x-e.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function W6(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function q6(e,t,i,r,s,n){let a=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,d=Math.sqrt((a+l)*(a+l)+(o+h)*(o+h)),c;return o2(t,e,i)>Math.PI&&(d*=-1),gh(h,o)?c=(o+h)*(r/d-.5)*8/3/(a-l):c=(a+l)*(r/d-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*a),n.set(i.x+c*h,i.y-c*l),[s,n]}function $x(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function ew(e,t){return sg(e.position,e.controls[1].position,t.position)&&sg(e.position,t.controls[0].position,t.position)}function X6(e,t,i,r,s=.5){let n=Cl.subVectors(t,e).multiplyScalar(s).add(e),a=Zu.subVectors(i,t).multiplyScalar(s).add(t),o=z6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=N6.subVectors(a,n).multiplyScalar(s).add(n),d=U6.subVectors(o,a).multiplyScalar(s).add(a),c=o,u=F6.subVectors(d,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,d.x,d.y,c.x,c.y,r.x,r.y]}function Y6(e,t,i=12,r=!0){let s=a2.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=Pv(t[l]),d=Cl,c=Na(h,i);o.push(c);for(let u=0;u<=c;u++)if(h instanceof Jr||h instanceof Jn||h instanceof is){if(h.getPoint(u/c,d),s.set(d.x,d.y,0),n!==void 0&&G6(n,s))continue;n===void 0&&(n=n2),n.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}return r&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),e}function Q6(e,t,i,r=12,s=!0){let n=a2.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,d=Pv(t[l]),c=Cl,u=Na(d,r);o.push(u);for(let p=0;p<=u;p++)if(d instanceof Jr||d instanceof Jn||d instanceof is){if(d.getPoint(p/u,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=n2:(e.setXYZ(a,h.x,h.y,h.z),a++,e.setXYZ(a,n.x,n.y,n.z),a++),h.copy(n)}}return s&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),o}function tw(e,t=12,i=!1){let r=[];for(let s=0,n=e.length;s<n;s++){let a=e[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=Na(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Na(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Na(e[0].roundedCurveCorner,t)*.5),r}function Na(e,t=12){return e&&e instanceof Iu?t*2:e&&(e instanceof is||e instanceof m_)?1:e&&e instanceof jg?t*e.points.length:t}function Z6(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=Pv(t[a]),l=Na(o,i),h=Cl;for(let d=0;d<=l;d++)if(o instanceof Jr||o instanceof Jn||o instanceof is){if(o.getPoint(d/l,h),s!==void 0&&j6(s,h,Jl))continue;s===void 0&&(s=Zu),s.copy(h),e.push(h.x,h.y),n++}}return gh(e[0],e[e.length-2],Jl)&&gh(e[1],e[e.length-1],Jl)&&(e.pop(),e.pop()),r&&n>1&&!(gh(e[n-1],e[1],Jl)&&gh(e[n-2],e[0],Jl))&&(e.push(e[0],e[1]),n++),e}var yf=new k,K6=new k,J6=new k,$6=new k,ek=new k,tk=new k,Gt=class extends Hd{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new pr(new M(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=st.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Gt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Zo.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Gt.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=e-t;if(n<=s.points.length-1)return s.points[n];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=yf.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=st.generateUUID()){let r;e instanceof k?r=e:r=new k(e,t);let s=new Zo(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return Y6(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=tw(this.points,e,!1),this.roundedCurveDivisions=tw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return Q6(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Z6(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Na(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if($x(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(yf.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=n[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){$x(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&V6(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,d=s.curveAfter;if(h===void 0||d===void 0)continue;let c=s.roundedCurveBefore,u=s.roundedCurveAfter,p=h.getLength(),g=d.getLength(),f=Math.min(o,p*.499),m=Math.min(o,g*.499),v=Math.min(f,m),y=1-v/p,x=v/g,w=h.getPointAt(y,yf),_=d.getPointAt(x,K6);this._subSplitCurve(h,c,y,w,void 0),this._subSplitCurve(d,u,x,void 0,_);let S;if(this.useCubicForRoundedCorners){let A=o2(w,s.position,_)/2,b=Math.tan(A)*w.distanceTo(s.position),[E,C]=H6(w,_,b,J6,$6),T=W6(E,C,s.position),[P,L]=q6(T,w,_,b,ek,tk);S=new Jr(w.clone(),P.clone(),L.clone(),_.clone())}else S=new Jn(w.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=S,this.roundedCurves.splice(i+t,0,S),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof is)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,o=n.getUtoTmapping(i,0),l=X6(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return t}clone(){let e=new Gt(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],n=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],d=e.points[r+6],c=new Zo(st.generateUUID(),new k(s,n));c.controls[0].position.set(a,o),c.controls[1].position.set(l,h),c.roundness=d,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Gt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof Jr&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)},i=r=>{let s=[],n,a;for(n=0,a=r.length;n<a;n++)r[n]instanceof Jn&&(r[n]=k6(r[n]));for(n=0,a=r.length;n<a;n++){let h=r[n],d=n>0?r[n-1]:null,c;h instanceof Jr?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof is&&(c=this.createPoint(h.v1)),c!==void 0&&(d!==null&&t(c,d),s.push(c))}let o=r[r.length-1],l=!1;return o instanceof Jr?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof is&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof Hd&&(this.shapeHoles=e.holes.map(r=>{let s=new Gt;return s.fromShape(r),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},ng=Math.PI*2;function xf({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function ik(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),n=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function iw(e,t,i,r){let s=e*r-t*i<0?-1:1,n=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(n)}function rk(e,t,i,r,s,n,a,o,l,h){let d=Math.pow(s,2),c=Math.pow(n,2),u=Math.pow(a,2),p=Math.pow(o,2),g=d*c-d*p-c*u;g<0&&(g=0),g/=d*p+c*u,g=Math.sqrt(g)*(l===h?-1:1);let f=g*s/n*o,m=g*-n/s*a,v=f+(e+i)/2,y=m+(t+r)/2,x=(a-f)/s,w=(o-m)/n,_=(-a-f)/s,S=(-o-m)/n,A=iw(1,0,x,w),b=iw(x,w,_,S);return!h&&b>0&&(b-=ng),h&&b<0&&(b+=ng),{centerx:v,centery:y,ang1:A,ang2:b}}function sk({px:e,py:t,cx:i,cy:r,rx:s,ry:n,largeArcFlag:a,sweepFlag:o}){let l=[];if(s===0||n===0)return[];let h=(e-i)/2,d=(t-r)/2;if(h===0&&d===0)return[];s=Math.abs(s),n=Math.abs(n);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(d,2)/Math.pow(n,2);c>1&&(s*=Math.sqrt(c),n*=Math.sqrt(c));let u=rk(e,t,i,r,s,n,h,d,a,o),{ang1:p,ang2:g}=u,{centerx:f,centery:m}=u,v=Math.abs(g)/(ng/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);g/=y;for(let x=0;x<y;x++)l.push(ik(p,g)),p+=g;return l.map(x=>{let{x:w,y:_}=xf(x[0],s,n,f,m),{x:S,y:A}=xf(x[1],s,n,f,m),{x:b,y:E}=xf(x[2],s,n,f,m);return{x1:w,y1:_,x2:S,y2:A,x:b,y:E}})}var _t;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(_t||(_t={}));var ii;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ii||(ii={}));function Ge(e,t){if(!e)throw t||"Assertion Failed!"}var Be=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Ge(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?s<n?i.t-t.t+(t.t-r.t)*(s/(s+n)):i.t-r.t+(r.t-t.t)*(n/(s+n)):0},e.edgeSign=function(t,i,r){Ge(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?(i.t-r.t)*s+(i.t-t.t)*n:0},e.transEval=function(t,i,r){Ge(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?s<n?i.s-t.s+(t.s-r.s)*(s/(s+n)):i.s-r.s+(r.s-t.s)*(n/(s+n)):0},e.transSign=function(t,i,r){Ge(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?(i.s-r.s)*s+(i.s-t.s)*n:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,n){var a,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(a=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,i.s)):(a=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,s.s)):n.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(a=e.transEval(t,r,i),o=e.transEval(r,i,s),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,i.t)):(a=e.transSign(t,r,i),o=-e.transSign(t,s,i),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,s.t)):n.t=(r.t+i.t)/2},e}(),$l=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),nd=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Oo=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),rw=function(){function e(){var t=new Oo,i=new $l,r=new nd(0),s=new nd(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new nd(0),r=new nd(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;Ge(s,"Vertex can't be null!");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i;var a=i;do a.Org=s,a=a.Onext;while(a!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Ge(s,"Face can't be null");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var a=i;do a.Lface=s,a=a.Lnext;while(a!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.makeEdge=function(){var t=new Oo,i=new Oo,r=new $l,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var n=new Oo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new $l;this.makeFace_(a,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new $l;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new Oo;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),n=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(n,i),s.Org=t.Dst,n.Org=i.Org,s.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new $l;this.makeFace_(a,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,n,a,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=i);a=t.prev,o=t.next,o.prev=a,a.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,n,a,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,a=r.Org;s=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(n.Lface),o+l-2<=t&&Be.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Be.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(s=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,n,a,o,l,h;for(n=t,n=t;(s=n.next)!==t;n=s){Ge(s.prev===n),l=s.anEdge;do Ge(l.Sym!==l),Ge(l.Sym.Sym===l),Ge(l.Lnext.Onext.Sym===l),Ge(l.Onext.Sym.Lnext===l),Ge(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Ge(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){Ge(a.prev===o),l=a.anEdge;do Ge(l.Sym!==l),Ge(l.Sym.Sym===l),Ge(l.Lnext.Onext.Sym===l),Ge(l.Onext.Sym.Lnext===l),Ge(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Ge(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Ge(l.Sym.next===h.Sym),Ge(l.Sym!==l),Ge(l.Sym.Sym===l),Ge(l.Org!==null),Ge(l.Dst!==null),Ge(l.Lnext.Onext.Sym===l),Ge(l.Onext.Sym.Lnext===l);Ge(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),sw=function(){function e(){this.handle=null}return e}(),nw=function(){function e(){this.key=null,this.node=0}return e}(),nk=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new sw,this.handles[r]=new nw;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[i[a+1].handle].key,r[i[a].handle].key)&&++a,Ge(a<=this.max),n=i[a].handle,a>this.size||this.leq(r[s].key,r[n].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t>>1,n=i[a].handle,a===0||this.leq(r[n].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,n;for(n=this.nodes.length,this.nodes.length=this.max+1,s=n;s<this.nodes.length;s++)this.nodes[s]=new sw;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new nw}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;Ge(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),wf=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),aw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),ak=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new aw,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new aw;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),ok=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,n=i.eUp,a=r.eUp;if(n.Dst===s)return a.Dst===s?Be.vertLeq(n.Org,a.Org)?Be.edgeSign(a.Dst,n.Org,a.Org)<=0:Be.edgeSign(n.Dst,a.Org,n.Org)>=0:Be.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Be.edgeSign(n.Dst,s,n.Org)>=0;var o=Be.edgeEval(n.Dst,s,n.Org),l=Be.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Ge(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Ge(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new wf;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case _t.ODD:return(i&1)!==0;case _t.NONZERO:return i!==0;case _t.POSITIVE:return i>0;case _t.NEGATIVE:return i<0;case _t.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,n=null,a=i,o=i.eUp;a!==r;){if(a.fixUpperEdge=!1,n=e.regionBelow(a),s=n.eUp,s.Org!=o.Org){if(!n.fixUpperEdge){e.finishRegion(t,a);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,n,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,a),o=n.eUp,a=n}return o},e.addRightEdges=function(t,i,r,s,n,a){var o,l,h,d,c=!0;h=r;do Ge(Be.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(n===null&&(n=e.regionBelow(i).eUp.Rprev),l=i,d=n;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(d.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,d),e.deleteRegion(t,l),t.mesh.delete(d)),c=!1,l=o,d=h;l.dirty=!0,Ge(l.windingNumber-h.winding===o.windingNumber),a&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Be.vertL1dist(i,t),n=Be.vertL1dist(r,t),a=.5*n/(s+n),o=.5*s/(s+n);t.coords[0]+=a*i.coords[0]+o*r.coords[0],t.coords[1]+=a*i.coords[1]+o*r.coords[1],t.coords[2]+=a*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,n,a){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,n,a)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp;if(Be.vertLeq(s.Org,n.Org)){if(Be.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Be.vertEq(s.Org,n.Org)?s.Org!==n.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,n.Oprev,s)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(s,n.Oprev),i.dirty=r.dirty=!0)}else{if(Be.edgeSign(s.Dst,n.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a;if(Ge(!Be.vertEq(s.Dst,n.Dst)),Be.vertLeq(s.Dst,n.Dst)){if(Be.edgeSign(s.Dst,n.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,a=t.mesh.splitEdge(s),t.mesh.splice(n.Sym,a),a.Lface.inside=i.inside}else{if(Be.edgeSign(n.Dst,s.Dst,n.Org)>0)return!1;i.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(s.Lnext,n.Sym),a.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a=s.Org,o=n.Org,l=s.Dst,h=n.Dst,d,c,u=new Oo,p,g;if(Ge(!Be.vertEq(h,l)),Ge(Be.edgeSign(l,t.event,a)<=0),Ge(Be.edgeSign(h,t.event,o)>=0),Ge(a!==t.event&&o!==t.event),Ge(!i.fixUpperEdge&&!r.fixUpperEdge),a===o||(d=Math.min(a.t,l.t),c=Math.max(o.t,h.t),d>c))return!1;if(Be.vertLeq(a,o)){if(Be.edgeSign(h,a,o)>0)return!1}else if(Be.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Be.intersect(l,a,h,o,u),Ge(Math.min(a.t,l.t)<=u.t),Ge(u.t<=Math.max(o.t,h.t)),Ge(Math.min(h.s,l.s)<=u.s),Ge(u.s<=Math.max(o.s,a.s)),Be.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Be.vertLeq(a,o)?a:o,Be.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Be.vertEq(u,a)||Be.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Be.vertEq(l,t.event)&&Be.edgeSign(l,t.event,u)>=0||!Be.vertEq(h,t.event)&&Be.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Lnext,n.Oprev),r=i,i=e.topRightRegion(i),g=e.regionBelow(i).eUp.Rprev,r.eUp=n.Oprev,n=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,n.Onext,s.Rprev,g,!0),!0):(Be.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Be.edgeSign(h,t.event,u)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,s),s.Org.s=u.s,s.Org.t=u.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,a,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,n;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,n=r.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(n),r=e.regionBelow(i),n=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==n.Org)if(s.Dst!==n.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||n.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,n=r.Onext,a=e.regionBelow(i),o=i.eUp,l=a.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Be.vertEq(o.Org,t.event)&&(t.mesh.splice(n.Oprev,o),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),h=!0),Be.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,a,null),h=!0),h){e.addRightEdges(t,i,r.Onext,n,n,!0);return}Be.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,n,a,o,l;if(s=i.eUp,Be.vertEq(s.Org,r)){Ge(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Be.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}Ge(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(Ge(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Be.edgeGoesLeft(n)||(n=null),e.addRightEdges(t,i,a.Onext,o,n,!0)},e.connectLeftVertex=function(t,i){var r,s,n,a,o,l,h=new wf;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Be.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Be.vertLeq(o.Dst,a.Dst)?r:s,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(i.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(o.Dnext,i.anEdge);l=d.Sym}n.fixUpperEdge?e.fixUpperEdge(t,n,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);Ge(s!==null);var n=e.regionBelow(s),a=n.eUp,o=e.finishLeftRegions(t,n,null);o.Onext===a?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,a,a,!0)},e.addSentinel=function(t,i,r,s){var n=new wf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=s,a.Dst.s=i,a.Dst.t=s,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new ak(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,n=t.bmax[0]+i,a=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,n,a),e.addSentinel(t,s,n,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Ge(i.fixUpperEdge),Ge(++r===1)),Ge(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,n=t.mesh.eHead;for(i=n.next;i!==n;i=r)r=i.next,s=i.Lnext,Be.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,n=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)n++;for(n+=8,i=t.pq=new nk(n,Be.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,n;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,n=r.anEdge,Ge(n.Lnext!==n),n.Lnext.Lnext===n&&(e.addWinding(n.Onext,n),t.mesh.delete(n));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Be.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),lk=function(){function e(){this.mesh=new rw,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=_t.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,n,a,o,l=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],u=[0,0,0],p=[null,null,null],g=[null,null,null],f=this.mesh.vHead;i=f.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,g[m]=i,l[m]=n,p[m]=i;for(i=f.next;i!==f;i=i.next)for(var v=0;v<3;++v)n=i.coords[v],n<h[v]&&(h[v]=n,g[v]=i),n>l[v]&&(l[v]=n,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=g[y],s=p[y],d[0]=r.coords[0]-s.coords[0],d[1]=r.coords[1]-s.coords[1],d[2]=r.coords[2]-s.coords[2],i=f.next;i!==f;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],u[0]=d[1]*c[2]-d[2]*c[1],u[1]=d[2]*c[0]-d[0]*c[2],u[2]=d[0]*c[1]-d[1]*c[0],a=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],a>o&&(o=a,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,n=0,a=t.next;a!==t;a=a.next)if(s=a.anEdge,!(s.winding<=0))do n+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==a.anEdge);if(n<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),n=!0),r=this.sUnit,s=this.tUnit;var a=this.longAxis_(i);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,s[a]=0,s[(a+1)%3]=0,s[(a+2)%3]=i[a]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);n&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Be.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Be.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Be.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Be.edgeGoesLeft(s.Lnext)||Be.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)n=t.connect(s.Lnext,s),s=n.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Be.edgeGoesRight(r.Lprev)||Be.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)n=t.connect(s.Lnext,s),s=n.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,n=t.eHead.next;n!==t.eHead;n=s)s=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?i:-i:r?t.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var n,a=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){n=d.anEdge,l=0;do{var h=n.Org;h.n===-1&&(h.n=o,o++),l++,n=n.Lnext}while(n!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,i===ii.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var u=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(d.inside){n=d.anEdge,l=0;do{var h=n.Org;this.elements[u++]=h.n,l++,n=n.Lnext}while(n!==d.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===ii.CONNECTED_POLYGONS){n=d.anEdge;do this.elements[u++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==d.anEdge);for(var g=l;g<r;++g)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,d=0;n=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==s);this.elements[d++]=n,this.elements[d++]=a,n+=a}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new rw),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,n,a){if(t===void 0&&(t=_t.ODD),i===void 0&&(i=ii.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),ok.computeInterior(this,a);var o=this.mesh;return i===ii.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===ii.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Xn(e){var t=e.windingRule,i=t===void 0?_t.ODD:t,r=e.elementType,s=r===void 0?ii.POLYGONS:r,n=e.polySize,a=n===void 0?3:n,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,d=h===void 0?[0,0,1]:h,c=e.contours,u=c===void 0?[]:c,p=e.strict,g=p===void 0?!0:p,f=e.debug,m=f===void 0?!1:f;if(!u&&g)throw new Error("Contours can't be empty");if(u){var v=new lk;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<u.length;y++)v.addContour(l||2,u[y]);return v.tesselate(i,s,a,l,d,g),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}var EW=_t.ODD,CW=_t.NONZERO,TW=_t.POSITIVE,PW=_t.NEGATIVE,DW=_t.ABS_GEQ_TWO,OW=ii.POLYGONS,LW=ii.CONNECTED_POLYGONS,RW=ii.BOUNDARY_CONTOURS,ag=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*ag.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*ag.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(r,n*s,3*e);n+=3*e;let o=new Float32Array(r,n*s,3*e);n+=3*e;let l=new Float32Array(r,n*s,2*e);a.set(this.positions.slice(0,this.size*3)),o.set(this.normals.slice(0,this.size*3)),l.set(this.uvs.slice(0,this.size*2)),this.buffer=r,this.positions=a,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},l2=ag;l2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Dv={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},h2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},c2={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},bf=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),d2=class extends He{constructor(e,t,i=0,r=12,s=3,n=_t.ODD){super(),this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,t/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],r),o=this._shape.shapeHoles.map(_=>{let S=_.extractShapePointsToFlatArray([],r),A=[];for(let b=S.length-1;b>=1;b-=2){let E=S[b-1],C=S[b-0];A.push(E,C)}return A}),l;try{l=Xn({windingRule:n,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]})}catch{l=Dv}let h;try{h=Xn({windingRule:_t.ODD,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{h=h2}if(!l)throw new Error("error generating geometry");let d=l.elementCount;if(h){l.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let S=h.elements[_],A=_%2===0?l.vertexCount:0;l.elements.push(S+A)}for(let _=0;_<h.vertexIndices.length;_++){let S=h.vertexIndices[_],A=l.vertexCount;l.vertexIndices.push(S+A)}for(let _=0;_<h.vertices.length;_++){let S=h.vertices[_];l.vertices.push(S)}}let c=1/0,u=-1/0,p=1/0,g=-1/0;for(let _=0,S=l.vertexCount;_<S;_++){let A=_*2,b=l.vertices[A+0],E=l.vertices[A+1];b<c&&(c=b),b>u&&(u=b),E<p&&(p=E),E>g&&(g=E)}this._minX=c,this._minY=p,this._width=u-c,this._height=g-p,this._buffer=new l2(this._computeBufferEstimatedSize(l));let f=[],m=[];for(let _=l.elementCount-1;_>=0;_--){let S=_>=d,A=_*2,b=l.elements[A+0],E=l.elements[A+1],C=b+E,T={start:b,count:E,normals:[],continuous:[],concave:[]},P=b,L=C-1,D=b+1,j=this._shape.roundedCurves.length;do{let V=P-b,F=l.vertices[L*2+0],N=l.vertices[L*2+1],B=l.vertices[P*2+0],H=l.vertices[P*2+1],X=l.vertices[D*2+0],Q=l.vertices[D*2+1],U=B-F,ne=H-N,G=Math.sqrt(U*U+ne*ne);U/=G,ne/=G;let $=B-X,Z=H-Q,ve=Math.sqrt($*$+Z*Z);$/=ve,Z/=ve,T.normals[V*2+0]=-Z,T.normals[V*2+1]=$,T.concave[V]=U*Z-ne*$>0;let re=l.vertexIndices[P];if(Array.isArray(re))T.continuous[V]=!1;else{let[oe,ue]=this._shape.getCurveIndexFromVertexId(re-1,!0);if(ue>0&&ue<1)T.continuous[V]=!0;else{let be=ue===1?oe+1:oe-1;be=(be+j)%j;let Oe=ue===1?0:1,_e=this._shape.roundedCurves[oe].getTangent(ue),Se=this._shape.roundedCurves[be].getTangent(Oe);T.continuous[V]=_e.dot(Se)>.95}}S&&(T.normals[V*2+0]*=-1,T.normals[V*2+1]*=-1),[L,P,D]=[P,D,D+1],D>=C&&(D-=E)}while(D!==b+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(b*2,C*2),vertexCount:E,vertexIndices:new Array(E).fill(!0).map((V,F)=>[F,F]),elements:[0,E],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(b*2,C*2)});for(let V=1;V<=this._bevelSegments;V++){let F=V/this._bevelSegments*Math.PI/2,N=(1-Math.cos(F))*this._bevelSize,B=[],H=[],X=[],Q=[],U=0;for(let G=0;G<E;G++){let $=G*2,Z=(G-1+E)%E*2,ve=l.vertices[T.start*2+$+0],re=l.vertices[T.start*2+$+1],oe=-T.normals[Z+0]*N,ue=-T.normals[Z+1]*N,be=-T.normals[$+0]*N,Oe=-T.normals[$+1]*N;if(T.concave[G]||!T.concave[G]&&S){let _e=Math.atan2(ue,oe),Se=Math.atan2(Oe,be);Se>_e&&(Se-=Math.PI*2);let Ie=Se-_e;if(T.continuous[G]||S){let Xe=_e+Ie/2,ct=Math.cos(Xe)*N,R=Math.sin(Xe)*N;B[2*U+0]=ve+ct*(S?-1:1),B[2*U+1]=re+R*(S?-1:1),Q[U]=G,U++}else{let Xe=Math.max(1,Math.floor(r/4*Math.abs(Ie)/Math.PI));for(let ct=0;ct<=Xe;ct++){let R=_e+Ie*(ct/Xe),O=Math.cos(R)*N,ie=Math.sin(R)*N;B[2*U+0]=ve+O,B[2*U+1]=re+ie,Q[U]=G,U++}}}else B[2*U+0]=ve+oe,B[2*U+1]=re+ue,Q[U]=G,H[G]=U,U++,B[2*U+0]=ve,B[2*U+1]=re,Q[U]=G,U++,B[2*U+0]=ve+be,B[2*U+1]=re+Oe,Q[U]=G,X[G]=U,U++}let ne=Xn({windingRule:_t.POSITIVE,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[B],edgeCreateCallback:G=>{let $=G.Org.idx,Z=Q[$],ve=Q[($+1)%Q.length];G.idx=[Z,ve],G.Sym.idx=[ve,Z]},vertexIdCallback:G=>{let $=G.Lprev.idx;return[$?$[1]:0,G.idx?G.idx[0]:0]}});if(!ne)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!ne.vertexCount)break;for(let G=0;G<ne.vertexIndices.length;G++){let[$,Z]=ne.vertexIndices[G];if($===Z)continue;let ve=Z;Z<$&&(ve+=E);for(let re=$;re<ve;re++){let oe=re%E,ue=(re+1)%E;if(!T.continuous[oe]||!T.continuous[ue]){ne.vertexIndices[G]=[$,oe],ne.vertexIndices.splice(G+1,0,[ue,Z]),ne.vertices.splice((G+1)*2,0,ne.vertices[G*2],ne.vertices[G*2+1]);break}}}W.push({bevelI:V,angle:F,size:N,boundary:ne,reverseMap:Q,insetPoints:B})}let q=(V,F,N)=>{let B=0,H=V.boundary.vertexIndices.length;for(;B<H&&N(V.boundary.vertexIndices[F]);)F=(F+1)%H,B++;return B},z=f.length;for(let V=1;V<W.length;V++){let F=W[V-1],N=W[V],B=F.boundary.vertexIndices.length,H=N.boundary.vertexIndices.length;if(!B||!H)break;let X=T.concave.length,Q=0,U=bf(Q,E);for(;!F.boundary.vertexIndices.filter(U).length||!N.boundary.vertexIndices.filter(U).length;)Q++,U=bf(Q,E);let ne=F.boundary.vertexIndices.findIndex(U),G=N.boundary.vertexIndices.findIndex(U);do ne=(ne+1)%B;while(U(F.boundary.vertexIndices[ne]));do G=(G+1)%H;while(U(N.boundary.vertexIndices[G]));Q=(Q+1)%E;let $=Q,Z=this._buildBevelVert(T,F,(ne-1+B)%B),ve=this._buildBevelVert(T,N,(G-1+H)%H),re=Z,oe=ve,ue,be,Oe=!1;do{U=bf(Q,E);let _e=q(F,ne,U),Se=q(N,G,U),Ie=Oe;if(Oe=!1,_e&&!Se){for(let Xe=0;Xe<_e;Xe++)ue=this._buildBevelVert(T,F,(ne+Xe)%B,Xe/(_e-1)),f.push(re.topN,ue.topP,oe.topN),f.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue;Oe=!0}else if(!_e&&Se)for(let Xe=0;Xe<Se;Xe++)be=this._buildBevelVert(T,N,(G+Xe)%H,Xe/(Se-1)),f.push(oe.topN,re.topP,be.topP),f.push(re.bottomP,oe.bottomN,be.bottomP),oe=be;else if(_e&&Se)if(ue=this._buildBevelVert(T,F,ne,0),be=this._buildBevelVert(T,N,G,0),Ie?(f.push(re.topN,be.topP,oe.topN),f.push(re.topN,ue.topP,be.topP),f.push(be.bottomP,re.bottomN,oe.bottomN),f.push(be.bottomP,ue.bottomP,re.bottomN)):(f.push(oe.topN,re.topN,ue.topP),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,re.bottomN,oe.bottomN),f.push(ue.bottomP,oe.bottomN,be.bottomP)),re=ue,oe=be,_e===Se)for(let Xe=1;Xe<_e;Xe++)ue=this._buildBevelVert(T,F,(ne+Xe)%B,Xe/(_e-1)),be=this._buildBevelVert(T,N,(G+Xe)%H,Xe/(Se-1)),f.push(re.topN,ue.topP,oe.topN),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,re.bottomN,oe.bottomN),f.push(ue.bottomP,oe.bottomN,be.bottomP),re=ue,oe=be;else if(_e>Se){let Xe=_e/Se,ct=0;for(let R=1;R<_e;R++)ue=this._buildBevelVert(T,F,(ne+R)%B,R/(_e-1)),f.push(re.topN,ue.topP,oe.topN),f.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue,R>(ct+1)*Xe&&(ct++,be=this._buildBevelVert(T,N,(G+ct)%H,ct/(Se-1)),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,oe.bottomN,be.bottomP),oe=be)}else{let Xe=Se/_e,ct=0;for(let R=1;R<Se;R++)be=this._buildBevelVert(T,N,(G+R)%H,R/(Se-1)),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,oe.bottomN,be.bottomP),oe=be,R>(ct+1)*Xe&&(ct++,ue=this._buildBevelVert(T,F,(ne+ct)%B,ct/(_e-1)),f.push(re.topN,ue.topP,oe.topN),f.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue)}ne=(ne+_e)%B,G=(G+Se)%H,Q=(Q+1)%X}while(Q!==$)}if(this._depth>this._bevel*2&&this._buildWall(W,T,f),S){let V=[];for(let F=f.length-1;F>=z+2;F-=3){let N=f[F-2],B=f[F-1],H=f[F-0];V.push(H,B,N)}f.splice(z,f.length-z,...V)}if(S){let V=[];for(let F=W[W.length-1].boundary.vertices.length-1;F>=1;F-=2){let N=W[W.length-1].boundary.vertices[F-1],B=W[W.length-1].boundary.vertices[F-0];V.push(N,B)}m.push(V)}if(!S){let V=W[W.length-1],F;try{F=Xn({windingRule:W.length>1?_t.POSITIVE:_t.ODD,elementType:ii.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...m]})}catch{F=c2}if(!F)throw new Error("Error generating geometry for surface");o.length===0&&Object.assign(this,{capStartIndex:f.length});for(let N=0;N<F.elementCount*3;N+=3){let B=this._buildSurfaceVert(F,F.elements[N+0]),H=this._buildSurfaceVert(F,F.elements[N+1]),X=this._buildSurfaceVert(F,F.elements[N+2]);f.push(B.top,H.top,X.top),f.push(X.bottom,H.bottom,B.bottom)}}this.vertexCache={}}this._buffer.shrink();let v=new qe(Uint32Array.from(f),1),y=new qe(this._buffer.positions,3),x=new qe(this._buffer.normals,3),w=new qe(this._buffer.uvs,2);y.needsUpdate=!0,x.needsUpdate=!0,w.needsUpdate=!0,v.needsUpdate=!0,this.setAttribute("position",y),this.setAttribute("normal",x),this.setAttribute("uv",w),this.setIndex(v)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(e,t){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let r=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(r-this._minX)/this._width,a=(s-this._minY)/this._height,o=this._buffer.get(2),l=o*3,h=o*2,d={top:o+0,bottom:o+1};return this._buffer.positions[l+0]=r,this._buffer.positions[l+1]=s,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[h+0]=n,this._buffer.uvs[h+1]=a,this._buffer.positions[l+3]=r,this._buffer.positions[l+4]=s,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[h+2]=n,this._buffer.uvs[h+3]=a,this.vertexCache[i]=d,d}_buildBevelVert(e,t,i,r=1){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[n,a]=t.boundary.vertexIndices[i],o,l,h,d;n!==a?(l=n,o=a,d=!1,h=e.continuous[l]&&e.continuous[o]):(o=n,l=(o-1+e.count)%e.count,d=e.concave[o]&&t.bevelI>0,h=e.continuous[o]||d);let c=Math.cos(t.angle),u=Math.sin(t.angle),p=i*2,g=o*2,f=l*2,m=t.boundary.vertices[p+0],v=t.boundary.vertices[p+1],y=(1-u)*this._bevelSize,x=(m-this._minX)/this._width,w=(v-this._minY)/this._height,_=e.normals[g+0],S=e.normals[g+1],A=e.normals[f+0],b=e.normals[f+1];if(d){let L=A-_,D=b-S;_=_+L*(1-r),S=S+D*(1-r);let j=Math.sqrt(_*_+S*S);_/=j,S/=j}let E=this._buffer.get(h?2:4),C=E*3,T=E*2,P={i,fi:o,topP:E+0,topN:E+0,bottomP:E+1,bottomN:E+1};return this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=_*c,this._buffer.normals[C+1]=S*c,this._buffer.normals[C+2]=u,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=_*c,this._buffer.normals[C+4]=S*c,this._buffer.normals[C+5]=-u,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x,h||(E+=2,C+=6,T+=4,P.topP=E+0,P.bottomP=E+1,this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=A*c,this._buffer.normals[C+1]=b*c,this._buffer.normals[C+2]=u,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=A*c,this._buffer.normals[C+4]=b*c,this._buffer.normals[C+5]=-u,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x),this.vertexCache[s]=P,P}clone(){let e=new d2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vu(this.userData),e}},u2=class extends He{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=_t.ODD,this.elementType=ii.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:_t.ODD,elementType:ii.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),n,a=!0,o=!0,l,h;for(let u=0,p=r.length/2;u<p;u++){let g=u*2,f=r[g+0],m=r[g+1];if(l!==void 0&&f!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=f,h=m,!a&&!o)break}if(!a&&!o)try{n=Xn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=Dv}let d=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new qe(new Float32Array(d*3),3),this._normalAttribute=new qe(new Float32Array(d*3),3),this._uvAttribute=new qe(new Float32Array(d*2),2),this._indexAttribute=new qe(new Uint32Array(c*3),1),n){let u=1/0,p=-1/0,g=1/0,f=-1/0;for(let y=0,x=d;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1];_<u&&(u=_),_>p&&(p=_),S<g&&(g=S),S>f&&(f=S)}let m=p-u,v=f-g;for(let y=0,x=d;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1],A=(_-u)/m,b=(S-g)/v;this._positionAttribute.setXYZ(y,_,S,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,A,b)}for(let y=0,x=c;y<x;y++){let w=y*3,_=n.elements[w+0],S=n.elements[w+1],A=n.elements[w+2];this._indexAttribute.setX(w+0,_),this._indexAttribute.setX(w+1,S),this._indexAttribute.setX(w+2,A)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(n?.elementCount??1)*3)}clone(){let e=new u2(this._shape,this._curveSegments);return e.userData=Vu(this.userData),e}},p2=class extends d2{constructor(e,t,i=0,r=12,s=3,n=_t.ODD){super(e,t,i,r,s,n),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let e=new p2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vu(this.userData),e}},Qa=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:_t.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=e.shape??t?.shape,o=a?.roundness??i.roundness;a!==void 0&&(a instanceof Gt?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Gt(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Gt(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:n,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:n,windingRule:a}=e.parameters;e.shape.roundness=n;let o;return t<=0?o=new u2(e.shape,s,{windingRule:a}):o=new p2(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},f2=Math.PI*2,Ov=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,d=t*.5,c=i*.5,u=hk(h,d,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=Qa.create({shape:h,parameters:{subdivisions:u,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function hk(e,t,i,r,s,n){if(r>=f2)return s>30||s%4===0?(dk(e,t,i,n),Math.round(s/4)):ow(e,r,s,t,i,n);r=Math.max(r,.001);let a={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=sk({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?ck(e,a.x,a.y,h,s,t,i,n):ow(e,r,s,t,i,n)}function ck(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(Ko(t,i));for(let h=0,d=r.length;h<d;h++){let c=r[h],u=e.points[h],p=Ko(c.x,c.y);u.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?m2(e,n,a,o):e.addPoint(Ko(0,0)),l}function ow(e,t,i,r,s,n){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,d=Math.cos(l)*s;e.addPoint(Ko(h,d))}return t<f2?n>0?m2(e,r,s,n):e.addPoint(Ko(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&g2(e,r,s,n)),1}function dk(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(ad(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(ad(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(ad(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(ad(s,n-i,s+o,n-i,s-o,n-i)),r>0&&g2(e,t,i,r)}function Ko(e,t){return new Zo(st.generateUUID(),new k(e,t))}function ad(e,t,i,r,s,n){let a=Ko(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function m2(e,t,i,r){v2(e,t,i,r).forEach(s=>e.addPoint(s))}function g2(e,t,i,r){let s=v2(e,t,i,r),n=new Gt;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function v2(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new k(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=st.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),d=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(d),l.controls[1].position.copy(h)}),o}var uk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:d,cornerSegments:c}=e.parameters,u=new y2(!1,t,i,r,s,n,a,o,l,h,d,c);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},_f=new Ho([0,0,0],1),y2=class extends He{constructor(e=!0,t=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,d=1,c=1){if(super(),n===0)return;let u=e&&n===1;u&&(c=0),d>100&&(d=100),d===0&&(c=0);let p=()=>new M,g=new M,f=p(),m=p(),v=p(),y,x,w,_,S,A,b,E,C=p(),T=p(),P=p(),L=p(),D=p(),j=p(),W=p(),q=p(),z=i-2*o+.001,V=z/n,F=Math.ceil(a*n),N=F+1,B=z/F,H=-z/2,X=h+1,Q=2*Math.PI/h,U=Math.PI/2/c,ne=.01,G=Math.min((1-d/100)*o,o-ne),$=o-G,Z=0,ve=2,re=c*ve+ve,oe=X*re/ve,ue=oe+X*N,be=X*(N+re),[Oe,_e,Se]=[3,3,2].map(Te=>Array(be*Te).fill(0)),Ie=[],Xe=s-o;function ct(Te,Le){let Pe=Math.PI/2;A=Le*B,E=2*Math.PI*(A%V)/V+Pe,A+=H,b=Math.sin(E)*Xe,S=Math.cos(E)*Xe,e?Te.set(S,b,A):Te.set(S,A,b)}ct(g,-1e-10),ct(f,0),C.copy(g),ct(g,1);let R=g.distanceTo(f),O=u?0:$+G,ie=R*F+2*O,fe=G,ge=ie-O;for(let Te=0;Te<=F;Te++){ct(m,Te),q.subVectors(m,C).normalize(),C.copy(m),j.copy(m).setComponent(+e+1,0).normalize(),W.crossVectors(q,j).normalize();let Le=Te===0,Pe=Te===F,We=Le?3*Math.PI/2:U,ze=Le?fe:ge,dt=Le?X:ue,Ot=Le?0:be-X,Kt=q.clone().multiplyScalar(Le?-$:$).add(m),Y=q.clone().multiplyScalar(Le?-1:1).normalize();for(let se=0;se<X;se++){let pe=se*Q;if(T.addVectors(g.copy(j).multiplyScalar(o*Math.cos(pe)),f.copy(W).multiplyScalar(o*Math.sin(pe))),P.copy(T).normalize(),Le||Pe){u||(Z=Ot+se,[0,1,2].forEach(xe=>{Oe[Z*3+xe]=Kt.getComponent(xe),_e[Z*3+xe]=Y.getComponent(xe)}),Se[Z*2]=+Pe,Se[Z*2+1]=se/h),f.copy(P).multiplyScalar(G),v.addVectors(m,f);for(let xe=0;xe<c;xe++){let ke=xe*U+We;L.addVectors(g.copy(q).multiplyScalar($*Math.sin(ke)),f.copy(P).multiplyScalar($*Math.cos(ke))),D.copy(L).normalize(),f.addVectors(v,L),L.normalize(),Z=dt+xe*X+se,[0,1,2].forEach(Ut=>{Oe[Z*3+Ut]=f.getComponent(Ut),_e[Z*3+Ut]=D.getComponent(Ut)});let ft=+Le+Math.sin(ke);Se[Z*2]=(ze+$*ft)/ie,Se[Z*2+1]=se/h}}f.addVectors(m,T),Z=oe+Te*X+se,[0,1,2].forEach(xe=>{Oe[Z*3+xe]=f.getComponent(xe),_e[Z*3+xe]=P.getComponent(xe)}),Se[Z*2]=(O+Te*R)/ie,Se[Z*2+1]=se/h}}let Ae=N+2*c+ve,Ye=1,[Me,ce]=[+u,Ae-1];for(let Te=Me;Te<=ce-1;Te++){let Le=u&&Te===ce-1;for(let Pe=0;Pe<X-1;Pe++)y=Te*X+Pe,x=y+1,w=(Le?Pe:y)+X,_=(Le?Pe+1:x)+X,Te===0?Ie.push(x,_,w):Te===Ae-2?Ie.push(y,x,w):Ie.push(y,x,w,x,_,w)}this.setIndex(Ie),this.setAttribute("position",new De(Oe,3)),this.setAttribute("normal",new De(_e,3)),this.setAttribute("uv",new De(Se,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,n,a,o,l=6*(t-1)*e.radialSegments,h=t,d=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,n=s+1,a=(d?c:s)+i,o=(d?c+1:n)+i,r[l++]=s,r[l++]=n,r[l++]=a,r[l++]=n,r[l++]=o,r[l++]=a;return r.length=l,_f.array=r,_f.count=r.length,_f}},pk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new x2(t*.5,n,a):new A_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},x2=class extends Cv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,n,a,e,t,i),this.type=a}static fromJSON(e){return new x2(e.radius,e.corner,e.cornerSides)}},fk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new Hd;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new v_(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ps=new me,Sf=new Et,od=new M,wu=class extends Wi{constructor(){super(),this.uuid=st.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new _i().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let n=0,a=s.vertexNormals.length;n<a;n++)s.vertexNormals[n].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ps.makeRotationX(e),this.applyMatrix4(ps),this}rotateY(e){return ps.makeRotationY(e),this.applyMatrix4(ps),this}rotateZ(e){return ps.makeRotationZ(e),this.applyMatrix4(ps),this}translate(e,t,i){return ps.makeTranslation(e,t,i),this.applyMatrix4(ps),this}scale(e,t,i){return ps.makeScale(e,t,i),this.applyMatrix4(ps),this}lookAt(e){return Sf.lookAt(e),Sf.updateMatrix(),this.applyMatrix4(Sf.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,n=r.normal,a=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<s.count;c++)t.vertices.push(new M().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new Fe().fromBufferAttribute(a,c));function h(c,u,p,g){let f=a===void 0?[]:[t.colors[c].clone(),t.colors[u].clone(),t.colors[p].clone()],m=n===void 0?[]:[new M().fromBufferAttribute(n,c),new M().fromBufferAttribute(n,u),new M().fromBufferAttribute(n,p)],v=new og(c,u,p,m,f,g);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new k().fromBufferAttribute(o,c),new k().fromBufferAttribute(o,u),new k().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new k().fromBufferAttribute(l,c),new k().fromBufferAttribute(l,u),new k().fromBufferAttribute(l,p)])}let d=e.groups;if(d.length>0)for(let c=0;c<d.length;c++){let u=d[c],p=u.start,g=u.count;for(let f=p,m=p+g;f<m;f+=3)i!==void 0?h(i.getX(f),i.getX(f+1),i.getX(f+2),u.materialIndex):h(f,f+1,f+2,u.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(od).negate(),this.translate(od.x,od.y,od.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new me;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new M,t=new M;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=this.vertices[s.a],a=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,a),t.subVectors(n,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new M;if(e){let i=new M,r=new M;for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=this.vertices[a.a],l=this.vertices[a.b],h=this.vertices[a.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[a.a].add(i),t[a.b].add(i),t[a.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=s.vertexNormals;n.length===3?(n[0].copy(t[s.a]),n[1].copy(t[s.b]),n[2].copy(t[s.c])):(n[0]=t[s.a].clone(),n[1]=t[s.b].clone(),n[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,n=r.vertexNormals.length;s<n;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new wu;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let a=0,o=this.faces.length;a<o;a++){let l=new M,h={a:new M,b:new M,c:new M};s.push(l),n.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(a.normal),l.a.copy(a.vertexNormals[0]),l.b.copy(a.vertexNormals[1]),l.c.copy(a.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new si),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Nr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,n=this.vertices,a=e.vertices,o=this.faces,l=e.faces,h=this.colors,d=e.colors;t!==void 0&&(r=new _i().getNormalMatrix(t));for(let c=0,u=a.length;c<u;c++){let p=a[c].clone();t!==void 0&&p.applyMatrix4(t),n.push(p)}for(let c=0,u=d.length;c<u;c++)h.push(d[c].clone());for(let c=0,u=l.length;c<u;c++){let p=l[c],g,f,m=p.vertexNormals,v=p.vertexColors,y=new og(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,w=m.length;x<w;x++)g=m[x].clone(),r!==void 0&&g.applyMatrix3(r).normalize(),y.vertexNormals.push(g);y.color.copy(p.color);for(let x=0,w=v.length;x<w;x++)f=v[x],y.vertexColors.push(f.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let g=0,f=p.length;g<f;g++){let m=p[g],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[y].clone());this.faceVertexUvs[c].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],d=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[d]===void 0?(t[d]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[d]]}let n=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let d=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(d[c]===d[(c+1)%3]){n.push(o);break}}for(let o=n.length-1;o>=0;o--){let l=n[o];this.faces.splice(l,1);for(let h=0,d=this.faceVertexUvs.length;h<d;h++)this.faceVertexUvs[h].splice(l,1)}let a=this.vertices.length-i.length;return this.vertices=i,a}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new M(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],n,a;r&&r.length===t&&(n=[]),s&&s.length===t&&(a=[]);for(let o=0;o<t;o++){let l=e[o]._id;n&&n.push(r[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let g in p)p[g]!==void 0&&(e[g]=p[g]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let g=this.vertices[p];t.push(g.x,g.y,g.z)}let i=[],r=[],s={},n=[],a={},o=[],l={};for(let p=0;p<this.faces.length;p++){let g=this.faces[p],f=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=g.normal.length()>0,x=g.vertexNormals.length>0,w=g.color.r!==1||g.color.g!==1||g.color.b!==1,_=g.vertexColors.length>0,S=0;if(S=h(S,0,0),S=h(S,1,f),S=h(S,2,m),S=h(S,3,v),S=h(S,4,y),S=h(S,5,x),S=h(S,6,w),S=h(S,7,_),i.push(S),i.push(g.a,g.b,g.c),i.push(g.materialIndex),v){let A=this.faceVertexUvs[0][p];i.push(u(A[0]),u(A[1]),u(A[2]))}if(y&&i.push(d(g.normal)),x){let A=g.vertexNormals;i.push(d(A[0]),d(A[1]),d(A[2]))}if(w&&i.push(c(g.color)),_){let A=g.vertexColors;i.push(c(A[0]),c(A[1]),c(A[2]))}}function h(p,g,f){return f?p|1<<g:p&~(1<<g)}function d(p){let g=p.x.toString()+p.y.toString()+p.z.toString();return s[g]!==void 0||(s[g]=r.length/3,r.push(p.x,p.y,p.z)),s[g]}function c(p){let g=p.r.toString()+p.g.toString()+p.b.toString();return a[g]!==void 0||(a[g]=n.length,n.push(p.getHex())),a[g]}function u(p){let g=p.x.toString()+p.y.toString();return l[g]!==void 0||(l[g]=o.length/2,o.push(p.x,p.y)),l[g]}return e.data={},e.data.vertices=t,e.data.normals=r,n.length>0&&(e.data.colors=n),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new wu().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,u=t.length;c<u;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,u=i.length;c<u;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,u=r.length;c<u;c++)this.faces.push(r[c].clone());for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let g=0,f=p.length;g<f;g++){let m=p[g],v=[];for(let y=0,x=m.length;y<x;y++){let w=m[y];v.push(w.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,u=s.length;c<u;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let g=0,f=s[c].vertices.length;g<f;g++)p.vertices.push(s[c].vertices[g].clone())}if(s[c].normals!==void 0){p.normals=[];for(let g=0,f=s[c].normals.length;g<f;g++)p.normals.push(s[c].normals[g].clone())}this.morphTargets.push(p)}let n=e.morphNormals;for(let c=0,u=n.length;c<u;c++){let p={};if(n[c].vertexNormals!==void 0){p.vertexNormals=[];for(let g=0,f=n[c].vertexNormals.length;g<f;g++){let m=n[c].vertexNormals[g],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let g=0,f=n[c].faceNormals.length;g<f;g++)p.faceNormals.push(n[c].faceNormals[g].clone())}this.morphNormals.push(p)}let a=e.skinWeights;for(let c=0,u=a.length;c<u;c++)this.skinWeights.push(a[c].clone());let o=e.skinIndices;for(let c=0,u=o.length;c<u;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,u=l.length;c<u;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let d=e.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new mk().fromGeometry(this),t=new He,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",ld.call(new qe(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",ld.call(new qe(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",lw.call(new qe(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",hw.call(new qe(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",hw.call(new qe(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],n=e.morphTargets[r];for(let a=0,o=n.length;a<o;a++){let l=n[a],h=new De(l.data.length*3,3);h.name=l.name,s.push(ld.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new De(e.skinIndices.length*4,4);t.setAttribute("skinIndex",cw.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new De(e.skinWeights.length*4,4);t.setAttribute("skinWeight",cw.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new He,i=e.geometry;if(e.isPoints||e.isLine){let r=new De(i.vertices.length*3,3),s=new De(i.colors.length*3,3);if(t.setAttribute("position",ld.call(r,i.vertices)),t.setAttribute("color",lw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new De(i.lineDistances.length,1);t.setAttribute("lineDistance",gk.call(n,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};wu.prototype.isGeometry=!0;var mk=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,n=e.faces;for(r=0;r<n.length;r++){let a=n[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,n=r[1]&&r[1].length>0,a=e.morphTargets,o=a.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,d=h.length,c;if(d>0){c=[];for(let m=0;m<d;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let u=e.skinIndices,p=e.skinWeights,g=u.length===i.length,f=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let w=v.normal;this.normals.push(w,w,w)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][m];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new k,new k,new k))}if(n===!0){let w=r[1][m];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new k,new k,new k))}for(let w=0;w<o;w++){let _=a[w].vertices;l[w].data.push(_[v.a],_[v.b],_[v.c])}for(let w=0;w<d;w++){let _=h[w].vertexNormals[m];c[w].data.push(_.a,_.b,_.c)}g&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),f&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},og=class{constructor(e,t,i,r,s,n=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new M,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Fe,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=n}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function gk(e){return this.array.set(e),this}function lw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new Fe),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function hw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new k),t[i++]=n.x,t[i++]=n.y}return this}function ld(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new M),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function cw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new tt),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var vk=["a","b","c"];function yk(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Af(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function Mf(e,t,i,r,s,n){let a=Math.min(e,t),o=Math.max(e,t),l=a+"_"+o,h;if(r.has(l))h=r.get(l);else{let d=i[a],c=i[o];h={a:d,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),n[e].edges.push(h),n[t].edges.push(h)}function xk(e,t,i,r){let s,n,a;for(s=0,n=e.length;s<n;s++)i[s]={edges:[]};for(s=0,n=t.length;s<n;s++)a=t[s],Mf(a.a,a.b,e,r,a,i),Mf(a.b,a.c,e,r,a,i),Mf(a.c,a.a,e,r,a,i)}function hd(e,t,i,r,s){e.push(new og(t,i,r,void 0,void 0,s))}function xo(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function cd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var wk=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof He?e=new wu().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new M,i,r,s,n,a,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],d=h!==void 0&&h.length>0,c=[],u=new Map;xk(o,l,c,u);let p=[],g,f,m,v,y,x,w;for(let ne of Array.from(u.keys())){for(f=u.get(ne),m=new M,y=3/8,x=1/8,w=f.faces.length,w!=2&&(y=.5,x=0,w!=1),m.addVectors(f.a,f.b).multiplyScalar(y),t.set(0,0,0),n=0;n<w;n++){for(v=f.faces[n],a=0;a<3&&(g=o[yk(v,vk[a])],!(g!==f.a&&g!==f.b));a++);g&&t.add(g)}t.multiplyScalar(x),m.add(t),f.newEdge=p.length,p.push(m)}let _,S,A,b,E,C,T,P=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],E=c[r].edges,i=E.length,i==3?_=3/16:i>3&&(_=3/(8*i)),S=1-i*Number(_),A=_,i<=2&&(i==2?(S=3/4,A=1/8):i==1||i==0),T=C.clone().multiplyScalar(S),t.set(0,0,0),n=0;n<i;n++)b=E[n],g=b.a!==C?b.a:b.b,t.add(g);t.multiplyScalar(Number(A)),T.add(t),P.push(T)}let L=P.concat(p),D=P.length,j,W,q,z=[],V=[],F,N,B,H,X=new k,Q=new k,U=new k;for(r=0,s=l.length;r<s;r++)v=l[r],j=Number(Af(v.a,v.b,u).newEdge)+D,W=Number(Af(v.b,v.c,u).newEdge)+D,q=Number(Af(v.c,v.a,u).newEdge)+D,hd(z,j,W,q,v.materialIndex),hd(z,v.a,j,q,v.materialIndex),hd(z,v.b,W,j,v.materialIndex),hd(z,v.c,q,W,v.materialIndex),d&&(F=h[r],N=F[0],B=F[1],H=F[2],X.set(xo(N.x,B.x),xo(N.y,B.y)),Q.set(xo(B.x,H.x),xo(B.y,H.y)),U.set(xo(N.x,H.x),xo(N.y,H.y)),cd(V,X,Q,U),cd(V,N,X,U),cd(V,B,Q,X),cd(V,H,U,Q));e.vertices=L,e.faces=z,d&&(e.faceVertexUvs[0]=V)}},ai=new M,bk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new He().copy(new Is(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ai),r={width:ai.x,height:ai.y,depth:ai.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,n=e.geometry??new He().copy(new Is(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ai)):ai.set(a.width,a.height,a.depth),(t!==ai.x||i!==ai.y||r!==ai.z)&&n.scale(ai.x===0?1:t/ai.x,ai.y===0?1:i/ai.y,ai.z===0?1:r/ai.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new wk(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new T_(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ai);let n=100/ai.x;Object.assign(s.parameters,{width:100,height:ai.y*n,depth:ai.z*n}),t(this.build(s))})}},w2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5,c=0,u=0,p=2*Math.PI/r;for(let f=0;f<r;f++){let m=p*f,v=c+Math.sin(m)*h,y=u+Math.cos(m)*d;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let f=0,m=l.points.length;f<m;f++)l.points[f].roundness=s;l.roundness=s,l.update();let g=Qa.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(g,{userData:{...e,type:"PolygonGeometry"}})}},_k=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new Ak(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function eh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Ef(e,t,i,r,s,n){let a=t.clone().sub(e),o=i.clone().sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(e),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function Sk(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var Ak=class extends He{constructor(e=.5,t=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],d=[],c=0,u=t/2,p=Math.PI/i,g=e*Math.cos(Math.PI/i),f=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new M(0,-u,0),x=new M(0,u,0),w=new k(e,-u),_=new k(g,-u),S=new k(0,x.y).sub(_),A=new k(0,x.y).sub(w),b=new k(S.y,-S.x).normalize(),E=new k(A.y,-A.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new M(b.x,b.y,0),V=new M(Math.cos(f)*z.x,z.y,Math.sin(f)*z.x);T=z.angleTo(V)}let P=n/Math.tan((Math.PI-S.angle())/2),L=n/Math.tan((Math.PI-T)/2),D=new M;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),d.push(0,0);let z=c++,V=[],F=w.clone(),N=P/Math.cos(Math.PI/i);F.x-=N;for(let B=0;B<i;B++){let H=B/i*Math.PI*2+p,X=new k(Math.sin(H),Math.cos(H));eh(F,X,D),l.push(D.x,D.y,D.z),h.push(0,-1,0),d.push(0,0),V.push(c++)}for(let B=0;B<V.length;B++)o.push(V[B],z,V[(B+1)%V.length])}let j=[];{let z=new M,V=new M,F=new M,N=new M,B=new M,H=new M;for(let X=0;X<i;X++){let Q=X/i*Math.PI*2+p,U=(X+.5)/i*Math.PI*2+p,ne=(X+1)/i*Math.PI*2+p,G=new k(Math.sin(Q),Math.cos(Q)),$=new k(Math.sin(U),Math.cos(U)),Z=new k(Math.sin(ne),Math.cos(ne));eh(w,G,V),eh(w,Z,F),eh(b,$,z),Ef(x,V,F,L,L,N),l.push(N.x,N.y,N.z),Ef(V,x,F,L,P,B),l.push(B.x,B.y,B.z),Ef(F,V,x,P,L,H),l.push(H.x,H.y,H.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),d.push(0,0),d.push(0,0),d.push(0,0);let ve=c++,re=c++,oe=c++;if(o.push(ve,re,oe),n>0){{let Oe=V.clone().add(F).multiplyScalar(.5),_e=x.clone().sub(Oe).normalize(),Se=y.clone().sub(Oe).normalize().add(_e).normalize().multiplyScalar(-1),Ie=H.clone().sub(B);W(Oe,Ie,Se,S.angle())}let ue,be;{let Oe=new M;eh(E,Z,Oe);let _e=H.clone().add(N).multiplyScalar(.5);_e=Sk(_e,F,x);let Se=H.clone().sub(N);[ue,be]=W(_e,Se,Oe,T,N.y)}{let Oe=ue,_e=Oe.clone().setY(0).normalize(),Se=new M(0,-1,0),Ie=_e.clone().cross(Se);q(Oe,_e,Se,Ie)}j.concat(be);{let Oe=S.angle(),_e=Math.PI-Oe,Se=x.clone();Se.y-=n/Math.sin(Oe-Math.PI/2);let Ie=new M,Xe=[];for(let R=0;R<a;R++){let O=[],ie=Math.PI/2-_e*R/a,fe=Math.cos(ie),ge=Math.sin(ie),Ae=U;for(let Ye=0;Ye<=R;Ye++){let Me=Math.cos(Ae),ce=Math.sin(Ae);z.x=fe*ce,z.y=ge,z.z=fe*Me,Ie.copy(Se).addScaledVector(z,n),l.push(Ie.x,Ie.y,Ie.z),h.push(z.x,z.y,z.z),d.push(0,0),O.push(c++),Ae+=Math.PI*2/R/i}Xe.push(O)}be.reverse(),Xe.push(be);let ct=Xe.length-1;for(let R=0;R<ct;R++){let O=Xe[R],ie=Xe[R+1],fe=O.length-1;o.push(ie[1],O[0],ie[0]);for(let ge=1;ge<=fe;ge++)o.push(O[ge],O[ge-1],ie[ge]),o.push(ie[ge+1],O[ge],ie[ge])}}}}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(d,2));function W(z,V,F,N,B){let H=-N/2,X=(Math.PI-N)/2,Q=V.clone().normalize().cross(F);z.addScaledVector(F,-n/Math.sin(X));let U=new M,ne=new M,G=1,$=c,Z=[];for(let ve=0;ve<=a;ve++){let re=H+ve/a*N;ne.set(0,0,0),ne.addScaledVector(Q,Math.sin(re)),ne.addScaledVector(F,Math.cos(re));for(let oe=0;oe<=G;oe++){let ue=oe/G-.5;if(U.copy(z),U.addScaledVector(V,ue),U.addScaledVector(ne,n),B!=null){let be=Math.max(0,U.y-B);U.addScaledVector(V,-be/V.y)}l.push(U.x,U.y,U.z),h.push(ne.x,ne.y,ne.z),d.push(0,0),oe===0&&Z.push(c),c++}}for(let ve=0;ve<a;ve++)for(let re=0;re<G;re++){let oe=$+re+(G+1)*ve,ue=oe+(G+1),be=ue+1,Oe=oe+1;o.push(oe,ue,Oe),o.push(ue,be,Oe)}return[z.clone().addScaledVector(V,.5),Z]}function q(z,V,F,N){let B=Math.PI/2,H=A.angle()-B,X=[],Q=new M,U=new M;for(let G=0;G<=a;G++){let $=[],Z=G/a;for(let ve=0;ve<=G;ve++){let re=((G?ve/G:0)-.5)*v,oe=Math.cos(re),ue=Math.sin(re),be=Math.atan(Math.tan(H)*oe),Oe=(B+be)*Z,_e=Math.cos(Oe),Se=Math.sin(Oe);Q.set(0,0,0),Q.addScaledVector(V,Se*oe),Q.addScaledVector(F,_e),Q.addScaledVector(N,Se*ue),U.copy(z).addScaledVector(Q,n),l.push(U.x,U.y,U.z),h.push(Q.x,Q.y,Q.z),d.push(0,0),$.push(c++)}X.push($)}let ne=X.length-1;for(let G=0;G<ne;G++){let $=X[G],Z=X[G+1],ve=$.length-1;o.push($[0],Z[1],Z[0]);for(let re=1;re<=ve;re++)o.push($[re-1],$[re],Z[re]),o.push($[re],Z[re+1],Z[re])}}}},b2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},d={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function u(w,_,S){return _>i&&S>r?Math.min(w*i/_,w*r/S):_>i?w*i/_:S>r?w*r/S:w}let p=[];p[0]=s[0]===0?0:u(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:u(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:u(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:u(s[3],s[3]+s[0],s[3]+s[2]);let g=d.x,f=c.x,m=c.y,v=d.y;t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(f,v)),t.addPoint(t.createPoint(g,v)),t.isClosed=!0;let y=!0;for(let w=0,_=t.points.length;w<_;w++)t.points[w].roundness=p[w],w>0&&p[w]!==p[w-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=Qa.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},Mk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:n=64,phiStart:a,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,d=new Hg(.5*t,s,n,a,o,l,h);return d.scale(1,i/t,r/t),Object.assign(d,{userData:{...e,type:"SphereGeometry"}})}},Ek=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,n=new Lu(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},Ck=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=e.parameters,o=new Tk(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},Tk=class extends He{constructor(e=1,t=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let d=[],c=Math.PI/2,u=(ne=0,G=0,$=0)=>new M(ne,G,$),p=u(),g=u(),[f,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[w,_,S]=[u(y,-f,+v),u(y,-f,-v),u(y,+f,-v)],A=(ne,G=!1)=>Math.sin(ne-Math.PI/(1+ +G)),b=(ne,G=!1)=>Math.cos(ne-Math.PI/(1+ +G));S.y=Math.sin(r)*t-f;let E=Math.cos(r)*t-v,C=w.z-h;r<=c?(S.z=Math.min(E,C),S.z==C&&(S.y-=(E-C)/Math.tan(c-r))):_.z=Math.min(_.z-E-v,w.z-h),p.subVectors(w,_),g.subVectors(S,_);let T=Math.min(p.length(),g.length())*s/100,P=T*Math.tan(r/2),L=T/Math.cos(r/2),D=p.clone().normalize().add(g.normalize()).setLength(L).add(_);p.set(0,A(r,!0),b(r,!0)),d.push([S,p.clone()]);let j=(Math.PI-r)/n;for(let ne=0;ne<=n;ne++){let G=c+r+ne*j;p.set(0,Math.sin(G)*P,Math.cos(G)*P),p.add(D),g.set(0,A(G),b(G)),d.push([p.clone(),g.clone()])}d.push([w,u(0,1,0)]);let W=Math.sin(j/2)*P*2,q=d.length-1,z=d[0][0].distanceTo(d[1][0]),V=d[q-1][0].distanceTo(d[q][0]),F=z+W*n+V;d[0].push(1);for(let ne=0;ne<=n;ne++)d[ne+1].push(1-(z+ne*W)/F);d[q].push(0);let[N,B,H]=d[0],X,Q,U;for(let ne=1;ne<d.length;ne++)[X,Q,U]=d[ne],a.push(y,N.y,N.z,y,X.y,X.z,x,N.y,N.z,x,N.y,N.z,y,X.y,X.z,x,X.y,X.z),o.push(0,B.y,B.z,0,Q.y,Q.z,0,B.y,B.z,0,B.y,B.z,0,Q.y,Q.z,0,Q.y,Q.z),l.push(0,H,0,U,1,H,1,H,0,U,1,U),[N,B,H]=[X,Q,U];this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}},_2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,d=e.shape,c=t*.5,u=i*.5,p=0,g=0,f=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=u*r/100;if(s===3&&r===50){f=2*Math.PI/s;for(let w=0;w<s;w++){let _=f*w,S=p+Math.sin(_)*c,A=g+Math.cos(_)*u;d.addPoint(d.createPoint(S,A))}}else for(let w=0;w<s;w++){let _=p+Math.cos(m)*c,S=g+Math.sin(m)*u;d.addPoint(d.createPoint(_,S)),m+=f,_=p+Math.cos(m)*v,S=g+Math.sin(m)*y,w<=s,d.addPoint(d.createPoint(_,S)),m+=f}d.isClosed=!0;for(let w=0,_=d.points.length;w<_;w++)d.points[w].roundness=n;d.roundness=n,d.update();let x=Qa.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},Pk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new Lu(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},Dk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=Ok(t,i,r,t*.5,a,n,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function Ok(e,t,i,r,s,n,a,o,l,h,d){return[t,i]=[i,t],a=t/2,s/=2*Math.PI,s==1&&(h=0),new y2(!0,e,t,i,r,s,n,a,o,l,h,d)}var Lk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new M_(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},Rk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5;o?(l.addPoint(l.createPoint(-h,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))),l.isClosed=!0;for(let u=0,p=l.points.length;u<p;u++)l.points[u].roundness=r;l.roundness=r,l.update();let c=Qa.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function Ik(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function Bk(e,t,i){let r=[new M,new M,new M],s=[new M,new M,new M];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((n,a)=>{let o=s[a],l=st.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new me().makeBasis(r[0],r[1],r[2])}var zk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=t?.shapeData??Ov.create({parameters:qS}).userData.shape;return{path:e.path??hu.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...XS,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new Nk(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new He,{userData:{...e,type:"PathGeometry"}})}},Nk=class extends He{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)||!Ik(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,n=Math.floor(r*s),a=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,a-n+1),s+2),l=[],h=[];for(let C=0;C<o;C++){let T=this.inputs.path.isClosed?(C+n)%e.length:Math.min(C+n,e.length-1);l.push(e[T].clone()),h.push(t[T].clone())}let d=(C,T,P)=>{l[C]=l[C].clone().lerp(l[T],P),h[C]=Bk(h[C],h[T],P)},c=0,u=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(u||r===0)&&(c=u,d(0,1,c));let p=0,g=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&g&&(p=g,d(l.length-1,l.length-2,1-p)),i===0){let C=l.length-1;l[C].copy(l[0]),h[C].copy(h[0])}this._applyPathModifiers(h,c,p);let{regions:f,infos:m,vertices:v}=this._computeShapePoints(5),y=0,x=0;m.sort((C,T)=>C.start-T.start),m.forEach(C=>{C.verticesStart=y,C.verticesCount=C.continuous.reduce((T,P,L)=>T+(L===0||!P?2:1),0),x+=C.verticesCount,y=x});let w=x*o,_,S=0;if(this._isOpenEnded()){try{_=Xn({windingRule:_t.ODD,elementType:ii.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:f})}catch{_=c2}S=_.vertexCount}let A=w+2*S,b={positions:new Float32Array(A*3),normals:new Float32Array(A*3),uvs:new Float32Array(A*2)},E=[];m.forEach(C=>{this._extrudeRegion(C,v,h,l,b,E,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,w,E,b,h[0],l[0],!1),this._closeEnd(_,w+S,E,b,h[h.length-1],l[l.length-1],!0)),this.setAttribute("position",new qe(b.positions,3)),this.setAttribute("normal",new qe(b.normals,3)),this.setAttribute("uv",new qe(b.uvs,2)),this.setIndex(E)}_extractPathPoints(){let e=e2(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new M,n=new M,a=new M,o=new M,l=new M(0,1,0);for(let g=0;g<i;g++){let f=e[g],m;g===0?m=r?e[e.length-2]:f.clone().multiplyScalar(2).sub(e[1]):m=e[g-1];let v;g===i-1?v=r?e[1]:f.clone().multiplyScalar(2).sub(e[g-1]):v=e[g+1];let y=f.clone().sub(m).normalize(),x=v.clone().sub(f).normalize(),w=y.clone().add(x).normalize();a.copy(w),g===0&&(w.equals(l)||w.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(w).normalize(),S=w.clone().cross(_).normalize();l.copy(S),o.copy(_),g===0&&(s.copy(S),n.copy(w));let A=new me().makeBasis(_,S,w);t.push(A)}let h=r?n:a,d=r?s:new M(0,1,0),c=h.clone().cross(o).normalize(),u=Math.acos(d.dot(c));if(isNaN(u))return t;let p=d.clone().cross(c);h.dot(p)>0&&(u*=-1);for(let g=1;g<t.length;g++){let f=new me().makeRotationZ(u*g/t.length);t[g].multiply(f)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new me,h=new me;return e.forEach((d,c)=>{let u=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(st.lerp(s,s+n,u));let p=st.lerp(a,o,u);h.makeScale(p,p,p),d.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=_t.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let g=p.extractShapePointsToFlatArray([],e),f=[];for(let m=g.length-1;m>=1;m-=2){let v=g[m-1],y=g[m-0];f.push(v,y)}return f}),n;try{n=Xn({windingRule:t,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=Dv}let a;try{a=Xn({windingRule:_t.ODD,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=h2}if(!n)throw new Error("error generating geometry");let o=n.elementCount;if(a){n.elementCount+=a.elementCount;for(let p=0;p<a.elements.length;p++){let g=a.elements[p],f=p%2===0?n.vertexCount:0;n.elements.push(g+f)}for(let p=0;p<a.vertexIndices.length;p++){let g=a.vertexIndices[p],f=n.vertexCount;n.vertexIndices.push(g+f)}for(let p=0;p<a.vertices.length;p++){let g=a.vertices[p];n.vertices.push(g)}}let l=1/0,h=-1/0,d=1/0,c=-1/0;for(let p=0,g=n.vertexCount;p<g;p++){let f=p*2,m=n.vertices[f+0],v=n.vertices[f+1];m<l&&(l=m),m>h&&(h=m),v<d&&(d=v),v>c&&(c=v)}let u=[];for(let p=n.elementCount-1;p>=0;p--){let g=p>=o,f=p*2,m=n.elements[f+0],v=n.elements[f+1],y=m+v,x={start:m,count:v,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};u.push(x);let w=m,_=y-1,S=m+1,A=i.roundedCurves.length;do{let b=w-m,E=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[w*2+0],P=n.vertices[w*2+1],L=n.vertices[S*2+0],D=n.vertices[S*2+1],j=T-E,W=P-C,q=Math.sqrt(j*j+W*W);j/=q,W/=q;let z=T-L,V=P-D,F=Math.sqrt(z*z+V*V);z/=F,V/=F,x.normals[b*2+0]=-V,x.normals[b*2+1]=z;let N=n.vertexIndices[w];if(Array.isArray(N))x.continuous[b]=!1;else{let[B,H]=i.getCurveIndexFromVertexId(N-1,!0);if(H>0&&H<1)x.continuous[b]=!0;else{let X=H===1?B+1:B-1;X=(X+A)%A;let Q=H===1?0:1,U=i.roundedCurves[B].getTangent(H),ne=i.roundedCurves[X].getTangent(Q);x.continuous[b]=U.dot(ne)>.95}}g&&(x.normals[b*2+0]*=-1,x.normals[b*2+1]*=-1),[_,w,S]=[w,S,S+1],S>=y&&(S-=v)}while(S!==m+1)}return{regions:[r,...s],infos:u,vertices:n.vertices}}_insertVertex(e,t,i,r,s){let n=t*2,a=t*3;e.positions[a+0]=i.x,e.positions[a+1]=i.y,e.positions[a+2]=i.z,e.normals[a+0]=r.x,e.normals[a+1]=r.y,e.normals[a+2]=r.z,e.uvs[n+0]=s.x,e.uvs[n+1]=s.y}_extrudeRegion(e,t,i,r,s,n,a){let o=new M,l=new M,h=new M,d=new M,c=new k;i.forEach((p,g)=>{let f=r[g],m=e.verticesStart*i.length+e.verticesCount*g;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(f),e.continuous[v])d.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v==0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),d.copy(o).sub(l),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,g/(i.length-1)),this._insertVertex(s,m,h,d,c),m++,!e.continuous[v]||v===0){if(v===0)d.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,g/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),d.copy(l).sub(o),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,d,c),m++}}});let u=i.length-1;for(let p=0;p<u;p++){let g=e.verticesStart*i.length+e.verticesCount*p,f=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=g+m,w=g+y,_=f+y,S=f+m;e.isHole?n.push(x,_,w,x,S,_):n.push(x,w,_,x,_,S),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new M(0,0,a?-1:1).applyMatrix4(s),h=new M,d=new k;for(let u=0;u<o;u++){let p=2*u;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(n),this._insertVertex(r,t+u,h,l,d)}let c=e.elements;for(let u=0;u<e.elementCount;u++){let p=3*u,g=c[p+0]+t,f=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(g,f,m)}}};function S2(){let e=new He;return e.setAttribute("position",new qe(new Float32Array([]),3)),e.setIndex(new qe(new Uint16Array([]),1)),e}var Uk=S2().attributes,Fk=12,kk=1,A2=class extends He{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,Uk),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,text:o,textTransform:l}=e,h=l===2?o.toUpperCase():l===3?o.toLowerCase():o,d=jk(e,t,h),{shapes:c,charWidths:u,charCoords:p}=t.generateShapes(d,e),g=i*.5,f=r*.5,m=c.map(x=>new Gt().fromShape(x));this.vectorShapes=m;let v=m.map(x=>Qa.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?_t.NONZERO:_t.ODD,subdivisions:this.isLowResolution&&s>0?kk:Fk}})),y=v.length?Ta(v):S2();y.translate(-g,f,0),this.dispose(),this.wrappedText=d,this.charCoords=p,this.charWidths=u,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,w])=>{this.setAttribute(x,w)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Va(new He,A2.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function jk(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
3138
+ }`;function VD(e,t,i){let r=new Ug,s=new k,n=new k,a=new tt,o=new u_({depthPacking:$b}),l=new kD,h={},d=i.maxTextureSize,c={[rs]:gi,[gi]:rs,[mr]:mr},u=new It({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:jD,fragmentShader:GD}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let g=new He;g.setAttribute("position",new qe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let f=new tr(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ig,this.render=function(w,_,S){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let A=e.getRenderTarget(),b=e.getActiveCubeFace(),E=e.getActiveMipmapLevel(),C=e.state;C.setBlending(ri),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,P=w.length;T<P;T++){let L=w[T],D=L.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",L,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;s.copy(D.mapSize);let j=D.getFrameExtents();if(s.multiply(j),n.copy(D.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(n.x=Math.floor(d/j.x),s.x=n.x*j.x,D.mapSize.x=n.x),s.y>d&&(n.y=Math.floor(d/j.y),s.y=n.y*j.y,D.mapSize.y=n.y)),D.map===null){let q=this.type!==uh?{minFilter:Dt,magFilter:Dt}:{};D.map=new St(s.x,s.y,q),D.map.texture.name=L.name+".shadowMap",D.camera.updateProjectionMatrix()}e.setRenderTarget(D.map),e.clear();let W=D.getViewportCount();for(let q=0;q<W;q++){let z=D.getViewport(q);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),D.updateMatrices(L,q),r=D.getFrustum(),x(_,S,D.camera,L,this.type)}D.isPointLightShadow!==!0&&this.type===uh&&v(D,S),D.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(A,b,E)};function v(w,_){let S=t.update(f);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new St(s.x,s.y)),u.uniforms.shadow_pass.value=w.map.texture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,e.setRenderTarget(w.mapPass),e.clear(),e.renderBufferDirect(_,null,S,u,f,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,e.setRenderTarget(w.map),e.clear(),e.renderBufferDirect(_,null,S,p,f,null)}function y(w,_,S,A,b,E){let C=null,T=S.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(T!==void 0)C=T;else if(C=S.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let P=C.uuid,L=_.uuid,D=h[P];D===void 0&&(D={},h[P]=D);let j=D[L];j===void 0&&(j=C.clone(),D[L]=j),C=j}return C.visible=_.visible,C.wireframe=_.wireframe,E===uh?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:c[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,S.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(S.matrixWorld),C.nearDistance=A,C.farDistance=b),C}function x(w,_,S,A,b){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===uh)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,w.matrixWorld);let C=t.update(w),T=w.material;if(Array.isArray(T)){let P=C.groups;for(let L=0,D=P.length;L<D;L++){let j=P[L],W=T[j.materialIndex];if(W&&W.visible){let q=y(w,W,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,q,w,j)}}}else if(T.visible){let P=y(w,T,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,P,w,null)}}let E=w.children;for(let C=0,T=E.length;C<T;C++)x(E[C],_,S,A,b)}}function HD(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,se=new tt,pe=null,xe=new tt(0,0,0,0);return{setMask:function(ke){pe!==ke&&!Y&&(e.colorMask(ke,ke,ke,ke),pe=ke)},setLocked:function(ke){Y=ke},setClear:function(ke,ft,Ut,Mi,aa){aa===!0&&(ke*=Mi,ft*=Mi,Ut*=Mi),se.set(ke,ft,Ut,Mi),xe.equals(se)===!1&&(e.clearColor(ke,ft,Ut,Mi),xe.copy(se))},reset:function(){Y=!1,pe=null,xe.set(-1,0,0,0)}}}function n(){let Y=!1,se=null,pe=null,xe=null;return{setTest:function(ke){ke?ne(2929):G(2929)},setMask:function(ke){se!==ke&&!Y&&(e.depthMask(ke),se=ke)},setFunc:function(ke){if(pe!==ke){switch(ke){case cE:e.depthFunc(512);break;case dE:e.depthFunc(519);break;case uE:e.depthFunc(513);break;case nm:e.depthFunc(515);break;case pE:e.depthFunc(514);break;case fE:e.depthFunc(518);break;case mE:e.depthFunc(516);break;case gE:e.depthFunc(517);break;default:e.depthFunc(515)}pe=ke}},setLocked:function(ke){Y=ke},setClear:function(ke){xe!==ke&&(e.clearDepth(ke),xe=ke)},reset:function(){Y=!1,se=null,pe=null,xe=null}}}function a(){let Y=!1,se=null,pe=null,xe=null,ke=null,ft=null,Ut=null,Mi=null,aa=null;return{setTest:function(zt){Y||(zt?ne(2960):G(2960))},setMask:function(zt){se!==zt&&!Y&&(e.stencilMask(zt),se=zt)},setFunc:function(zt,js,xr){(pe!==zt||xe!==js||ke!==xr)&&(e.stencilFunc(zt,js,xr),pe=zt,xe=js,ke=xr)},setOp:function(zt,js,xr){(ft!==zt||Ut!==js||Mi!==xr)&&(e.stencilOp(zt,js,xr),ft=zt,Ut=js,Mi=xr)},setLocked:function(zt){Y=zt},setClear:function(zt){aa!==zt&&(e.clearStencil(zt),aa=zt)},reset:function(){Y=!1,se=null,pe=null,xe=null,ke=null,ft=null,Ut=null,Mi=null,aa=null}}}let o=new s,l=new n,h=new a,d=new WeakMap,c=new WeakMap,u={},p={},g=new WeakMap,f=[],m=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,E=!1,C=null,T=null,P=null,L=null,D=null,j=e.getParameter(35661),W=!1,q=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(z)[1]),W=q>=1):z.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),W=q>=2);let V=null,F={},N=e.getParameter(3088),B=e.getParameter(2978),H=new tt().fromArray(N),X=new tt().fromArray(B);function Q(Y,se,pe){let xe=new Uint8Array(4),ke=e.createTexture();e.bindTexture(Y,ke),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let ft=0;ft<pe;ft++)e.texImage2D(se+ft,0,6408,1,1,0,6408,5121,xe);return ke}let U={};U[3553]=Q(3553,3553,1),U[34067]=Q(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ne(2929),l.setFunc(nm),Oe(!1),_e(C0),ne(2884),ue(ri);function ne(Y){u[Y]!==!0&&(e.enable(Y),u[Y]=!0)}function G(Y){u[Y]!==!1&&(e.disable(Y),u[Y]=!1)}function $(Y,se){return p[Y]!==se?(e.bindFramebuffer(Y,se),p[Y]=se,r&&(Y===36009&&(p[36160]=se),Y===36160&&(p[36009]=se)),!0):!1}function Z(Y,se){let pe=f,xe=!1;if(Y)if(pe=g.get(se),pe===void 0&&(pe=[],g.set(se,pe)),Y.isWebGLMultipleRenderTargets){let ke=Y.texture;if(pe.length!==ke.length||pe[0]!==36064){for(let ft=0,Ut=ke.length;ft<Ut;ft++)pe[ft]=36064+ft;pe.length=ke.length,xe=!0}}else pe[0]!==36064&&(pe[0]=36064,xe=!0);else pe[0]!==1029&&(pe[0]=1029,xe=!0);xe&&(i.isWebGL2?e.drawBuffers(pe):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function ve(Y){return m!==Y?(e.useProgram(Y),m=Y,!0):!1}let re={[Po]:32774,[$M]:32778,[eE]:32779};if(r)re[O0]=32775,re[L0]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(re[O0]=Y.MIN_EXT,re[L0]=Y.MAX_EXT)}let oe={[tE]:0,[iE]:1,[rE]:768,[Xb]:770,[hE]:776,[oE]:774,[nE]:772,[sE]:769,[Yb]:771,[lE]:775,[aE]:773};function ue(Y,se,pe,xe,ke,ft,Ut,Mi){if(Y===ri){v===!0&&(G(3042),v=!1);return}if(v===!1&&(ne(3042),v=!0),Y!==JM){if(Y!==y||Mi!==E){if((x!==Po||S!==Po)&&(e.blendEquation(32774),x=Po,S=Po),Mi)switch(Y){case Vo:e.blendFuncSeparate(1,771,1,771);break;case T0:e.blendFunc(1,1);break;case P0:e.blendFuncSeparate(0,769,0,1);break;case D0:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Vo:e.blendFuncSeparate(770,771,1,771);break;case T0:e.blendFunc(770,1);break;case P0:e.blendFuncSeparate(0,769,0,1);break;case D0:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}w=null,_=null,A=null,b=null,y=Y,E=Mi}return}ke=ke||se,ft=ft||pe,Ut=Ut||xe,(se!==x||ke!==S)&&(e.blendEquationSeparate(re[se],re[ke]),x=se,S=ke),(pe!==w||xe!==_||ft!==A||Ut!==b)&&(e.blendFuncSeparate(oe[pe],oe[xe],oe[ft],oe[Ut]),w=pe,_=xe,A=ft,b=Ut),y=Y,E=!1}function be(Y,se){Y.side===mr?G(2884):ne(2884);let pe=Y.side===gi;se&&(pe=!pe),Oe(pe),Y.blending===Vo&&Y.transparent===!1?ue(ri):ue(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),o.setMask(Y.colorWrite);let xe=Y.stencilWrite;h.setTest(xe),xe&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),Ie(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ne(32926):G(32926)}function Oe(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function _e(Y){Y!==ZM?(ne(2884),Y!==T&&(Y===C0?e.cullFace(1029):Y===KM?e.cullFace(1028):e.cullFace(1032))):G(2884),T=Y}function Se(Y){Y!==P&&(W&&e.lineWidth(Y),P=Y)}function Ie(Y,se,pe){Y?(ne(32823),(L!==se||D!==pe)&&(e.polygonOffset(se,pe),L=se,D=pe)):G(32823)}function Xe(Y){Y?ne(3089):G(3089)}function ct(Y){Y===void 0&&(Y=33984+j-1),V!==Y&&(e.activeTexture(Y),V=Y)}function R(Y,se,pe){pe===void 0&&(V===null?pe=33984+j-1:pe=V);let xe=F[pe];xe===void 0&&(xe={type:void 0,texture:void 0},F[pe]=xe),(xe.type!==Y||xe.texture!==se)&&(V!==pe&&(e.activeTexture(pe),V=pe),e.bindTexture(Y,se||U[Y]),xe.type=Y,xe.texture=se)}function O(){let Y=F[V];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ie(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function fe(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ge(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ae(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ye(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Me(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ce(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Te(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Pe(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function We(Y){H.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),H.copy(Y))}function ze(Y){X.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),X.copy(Y))}function dt(Y,se){let pe=c.get(se);pe===void 0&&(pe=new WeakMap,c.set(se,pe));let xe=pe.get(Y);xe===void 0&&(xe=e.getUniformBlockIndex(se,Y.name),pe.set(Y,xe))}function Ot(Y,se){let pe=c.get(se).get(Y);d.get(se)!==pe&&(e.uniformBlockBinding(se,pe,Y.__bindingPointIndex),d.set(se,pe))}function Kt(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),u={},V=null,F={},p={},g=new WeakMap,f=[],m=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,E=!1,C=null,T=null,P=null,L=null,D=null,H.set(0,0,e.canvas.width,e.canvas.height),X.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ne,disable:G,bindFramebuffer:$,drawBuffers:Z,useProgram:ve,setBlending:ue,setMaterial:be,setFlipSided:Oe,setCullFace:_e,setLineWidth:Se,setPolygonOffset:Ie,setScissorTest:Xe,activeTexture:ct,bindTexture:R,unbindTexture:O,compressedTexImage2D:ie,compressedTexImage3D:fe,texImage2D:Le,texImage3D:Pe,updateUBOMapping:dt,uniformBlockBinding:Ot,texStorage2D:ce,texStorage3D:Te,texSubImage2D:ge,texSubImage3D:Ae,compressedTexSubImage2D:Ye,compressedTexSubImage3D:Me,scissor:We,viewport:ze,reset:Kt}}function WD(e,t,i,r,s,n,a){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,d=s.maxTextureSize,c=s.maxSamples,u=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap,f,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,O){return v?new OffscreenCanvas(R,O):kd("canvas")}function x(R,O,ie,fe){let ge=1;if((R.width>fe||R.height>fe)&&(ge=fe/Math.max(R.width,R.height)),ge<1||O===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ae=O?Fd:Math.floor,Ye=Ae(ge*R.width),Me=Ae(ge*R.height);f===void 0&&(f=y(Ye,Me));let ce=ie?y(Ye,Me):f;return ce.width=Ye,ce.height=Me,ce.getContext("2d").drawImage(R,0,0,Ye,Me),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Ye+"x"+Me+")."),ce}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function w(R){return dm(R.width)&&dm(R.height)}function _(R){return o?!1:R.wrapS!==Yt||R.wrapT!==Yt||R.minFilter!==Dt&&R.minFilter!==et}function S(R,O){return R.generateMipmaps&&O&&R.minFilter!==Dt&&R.minFilter!==et}function A(R){e.generateMipmap(R)}function b(R,O,ie,fe,ge=!1){if(o===!1)return O;if(R!==null){if(e[R]!==void 0)return e[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ae=O;return O===6403&&(ie===5126&&(Ae=33326),ie===5131&&(Ae=33325),ie===5121&&(Ae=33321)),O===33319&&(ie===5126&&(Ae=33328),ie===5131&&(Ae=33327),ie===5121&&(Ae=33323)),O===6408&&(ie===5126&&(Ae=34836),ie===5131&&(Ae=34842),ie===5121&&(Ae=fe===Ke&&ge===!1?35907:32856),ie===32819&&(Ae=32854),ie===32820&&(Ae=32855)),(Ae===33325||Ae===33326||Ae===33327||Ae===33328||Ae===34842||Ae===34836)&&t.get("EXT_color_buffer_float"),Ae}function E(R,O,ie){return S(R,ie)===!0||R.isFramebufferTexture&&R.minFilter!==Dt&&R.minFilter!==et?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 C(R){return R===Dt||R===R0||R===mp?9728:9729}function T(R){let O=R.target;O.removeEventListener("dispose",T),L(O),O.isVideoTexture&&g.delete(O)}function P(R){let O=R.target;O.removeEventListener("dispose",P),j(O)}function L(R){let O=r.get(R);if(O.__webglInit===void 0)return;let ie=R.source,fe=m.get(ie);if(fe){let ge=fe[O.__cacheKey];ge.usedTimes--,ge.usedTimes===0&&D(R),Object.keys(fe).length===0&&m.delete(ie)}r.remove(R)}function D(R){let O=r.get(R);e.deleteTexture(O.__webglTexture);let ie=R.source,fe=m.get(ie);delete fe[O.__cacheKey],a.memory.textures--}function j(R){let O=R.texture,ie=r.get(R),fe=r.get(O);if(fe.__webglTexture!==void 0&&(e.deleteTexture(fe.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++)e.deleteFramebuffer(ie.__webglFramebuffer[ge]),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer[ge]);else{if(e.deleteFramebuffer(ie.__webglFramebuffer),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let ge=0;ge<ie.__webglColorRenderbuffer.length;ge++)ie.__webglColorRenderbuffer[ge]&&e.deleteRenderbuffer(ie.__webglColorRenderbuffer[ge]);ie.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ie.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let ge=0,Ae=O.length;ge<Ae;ge++){let Ye=r.get(O[ge]);Ye.__webglTexture&&(e.deleteTexture(Ye.__webglTexture),a.memory.textures--),r.remove(O[ge])}r.remove(O),r.remove(R)}let W=0;function q(){W=0}function z(){let R=W;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),W+=1,R}function V(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 F(R,O){let ie=r.get(R);if(R.isVideoTexture&&Xe(R),R.isRenderTargetTexture===!1&&R.version>0&&ie.__version!==R.version){let fe=R.image;if(fe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(fe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{G(ie,R,O);return}}i.bindTexture(3553,ie.__webglTexture,33984+O)}function N(R,O){let ie=r.get(R);if(R.version>0&&ie.__version!==R.version){G(ie,R,O);return}i.bindTexture(35866,ie.__webglTexture,33984+O)}function B(R,O){let ie=r.get(R);if(R.version>0&&ie.__version!==R.version){G(ie,R,O);return}i.bindTexture(32879,ie.__webglTexture,33984+O)}function H(R,O){let ie=r.get(R);if(R.version>0&&ie.__version!==R.version){$(ie,R,O);return}i.bindTexture(34067,ie.__webglTexture,33984+O)}let X={[ln]:10497,[Yt]:33071,[lm]:33648},Q={[Dt]:9728,[R0]:9984,[mp]:9986,[et]:9729,[AE]:9985,[il]:9987};function U(R,O,ie){if(ie?(e.texParameteri(R,10242,X[O.wrapS]),e.texParameteri(R,10243,X[O.wrapT]),(R===32879||R===35866)&&e.texParameteri(R,32882,X[O.wrapR]),e.texParameteri(R,10240,Q[O.magFilter]),e.texParameteri(R,10241,Q[O.minFilter])):(e.texParameteri(R,10242,33071),e.texParameteri(R,10243,33071),(R===32879||R===35866)&&e.texParameteri(R,32882,33071),(O.wrapS!==Yt||O.wrapT!==Yt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(R,10240,C(O.magFilter)),e.texParameteri(R,10241,C(O.minFilter)),O.minFilter!==Dt&&O.minFilter!==et&&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 fe=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Dt||O.minFilter!==mp&&O.minFilter!==il||O.type===Or&&t.has("OES_texture_float_linear")===!1||o===!1&&O.type===rl&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(e.texParameterf(R,fe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function ne(R,O){let ie=!1;R.__webglInit===void 0&&(R.__webglInit=!0,O.addEventListener("dispose",T));let fe=O.source,ge=m.get(fe);ge===void 0&&(ge={},m.set(fe,ge));let Ae=V(O);if(Ae!==R.__cacheKey){ge[Ae]===void 0&&(ge[Ae]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),ge[Ae].usedTimes++;let Ye=ge[R.__cacheKey];Ye!==void 0&&(ge[R.__cacheKey].usedTimes--,Ye.usedTimes===0&&D(O)),R.__cacheKey=Ae,R.__webglTexture=ge[Ae].texture}return ie}function G(R,O,ie){let fe=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(fe=35866),O.isData3DTexture&&(fe=32879);let ge=ne(R,O),Ae=O.source;i.bindTexture(fe,R.__webglTexture,33984+ie);let Ye=r.get(Ae);if(Ae.version!==Ye.__version||ge===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Me=_(O)&&w(O.image)===!1,ce=x(O.image,Me,!1,d);ce=ct(O,ce);let Te=w(ce)||o,Le=n.convert(O.format,O.encoding),Pe=n.convert(O.type),We=b(O.internalFormat,Le,Pe,O.encoding,O.isVideoTexture);U(fe,O,Te);let ze,dt=O.mipmaps,Ot=o&&O.isVideoTexture!==!0,Kt=Ye.__version===void 0||ge===!0,Y=E(O,ce,Te);if(O.isDepthTexture)We=6402,o?O.type===Or?We=36012:O.type===Gn?We=33190:O.type===Oa?We=35056:We=33189:O.type===Or&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===La&&We===6402&&O.type!==Kb&&O.type!==Gn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Gn,Pe=n.convert(O.type)),O.format===ja&&We===6402&&(We=34041,O.type!==Oa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Oa,Pe=n.convert(O.type))),Kt&&(Ot?i.texStorage2D(3553,1,We,ce.width,ce.height):i.texImage2D(3553,0,We,ce.width,ce.height,0,Le,Pe,null));else if(O.isDataTexture)if(dt.length>0&&Te){Ot&&Kt&&i.texStorage2D(3553,Y,We,dt[0].width,dt[0].height);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],Ot?i.texSubImage2D(3553,se,0,0,ze.width,ze.height,Le,Pe,ze.data):i.texImage2D(3553,se,We,ze.width,ze.height,0,Le,Pe,ze.data);O.generateMipmaps=!1}else Ot?(Kt&&i.texStorage2D(3553,Y,We,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,ce.width,ce.height,Le,Pe,ce.data)):i.texImage2D(3553,0,We,ce.width,ce.height,0,Le,Pe,ce.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ot&&Kt&&i.texStorage3D(35866,Y,We,dt[0].width,dt[0].height,ce.depth);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],O.format!==Kr?Le!==null?Ot?i.compressedTexSubImage3D(35866,se,0,0,0,ze.width,ze.height,ce.depth,Le,ze.data,0,0):i.compressedTexImage3D(35866,se,We,ze.width,ze.height,ce.depth,0,ze.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage3D(35866,se,0,0,0,ze.width,ze.height,ce.depth,Le,Pe,ze.data):i.texImage3D(35866,se,We,ze.width,ze.height,ce.depth,0,Le,Pe,ze.data)}else{Ot&&Kt&&i.texStorage2D(3553,Y,We,dt[0].width,dt[0].height);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],O.format!==Kr?Le!==null?Ot?i.compressedTexSubImage2D(3553,se,0,0,ze.width,ze.height,Le,ze.data):i.compressedTexImage2D(3553,se,We,ze.width,ze.height,0,ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage2D(3553,se,0,0,ze.width,ze.height,Le,Pe,ze.data):i.texImage2D(3553,se,We,ze.width,ze.height,0,Le,Pe,ze.data)}else if(O.isDataArrayTexture)Ot?(Kt&&i.texStorage3D(35866,Y,We,ce.width,ce.height,ce.depth),i.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,Le,Pe,ce.data)):i.texImage3D(35866,0,We,ce.width,ce.height,ce.depth,0,Le,Pe,ce.data);else if(O.isData3DTexture)Ot?(Kt&&i.texStorage3D(32879,Y,We,ce.width,ce.height,ce.depth),i.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,Le,Pe,ce.data)):i.texImage3D(32879,0,We,ce.width,ce.height,ce.depth,0,Le,Pe,ce.data);else if(O.isFramebufferTexture){if(Kt)if(Ot)i.texStorage2D(3553,Y,We,ce.width,ce.height);else{let se=ce.width,pe=ce.height;for(let xe=0;xe<Y;xe++)i.texImage2D(3553,xe,We,se,pe,0,Le,Pe,null),se>>=1,pe>>=1}}else if(dt.length>0&&Te){Ot&&Kt&&i.texStorage2D(3553,Y,We,dt[0].width,dt[0].height);for(let se=0,pe=dt.length;se<pe;se++)ze=dt[se],Ot?i.texSubImage2D(3553,se,0,0,Le,Pe,ze):i.texImage2D(3553,se,We,Le,Pe,ze);O.generateMipmaps=!1}else Ot?(Kt&&i.texStorage2D(3553,Y,We,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,Le,Pe,ce)):i.texImage2D(3553,0,We,Le,Pe,ce);S(O,Te)&&A(fe),Ye.__version=Ae.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function $(R,O,ie){if(O.image.length!==6)return;let fe=ne(R,O),ge=O.source;i.bindTexture(34067,R.__webglTexture,33984+ie);let Ae=r.get(ge);if(ge.version!==Ae.__version||fe===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Ye=O.isCompressedTexture||O.image[0].isCompressedTexture,Me=O.image[0]&&O.image[0].isDataTexture,ce=[];for(let se=0;se<6;se++)!Ye&&!Me?ce[se]=x(O.image[se],!1,!0,h):ce[se]=Me?O.image[se].image:O.image[se],ce[se]=ct(O,ce[se]);let Te=ce[0],Le=w(Te)||o,Pe=n.convert(O.format,O.encoding),We=n.convert(O.type),ze=b(O.internalFormat,Pe,We,O.encoding),dt=o&&O.isVideoTexture!==!0,Ot=Ae.__version===void 0||fe===!0,Kt=E(O,Te,Le);U(34067,O,Le);let Y;if(Ye){dt&&Ot&&i.texStorage2D(34067,Kt,ze,Te.width,Te.height);for(let se=0;se<6;se++){Y=ce[se].mipmaps;for(let pe=0;pe<Y.length;pe++){let xe=Y[pe];O.format!==Kr?Pe!==null?dt?i.compressedTexSubImage2D(34069+se,pe,0,0,xe.width,xe.height,Pe,xe.data):i.compressedTexImage2D(34069+se,pe,ze,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):dt?i.texSubImage2D(34069+se,pe,0,0,xe.width,xe.height,Pe,We,xe.data):i.texImage2D(34069+se,pe,ze,xe.width,xe.height,0,Pe,We,xe.data)}}}else{Y=O.mipmaps,dt&&Ot&&(Y.length>0&&Kt++,i.texStorage2D(34067,Kt,ze,ce[0].width,ce[0].height));for(let se=0;se<6;se++)if(Me){dt?i.texSubImage2D(34069+se,0,0,0,ce[se].width,ce[se].height,Pe,We,ce[se].data):i.texImage2D(34069+se,0,ze,ce[se].width,ce[se].height,0,Pe,We,ce[se].data);for(let pe=0;pe<Y.length;pe++){let xe=Y[pe].image[se].image;dt?i.texSubImage2D(34069+se,pe+1,0,0,xe.width,xe.height,Pe,We,xe.data):i.texImage2D(34069+se,pe+1,ze,xe.width,xe.height,0,Pe,We,xe.data)}}else{dt?i.texSubImage2D(34069+se,0,0,0,Pe,We,ce[se]):i.texImage2D(34069+se,0,ze,Pe,We,ce[se]);for(let pe=0;pe<Y.length;pe++){let xe=Y[pe];dt?i.texSubImage2D(34069+se,pe+1,0,0,Pe,We,xe.image[se]):i.texImage2D(34069+se,pe+1,ze,Pe,We,xe.image[se])}}}S(O,Le)&&A(34067),Ae.__version=ge.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function Z(R,O,ie,fe,ge){let Ae=n.convert(ie.format,ie.encoding),Ye=n.convert(ie.type),Me=b(ie.internalFormat,Ae,Ye,ie.encoding);r.get(O).__hasExternalTextures||(ge===32879||ge===35866?i.texImage3D(ge,0,Me,O.width,O.height,O.depth,0,Ae,Ye,null):i.texImage2D(ge,0,Me,O.width,O.height,0,Ae,Ye,null)),i.bindFramebuffer(36160,R),Ie(O)?u.framebufferTexture2DMultisampleEXT(36160,fe,ge,r.get(ie).__webglTexture,0,Se(O)):(ge===3553||ge>=34069&&ge<=34074)&&e.framebufferTexture2D(36160,fe,ge,r.get(ie).__webglTexture,0),i.bindFramebuffer(36160,null)}function ve(R,O,ie){if(e.bindRenderbuffer(36161,R),O.depthBuffer&&!O.stencilBuffer){let fe=33189;if(ie||Ie(O)){let ge=O.depthTexture;ge&&ge.isDepthTexture&&(ge.type===Or?fe=36012:ge.type===Gn&&(fe=33190));let Ae=Se(O);Ie(O)?u.renderbufferStorageMultisampleEXT(36161,Ae,fe,O.width,O.height):e.renderbufferStorageMultisample(36161,Ae,fe,O.width,O.height)}else e.renderbufferStorage(36161,fe,O.width,O.height);e.framebufferRenderbuffer(36160,36096,36161,R)}else if(O.depthBuffer&&O.stencilBuffer){let fe=Se(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,fe,35056,O.width,O.height):Ie(O)?u.renderbufferStorageMultisampleEXT(36161,fe,35056,O.width,O.height):e.renderbufferStorage(36161,34041,O.width,O.height),e.framebufferRenderbuffer(36160,33306,36161,R)}else{let fe=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let ge=0;ge<fe.length;ge++){let Ae=fe[ge],Ye=n.convert(Ae.format,Ae.encoding),Me=n.convert(Ae.type),ce=b(Ae.internalFormat,Ye,Me,Ae.encoding),Te=Se(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,Te,ce,O.width,O.height):Ie(O)?u.renderbufferStorageMultisampleEXT(36161,Te,ce,O.width,O.height):e.renderbufferStorage(36161,ce,O.width,O.height)}}e.bindRenderbuffer(36161,null)}function re(R,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,R),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),F(O.depthTexture,0);let ie=r.get(O.depthTexture).__webglTexture,fe=Se(O);if(O.depthTexture.format===La)Ie(O)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,ie,0,fe):e.framebufferTexture2D(36160,36096,3553,ie,0);else if(O.depthTexture.format===ja)Ie(O)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,ie,0,fe):e.framebufferTexture2D(36160,33306,3553,ie,0);else throw new Error("Unknown depthTexture format")}function oe(R){let O=r.get(R),ie=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!O.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");re(O.__webglFramebuffer,R)}else if(ie){O.__webglDepthbuffer=[];for(let fe=0;fe<6;fe++)i.bindFramebuffer(36160,O.__webglFramebuffer[fe]),O.__webglDepthbuffer[fe]=e.createRenderbuffer(),ve(O.__webglDepthbuffer[fe],R,!1)}else i.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=e.createRenderbuffer(),ve(O.__webglDepthbuffer,R,!1);i.bindFramebuffer(36160,null)}function ue(R,O,ie){let fe=r.get(R);O!==void 0&&Z(fe.__webglFramebuffer,R,R.texture,36064,3553),ie!==void 0&&oe(R)}function be(R){let O=R.texture,ie=r.get(R),fe=r.get(O);R.addEventListener("dispose",P),R.isWebGLMultipleRenderTargets!==!0&&(fe.__webglTexture===void 0&&(fe.__webglTexture=e.createTexture()),fe.__version=O.version,a.memory.textures++);let ge=R.isWebGLCubeRenderTarget===!0,Ae=R.isWebGLMultipleRenderTargets===!0,Ye=w(R)||o;if(ge){ie.__webglFramebuffer=[];for(let Me=0;Me<6;Me++)ie.__webglFramebuffer[Me]=e.createFramebuffer()}else{if(ie.__webglFramebuffer=e.createFramebuffer(),Ae)if(s.drawBuffers){let Me=R.texture;for(let ce=0,Te=Me.length;ce<Te;ce++){let Le=r.get(Me[ce]);Le.__webglTexture===void 0&&(Le.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&R.samples>0&&Ie(R)===!1){let Me=Ae?O:[O];ie.__webglMultisampledFramebuffer=e.createFramebuffer(),ie.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ie.__webglMultisampledFramebuffer);for(let ce=0;ce<Me.length;ce++){let Te=Me[ce];ie.__webglColorRenderbuffer[ce]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ie.__webglColorRenderbuffer[ce]);let Le=n.convert(Te.format,Te.encoding),Pe=n.convert(Te.type),We=b(Te.internalFormat,Le,Pe,Te.encoding,R.isXRRenderTarget===!0),ze=Se(R);e.renderbufferStorageMultisample(36161,ze,We,R.width,R.height),e.framebufferRenderbuffer(36160,36064+ce,36161,ie.__webglColorRenderbuffer[ce])}e.bindRenderbuffer(36161,null),R.depthBuffer&&(ie.__webglDepthRenderbuffer=e.createRenderbuffer(),ve(ie.__webglDepthRenderbuffer,R,!0)),i.bindFramebuffer(36160,null)}}if(ge){i.bindTexture(34067,fe.__webglTexture),U(34067,O,Ye);for(let Me=0;Me<6;Me++)Z(ie.__webglFramebuffer[Me],R,O,36064,34069+Me);S(O,Ye)&&A(34067),i.unbindTexture()}else if(Ae){let Me=R.texture;for(let ce=0,Te=Me.length;ce<Te;ce++){let Le=Me[ce],Pe=r.get(Le);i.bindTexture(3553,Pe.__webglTexture),U(3553,Le,Ye),Z(ie.__webglFramebuffer,R,Le,36064+ce,3553),S(Le,Ye)&&A(3553)}i.unbindTexture()}else{let Me=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(o?Me=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Me,fe.__webglTexture),U(Me,O,Ye),Z(ie.__webglFramebuffer,R,O,36064,Me),S(O,Ye)&&A(Me),i.unbindTexture()}R.depthBuffer&&oe(R)}function Oe(R){let O=w(R)||o,ie=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let fe=0,ge=ie.length;fe<ge;fe++){let Ae=ie[fe];if(S(Ae,O)){let Ye=R.isWebGLCubeRenderTarget?34067:3553,Me=r.get(Ae).__webglTexture;i.bindTexture(Ye,Me),A(Ye),i.unbindTexture()}}}function _e(R){if(o&&R.samples>0&&Ie(R)===!1){let O=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ie=R.width,fe=R.height,ge=16384,Ae=[],Ye=R.stencilBuffer?33306:36096,Me=r.get(R),ce=R.isWebGLMultipleRenderTargets===!0;if(ce)for(let Te=0;Te<O.length;Te++)i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Te,36161,null),i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Te,3553,null,0);i.bindFramebuffer(36008,Me.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Me.__webglFramebuffer);for(let Te=0;Te<O.length;Te++){Ae.push(36064+Te),R.depthBuffer&&Ae.push(Ye);let Le=Me.__ignoreDepthValues!==void 0?Me.__ignoreDepthValues:!1;if(Le===!1&&(R.depthBuffer&&(ge|=256),R.stencilBuffer&&(ge|=1024)),ce&&e.framebufferRenderbuffer(36008,36064,36161,Me.__webglColorRenderbuffer[Te]),Le===!0&&(e.invalidateFramebuffer(36008,[Ye]),e.invalidateFramebuffer(36009,[Ye])),ce){let Pe=r.get(O[Te]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Pe,0)}e.blitFramebuffer(0,0,ie,fe,0,0,ie,fe,ge,9728),p&&e.invalidateFramebuffer(36008,Ae)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ce)for(let Te=0;Te<O.length;Te++){i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Te,36161,Me.__webglColorRenderbuffer[Te]);let Le=r.get(O[Te]).__webglTexture;i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Te,3553,Le,0)}i.bindFramebuffer(36009,Me.__webglMultisampledFramebuffer)}}function Se(R){return Math.min(c,R.samples)}function Ie(R){let O=r.get(R);return o&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Xe(R){let O=a.render.frame;g.get(R)!==O&&(g.set(R,O),R.update())}function ct(R,O){let ie=R.encoding,fe=R.format,ge=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===cm||ie!==Rs&&(ie===Ke?o===!1?t.has("EXT_sRGB")===!0&&fe===Kr?(R.format=cm,R.minFilter=et,R.generateMipmaps=!1):O=i_.sRGBToLinear(O):(fe!==Kr||ge!==Bi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ie)),O}this.allocateTextureUnit=z,this.resetTextureUnits=q,this.setTexture2D=F,this.setTexture2DArray=N,this.setTexture3D=B,this.setTextureCube=H,this.rebindTextures=ue,this.setupRenderTarget=be,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=_e,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=Ie}function qD(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Bi)return 5121;if(n===TE)return 32819;if(n===PE)return 32820;if(n===ME)return 5120;if(n===EE)return 5122;if(n===Kb)return 5123;if(n===CE)return 5124;if(n===Gn)return 5125;if(n===Or)return 5126;if(n===rl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===DE)return 6406;if(n===Kr)return 6408;if(n===OE)return 6409;if(n===LE)return 6410;if(n===La)return 6402;if(n===ja)return 34041;if(n===cm)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===RE)return 6403;if(n===IE)return 36244;if(n===Jb)return 33319;if(n===BE)return 33320;if(n===zE)return 36249;if(n===gp||n===vp||n===yp||n===xp)if(a===Ke)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===gp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===vp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===yp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===xp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===gp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===vp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===yp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===xp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===I0||n===B0||n===z0||n===N0)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===I0)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===B0)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===z0)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===N0)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===NE)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===U0||n===F0)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===U0)return a===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===F0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===k0||n===j0||n===G0||n===V0||n===H0||n===W0||n===q0||n===X0||n===Y0||n===Q0||n===Z0||n===K0||n===J0||n===$0)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===k0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===j0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===G0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===V0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===H0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===W0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===q0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===X0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Y0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Q0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Z0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===K0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===J0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===$0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===wp)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===wp)return a===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===UE||n===ey||n===ty||n===iy)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===wp)return o.COMPRESSED_RED_RGTC1_EXT;if(n===ey)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ty)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===iy)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Oa?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[n]!==void 0?e[n]:null}return{convert:s}}var XD=class extends Li{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Bo=class extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}},YD={type:"move"},qp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Bo,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 Bo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Bo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let g of e.hand.values()){let f=t.getJointPose(g,i),m=this._getHandJoint(l,g);f!==null&&(m.matrix.fromArray(f.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=f.radius),m.visible=f!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],c=h.position.distanceTo(d.position),u=.02,p=.005;l.inputState.pinching&&c>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=u-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(YD)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Bo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},nl=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:La,h!==La&&h!==ja)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===La&&(i=Gn),i===void 0&&h===ja&&(i=Oa),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Dt,this.minFilter=o!==void 0?o:Dt,this.flipY=!1,this.generateMipmaps=!1}},QD=class extends Wi{constructor(e,t){super();let i=this,r=null,s=1,n=null,a="local-floor",o=1,l=null,h=null,d=null,c=null,u=null,p=null,g=t.getContextAttributes(),f=null,m=null,v=[],y=[],x=new Set,w=new Map,_=new Li;_.layers.enable(1),_.viewport=new tt;let S=new Li;S.layers.enable(2),S.viewport=new tt;let A=[_,S],b=new XD;b.layers.enable(1),b.layers.enable(2);let E=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(N){let B=v[N];return B===void 0&&(B=new qp,v[N]=B),B.getTargetRaySpace()},this.getControllerGrip=function(N){let B=v[N];return B===void 0&&(B=new qp,v[N]=B),B.getGripSpace()},this.getHand=function(N){let B=v[N];return B===void 0&&(B=new qp,v[N]=B),B.getHandSpace()};function T(N){let B=y.indexOf(N.inputSource);if(B===-1)return;let H=v[B];H!==void 0&&H.dispatchEvent({type:N.type,data:N.inputSource})}function P(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",L);for(let N=0;N<v.length;N++){let B=y[N];B!==null&&(y[N]=null,v[N].disconnect(B))}E=null,C=null,e.setRenderTarget(f),u=null,c=null,d=null,r=null,m=null,F.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(N){s=N,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(N){a=N,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(N){l=N},this.getBaseLayer=function(){return c!==null?c:u},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(N){if(r=N,r!==null){if(f=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",P),r.addEventListener("inputsourceschange",L),g.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let B={antialias:r.renderState.layers===void 0?g.antialias:!0,alpha:g.alpha,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(r,t,B),r.updateRenderState({baseLayer:u}),m=new St(u.framebufferWidth,u.framebufferHeight,{format:Kr,type:Bi,encoding:e.outputEncoding,stencilBuffer:g.stencil})}else{let B=null,H=null,X=null;g.depth&&(X=g.stencil?35056:33190,B=g.stencil?ja:La,H=g.stencil?Oa:Gn);let Q={colorFormat:32856,depthFormat:X,scaleFactor:s};d=new XRWebGLBinding(r,t),c=d.createProjectionLayer(Q),r.updateRenderState({layers:[c]}),m=new St(c.textureWidth,c.textureHeight,{format:Kr,type:Bi,depthTexture:new nl(c.textureWidth,c.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,B),stencilBuffer:g.stencil,encoding:e.outputEncoding,samples:g.antialias?4:0});let U=e.properties.get(m);U.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),F.setContext(r),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function L(N){for(let B=0;B<N.removed.length;B++){let H=N.removed[B],X=y.indexOf(H);X>=0&&(y[X]=null,v[X].disconnect(H))}for(let B=0;B<N.added.length;B++){let H=N.added[B],X=y.indexOf(H);if(X===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(H),X=U;break}else if(y[U]===null){y[U]=H,X=U;break}if(X===-1)break}let Q=v[X];Q&&Q.connect(H)}}let D=new M,j=new M;function W(N,B,H){D.setFromMatrixPosition(B.matrixWorld),j.setFromMatrixPosition(H.matrixWorld);let X=D.distanceTo(j),Q=B.projectionMatrix.elements,U=H.projectionMatrix.elements,ne=Q[14]/(Q[10]-1),G=Q[14]/(Q[10]+1),$=(Q[9]+1)/Q[5],Z=(Q[9]-1)/Q[5],ve=(Q[8]-1)/Q[0],re=(U[8]+1)/U[0],oe=ne*ve,ue=ne*re,be=X/(-ve+re),Oe=be*-ve;B.matrixWorld.decompose(N.position,N.quaternion,N.scale),N.translateX(Oe),N.translateZ(be),N.matrixWorld.compose(N.position,N.quaternion,N.scale),N.matrixWorldInverse.copy(N.matrixWorld).invert();let _e=ne+be,Se=G+be,Ie=oe-Oe,Xe=ue+(X-Oe),ct=$*G/Se*_e,R=Z*G/Se*_e;N.projectionMatrix.makePerspective(Ie,Xe,ct,R,_e,Se)}function q(N,B){B===null?N.matrixWorld.copy(N.matrix):N.matrixWorld.multiplyMatrices(B.matrixWorld,N.matrix),N.matrixWorldInverse.copy(N.matrixWorld).invert()}this.updateCamera=function(N){if(r===null)return;b.near=S.near=_.near=N.near,b.far=S.far=_.far=N.far,(E!==b.near||C!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),E=b.near,C=b.far);let B=N.parent,H=b.cameras;q(b,B);for(let Q=0;Q<H.length;Q++)q(H[Q],B);b.matrixWorld.decompose(b.position,b.quaternion,b.scale),N.matrix.copy(b.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);let X=N.children;for(let Q=0,U=X.length;Q<U;Q++)X[Q].updateMatrixWorld(!0);H.length===2?W(b,_,S):b.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return b},this.getFoveation=function(){if(!(c===null&&u===null))return o},this.setFoveation=function(N){o=N,c!==null&&(c.fixedFoveation=N),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=N)},this.getPlanes=function(){return x};let z=null;function V(N,B){if(h=B.getViewerPose(l||n),p=B,h!==null){let H=h.views;u!==null&&(e.setRenderTargetFramebuffer(m,u.framebuffer),e.setRenderTarget(m));let X=!1;H.length!==b.cameras.length&&(b.cameras.length=0,X=!0);for(let Q=0;Q<H.length;Q++){let U=H[Q],ne=null;if(u!==null)ne=u.getViewport(U);else{let $=d.getViewSubImage(c,U);ne=$.viewport,Q===0&&(e.setRenderTargetTextures(m,$.colorTexture,c.ignoreDepthValues?void 0:$.depthStencilTexture),e.setRenderTarget(m))}let G=A[Q];G===void 0&&(G=new Li,G.layers.enable(Q),G.viewport=new tt,A[Q]=G),G.matrix.fromArray(U.transform.matrix),G.projectionMatrix.fromArray(U.projectionMatrix),G.viewport.set(ne.x,ne.y,ne.width,ne.height),Q===0&&b.matrix.copy(G.matrix),X===!0&&b.cameras.push(G)}}for(let H=0;H<v.length;H++){let X=y[H],Q=v[H];X!==null&&Q!==void 0&&Q.update(X,B,l||n)}if(z&&z(N,B),B.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:B.detectedPlanes});let H=null;for(let X of x)B.detectedPlanes.has(X)||(H===null&&(H=[]),H.push(X));if(H!==null)for(let X of H)x.delete(X),w.delete(X),i.dispatchEvent({type:"planeremoved",data:X});for(let X of B.detectedPlanes)if(!x.has(X))x.add(X),w.set(X,B.lastChangedTime),i.dispatchEvent({type:"planeadded",data:X});else{let Q=w.get(X);X.lastChangedTime>Q&&(w.set(X,X.lastChangedTime),i.dispatchEvent({type:"planechanged",data:X}))}}p=null}let F=new o_;F.setAnimationLoop(V),this.setAnimationLoop=function(N){z=N},this.dispose=function(){}}};function ZD(e,t){function i(f,m){m.color.getRGB(f.fogColor.value,a_(e)),m.isFog?(f.fogNear.value=m.near,f.fogFar.value=m.far):m.isFogExp2&&(f.fogDensity.value=m.density)}function r(f,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(f,m):m.isMeshToonMaterial?(s(f,m),d(f,m)):m.isMeshPhongMaterial?(s(f,m),h(f,m)):m.isMeshStandardMaterial?(s(f,m),c(f,m),m.isMeshPhysicalMaterial&&u(f,m,x)):m.isMeshMatcapMaterial?(s(f,m),p(f,m)):m.isMeshDepthMaterial?s(f,m):m.isMeshDistanceMaterial?(s(f,m),g(f,m)):m.isMeshNormalMaterial?s(f,m):m.isLineBasicMaterial?(n(f,m),m.isLineDashedMaterial&&a(f,m)):m.isPointsMaterial?o(f,m,v,y):m.isSpriteMaterial?l(f,m):m.isShadowMaterial?(f.color.value.copy(m.color),f.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(f,m){f.opacity.value=m.opacity,m.color&&f.diffuse.value.copy(m.color),m.emissive&&f.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(f.map.value=m.map),m.alphaMap&&(f.alphaMap.value=m.alphaMap),m.bumpMap&&(f.bumpMap.value=m.bumpMap,f.bumpScale.value=m.bumpScale,m.side===gi&&(f.bumpScale.value*=-1)),m.displacementMap&&(f.displacementMap.value=m.displacementMap,f.displacementScale.value=m.displacementScale,f.displacementBias.value=m.displacementBias),m.emissiveMap&&(f.emissiveMap.value=m.emissiveMap),m.normalMap&&(f.normalMap.value=m.normalMap,f.normalScale.value.copy(m.normalScale),m.side===gi&&f.normalScale.value.negate()),m.specularMap&&(f.specularMap.value=m.specularMap),m.alphaTest>0&&(f.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(f.envMap.value=v,f.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=m.reflectivity,f.ior.value=m.ior,f.refractionRatio.value=m.refractionRatio),m.lightMap){f.lightMap.value=m.lightMap;let w=e.physicallyCorrectLights!==!0?Math.PI:1;f.lightMapIntensity.value=m.lightMapIntensity*w}m.aoMap&&(f.aoMap.value=m.aoMap,f.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),f.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),f.uv2Transform.value.copy(x.matrix))}function n(f,m){f.diffuse.value.copy(m.color),f.opacity.value=m.opacity}function a(f,m){f.dashSize.value=m.dashSize,f.totalSize.value=m.dashSize+m.gapSize,f.scale.value=m.scale}function o(f,m,v,y){f.diffuse.value.copy(m.color),f.opacity.value=m.opacity,f.size.value=m.size*v,f.scale.value=y*.5,m.map&&(f.map.value=m.map),m.alphaMap&&(f.alphaMap.value=m.alphaMap),m.alphaTest>0&&(f.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),f.uvTransform.value.copy(x.matrix))}function l(f,m){f.diffuse.value.copy(m.color),f.opacity.value=m.opacity,f.rotation.value=m.rotation,m.map&&(f.map.value=m.map),m.alphaMap&&(f.alphaMap.value=m.alphaMap),m.alphaTest>0&&(f.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),f.uvTransform.value.copy(v.matrix))}function h(f,m){f.specular.value.copy(m.specular),f.shininess.value=Math.max(m.shininess,1e-4)}function d(f,m){m.gradientMap&&(f.gradientMap.value=m.gradientMap)}function c(f,m){f.roughness.value=m.roughness,f.metalness.value=m.metalness,m.roughnessMap&&(f.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(f.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(f.envMapIntensity.value=m.envMapIntensity)}function u(f,m,v){f.ior.value=m.ior,m.sheen>0&&(f.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),f.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(f.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(f.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(f.clearcoat.value=m.clearcoat,f.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(f.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(f.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),f.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===gi&&f.clearcoatNormalScale.value.negate())),m.iridescence>0&&(f.iridescence.value=m.iridescence,f.iridescenceIOR.value=m.iridescenceIOR,f.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(f.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(f.transmission.value=m.transmission,f.transmissionSamplerMap.value=v.texture,f.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(f.transmissionMap.value=m.transmissionMap),f.thickness.value=m.thickness,m.thicknessMap&&(f.thicknessMap.value=m.thicknessMap),f.attenuationDistance.value=m.attenuationDistance,f.attenuationColor.value.copy(m.attenuationColor)),f.specularIntensity.value=m.specularIntensity,f.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(f.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(f.specularColorMap.value=m.specularColorMap)}function p(f,m){m.matcap&&(f.matcap.value=m.matcap)}function g(f,m){f.referencePosition.value.copy(m.referencePosition),f.nearDistance.value=m.nearDistance,f.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function KD(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let w=x.program;r.uniformBlockBinding(y,w)}function h(y,x){let w=s[y.id];w===void 0&&(g(y),w=d(y),s[y.id]=w,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let S=t.render.frame;n[y.id]!==S&&(u(y),n[y.id]=S)}function d(y){let x=c();y.__bindingPointIndex=x;let w=e.createBuffer(),_=y.__size,S=y.usage;return e.bindBuffer(35345,w),e.bufferData(35345,_,S),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,w),w}function c(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let x=s[y.id],w=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let S=0,A=w.length;S<A;S++){let b=w[S];if(p(b,S,_)===!0){let E=b.__offset,C=Array.isArray(b.value)?b.value:[b.value],T=0;for(let P=0;P<C.length;P++){let L=C[P],D=f(L);typeof L=="number"?(b.__data[0]=L,e.bufferSubData(35345,E+T,b.__data)):L.isMatrix3?(b.__data[0]=L.elements[0],b.__data[1]=L.elements[1],b.__data[2]=L.elements[2],b.__data[3]=L.elements[0],b.__data[4]=L.elements[3],b.__data[5]=L.elements[4],b.__data[6]=L.elements[5],b.__data[7]=L.elements[0],b.__data[8]=L.elements[6],b.__data[9]=L.elements[7],b.__data[10]=L.elements[8],b.__data[11]=L.elements[0]):(L.toArray(b.__data,T),T+=D.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,E,b.__data)}}e.bindBuffer(35345,null)}function p(y,x,w){let _=y.value;if(w[x]===void 0){if(typeof _=="number")w[x]=_;else{let S=Array.isArray(_)?_:[_],A=[];for(let b=0;b<S.length;b++)A.push(S[b].clone());w[x]=A}return!0}else if(typeof _=="number"){if(w[x]!==_)return w[x]=_,!0}else{let S=Array.isArray(w[x])?w[x]:[w[x]],A=Array.isArray(_)?_:[_];for(let b=0;b<S.length;b++){let E=S[b];if(E.equals(A[b])===!1)return E.copy(A[b]),!0}}return!1}function g(y){let x=y.uniforms,w=0,_=16,S=0;for(let A=0,b=x.length;A<b;A++){let E=x[A],C={boundary:0,storage:0},T=Array.isArray(E.value)?E.value:[E.value];for(let P=0,L=T.length;P<L;P++){let D=T[P],j=f(D);C.boundary+=j.boundary,C.storage+=j.storage}if(E.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=w,A>0){S=w%_;let P=_-S;S!==0&&P-C.boundary<0&&(w+=_-S,E.__offset=w)}w+=C.storage}return S=w%_,S>0&&(w+=_-S),y.__size=w,y.__cache={},this}function f(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){let x=y.target;x.removeEventListener("dispose",m);let w=a.indexOf(x.__bindingPointIndex);a.splice(w,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete n[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function JD(){let e=kd("canvas");return e.style.display="block",e}function p_(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:JD(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,n=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,d;i!==null?d=i.getContextAttributes().alpha:d=e.alpha!==void 0?e.alpha:!1;let c=null,u=null,p=[],g=[];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=Rs,this.physicallyCorrectLights=!1,this.toneMapping=dn,this.toneMappingExposure=1;let f=this,m=!1,v=0,y=0,x=null,w=-1,_=null,S=new tt,A=new tt,b=null,E=t.width,C=t.height,T=1,P=null,L=null,D=new tt(0,0,E,C),j=new tt(0,0,E,C),W=!1,q=new Ug,z=!1,V=!1,F=null,N=new me,B=new k,H=new M,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Q(){return x===null?T:1}let U=i;function ne(I,ee){for(let ae=0;ae<I.length;ae++){let J=I[ae],le=t.getContext(J,ee);if(le!==null)return le}return null}try{let I={alpha:!0,depth:r,stencil:s,antialias:n,premultipliedAlpha:a,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${fl}`),t.addEventListener("webglcontextlost",We,!1),t.addEventListener("webglcontextrestored",ze,!1),t.addEventListener("webglcontextcreationerror",dt,!1),U===null){let ee=["webgl2","webgl","experimental-webgl"];if(f.isWebGL1Renderer===!0&&ee.shift(),U=ne(ee,I),U===null)throw ne(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}U.getShaderPrecisionFormat===void 0&&(U.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(I){throw console.error("THREE.WebGLRenderer: "+I.message),I}let G,$,Z,ve,re,oe,ue,be,Oe,_e,Se,Ie,Xe,ct,R,O,ie,fe,ge,Ae,Ye,Me,ce,Te;function Le(){G=new dP(U),$=new nP(U,G,e),G.init($),Me=new qD(U,G,$),Z=new HD(U,G,$),ve=new fP,re=new OD,oe=new WD(U,G,Z,re,$,Me,ve),ue=new oP(f),be=new cP(f),Oe=new SC(U,$),ce=new rP(U,G,Oe,$),_e=new uP(U,Oe,ve,ce),Se=new yP(U,_e,Oe,ve),ge=new vP(U,$,oe),O=new aP(re),Ie=new DD(f,ue,be,G,$,ce,O),Xe=new ZD(f,re),ct=new RD,R=new FD(G,$),fe=new iP(f,ue,be,Z,Se,d,a),ie=new VD(f,Se,$),Te=new KD(U,ve,$,Z),Ae=new sP(U,G,ve,$),Ye=new pP(U,G,ve,$),ve.programs=Ie.programs,f.capabilities=$,f.extensions=G,f.properties=re,f.renderLists=ct,f.shadowMap=ie,f.state=Z,f.info=ve}Le();let Pe=new QD(f,U);this.xr=Pe,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let I=G.get("WEBGL_lose_context");I&&I.loseContext()},this.forceContextRestore=function(){let I=G.get("WEBGL_lose_context");I&&I.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(I){I!==void 0&&(T=I,this.setSize(E,C,!1))},this.getSize=function(I){return I.set(E,C)},this.setSize=function(I,ee,ae){if(Pe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=I,C=ee,t.width=Math.floor(I*T),t.height=Math.floor(ee*T),ae!==!1&&(t.style.width=I+"px",t.style.height=ee+"px"),this.setViewport(0,0,I,ee)},this.getDrawingBufferSize=function(I){return I.set(E*T,C*T).floor()},this.setDrawingBufferSize=function(I,ee,ae){E=I,C=ee,T=ae,t.width=Math.floor(I*ae),t.height=Math.floor(ee*ae),this.setViewport(0,0,I,ee)},this.getCurrentViewport=function(I){return I.copy(S)},this.getViewport=function(I){return I.copy(D)},this.setViewport=function(I,ee,ae,J){I.isVector4?D.set(I.x,I.y,I.z,I.w):D.set(I,ee,ae,J),Z.viewport(S.copy(D).multiplyScalar(T).floor())},this.getScissor=function(I){return I.copy(j)},this.setScissor=function(I,ee,ae,J){I.isVector4?j.set(I.x,I.y,I.z,I.w):j.set(I,ee,ae,J),Z.scissor(A.copy(j).multiplyScalar(T).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(I){Z.setScissorTest(W=I)},this.setOpaqueSort=function(I){P=I},this.setTransparentSort=function(I){L=I},this.getClearColor=function(I){return I.copy(fe.getClearColor())},this.setClearColor=function(){fe.setClearColor.apply(fe,arguments)},this.getClearAlpha=function(){return fe.getClearAlpha()},this.setClearAlpha=function(){fe.setClearAlpha.apply(fe,arguments)},this.clear=function(I=!0,ee=!0,ae=!0){let J=0;I&&(J|=16384),ee&&(J|=256),ae&&(J|=1024),U.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",We,!1),t.removeEventListener("webglcontextrestored",ze,!1),t.removeEventListener("webglcontextcreationerror",dt,!1),ct.dispose(),R.dispose(),re.dispose(),ue.dispose(),be.dispose(),Se.dispose(),ce.dispose(),Te.dispose(),Ie.dispose(),Pe.dispose(),Pe.removeEventListener("sessionstart",xe),Pe.removeEventListener("sessionend",ke),F&&(F.dispose(),F=null),ft.stop()};function We(I){I.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function ze(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let I=ve.autoReset,ee=ie.enabled,ae=ie.autoUpdate,J=ie.needsUpdate,le=ie.type;Le(),ve.autoReset=I,ie.enabled=ee,ie.autoUpdate=ae,ie.needsUpdate=J,ie.type=le}function dt(I){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function Ot(I){let ee=I.target;ee.removeEventListener("dispose",Ot),Kt(ee)}function Kt(I){Y(I),re.remove(I)}function Y(I){let ee=re.get(I).programs;ee!==void 0&&(ee.forEach(function(ae){Ie.releaseProgram(ae)}),I.isShaderMaterial&&Ie.releaseShaderCache(I))}this.renderBufferDirect=function(I,ee,ae,J,le,Re){ee===null&&(ee=X);let $e=le.isMesh&&le.matrixWorld.determinant()<0,nt=DM(I,ee,ae,J,le);Z.setMaterial(J,$e);let lt=ae.index,Ct=1;J.wireframe===!0&&(lt=_e.getWireframeAttribute(ae),Ct=2);let mt=ae.drawRange,ut=ae.attributes.position,Ei=mt.start*Ct,lr=(mt.start+mt.count)*Ct;Re!==null&&(Ei=Math.max(Ei,Re.start*Ct),lr=Math.min(lr,(Re.start+Re.count)*Ct)),lt!==null?(Ei=Math.max(Ei,0),lr=Math.min(lr,lt.count)):ut!=null&&(Ei=Math.max(Ei,0),lr=Math.min(lr,ut.count));let Gs=lr-Ei;if(Gs<0||Gs===1/0)return;ce.setup(le,J,nt,ae,lt);let oa,Jt=Ae;if(lt!==null&&(oa=Oe.get(lt),Jt=Ye,Jt.setIndex(oa)),le.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*Q()),Jt.setMode(1)):Jt.setMode(4);else if(le.isLine){let pt=J.linewidth;pt===void 0&&(pt=1),Z.setLineWidth(pt*Q()),le.isLineSegments?Jt.setMode(1):le.isLineLoop?Jt.setMode(2):Jt.setMode(3)}else le.isPoints?Jt.setMode(0):le.isSprite&&Jt.setMode(4);if(le.isInstancedMesh)Jt.renderInstances(Ei,Gs,le.count);else if(ae.isInstancedBufferGeometry){let pt=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,cp=Math.min(ae.instanceCount,pt);Jt.renderInstances(Ei,Gs,cp)}else Jt.render(Ei,Gs)},this.compile=function(I,ee){function ae(J,le,Re){J.transparent===!0&&J.side===mr&&J.forceSinglePass===!1?(J.side=gi,J.needsUpdate=!0,xr(J,le,Re),J.side=rs,J.needsUpdate=!0,xr(J,le,Re),J.side=mr):xr(J,le,Re)}u=R.get(I),u.init(),g.push(u),I.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(u.pushLight(J),J.castShadow&&u.pushShadow(J))}),u.setupLights(f.physicallyCorrectLights),I.traverse(function(J){let le=J.material;if(le)if(Array.isArray(le))for(let Re=0;Re<le.length;Re++){let $e=le[Re];ae($e,I,J)}else ae(le,I,J)}),g.pop(),u=null};let se=null;function pe(I){se&&se(I)}function xe(){ft.stop()}function ke(){ft.start()}let ft=new o_;ft.setAnimationLoop(pe),typeof self<"u"&&ft.setContext(self),this.setAnimationLoop=function(I){se=I,Pe.setAnimationLoop(I),I===null?ft.stop():ft.start()},Pe.addEventListener("sessionstart",xe),Pe.addEventListener("sessionend",ke),this.render=function(I,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Pe.enabled===!0&&Pe.isPresenting===!0&&(Pe.cameraAutoUpdate===!0&&Pe.updateCamera(ee),ee=Pe.getCamera()),I.isScene===!0&&I.onBeforeRender(f,I,ee,x),u=R.get(I,g.length),u.init(),g.push(u),N.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),q.setFromProjectionMatrix(N),V=this.localClippingEnabled,z=O.init(this.clippingPlanes,V),c=ct.get(I,p.length),c.init(),p.push(c),Ut(I,ee,0,f.sortObjects),c.finish(),f.sortObjects===!0&&c.sort(P,L),z===!0&&O.beginShadows();let ae=u.state.shadowsArray;if(ie.render(ae,I,ee),z===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),fe.render(c,I),u.setupLights(f.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let le=0,Re=J.length;le<Re;le++){let $e=J[le];Mi(c,I,$e,$e.viewport)}}else Mi(c,I,ee);x!==null&&(oe.updateMultisampleRenderTarget(x),oe.updateRenderTargetMipmap(x)),I.isScene===!0&&I.onAfterRender(f,I,ee),ce.resetDefaultState(),w=-1,_=null,g.pop(),g.length>0?u=g[g.length-1]:u=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function Ut(I,ee,ae,J){if(I.visible===!1)return;if(I.layers.test(ee.layers)){if(I.isGroup)ae=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update(ee);else if(I.isLight)u.pushLight(I),I.castShadow&&u.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||q.intersectsSprite(I)){J&&H.setFromMatrixPosition(I.matrixWorld).applyMatrix4(N);let Re=Se.update(I),$e=I.material;$e.visible&&c.push(I,Re,$e,ae,H.z,null)}}else if((I.isMesh||I.isLine||I.isPoints)&&(I.isSkinnedMesh&&I.skeleton.frame!==ve.render.frame&&(I.skeleton.update(),I.skeleton.frame=ve.render.frame),!I.frustumCulled||q.intersectsObject(I))){J&&H.setFromMatrixPosition(I.matrixWorld).applyMatrix4(N);let Re=Se.update(I),$e=I.material;if(Array.isArray($e)){let nt=Re.groups;for(let lt=0,Ct=nt.length;lt<Ct;lt++){let mt=nt[lt],ut=$e[mt.materialIndex];ut&&ut.visible&&c.push(I,Re,ut,ae,H.z,mt)}}else $e.visible&&c.push(I,Re,$e,ae,H.z,null)}}let le=I.children;for(let Re=0,$e=le.length;Re<$e;Re++)Ut(le[Re],ee,ae,J)}function Mi(I,ee,ae,J){let le=I.opaque,Re=I.transmissive,$e=I.transparent;u.setupLightsView(ae),z===!0&&O.setGlobalState(f.clippingPlanes,ae),Re.length>0&&aa(le,ee,ae),J&&Z.viewport(S.copy(J)),le.length>0&&zt(le,ee,ae),Re.length>0&&zt(Re,ee,ae),$e.length>0&&zt($e,ee,ae),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function aa(I,ee,ae){let J=$.isWebGL2;F===null&&(F=new St(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?rl:Bi,minFilter:il,samples:J&&n===!0?4:0})),f.getDrawingBufferSize(B),J?F.setSize(B.x,B.y):F.setSize(Fd(B.x),Fd(B.y));let le=f.getRenderTarget();f.setRenderTarget(F),f.clear();let Re=f.toneMapping;f.toneMapping=dn,zt(I,ee,ae),f.toneMapping=Re,oe.updateMultisampleRenderTarget(F),oe.updateRenderTargetMipmap(F),f.setRenderTarget(le)}function zt(I,ee,ae){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let le=0,Re=I.length;le<Re;le++){let $e=I[le],nt=$e.object,lt=$e.geometry,Ct=J===null?$e.material:J,mt=$e.group;nt.layers.test(ae.layers)&&js(nt,ee,ae,lt,Ct,mt)}}function js(I,ee,ae,J,le,Re){I.onBeforeRender(f,ee,ae,J,le,Re),I.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),le.onBeforeRender(f,ee,ae,J,I,Re),le.transparent===!0&&le.side===mr&&le.forceSinglePass===!1?(le.side=gi,le.needsUpdate=!0,f.renderBufferDirect(ae,ee,J,le,I,Re),le.side=rs,le.needsUpdate=!0,f.renderBufferDirect(ae,ee,J,le,I,Re),le.side=mr):f.renderBufferDirect(ae,ee,J,le,I,Re),I.onAfterRender(f,ee,ae,J,le,Re)}function xr(I,ee,ae){ee.isScene!==!0&&(ee=X);let J=re.get(I),le=u.state.lights,Re=u.state.shadowsArray,$e=le.state.version,nt=Ie.getParameters(I,le.state,Re,ee,ae),lt=Ie.getProgramCacheKey(nt),Ct=J.programs;J.environment=I.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(I.isMeshStandardMaterial?be:ue).get(I.envMap||J.environment),Ct===void 0&&(I.addEventListener("dispose",Ot),Ct=new Map,J.programs=Ct);let mt=Ct.get(lt);if(mt!==void 0){if(J.currentProgram===mt&&J.lightsStateVersion===$e)return _0(I,nt),mt}else nt.uniforms=Ie.getUniforms(I),I.onBuild(ae,nt,f),I.onBeforeCompile(nt,f),mt=Ie.acquireProgram(nt,lt),Ct.set(lt,mt),J.uniforms=nt.uniforms;let ut=J.uniforms;(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)&&(ut.clippingPlanes=O.uniform),_0(I,nt),J.needsLights=LM(I),J.lightsStateVersion=$e,J.needsLights&&(ut.ambientLightColor.value=le.state.ambient,ut.lightProbe.value=le.state.probe,ut.directionalLights.value=le.state.directional,ut.directionalLightShadows.value=le.state.directionalShadow,ut.spotLights.value=le.state.spot,ut.spotLightShadows.value=le.state.spotShadow,ut.rectAreaLights.value=le.state.rectArea,ut.ltc_1.value=le.state.rectAreaLTC1,ut.ltc_2.value=le.state.rectAreaLTC2,ut.pointLights.value=le.state.point,ut.pointLightShadows.value=le.state.pointShadow,ut.hemisphereLights.value=le.state.hemi,ut.directionalShadowMap.value=le.state.directionalShadowMap,ut.directionalShadowMatrix.value=le.state.directionalShadowMatrix,ut.spotShadowMap.value=le.state.spotShadowMap,ut.spotLightMatrix.value=le.state.spotLightMatrix,ut.spotLightMap.value=le.state.spotLightMap,ut.pointShadowMap.value=le.state.pointShadowMap,ut.pointShadowMatrix.value=le.state.pointShadowMatrix);let Ei=mt.getUniforms(),lr=Ed.seqWithValue(Ei.seq,ut);return J.currentProgram=mt,J.uniformsList=lr,mt}function _0(I,ee){let ae=re.get(I);ae.outputEncoding=ee.outputEncoding,ae.instancing=ee.instancing,ae.skinning=ee.skinning,ae.morphTargets=ee.morphTargets,ae.morphNormals=ee.morphNormals,ae.morphColors=ee.morphColors,ae.morphTargetsCount=ee.morphTargetsCount,ae.numClippingPlanes=ee.numClippingPlanes,ae.numIntersection=ee.numClipIntersection,ae.vertexAlphas=ee.vertexAlphas,ae.vertexTangents=ee.vertexTangents,ae.toneMapping=ee.toneMapping}function DM(I,ee,ae,J,le){ee.isScene!==!0&&(ee=X),oe.resetTextureUnits();let Re=ee.fog,$e=J.isMeshStandardMaterial?ee.environment:null,nt=x===null?f.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Rs,lt=(J.isMeshStandardMaterial?be:ue).get(J.envMap||$e),Ct=J.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,mt=!!J.normalMap&&!!ae.attributes.tangent,ut=!!ae.morphAttributes.position,Ei=!!ae.morphAttributes.normal,lr=!!ae.morphAttributes.color,Gs=J.toneMapped?f.toneMapping:dn,oa=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Jt=oa!==void 0?oa.length:0,pt=re.get(J),cp=u.state.lights;if(z===!0&&(V===!0||I!==_)){let hr=I===_&&J.id===w;O.setState(J,I,hr)}let dp=!1;J.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==cp.state.version||pt.outputEncoding!==nt||le.isInstancedMesh&&pt.instancing===!1||!le.isInstancedMesh&&pt.instancing===!0||le.isSkinnedMesh&&pt.skinning===!1||!le.isSkinnedMesh&&pt.skinning===!0||pt.envMap!==lt||J.fog===!0&&pt.fog!==Re||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==O.numPlanes||pt.numIntersection!==O.numIntersection)||pt.vertexAlphas!==Ct||pt.vertexTangents!==mt||pt.morphTargets!==ut||pt.morphNormals!==Ei||pt.morphColors!==lr||pt.toneMapping!==Gs||$.isWebGL2===!0&&pt.morphTargetsCount!==Jt)&&(dp=!0):(dp=!0,pt.__version=J.version);let la=pt.currentProgram;dp===!0&&(la=xr(J,ee,le));let S0=!1,Rl=!1,up=!1,xi=la.getUniforms(),ha=pt.uniforms;if(Z.useProgram(la.program)&&(S0=!0,Rl=!0,up=!0),J.id!==w&&(w=J.id,Rl=!0),S0||_!==I){if(xi.setValue(U,"projectionMatrix",I.projectionMatrix),$.logarithmicDepthBuffer&&xi.setValue(U,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2)),_!==I&&(_=I,Rl=!0,up=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let hr=xi.map.cameraPosition;hr!==void 0&&hr.setValue(U,H.setFromMatrixPosition(I.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&xi.setValue(U,"isOrthographic",I.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||le.isSkinnedMesh)&&xi.setValue(U,"viewMatrix",I.matrixWorldInverse)}if(le.isSkinnedMesh){xi.setOptional(U,le,"bindMatrix"),xi.setOptional(U,le,"bindMatrixInverse");let hr=le.skeleton;hr&&($.floatVertexTextures?(hr.boneTexture===null&&hr.computeBoneTexture(),xi.setValue(U,"boneTexture",hr.boneTexture,oe),xi.setValue(U,"boneTextureSize",hr.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 pp=ae.morphAttributes;if((pp.position!==void 0||pp.normal!==void 0||pp.color!==void 0&&$.isWebGL2===!0)&&ge.update(le,ae,J,la),(Rl||pt.receiveShadow!==le.receiveShadow)&&(pt.receiveShadow=le.receiveShadow,xi.setValue(U,"receiveShadow",le.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(ha.envMap.value=lt,ha.flipEnvMap.value=lt.isCubeTexture&&lt.isRenderTargetTexture===!1?-1:1),Rl&&(xi.setValue(U,"toneMappingExposure",f.toneMappingExposure),pt.needsLights&&OM(ha,up),Re&&J.fog===!0&&Xe.refreshFogUniforms(ha,Re),Xe.refreshMaterialUniforms(ha,J,T,C,F),Ed.upload(U,pt.uniformsList,ha,oe)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Ed.upload(U,pt.uniformsList,ha,oe),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&xi.setValue(U,"center",le.center),xi.setValue(U,"modelViewMatrix",le.modelViewMatrix),xi.setValue(U,"normalMatrix",le.normalMatrix),xi.setValue(U,"modelMatrix",le.matrixWorld),le.previousModelViewMatrix&&xi.setValue(U,"previousModelViewMatrix",le.previousModelViewMatrix),I.previousProjectionMatrix&&xi.setValue(U,"previousProjectionMatrix",I.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let hr=J.uniformsGroups;for(let fp=0,RM=hr.length;fp<RM;fp++)if($.isWebGL2){let A0=hr[fp];Te.update(A0,la),Te.bind(A0,la)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return la}function OM(I,ee){I.ambientLightColor.needsUpdate=ee,I.lightProbe.needsUpdate=ee,I.directionalLights.needsUpdate=ee,I.directionalLightShadows.needsUpdate=ee,I.pointLights.needsUpdate=ee,I.pointLightShadows.needsUpdate=ee,I.spotLights.needsUpdate=ee,I.spotLightShadows.needsUpdate=ee,I.rectAreaLights.needsUpdate=ee,I.hemisphereLights.needsUpdate=ee}function LM(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(I,ee,ae){re.get(I.texture).__webglTexture=ee,re.get(I.depthTexture).__webglTexture=ae;let J=re.get(I);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=ae===void 0,J.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(I,ee){let ae=re.get(I);ae.__webglFramebuffer=ee,ae.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(I,ee=0,ae=0){x=I,v=ee,y=ae;let J=!0,le=null,Re=!1,$e=!1;if(I){let nt=re.get(I);nt.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):nt.__webglFramebuffer===void 0?oe.setupRenderTarget(I):nt.__hasExternalTextures&&oe.rebindTextures(I,re.get(I.texture).__webglTexture,re.get(I.depthTexture).__webglTexture);let lt=I.texture;(lt.isData3DTexture||lt.isDataArrayTexture||lt.isCompressedArrayTexture)&&($e=!0);let Ct=re.get(I).__webglFramebuffer;I.isWebGLCubeRenderTarget?(le=Ct[ee],Re=!0):$.isWebGL2&&I.samples>0&&oe.useMultisampledRTT(I)===!1?le=re.get(I).__webglMultisampledFramebuffer:le=Ct,S.copy(I.viewport),A.copy(I.scissor),b=I.scissorTest}else S.copy(D).multiplyScalar(T).floor(),A.copy(j).multiplyScalar(T).floor(),b=W;if(Z.bindFramebuffer(36160,le)&&$.drawBuffers&&J&&Z.drawBuffers(I,le),Z.viewport(S),Z.scissor(A),Z.setScissorTest(b),Re){let nt=re.get(I.texture);U.framebufferTexture2D(36160,36064,34069+ee,nt.__webglTexture,ae)}else if($e){let nt=re.get(I.texture),lt=ee||0;U.framebufferTextureLayer(36160,36064,nt.__webglTexture,ae||0,lt)}w=-1},this.readRenderTargetPixels=function(I,ee,ae,J,le,Re,$e){if(!(I&&I.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let nt=re.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&$e!==void 0&&(nt=nt[$e]),nt){Z.bindFramebuffer(36160,nt);try{let lt=I.texture,Ct=lt.format,mt=lt.type;if(Ct!==Kr&&Me.convert(Ct)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ut=mt===rl&&(G.has("EXT_color_buffer_half_float")||$.isWebGL2&&G.has("EXT_color_buffer_float"));if(mt!==Bi&&Me.convert(mt)!==U.getParameter(35738)&&!(mt===Or&&($.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!ut){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=I.width-J&&ae>=0&&ae<=I.height-le&&U.readPixels(ee,ae,J,le,Me.convert(Ct),Me.convert(mt),Re)}finally{let lt=x!==null?re.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,lt)}}},this.copyFramebufferToTexture=function(I,ee,ae=0){let J=Math.pow(2,-ae),le=Math.floor(ee.image.width*J),Re=Math.floor(ee.image.height*J);oe.setTexture2D(ee,0),U.copyTexSubImage2D(3553,ae,0,0,I.x,I.y,le,Re),Z.unbindTexture()},this.copyTextureToTexture=function(I,ee,ae,J=0){let le=ee.image.width,Re=ee.image.height,$e=Me.convert(ae.format),nt=Me.convert(ae.type);oe.setTexture2D(ae,0),U.pixelStorei(37440,ae.flipY),U.pixelStorei(37441,ae.premultiplyAlpha),U.pixelStorei(3317,ae.unpackAlignment),ee.isDataTexture?U.texSubImage2D(3553,J,I.x,I.y,le,Re,$e,nt,ee.image.data):ee.isCompressedTexture?U.compressedTexSubImage2D(3553,J,I.x,I.y,ee.mipmaps[0].width,ee.mipmaps[0].height,$e,ee.mipmaps[0].data):U.texSubImage2D(3553,J,I.x,I.y,$e,nt,ee.image),J===0&&ae.generateMipmaps&&U.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(I,ee,ae,J,le=0){if(f.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Re=I.max.x-I.min.x+1,$e=I.max.y-I.min.y+1,nt=I.max.z-I.min.z+1,lt=Me.convert(J.format),Ct=Me.convert(J.type),mt;if(J.isData3DTexture)oe.setTexture3D(J,0),mt=32879;else if(J.isDataArrayTexture)oe.setTexture2DArray(J,0),mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,J.flipY),U.pixelStorei(37441,J.premultiplyAlpha),U.pixelStorei(3317,J.unpackAlignment);let ut=U.getParameter(3314),Ei=U.getParameter(32878),lr=U.getParameter(3316),Gs=U.getParameter(3315),oa=U.getParameter(32877),Jt=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;U.pixelStorei(3314,Jt.width),U.pixelStorei(32878,Jt.height),U.pixelStorei(3316,I.min.x),U.pixelStorei(3315,I.min.y),U.pixelStorei(32877,I.min.z),ae.isDataTexture||ae.isData3DTexture?U.texSubImage3D(mt,le,ee.x,ee.y,ee.z,Re,$e,nt,lt,Ct,Jt.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(mt,le,ee.x,ee.y,ee.z,Re,$e,nt,lt,Jt.data)):U.texSubImage3D(mt,le,ee.x,ee.y,ee.z,Re,$e,nt,lt,Ct,Jt),U.pixelStorei(3314,ut),U.pixelStorei(32878,Ei),U.pixelStorei(3316,lr),U.pixelStorei(3315,Gs),U.pixelStorei(32877,oa),le===0&&J.generateMipmaps&&U.generateMipmap(mt),Z.unbindTexture()},this.initTexture=function(I){I.isCubeTexture?oe.setTextureCube(I,0):I.isData3DTexture?oe.setTexture3D(I,0):I.isDataArrayTexture||I.isCompressedArrayTexture?oe.setTexture2DArray(I,0):oe.setTexture2D(I,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var $D=class extends p_{};$D.prototype.isWebGL1Renderer=!0;var f_=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Fe(e),this.near=t,this.far=i}clone(){return new f_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Ia=class extends Et{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},eO=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=hm,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ds()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ds()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ds()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ni=new M,pm=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ni.fromBufferAttribute(this,t),Ni.applyMatrix4(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ni.fromBufferAttribute(this,t),Ni.applyNormalMatrix(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ni.fromBufferAttribute(this,t),Ni.transformDirection(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}setX(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=hn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=hn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=hn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=hn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array),s=Tt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new qe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new pm(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},fm=class extends ci{constructor(e=null,t=1,i=1,r,s,n,a,o,l=Dt,h=Dt,d,c){super(null,n,a,o,l,h,r,s,d,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tO=class extends qe{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},ta=class extends tc{constructor(e){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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},ky=new M,jy=new M,Gy=new me,Xp=new ml,Nc=new Nr,Gd=class extends Et{constructor(e=new He,t=new ta){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)ky.fromBufferAttribute(t,r-1),jy.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=ky.distanceTo(jy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,n=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Nc.copy(i.boundingSphere),Nc.applyMatrix4(r),Nc.radius+=s,e.ray.intersectsSphere(Nc)===!1)return;Gy.copy(r).invert(),Xp.copy(e.ray).applyMatrix4(Gy);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new M,h=new M,d=new M,c=new M,u=this.isLineSegments?2:1,p=i.index,g=i.attributes.position;if(p!==null){let f=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=f,y=m-1;v<y;v+=u){let x=p.getX(v),w=p.getX(v+1);if(l.fromBufferAttribute(g,x),h.fromBufferAttribute(g,w),Xp.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(c);_<e.near||_>e.far||t.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let f=Math.max(0,n.start),m=Math.min(g.count,n.start+n.count);for(let v=f,y=m-1;v<y;v+=u){if(l.fromBufferAttribute(g,v),h.fromBufferAttribute(g,v+1),Xp.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}},Vy=new M,Hy=new M,ic=class extends Gd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Vy.fromBufferAttribute(t,r),Hy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Vy.distanceTo(Hy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},iO=class extends ci{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isVideoTexture=!0,this.minFilter=n!==void 0?n:et,this.magFilter=s!==void 0?s:et,this.generateMipmaps=!1;let h=this;function d(){h.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Fs=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],d=i[r+1]-h,c=(n-h)/d;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new k:new M);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new M,r=[],s=[],n=[],a=new M,o=new me;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new M)}s[0]=new M,n[0]=new M;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),c<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),n[u]=n[u-1].clone(),a.crossVectors(r[u-1],r[u]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(hi(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(o.makeRotationAxis(a,p))}n[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(hi(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(u=-u);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Iu=class extends Fs{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t){let i=t||new k,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),c=o-this.aX,u=l-this.aY;o=c*h-u*d+this.aX,l=c*d+u*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},rO=class extends Iu{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function kg(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,d,c){let u=(a-n)/h-(o-n)/(h+d)+(o-a)/d,p=(o-a)/d-(l-a)/(d+c)+(l-o)/c;u*=d,p*=d,s(a,o,u,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var Uc=new M,Yp=new kg,Qp=new kg,Zp=new kg,sO=class extends Fs{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new M){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(Uc.subVectors(r[0],r[1]).add(r[0]),l=Uc);let d=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(Uc.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Uc),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),u),g=Math.pow(d.distanceToSquared(c),u),f=Math.pow(c.distanceToSquared(h),u);g<1e-4&&(g=1),p<1e-4&&(p=g),f<1e-4&&(f=g),Yp.initNonuniformCatmullRom(l.x,d.x,c.x,h.x,p,g,f),Qp.initNonuniformCatmullRom(l.y,d.y,c.y,h.y,p,g,f),Zp.initNonuniformCatmullRom(l.z,d.z,c.z,h.z,p,g,f)}else this.curveType==="catmullrom"&&(Yp.initCatmullRom(l.x,d.x,c.x,h.x,this.tension),Qp.initCatmullRom(l.y,d.y,c.y,h.y,this.tension),Zp.initCatmullRom(l.z,d.z,c.z,h.z,this.tension));return i.set(Yp.calc(o),Qp.calc(o),Zp.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new M().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Wy(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function nO(e,t){let i=1-e;return i*i*t}function aO(e,t){return 2*(1-e)*e*t}function oO(e,t){return e*e*t}function Sh(e,t,i,r){return nO(e,t)+aO(e,i)+oO(e,r)}function lO(e,t){let i=1-e;return i*i*i*t}function hO(e,t){let i=1-e;return 3*i*i*e*t}function cO(e,t){return 3*(1-e)*e*e*t}function dO(e,t){return e*e*e*t}function Ah(e,t,i,r,s){return lO(e,t)+hO(e,i)+cO(e,r)+dO(e,s)}var Jr=class extends Fs{constructor(e=new k,t=new k,i=new k,r=new k){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(Ah(e,r.x,s.x,n.x,a.x),Ah(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Cd=class extends Fs{constructor(e=new M,t=new M,i=new M,r=new M){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(Ah(e,r.x,s.x,n.x,a.x),Ah(e,r.y,s.y,n.y,a.y),Ah(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},is=class extends Fs{constructor(e=new k,t=new k){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new k){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new k;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},m_=class extends Fs{constructor(e=new M,t=new M){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new M){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Jn=class extends Fs{constructor(e=new k,t=new k,i=new k){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Sh(e,r.x,s.x,n.x),Sh(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},uO=class extends Fs{constructor(e=new M,t=new M,i=new M){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Sh(e,r.x,s.x,n.x),Sh(e,r.y,s.y,n.y),Sh(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},jg=class extends Fs{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new k){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],d=r[n>r.length-3?r.length-1:n+2];return i.set(Wy(a,o.x,l.x,h.x,d.x),Wy(a,o.y,l.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new k().fromArray(r))}return this}},pO=Object.freeze({__proto__:null,ArcCurve:rO,CatmullRomCurve3:sO,CubicBezierCurve:Jr,CubicBezierCurve3:Cd,EllipseCurve:Iu,LineCurve:is,LineCurve3:m_,QuadraticBezierCurve:Jn,QuadraticBezierCurve3:uO,SplineCurve:jg}),g_=class extends Fs{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new is(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new pO[r.type]().fromJSON(r))}return this}},Vd=class extends g_{constructor(e){super(),this.type="Path",this.currentPoint=new k,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new is(this.currentPoint.clone(),new k(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Jn(this.currentPoint.clone(),new k(e,t),new k(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new Jr(this.currentPoint.clone(),new k(e,t),new k(i,r),new k(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new jg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new Iu(e,t,i,r,s,n,a,o);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},v_=class extends He{constructor(e=[new k(0,-.5),new k(.5,0),new k(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=hi(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,d=new M,c=new k,u=new M,p=new M,g=new M,f=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:f=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-f,u.z=m*0,g.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(g.x,g.y,g.z);break;default:f=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-f,u.z=m*0,p.copy(u),u.x+=g.x,u.y+=g.y,u.z+=g.z,u.normalize(),o.push(u.x,u.y,u.z),g.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),w=Math.cos(y);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*x,d.y=e[_].y,d.z=e[_].x*w,n.push(d.x,d.y,d.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let S=o[3*_+0]*x,A=o[3*_+1],b=o[3*_+0]*w;l.push(S,A,b)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,w=x,_=x+e.length,S=x+e.length+1,A=x+1;s.push(w,_,A),s.push(S,A,_)}this.setIndex(s),this.setAttribute("position",new De(n,3)),this.setAttribute("uv",new De(a,2)),this.setAttribute("normal",new De(l,3))}static fromJSON(e){return new v_(e.points,e.segments,e.phiStart,e.phiLength)}},Gg=class extends He{constructor(e=1,t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],d=[],c=[],u=[],p=0,g=[],f=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function v(){let x=new M,w=new M,_=0,S=(t-e)/i;for(let A=0;A<=s;A++){let b=[],E=A/s,C=E*(t-e)+e;for(let T=0;T<=r;T++){let P=T/r,L=P*o+a,D=Math.sin(L),j=Math.cos(L);w.x=C*D,w.y=-E*i+f,w.z=C*j,d.push(w.x,w.y,w.z),x.set(D,S,j).normalize(),c.push(x.x,x.y,x.z),u.push(P,1-E),b.push(p++)}g.push(b)}for(let A=0;A<r;A++)for(let b=0;b<s;b++){let E=g[b][A],C=g[b+1][A],T=g[b+1][A+1],P=g[b][A+1];h.push(E,C,P),h.push(C,T,P),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let w=p,_=new k,S=new M,A=0,b=x===!0?e:t,E=x===!0?1:-1;for(let T=1;T<=r;T++)d.push(0,f*E,0),c.push(0,E,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let P=T/r*o+a,L=Math.cos(P),D=Math.sin(P);S.x=b*D,S.y=f*E,S.z=b*L,d.push(S.x,S.y,S.z),c.push(0,E,0),_.x=L*.5+.5,_.y=D*.5*E+.5,u.push(_.x,_.y),p++}for(let T=0;T<r;T++){let P=w+T,L=C+T;x===!0?h.push(L,L+1,P):h.push(L+1,L,P),A+=3}l.addGroup(m,A,x===!0?1:2),m+=A}}static fromJSON(e){return new Gg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},y_=class extends Gg{constructor(e=1,t=1,i=32,r=1,s=!1,n=0,a=Math.PI*2){super(0,e,t,i,r,s,n,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:n,thetaLength:a}}static fromJSON(e){return new y_(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Vg=class extends He{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],n=[];a(r),l(i),h(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new M,x=new M,w=new M;for(let _=0;_<t.length;_+=3)u(t[_+0],y),u(t[_+1],x),u(t[_+2],w),o(y,x,w,v)}function o(v,y,x,w){let _=w+1,S=[];for(let A=0;A<=_;A++){S[A]=[];let b=v.clone().lerp(x,A/_),E=y.clone().lerp(x,A/_),C=_-A;for(let T=0;T<=C;T++)T===0&&A===_?S[A][T]=b:S[A][T]=b.clone().lerp(E,T/C)}for(let A=0;A<_;A++)for(let b=0;b<2*(_-A)-1;b++){let E=Math.floor(b/2);b%2===0?(c(S[A][E+1]),c(S[A+1][E]),c(S[A][E])):(c(S[A][E+1]),c(S[A+1][E+1]),c(S[A+1][E]))}}function l(v){let y=new M;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new M;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=f(v)/2/Math.PI+.5,w=m(v)/Math.PI+.5;n.push(x,1-w)}p(),d()}function d(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],w=n[v+4],_=Math.max(y,x,w),S=Math.min(y,x,w);_>.9&&S<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),w<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function u(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new M,y=new M,x=new M,w=new M,_=new k,S=new k,A=new k;for(let b=0,E=0;b<s.length;b+=9,E+=6){v.set(s[b+0],s[b+1],s[b+2]),y.set(s[b+3],s[b+4],s[b+5]),x.set(s[b+6],s[b+7],s[b+8]),_.set(n[E+0],n[E+1]),S.set(n[E+2],n[E+3]),A.set(n[E+4],n[E+5]),w.copy(v).add(y).add(x).divideScalar(3);let C=f(w);g(_,E+0,v,C),g(S,E+2,y,C),g(A,E+4,x,C)}}function g(v,y,x,w){w<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=w/2/Math.PI+.5)}function f(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Vg(e.vertices,e.indices,e.radius,e.details)}},x_=class extends Vg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,n,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new x_(e.radius,e.detail)}},Hd=class extends Vd{constructor(e){super(e),this.uuid=Ds(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Vd().fromJSON(r))}return this}},fO={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=w_(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,d,c,u,p;if(r&&(n=xO(e,t,n,i)),e.length>80*i){o=h=e[0],l=d=e[1];for(let g=i;g<s;g+=i)c=e[g],u=e[g+1],c<o&&(o=c),u<l&&(l=u),c>h&&(h=c),u>d&&(d=u);p=Math.max(h-o,d-l),p=p!==0?32767/p:0}return zh(n,a,i,o,l,p,0),a}};function w_(e,t,i,r,s){let n,a;if(s===DO(e,t,i,r)>0)for(n=t;n<i;n+=r)a=qy(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=qy(n,e[n],e[n+1],a);return a&&Bu(a,a.next)&&(Uh(a),a=a.next),a}function Ga(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Bu(i,i.next)||Ft(i.prev,i,i.next)===0)){if(Uh(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function zh(e,t,i,r,s,n,a){if(!e)return;!a&&n&&AO(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?gO(e,r,s,n):mO(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Uh(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=vO(Ga(e),t,i),zh(e,t,i,r,s,n,2)):a===2&&yO(e,t,i,r,s,n):zh(Ga(e),t,i,r,s,n,1);break}}}function mO(e){let t=e.prev,i=e,r=e.next;if(Ft(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,d=s<n?s<a?s:a:n<a?n:a,c=o<l?o<h?o:h:l<h?l:h,u=s>n?s>a?s:a:n>a?n:a,p=o>l?o>h?o:h:l>h?l:h,g=r.next;for(;g!==t;){if(g.x>=d&&g.x<=u&&g.y>=c&&g.y<=p&&zo(s,o,n,l,a,h,g.x,g.y)&&Ft(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function gO(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Ft(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,d=s.y,c=n.y,u=a.y,p=o<l?o<h?o:h:l<h?l:h,g=d<c?d<u?d:u:c<u?c:u,f=o>l?o>h?o:h:l>h?l:h,m=d>c?d>u?d:u:c>u?c:u,v=mm(p,g,t,i,r),y=mm(f,m,t,i,r),x=e.prevZ,w=e.nextZ;for(;x&&x.z>=v&&w&&w.z<=y;){if(x.x>=p&&x.x<=f&&x.y>=g&&x.y<=m&&x!==s&&x!==a&&zo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=p&&w.x<=f&&w.y>=g&&w.y<=m&&w!==s&&w!==a&&zo(o,d,l,c,h,u,w.x,w.y)&&Ft(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=f&&x.y>=g&&x.y<=m&&x!==s&&x!==a&&zo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=y;){if(w.x>=p&&w.x<=f&&w.y>=g&&w.y<=m&&w!==s&&w!==a&&zo(o,d,l,c,h,u,w.x,w.y)&&Ft(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function vO(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!Bu(s,n)&&b_(s,r,r.next,n)&&Nh(s,n)&&Nh(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),Uh(r),Uh(r.next),r=e=n),r=r.next}while(r!==e);return Ga(r)}function yO(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&CO(a,o)){let l=__(a,o);a=Ga(a,a.next),l=Ga(l,l.next),zh(a,t,i,r,s,n,0),zh(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function xO(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=w_(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(EO(h));for(s.sort(wO),n=0;n<s.length;n++)i=bO(s[n],i);return i}function wO(e,t){return e.x-t.x}function bO(e,t){let i=_O(e,t);if(!i)return t;let r=__(i,e);return Ga(r,r.next),Ga(i,i.next)}function _O(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let u=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=n&&u>r&&(r=u,s=i.x<i.next.x?i:i.next,u===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,d=1/0,c;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&zo(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(c=Math.abs(a-i.y)/(n-i.x),Nh(i,e)&&(c<d||c===d&&(i.x>s.x||i.x===s.x&&SO(s,i)))&&(s=i,d=c)),i=i.next;while(i!==o);return s}function SO(e,t){return Ft(e.prev,e,t.prev)<0&&Ft(t.next,e,e.next)<0}function AO(e,t,i,r){let s=e;do s.z===0&&(s.z=mm(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,MO(s)}function MO(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function mm(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function EO(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function zo(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function CO(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!TO(e,t)&&(Nh(e,t)&&Nh(t,e)&&PO(e,t)&&(Ft(e.prev,e,t.prev)||Ft(e,t.prev,t))||Bu(e,t)&&Ft(e.prev,e,e.next)>0&&Ft(t.prev,t,t.next)>0)}function Ft(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Bu(e,t){return e.x===t.x&&e.y===t.y}function b_(e,t,i,r){let s=kc(Ft(e,t,i)),n=kc(Ft(e,t,r)),a=kc(Ft(i,r,e)),o=kc(Ft(i,r,t));return!!(s!==n&&a!==o||s===0&&Fc(e,i,t)||n===0&&Fc(e,r,t)||a===0&&Fc(i,e,r)||o===0&&Fc(i,t,r))}function Fc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function kc(e){return e>0?1:e<0?-1:0}function TO(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&b_(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Nh(e,t){return Ft(e.prev,e,e.next)<0?Ft(e,t,e.next)>=0&&Ft(e,e.prev,t)>=0:Ft(e,t,e.prev)<0||Ft(e,e.next,t)<0}function PO(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function __(e,t){let i=new gm(e.i,e.x,e.y),r=new gm(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function qy(e,t,i,r){let s=new gm(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Uh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function gm(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function DO(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var S_=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return S_.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Xy(e),Yy(i,e);let n=e.length;t.forEach(Xy);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,Yy(i,t[o]);let a=fO.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function Xy(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Yy(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var A_=class extends Vg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new A_(e.radius,e.detail)}},Hg=class extends He{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:n,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(n+a,Math.PI),l=0,h=[],d=new M,c=new M,u=[],p=[],g=[],f=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&n==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let w=0;w<=t;w++){let _=w/t;d.x=-e*Math.cos(r+_*s)*Math.sin(n+y*a),d.y=e*Math.cos(n+y*a),d.z=e*Math.sin(r+_*s)*Math.sin(n+y*a),p.push(d.x,d.y,d.z),c.copy(d).normalize(),g.push(c.x,c.y,c.z),f.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],w=h[m+1][v],_=h[m+1][v+1];(m!==0||n>0)&&u.push(y,x,_),(m!==i-1||o<Math.PI)&&u.push(x,w,_)}this.setIndex(u),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(g,3)),this.setAttribute("uv",new De(f,2))}static fromJSON(e){return new Hg(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},M_=class extends He{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:n},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],h=[],d=new M,c=new M,u=new M,p=new M,g=new M,f=new M,m=new M;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,n,e,u),v(x+.01,s,n,e,p),f.subVectors(p,u),m.addVectors(p,u),g.crossVectors(f,m),m.crossVectors(g,f),g.normalize(),m.normalize();for(let w=0;w<=r;++w){let _=w/r*Math.PI*2,S=-t*Math.cos(_),A=t*Math.sin(_);d.x=u.x+(S*m.x+A*g.x),d.y=u.y+(S*m.y+A*g.y),d.z=u.z+(S*m.z+A*g.z),o.push(d.x,d.y,d.z),c.subVectors(d,u).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(w/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let w=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),S=(r+1)*y+x,A=(r+1)*(y-1)+x;a.push(w,_,A),a.push(_,S,A)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(h,2));function v(y,x,w,_,S){let A=Math.cos(y),b=Math.sin(y),E=w/x*y,C=Math.cos(E);S.x=_*(2+C)*.5*A,S.y=_*(2+C)*b*.5,S.z=_*Math.sin(E)*.5}}static fromJSON(e){return new M_(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Mn(e,t,i){return E_(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function jc(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function E_(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var zu=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];i:{e:{let n;t:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break e}n=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break e}n=i,i=0;break t}break i}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},OO=class extends zu{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ry,endingEnd:ry}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case sy:s=e,a=2*t-i;break;case ny:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case sy:n=e,o=2*i-t;break;case ny:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,d=this._offsetNext,c=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),g=p*p,f=g*p,m=-c*f+2*c*g-c*p,v=(1+c)*f+(-1.5-2*c)*g+(-.5+c)*p+1,y=(-1-u)*f+(1.5+u)*g+.5*p,x=u*f-u*g;for(let w=0;w!==a;++w)s[w]=m*n[h+w]+v*n[l+w]+y*n[o+w]+x*n[d+w];return s}},LO=class extends zu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),d=1-h;for(let c=0;c!==a;++c)s[c]=n[l+c]*d+n[o+c]*h;return s}},RO=class extends zu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},vn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=jc(t,this.TimeBufferType),this.values=jc(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:jc(e.times,Array),values:jc(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new RO(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new LO(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new OO(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case zd:t=this.InterpolantFactoryMethodDiscrete;break;case Nd:t=this.InterpolantFactoryMethodLinear;break;case bp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return zd;case this.InterpolantFactoryMethodLinear:return Nd;case this.InterpolantFactoryMethodSmooth:return bp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=Mn(i,s,n),this.values=Mn(this.values,s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&E_(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=Mn(this.times),t=Mn(this.values),i=this.getValueSize(),r=this.getInterpolation()===bp,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let d=a*i,c=d-i,u=d+i;for(let p=0;p!==i;++p){let g=t[d+p];if(g!==t[c+p]||g!==t[u+p]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let d=a*i,c=n*i;for(let u=0;u!==i;++u)t[c+u]=t[d+u]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=Mn(e,0,n),this.values=Mn(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=Mn(this.times,0),t=Mn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=Nd;var rc=class extends vn{};rc.prototype.ValueTypeName="bool";rc.prototype.ValueBufferType=Array;rc.prototype.DefaultInterpolation=zd;rc.prototype.InterpolantFactoryMethodLinear=void 0;rc.prototype.InterpolantFactoryMethodSmooth=void 0;var IO=class extends vn{};IO.prototype.ValueTypeName="color";var BO=class extends vn{};BO.prototype.ValueTypeName="number";var zO=class extends zu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)rt.slerpFlat(s,0,n,l-a,n,l,o);return s}},Wg=class extends vn{InterpolantFactoryMethodLinear(e){return new zO(this.times,this.values,this.getValueSize(),e)}};Wg.prototype.ValueTypeName="quaternion";Wg.prototype.DefaultInterpolation=Nd;Wg.prototype.InterpolantFactoryMethodSmooth=void 0;var sc=class extends vn{};sc.prototype.ValueTypeName="string";sc.prototype.ValueBufferType=Array;sc.prototype.DefaultInterpolation=zd;sc.prototype.InterpolantFactoryMethodLinear=void 0;sc.prototype.InterpolantFactoryMethodSmooth=void 0;var NO=class extends vn{};NO.prototype.ValueTypeName="vector";var Qy={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},C_=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,c=l.length;d<c;d+=2){let u=l[d],p=l[d+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},UO=new C_,qg=class{constructor(e){this.manager=e!==void 0?e:UO,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Ys={},FO=class extends Error{constructor(e,t){super(e),this.response=t}},vm=class extends qg{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=Qy.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ys[e]!==void 0){Ys[e].push({onLoad:t,onProgress:i,onError:r});return}Ys[e]=[],Ys[e].push({onLoad:t,onProgress:i,onError:r});let n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Ys[e],d=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=c?parseInt(c):0,p=u!==0,g=0,f=new ReadableStream({start(m){v();function v(){d.read().then(({done:y,value:x})=>{if(y)m.close();else{g+=x.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:g,total:u});for(let _=0,S=h.length;_<S;_++){let A=h[_];A.onProgress&&A.onProgress(w)}m.enqueue(x),v()}})}}});return new Response(f)}else throw new FO(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(d);return l.arrayBuffer().then(u=>c.decode(u))}}}).then(l=>{Qy.add(e,l);let h=Ys[e];delete Ys[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=Ys[e];if(h===void 0)throw this.manager.itemError(e),l;delete Ys[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onError&&u.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},nc=class extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Fe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},kO=class extends nc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Fe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Kp=new me,Zy=new M,Ky=new M,Xg=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new me,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ug,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;Zy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Zy),Ky.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ky),t.updateMatrixWorld(),Kp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Kp),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Kp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},jO=class extends Xg{constructor(){super(new Li(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Bh*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},GO=class extends nc{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new jO}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Jy=new me,Vl=new M,Jp=new M,VO=class extends Xg{constructor(){super(new Li(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new tt(2,1,1,1),new tt(0,1,1,1),new tt(3,1,1,1),new tt(1,1,1,1),new tt(3,0,1,1),new tt(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Vl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Vl),Jp.copy(i.position),Jp.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Jp),i.updateMatrixWorld(),r.makeTranslation(-Vl.x,-Vl.y,-Vl.z),Jy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Jy)}},HO=class extends nc{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new VO}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},WO=class extends Xg{constructor(){super(new jd(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},qO=class extends nc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new WO}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},XO=class extends He{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},T_=class extends qg{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new vm(s.manager);n.setPath(s.path),n.setRequestHeader(s.requestHeader),n.setWithCredentials(s.withCredentials),n.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,u){if(t[u]!==void 0)return t[u];let p=c.interleavedBuffers[u],g=s(c,p.buffer),f=yc(p.type,g),m=new eO(f,p.stride);return m.uuid=p.uuid,t[u]=m,m}function s(c,u){if(i[u]!==void 0)return i[u];let p=c.arrayBuffers[u],g=new Uint32Array(p).buffer;return i[u]=g,g}let n=e.isInstancedBufferGeometry?new XO:new He,a=e.data.index;if(a!==void 0){let c=yc(a.type,a.array);n.setIndex(new qe(c,1))}let o=e.data.attributes;for(let c in o){let u=o[c],p;if(u.isInterleavedBufferAttribute){let g=r(e.data,u.data);p=new pm(g,u.itemSize,u.offset,u.normalized)}else{let g=yc(u.type,u.array),f=u.isInstancedBufferAttribute?tO:qe;p=new f(g,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),n.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let u=l[c],p=[];for(let g=0,f=u.length;g<f;g++){let m=u[g],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new pm(y,m.itemSize,m.offset,m.normalized)}else{let y=yc(m.type,m.array);v=new qe(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),p.push(v)}n.morphAttributes[c]=p}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,u=h.length;c!==u;++c){let p=h[c];n.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let c=new M;d.center!==void 0&&c.fromArray(d.center),n.boundingSphere=new Nr(c,d.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},YO=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=$y(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=$y();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function $y(){return(typeof performance>"u"?Date:performance).now()}var Yg="\\[\\]\\.:\\/",QO=new RegExp("["+Yg+"]","g"),Qg="[^"+Yg+"]",ZO="[^"+Yg.replace("\\.","")+"]",KO=/((?:WC+[\/:])*)/.source.replace("WC",Qg),JO=/(WCOD+)?/.source.replace("WCOD",ZO),$O=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qg),eL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qg),tL=new RegExp("^"+KO+JO+$O+eL+"$"),iL=["material","materials","bones","map"],rL=class{constructor(e,t,i){let r=i||Pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Pt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Pt.parseTrackName(t),this.node=Pt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Pt.Composite(e,t,i):new Pt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(QO,"")}static parseTrackName(e){let t=tL.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);iL.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let n=0;n<s.length;n++){let a=s[n];if(a.name===t||a.uuid===t)return a;let o=i(a.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Pt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let n=e[r];if(n===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=s}else n.fromArray!==void 0&&n.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Pt.Composite=rL;Pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Pt.prototype.GetterByBindingType=[Pt.prototype._getValue_direct,Pt.prototype._getValue_array,Pt.prototype._getValue_arrayElement,Pt.prototype._getValue_toArray];Pt.prototype.SetterByBindingTypeAndVersioning=[[Pt.prototype._setValue_direct,Pt.prototype._setValue_direct_setNeedsUpdate,Pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_array,Pt.prototype._setValue_array_setNeedsUpdate,Pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_arrayElement,Pt.prototype._setValue_arrayElement_setNeedsUpdate,Pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_fromArray,Pt.prototype._setValue_fromArray_setNeedsUpdate,Pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var dW=new Float32Array(1),de=class{constructor(e){this.value=e}clone(){return new de(this.value.clone===void 0?this.value:this.value.clone())}},P_=class{constructor(e,t,i=0,r=1/0){this.ray=new ml(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new zg,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return ym(e,this,i,t),i.sort(e1),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)ym(e[r],this,i,t);return i.sort(e1),i}};function e1(e,t){return e.distance-t.distance}function ym(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let n=0,a=s.length;n<a;n++)ym(s[n],t,i,!0)}}var t1=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(hi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},i1=new k,sL=class{constructor(e=new k(1/0,1/0),t=new k(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=i1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return i1.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},r1=new M,Gc=new M,Rr=class{constructor(e=new M,t=new M){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){r1.subVectors(e,this.start),Gc.subVectors(this.end,this.start);let i=Gc.dot(Gc),r=Gc.dot(r1)/i;return t&&(r=hi(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},s1=new M,nL=class extends Et{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new He,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let n=0,a=1,o=32;n<o;n++,a++){let l=n/o*Math.PI*2,h=a/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new De(r,3));let s=new ta({fog:!1,toneMapped:!1});this.cone=new ic(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),s1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(s1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},aL=class extends tr{constructor(e,t,i){let r=new Hg(t,4,2),s=new gl({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},n1=new M,Vc=new M,a1=new M,oL=class extends Et{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new He;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new ta({fog:!1,toneMapped:!1});this.lightPlane=new Gd(r,s),this.add(this.lightPlane),r=new He,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Gd(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),n1.setFromMatrixPosition(this.light.matrixWorld),Vc.setFromMatrixPosition(this.light.target.matrixWorld),a1.subVectors(Vc,n1),this.lightPlane.lookAt(Vc),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(Vc),this.targetLine.scale.z=a1.length()}},Hc=new M,kt=new yl,Wd=class extends ic{constructor(e){let t=new He,i=new ta({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,g){o(p),o(g)}function o(p){r.push(0,0,0),s.push(0,0,0),n[p]===void 0&&(n[p]=[]),n[p].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();let l=new Fe(16755200),h=new Fe(16711680),d=new Fe(43775),c=new Fe(16777215),u=new Fe(3355443);this.setColors(l,h,d,c,u)}setColors(e,t,i,r,s){let n=this.geometry.getAttribute("color");n.setXYZ(0,e.r,e.g,e.b),n.setXYZ(1,e.r,e.g,e.b),n.setXYZ(2,e.r,e.g,e.b),n.setXYZ(3,e.r,e.g,e.b),n.setXYZ(4,e.r,e.g,e.b),n.setXYZ(5,e.r,e.g,e.b),n.setXYZ(6,e.r,e.g,e.b),n.setXYZ(7,e.r,e.g,e.b),n.setXYZ(8,e.r,e.g,e.b),n.setXYZ(9,e.r,e.g,e.b),n.setXYZ(10,e.r,e.g,e.b),n.setXYZ(11,e.r,e.g,e.b),n.setXYZ(12,e.r,e.g,e.b),n.setXYZ(13,e.r,e.g,e.b),n.setXYZ(14,e.r,e.g,e.b),n.setXYZ(15,e.r,e.g,e.b),n.setXYZ(16,e.r,e.g,e.b),n.setXYZ(17,e.r,e.g,e.b),n.setXYZ(18,e.r,e.g,e.b),n.setXYZ(19,e.r,e.g,e.b),n.setXYZ(20,e.r,e.g,e.b),n.setXYZ(21,e.r,e.g,e.b),n.setXYZ(22,e.r,e.g,e.b),n.setXYZ(23,e.r,e.g,e.b),n.setXYZ(24,t.r,t.g,t.b),n.setXYZ(25,t.r,t.g,t.b),n.setXYZ(26,t.r,t.g,t.b),n.setXYZ(27,t.r,t.g,t.b),n.setXYZ(28,t.r,t.g,t.b),n.setXYZ(29,t.r,t.g,t.b),n.setXYZ(30,t.r,t.g,t.b),n.setXYZ(31,t.r,t.g,t.b),n.setXYZ(32,i.r,i.g,i.b),n.setXYZ(33,i.r,i.g,i.b),n.setXYZ(34,i.r,i.g,i.b),n.setXYZ(35,i.r,i.g,i.b),n.setXYZ(36,i.r,i.g,i.b),n.setXYZ(37,i.r,i.g,i.b),n.setXYZ(38,r.r,r.g,r.b),n.setXYZ(39,r.r,r.g,r.b),n.setXYZ(40,s.r,s.g,s.b),n.setXYZ(41,s.r,s.g,s.b),n.setXYZ(42,s.r,s.g,s.b),n.setXYZ(43,s.r,s.g,s.b),n.setXYZ(44,s.r,s.g,s.b),n.setXYZ(45,s.r,s.g,s.b),n.setXYZ(46,s.r,s.g,s.b),n.setXYZ(47,s.r,s.g,s.b),n.setXYZ(48,s.r,s.g,s.b),n.setXYZ(49,s.r,s.g,s.b),n.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Ht("c",t,e,kt,0,0,-1),Ht("t",t,e,kt,0,0,1),Ht("n1",t,e,kt,-i,-r,-1),Ht("n2",t,e,kt,i,-r,-1),Ht("n3",t,e,kt,-i,r,-1),Ht("n4",t,e,kt,i,r,-1),Ht("f1",t,e,kt,-i,-r,1),Ht("f2",t,e,kt,i,-r,1),Ht("f3",t,e,kt,-i,r,1),Ht("f4",t,e,kt,i,r,1),Ht("u1",t,e,kt,i*.7,r*1.1,-1),Ht("u2",t,e,kt,-i*.7,r*1.1,-1),Ht("u3",t,e,kt,0,r*2,-1),Ht("cf1",t,e,kt,-i,0,1),Ht("cf2",t,e,kt,i,0,1),Ht("cf3",t,e,kt,0,-r,1),Ht("cf4",t,e,kt,0,r,1),Ht("cn1",t,e,kt,-i,0,-1),Ht("cn2",t,e,kt,i,0,-1),Ht("cn3",t,e,kt,0,-r,-1),Ht("cn4",t,e,kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ht(e,t,i,r,s,n,a){Hc.set(s,n,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,d=o.length;h<d;h++)l.setXYZ(o[h],Hc.x,Hc.y,Hc.z)}}var qd=class extends ic{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new He;s.setIndex(new qe(i,1)),s.setAttribute("position",new De(r,3)),super(s,new ta({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},lL=class extends ic{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new He;r.setAttribute("position",new De(t,3)),r.setAttribute("color",new De(i,3));let s=new ta({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Fe,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:fl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=fl);var Hl=".",Zg=Symbol("target"),D_=Symbol("unsubscribe");function xm(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function hL(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var As=Array.isArray;function Kg(e){return typeof e=="symbol"}var cL={after:(e,t)=>As(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>As(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Hl),Kg(t)?e+t.toString():e+t):e,initial:e=>{if(As(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Hl);return t===-1?"":e.slice(0,t)},last:e=>{if(As(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Hl);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(As(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Hl);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(Hl,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Cr=cL;function dL(e){return typeof e=="object"&&typeof e.next=="function"}function uL(e,t,i,r,s){let n=e.next;if(t.name==="entries")e.next=function(){let a=n.call(this);return a.done===!1&&(a.value[0]=s(a.value[0],t,a.value[0],r),a.value[1]=s(a.value[1],t,a.value[0],r)),a};else if(t.name==="values"){let a=i[Zg].keys();e.next=function(){let o=n.call(this);return o.done===!1&&(o.value=s(o.value,t,a.next().value,r)),o}}else e.next=function(){let a=n.call(this);return a.done===!1&&(a.value=s(a.value,t,a.value,r)),a};return e}function o1(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Kg(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var pL=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],n=s||e;this._pathCache.set(n,t);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(e,i):e,this._proxyCache.set(n,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Cr.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&"set"in n?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function wm(e){return toString.call(e)==="[object Object]"}function Wc(){return!0}function go(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var O_=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),fL=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),L_={push:Wc,pop:Wc,shift:Wc,unshift:Wc,copyWithin:go,reverse:go,sort:go,splice:go,flat:go,fill:go},mL=new Set([...O_,...fL,...Object.keys(L_)]);function qc(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var R_=["keys","values","entries"],I_=new Set(["has","toString"]),B_={add:qc,clear:qc,delete:qc,forEach:qc},gL=new Set([...I_,...Object.keys(B_),...R_]);function Xc(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var vL=new Set([...I_,"get"]),z_={set:Xc,clear:Xc,delete:Xc,forEach:Xc},yL=new Set([...vL,...Object.keys(z_),...R_]),$n=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return O_.has(e)}_shallowClone(e){let t=e;if(wm(e))t={...e};else if(As(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(As(r)?this._onIsChanged=L_[t]:r instanceof Set?this._onIsChanged=B_[t]:r instanceof Map&&(this._onIsChanged=z_[t]),r):i}update(e,t,i){let r=Cr.after(e,this._path);if(t!=="length"){let s=this.clone;Cr.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],Cr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},l1=class extends $n{static isHandledMethod(e){return mL.has(e)}},xL=class extends $n{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},h1=class extends $n{static isHandledMethod(e){return gL.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},c1=class extends $n{static isHandledMethod(e){return yL.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},wL=class extends $n{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},bL=class extends $n{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Do=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return wm(e)||As(e)||xm(e)}static isHandledMethod(e,t){return wm(e)?$n.isHandledMethod(t):As(e)?l1.isHandledMethod(t):e instanceof Set?h1.isHandledMethod(t):e instanceof Map?c1.isHandledMethod(t):xm(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=$n;As(e)?r=l1:e instanceof Date?r=xL:e instanceof Set?r=h1:e instanceof Map?r=c1:e instanceof WeakSet?r=wL:e instanceof WeakMap&&(r=bL),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=Do.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},_L={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Jg=(e,t,i={})=>{i={..._L,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new pL(s),h=typeof i.onValidate=="function",d=new Do(h),c=(y,x,w,_,S)=>!h||d.isCloning||i.onValidate(Cr.concat(l.getPath(y),x),w,_,S)===!0,u=(y,x,w,_)=>{!o1(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,w,_)},p=(y,x,w,_,S)=>{d.isCloning?d.update(y,x,_):t(Cr.concat(y,x),w,_,S)},g=y=>y&&(y[r]||y),f=(y,x,w,_)=>hL(y)||w==="constructor"||n&&!Do.isHandledMethod(x,w)||o1(l,i,w)||l.isGetInvariant(x,w)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,Cr.concat(_,w),m,r)),m={get(y,x,w){if(Kg(x)){if(x===r||x===Zg)return y;if(x===D_&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=xm(y)?Reflect.get(y,x):Reflect.get(y,x,w);return f(_,y,x)},set(y,x,w,_){w=g(w);let S=y[r]||y,A=S[x];if(s(A,w)&&x in y)return!0;let b=c(y,x,w,A);return b&&l.setProperty(S,x,w,_,A)?(u(y,x,y[x],A),!0):!b},defineProperty(y,x,w){if(!l.isSameDescriptor(w,y,x)){let _=y[x];c(y,x,w.value,_)&&l.defineProperty(y,x,w,_)&&u(y,x,w.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let w=Reflect.get(y,x),_=c(y,x,void 0,w);return _&&l.deleteProperty(y,x,w)?(u(y,x,void 0,w),!0):!_},apply(y,x,w){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,w);if((o===!1||o!==!0&&!o.includes(y.name))&&Do.isHandledType(_)){let S=Cr.initial(l.getPath(y)),A=Do.isHandledMethod(_,y.name);d.start(_,S,w);let b=Reflect.apply(y,d.preferredThisArg(y,x,_),A?w.map(T=>g(T)):w),E=d.isChanged(_,s),C=d.stop();if(Do.isHandledType(b)&&A&&(x instanceof Map&&y.name==="get"&&(S=Cr.concat(S,w[0])),b=l.getProxy(b,S,m)),E){let T={name:y.name,args:w,result:b},P=d.isCloning?Cr.initial(S):S,L=d.isCloning?Cr.last(S):"";c(Cr.get(e,P),L,_,C,T)?p(P,L,_,C,T):d.undo(_)}return(x instanceof Map||x instanceof Set)&&dL(b)?uL(b,y,x,S,f):b}return Reflect.apply(y,x,w)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};Jg.target=e=>e&&e[Zg]||e;Jg.unsubscribe=e=>e[D_]||e;var d1=Jg,SL=typeof global=="object"&&global&&global.Object===Object&&global,N_=SL,AL=typeof self=="object"&&self&&self.Object===Object&&self,ML=N_||AL||Function("return this")(),as=ML,EL=as.Symbol,Ur=EL,U_=Object.prototype,CL=U_.hasOwnProperty,TL=U_.toString,Wl=Ur?Ur.toStringTag:void 0;function PL(e){var t=CL.call(e,Wl),i=e[Wl];try{e[Wl]=void 0;var r=!0}catch{}var s=TL.call(e);return r&&(t?e[Wl]=i:delete e[Wl]),s}var DL=PL,OL=Object.prototype,LL=OL.toString;function RL(e){return LL.call(e)}var IL=RL,BL="[object Null]",zL="[object Undefined]",u1=Ur?Ur.toStringTag:void 0;function NL(e){return e==null?e===void 0?zL:BL:u1&&u1 in Object(e)?DL(e):IL(e)}var qa=NL;function UL(e){return e!=null&&typeof e=="object"}var fn=UL,FL="[object Symbol]";function kL(e){return typeof e=="symbol"||fn(e)&&qa(e)==FL}var Nu=kL;function jL(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var F_=jL,GL=Array.isArray,Bs=GL,VL=1/0,p1=Ur?Ur.prototype:void 0,f1=p1?p1.toString:void 0;function k_(e){if(typeof e=="string")return e;if(Bs(e))return F_(e,k_)+"";if(Nu(e))return f1?f1.call(e):"";var t=e+"";return t=="0"&&1/e==-VL?"-0":t}var HL=k_,WL=/\s/;function qL(e){for(var t=e.length;t--&&WL.test(e.charAt(t)););return t}var XL=qL,YL=/^\s+/;function QL(e){return e&&e.slice(0,XL(e)+1).replace(YL,"")}var ZL=QL;function KL(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ss=KL,m1=0/0,JL=/^[-+]0x[0-9a-f]+$/i,$L=/^0b[01]+$/i,e4=/^0o[0-7]+$/i,t4=parseInt;function i4(e){if(typeof e=="number")return e;if(Nu(e))return m1;if(ss(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ss(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=ZL(e);var i=$L.test(e);return i||e4.test(e)?t4(e.slice(2),i?2:8):JL.test(e)?m1:+e}var g1=i4;function r4(e){return e}var s4=r4,n4="[object AsyncFunction]",a4="[object Function]",o4="[object GeneratorFunction]",l4="[object Proxy]";function h4(e){if(!ss(e))return!1;var t=qa(e);return t==a4||t==o4||t==n4||t==l4}var j_=h4,c4=as["__core-js_shared__"],$p=c4,v1=function(){var e=/[^.]+$/.exec($p&&$p.keys&&$p.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function d4(e){return!!v1&&v1 in e}var u4=d4,p4=Function.prototype,f4=p4.toString;function m4(e){if(e!=null){try{return f4.call(e)}catch{}try{return e+""}catch{}}return""}var Xa=m4,g4=/[\\^$.*+?()[\]{}|]/g,v4=/^\[object .+?Constructor\]$/,y4=Function.prototype,x4=Object.prototype,w4=y4.toString,b4=x4.hasOwnProperty,_4=RegExp("^"+w4.call(b4).replace(g4,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function S4(e){if(!ss(e)||u4(e))return!1;var t=j_(e)?_4:v4;return t.test(Xa(e))}var A4=S4;function M4(e,t){return e?.[t]}var E4=M4;function C4(e,t){var i=E4(e,t);return A4(i)?i:void 0}var Ya=C4,T4=Ya(as,"WeakMap"),bm=T4,y1=Object.create,P4=function(){function e(){}return function(t){if(!ss(t))return{};if(y1)return y1(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),D4=P4;function O4(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var L4=O4;function R4(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var I4=R4,B4=800,z4=16,N4=Date.now;function U4(e){var t=0,i=0;return function(){var r=N4(),s=z4-(r-i);if(i=r,s>0){if(++t>=B4)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var F4=U4;function k4(e){return function(){return e}}var j4=k4,G4=function(){try{var e=Ya(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Xd=G4,V4=Xd?function(e,t){return Xd(e,"toString",{configurable:!0,enumerable:!1,value:j4(t),writable:!0})}:s4,H4=V4,W4=F4(H4),q4=W4;function X4(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var Y4=X4,Q4=9007199254740991,Z4=/^(?:0|[1-9]\d*)$/;function K4(e,t){var i=typeof e;return t=t??Q4,!!t&&(i=="number"||i!="symbol"&&Z4.test(e))&&e>-1&&e%1==0&&e<t}var $g=K4;function J4(e,t,i){t=="__proto__"&&Xd?Xd(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var G_=J4;function $4(e,t){return e===t||e!==e&&t!==t}var ev=$4,eR=Object.prototype,tR=eR.hasOwnProperty;function iR(e,t,i){var r=e[t];(!(tR.call(e,t)&&ev(r,i))||i===void 0&&!(t in e))&&G_(e,t,i)}var tv=iR;function rR(e,t,i,r){var s=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?G_(i,o,l):tv(i,o,l)}return i}var ac=rR,x1=Math.max;function sR(e,t,i){return t=x1(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=x1(r.length-t,0),a=Array(n);++s<n;)a[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(a),L4(e,this,o)}}var nR=sR,aR=9007199254740991;function oR(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=aR}var iv=oR;function lR(e){return e!=null&&iv(e.length)&&!j_(e)}var V_=lR,hR=Object.prototype;function cR(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||hR;return e===i}var rv=cR;function dR(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var uR=dR,pR="[object Arguments]";function fR(e){return fn(e)&&qa(e)==pR}var w1=fR,H_=Object.prototype,mR=H_.hasOwnProperty,gR=H_.propertyIsEnumerable,vR=w1(function(){return arguments}())?w1:function(e){return fn(e)&&mR.call(e,"callee")&&!gR.call(e,"callee")},sv=vR;function yR(){return!1}var xR=yR,W_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,b1=W_&&typeof module=="object"&&module&&!module.nodeType&&module,wR=b1&&b1.exports===W_,_1=wR?as.Buffer:void 0,bR=_1?_1.isBuffer:void 0,_R=bR||xR,Yd=_R,SR="[object Arguments]",AR="[object Array]",MR="[object Boolean]",ER="[object Date]",CR="[object Error]",TR="[object Function]",PR="[object Map]",DR="[object Number]",OR="[object Object]",LR="[object RegExp]",RR="[object Set]",IR="[object String]",BR="[object WeakMap]",zR="[object ArrayBuffer]",NR="[object DataView]",UR="[object Float32Array]",FR="[object Float64Array]",kR="[object Int8Array]",jR="[object Int16Array]",GR="[object Int32Array]",VR="[object Uint8Array]",HR="[object Uint8ClampedArray]",WR="[object Uint16Array]",qR="[object Uint32Array]",Bt={};Bt[UR]=Bt[FR]=Bt[kR]=Bt[jR]=Bt[GR]=Bt[VR]=Bt[HR]=Bt[WR]=Bt[qR]=!0;Bt[SR]=Bt[AR]=Bt[zR]=Bt[MR]=Bt[NR]=Bt[ER]=Bt[CR]=Bt[TR]=Bt[PR]=Bt[DR]=Bt[OR]=Bt[LR]=Bt[RR]=Bt[IR]=Bt[BR]=!1;function XR(e){return fn(e)&&iv(e.length)&&!!Bt[qa(e)]}var YR=XR;function QR(e){return function(t){return e(t)}}var nv=QR,q_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mh=q_&&typeof module=="object"&&module&&!module.nodeType&&module,ZR=Mh&&Mh.exports===q_,ef=ZR&&N_.process,KR=function(){try{var e=Mh&&Mh.require&&Mh.require("util").types;return e||ef&&ef.binding&&ef.binding("util")}catch{}}(),al=KR,S1=al&&al.isTypedArray,JR=S1?nv(S1):YR,X_=JR,$R=Object.prototype,eI=$R.hasOwnProperty;function tI(e,t){var i=Bs(e),r=!i&&sv(e),s=!i&&!r&&Yd(e),n=!i&&!r&&!s&&X_(e),a=i||r||s||n,o=a?uR(e.length,String):[],l=o.length;for(var h in e)(t||eI.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||$g(h,l)))&&o.push(h);return o}var Y_=tI;function iI(e,t){return function(i){return e(t(i))}}var Q_=iI,rI=Q_(Object.keys,Object),sI=rI,nI=Object.prototype,aI=nI.hasOwnProperty;function oI(e){if(!rv(e))return sI(e);var t=[];for(var i in Object(e))aI.call(e,i)&&i!="constructor"&&t.push(i);return t}var lI=oI;function hI(e){return V_(e)?Y_(e):lI(e)}var av=hI;function cI(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var dI=cI,uI=Object.prototype,pI=uI.hasOwnProperty;function fI(e){if(!ss(e))return dI(e);var t=rv(e),i=[];for(var r in e)r=="constructor"&&(t||!pI.call(e,r))||i.push(r);return i}var mI=fI;function gI(e){return V_(e)?Y_(e,!0):mI(e)}var ov=gI,vI=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yI=/^\w*$/;function xI(e,t){if(Bs(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Nu(e)?!0:yI.test(e)||!vI.test(e)||t!=null&&e in Object(t)}var wI=xI,bI=Ya(Object,"create"),Fh=bI;function _I(){this.__data__=Fh?Fh(null):{},this.size=0}var SI=_I;function AI(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var MI=AI,EI="__lodash_hash_undefined__",CI=Object.prototype,TI=CI.hasOwnProperty;function PI(e){var t=this.__data__;if(Fh){var i=t[e];return i===EI?void 0:i}return TI.call(t,e)?t[e]:void 0}var DI=PI,OI=Object.prototype,LI=OI.hasOwnProperty;function RI(e){var t=this.__data__;return Fh?t[e]!==void 0:LI.call(t,e)}var II=RI,BI="__lodash_hash_undefined__";function zI(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Fh&&t===void 0?BI:t,this}var NI=zI;function wl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}wl.prototype.clear=SI;wl.prototype.delete=MI;wl.prototype.get=DI;wl.prototype.has=II;wl.prototype.set=NI;var A1=wl;function UI(){this.__data__=[],this.size=0}var FI=UI;function kI(e,t){for(var i=e.length;i--;)if(ev(e[i][0],t))return i;return-1}var Uu=kI,jI=Array.prototype,GI=jI.splice;function VI(e){var t=this.__data__,i=Uu(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():GI.call(t,i,1),--this.size,!0}var HI=VI;function WI(e){var t=this.__data__,i=Uu(t,e);return i<0?void 0:t[i][1]}var qI=WI;function XI(e){return Uu(this.__data__,e)>-1}var YI=XI;function QI(e,t){var i=this.__data__,r=Uu(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var ZI=QI;function bl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}bl.prototype.clear=FI;bl.prototype.delete=HI;bl.prototype.get=qI;bl.prototype.has=YI;bl.prototype.set=ZI;var Fu=bl,KI=Ya(as,"Map"),kh=KI;function JI(){this.size=0,this.__data__={hash:new A1,map:new(kh||Fu),string:new A1}}var $I=JI;function eB(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var tB=eB;function iB(e,t){var i=e.__data__;return tB(t)?i[typeof t=="string"?"string":"hash"]:i.map}var ku=iB;function rB(e){var t=ku(this,e).delete(e);return this.size-=t?1:0,t}var sB=rB;function nB(e){return ku(this,e).get(e)}var aB=nB;function oB(e){return ku(this,e).has(e)}var lB=oB;function hB(e,t){var i=ku(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var cB=hB;function _l(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}_l.prototype.clear=$I;_l.prototype.delete=sB;_l.prototype.get=aB;_l.prototype.has=lB;_l.prototype.set=cB;var ju=_l,dB="Expected a function";function lv(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(dB);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],n=i.cache;if(n.has(s))return n.get(s);var a=e.apply(this,r);return i.cache=n.set(s,a)||n,a};return i.cache=new(lv.Cache||ju),i}lv.Cache=ju;var uB=lv,pB=500;function fB(e){var t=uB(e,function(r){return i.size===pB&&i.clear(),r}),i=t.cache;return t}var mB=fB,gB=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vB=/\\(\\)?/g,yB=mB(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(gB,function(i,r,s,n){t.push(s?n.replace(vB,"$1"):r||i)}),t}),xB=yB;function wB(e){return e==null?"":HL(e)}var bB=wB;function _B(e,t){return Bs(e)?e:wI(e,t)?[e]:xB(bB(e))}var Sl=_B,SB=1/0;function AB(e){if(typeof e=="string"||Nu(e))return e;var t=e+"";return t=="0"&&1/e==-SB?"-0":t}var Gu=AB;function MB(e,t){t=Sl(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Gu(t[i++])];return i&&i==r?e:void 0}var Z_=MB;function EB(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var hv=EB,M1=Ur?Ur.isConcatSpreadable:void 0;function CB(e){return Bs(e)||sv(e)||!!(M1&&e&&e[M1])}var TB=CB;function K_(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=TB),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?K_(o,t-1,i,r,s):hv(s,o):r||(s[s.length]=o)}return s}var PB=K_;function DB(e){var t=e==null?0:e.length;return t?PB(e,1):[]}var OB=DB;function LB(e){return q4(nR(e,void 0,OB),e+"")}var J_=LB,RB=Q_(Object.getPrototypeOf,Object),cv=RB,IB="[object Object]",BB=Function.prototype,zB=Object.prototype,$_=BB.toString,NB=zB.hasOwnProperty,UB=$_.call(Object);function FB(e){if(!fn(e)||qa(e)!=IB)return!1;var t=cv(e);if(t===null)return!0;var i=NB.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&$_.call(i)==UB}var kB=FB;function jB(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var n=Array(s);++r<s;)n[r]=e[r+t];return n}var GB=jB;function VB(){this.__data__=new Fu,this.size=0}var HB=VB;function WB(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var qB=WB;function XB(e){return this.__data__.get(e)}var YB=XB;function QB(e){return this.__data__.has(e)}var ZB=QB,KB=200;function JB(e,t){var i=this.__data__;if(i instanceof Fu){var r=i.__data__;if(!kh||r.length<KB-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new ju(r)}return i.set(e,t),this.size=i.size,this}var $B=JB;function Al(e){var t=this.__data__=new Fu(e);this.size=t.size}Al.prototype.clear=HB;Al.prototype.delete=qB;Al.prototype.get=YB;Al.prototype.has=ZB;Al.prototype.set=$B;var Td=Al;function ez(e,t){return e&&ac(t,av(t),e)}var tz=ez;function iz(e,t){return e&&ac(t,ov(t),e)}var rz=iz,eS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,E1=eS&&typeof module=="object"&&module&&!module.nodeType&&module,sz=E1&&E1.exports===eS,C1=sz?as.Buffer:void 0,T1=C1?C1.allocUnsafe:void 0;function nz(e,t){if(t)return e.slice();var i=e.length,r=T1?T1(i):new e.constructor(i);return e.copy(r),r}var az=nz;function oz(e,t){for(var i=-1,r=e==null?0:e.length,s=0,n=[];++i<r;){var a=e[i];t(a,i,e)&&(n[s++]=a)}return n}var lz=oz;function hz(){return[]}var tS=hz,cz=Object.prototype,dz=cz.propertyIsEnumerable,P1=Object.getOwnPropertySymbols,uz=P1?function(e){return e==null?[]:(e=Object(e),lz(P1(e),function(t){return dz.call(e,t)}))}:tS,dv=uz;function pz(e,t){return ac(e,dv(e),t)}var fz=pz,mz=Object.getOwnPropertySymbols,gz=mz?function(e){for(var t=[];e;)hv(t,dv(e)),e=cv(e);return t}:tS,iS=gz;function vz(e,t){return ac(e,iS(e),t)}var yz=vz;function xz(e,t,i){var r=t(e);return Bs(e)?r:hv(r,i(e))}var rS=xz;function wz(e){return rS(e,av,dv)}var _m=wz;function bz(e){return rS(e,ov,iS)}var sS=bz,_z=Ya(as,"DataView"),Sm=_z,Sz=Ya(as,"Promise"),Am=Sz,Az=Ya(as,"Set"),Mm=Az,D1="[object Map]",Mz="[object Object]",O1="[object Promise]",L1="[object Set]",R1="[object WeakMap]",I1="[object DataView]",Ez=Xa(Sm),Cz=Xa(kh),Tz=Xa(Am),Pz=Xa(Mm),Dz=Xa(bm),xa=qa;(Sm&&xa(new Sm(new ArrayBuffer(1)))!=I1||kh&&xa(new kh)!=D1||Am&&xa(Am.resolve())!=O1||Mm&&xa(new Mm)!=L1||bm&&xa(new bm)!=R1)&&(xa=function(e){var t=qa(e),i=t==Mz?e.constructor:void 0,r=i?Xa(i):"";if(r)switch(r){case Ez:return I1;case Cz:return D1;case Tz:return O1;case Pz:return L1;case Dz:return R1}return t});var jh=xa,Oz=Object.prototype,Lz=Oz.hasOwnProperty;function Rz(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&Lz.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var Iz=Rz,Bz=as.Uint8Array,Qd=Bz;function zz(e){var t=new e.constructor(e.byteLength);return new Qd(t).set(new Qd(e)),t}var uv=zz;function Nz(e,t){var i=t?uv(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var Uz=Nz,Fz=/\w*$/;function kz(e){var t=new e.constructor(e.source,Fz.exec(e));return t.lastIndex=e.lastIndex,t}var jz=kz,B1=Ur?Ur.prototype:void 0,z1=B1?B1.valueOf:void 0;function Gz(e){return z1?Object(z1.call(e)):{}}var Vz=Gz;function Hz(e,t){var i=t?uv(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var Wz=Hz,qz="[object Boolean]",Xz="[object Date]",Yz="[object Map]",Qz="[object Number]",Zz="[object RegExp]",Kz="[object Set]",Jz="[object String]",$z="[object Symbol]",e5="[object ArrayBuffer]",t5="[object DataView]",i5="[object Float32Array]",r5="[object Float64Array]",s5="[object Int8Array]",n5="[object Int16Array]",a5="[object Int32Array]",o5="[object Uint8Array]",l5="[object Uint8ClampedArray]",h5="[object Uint16Array]",c5="[object Uint32Array]";function d5(e,t,i){var r=e.constructor;switch(t){case e5:return uv(e);case qz:case Xz:return new r(+e);case t5:return Uz(e,i);case i5:case r5:case s5:case n5:case a5:case o5:case l5:case h5:case c5:return Wz(e,i);case Yz:return new r;case Qz:case Jz:return new r(e);case Zz:return jz(e);case Kz:return new r;case $z:return Vz(e)}}var u5=d5;function p5(e){return typeof e.constructor=="function"&&!rv(e)?D4(cv(e)):{}}var f5=p5,m5="[object Map]";function g5(e){return fn(e)&&jh(e)==m5}var v5=g5,N1=al&&al.isMap,y5=N1?nv(N1):v5,x5=y5,w5="[object Set]";function b5(e){return fn(e)&&jh(e)==w5}var _5=b5,U1=al&&al.isSet,S5=U1?nv(U1):_5,A5=S5,M5=1,E5=2,C5=4,nS="[object Arguments]",T5="[object Array]",P5="[object Boolean]",D5="[object Date]",O5="[object Error]",aS="[object Function]",L5="[object GeneratorFunction]",R5="[object Map]",I5="[object Number]",oS="[object Object]",B5="[object RegExp]",z5="[object Set]",N5="[object String]",U5="[object Symbol]",F5="[object WeakMap]",k5="[object ArrayBuffer]",j5="[object DataView]",G5="[object Float32Array]",V5="[object Float64Array]",H5="[object Int8Array]",W5="[object Int16Array]",q5="[object Int32Array]",X5="[object Uint8Array]",Y5="[object Uint8ClampedArray]",Q5="[object Uint16Array]",Z5="[object Uint32Array]",Lt={};Lt[nS]=Lt[T5]=Lt[k5]=Lt[j5]=Lt[P5]=Lt[D5]=Lt[G5]=Lt[V5]=Lt[H5]=Lt[W5]=Lt[q5]=Lt[R5]=Lt[I5]=Lt[oS]=Lt[B5]=Lt[z5]=Lt[N5]=Lt[U5]=Lt[X5]=Lt[Y5]=Lt[Q5]=Lt[Z5]=!0;Lt[O5]=Lt[aS]=Lt[F5]=!1;function Pd(e,t,i,r,s,n){var a,o=t&M5,l=t&E5,h=t&C5;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!ss(e))return e;var d=Bs(e);if(d){if(a=Iz(e),!o)return I4(e,a)}else{var c=jh(e),u=c==aS||c==L5;if(Yd(e))return az(e,o);if(c==oS||c==nS||u&&!s){if(a=l||u?{}:f5(e),!o)return l?yz(e,rz(a,e)):fz(e,tz(a,e))}else{if(!Lt[c])return s?e:{};a=u5(e,c,o)}}n||(n=new Td);var p=n.get(e);if(p)return p;n.set(e,a),A5(e)?e.forEach(function(m){a.add(Pd(m,t,i,m,e,n))}):x5(e)&&e.forEach(function(m,v){a.set(v,Pd(m,t,i,v,e,n))});var g=h?l?sS:_m:l?ov:av,f=d?void 0:g(e);return Y4(f||e,function(m,v){f&&(v=m,m=e[v]),tv(a,v,Pd(m,t,i,v,e,n))}),a}var lS=Pd,K5=1,J5=4;function $5(e){return lS(e,K5|J5)}var Vu=$5,eN="__lodash_hash_undefined__";function tN(e){return this.__data__.set(e,eN),this}var iN=tN;function rN(e){return this.__data__.has(e)}var sN=rN;function Zd(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new ju;++t<i;)this.add(e[t])}Zd.prototype.add=Zd.prototype.push=iN;Zd.prototype.has=sN;var nN=Zd;function aN(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var oN=aN;function lN(e,t){return e.has(t)}var hN=lN,cN=1,dN=2;function uN(e,t,i,r,s,n){var a=i&cN,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var h=n.get(e),d=n.get(t);if(h&&d)return h==t&&d==e;var c=-1,u=!0,p=i&dN?new nN:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var g=e[c],f=t[c];if(r)var m=a?r(f,g,c,t,e,n):r(g,f,c,e,t,n);if(m!==void 0){if(m)continue;u=!1;break}if(p){if(!oN(t,function(v,y){if(!hN(p,y)&&(g===v||s(g,v,i,r,n)))return p.push(y)})){u=!1;break}}else if(!(g===f||s(g,f,i,r,n))){u=!1;break}}return n.delete(e),n.delete(t),u}var hS=uN;function pN(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var fN=pN;function mN(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var gN=mN,vN=1,yN=2,xN="[object Boolean]",wN="[object Date]",bN="[object Error]",_N="[object Map]",SN="[object Number]",AN="[object RegExp]",MN="[object Set]",EN="[object String]",CN="[object Symbol]",TN="[object ArrayBuffer]",PN="[object DataView]",F1=Ur?Ur.prototype:void 0,tf=F1?F1.valueOf:void 0;function DN(e,t,i,r,s,n,a){switch(i){case PN:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case TN:return!(e.byteLength!=t.byteLength||!n(new Qd(e),new Qd(t)));case xN:case wN:case SN:return ev(+e,+t);case bN:return e.name==t.name&&e.message==t.message;case AN:case EN:return e==t+"";case _N:var o=fN;case MN:var l=r&vN;if(o||(o=gN),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=yN,a.set(e,t);var d=hS(o(e),o(t),r,s,n,a);return a.delete(e),d;case CN:if(tf)return tf.call(e)==tf.call(t)}return!1}var ON=DN,LN=1,RN=Object.prototype,IN=RN.hasOwnProperty;function BN(e,t,i,r,s,n){var a=i&LN,o=_m(e),l=o.length,h=_m(t),d=h.length;if(l!=d&&!a)return!1;for(var c=l;c--;){var u=o[c];if(!(a?u in t:IN.call(t,u)))return!1}var p=n.get(e),g=n.get(t);if(p&&g)return p==t&&g==e;var f=!0;n.set(e,t),n.set(t,e);for(var m=a;++c<l;){u=o[c];var v=e[u],y=t[u];if(r)var x=a?r(y,v,u,t,e,n):r(v,y,u,e,t,n);if(!(x===void 0?v===y||s(v,y,i,r,n):x)){f=!1;break}m||(m=u=="constructor")}if(f&&!m){var w=e.constructor,_=t.constructor;w!=_&&"constructor"in e&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof _=="function"&&_ instanceof _)&&(f=!1)}return n.delete(e),n.delete(t),f}var zN=BN,NN=1,k1="[object Arguments]",j1="[object Array]",Yc="[object Object]",UN=Object.prototype,G1=UN.hasOwnProperty;function FN(e,t,i,r,s,n){var a=Bs(e),o=Bs(t),l=a?j1:jh(e),h=o?j1:jh(t);l=l==k1?Yc:l,h=h==k1?Yc:h;var d=l==Yc,c=h==Yc,u=l==h;if(u&&Yd(e)){if(!Yd(t))return!1;a=!0,d=!1}if(u&&!d)return n||(n=new Td),a||X_(e)?hS(e,t,i,r,s,n):ON(e,t,l,i,r,s,n);if(!(i&NN)){var p=d&&G1.call(e,"__wrapped__"),g=c&&G1.call(t,"__wrapped__");if(p||g){var f=p?e.value():e,m=g?t.value():t;return n||(n=new Td),s(f,m,i,r,n)}}return u?(n||(n=new Td),zN(e,t,i,r,s,n)):!1}var kN=FN;function cS(e,t,i,r,s){return e===t?!0:e==null||t==null||!fn(e)&&!fn(t)?e!==e&&t!==t:kN(e,t,i,r,cS,s)}var jN=cS;function GN(e,t){return e!=null&&t in Object(e)}var VN=GN;function HN(e,t,i){t=Sl(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=Gu(t[r]);if(!(n=e!=null&&i(e,a)))break;e=e[a]}return n||++r!=s?n:(s=e==null?0:e.length,!!s&&iv(s)&&$g(a,s)&&(Bs(e)||sv(e)))}var WN=HN;function qN(e,t){return e!=null&&WN(e,t,VN)}var XN=qN,YN=function(){return as.Date.now()},rf=YN,QN="Expected a function",ZN=Math.max,KN=Math.min;function JN(e,t,i){var r,s,n,a,o,l,h=0,d=!1,c=!1,u=!0;if(typeof e!="function")throw new TypeError(QN);t=g1(t)||0,ss(i)&&(d=!!i.leading,c="maxWait"in i,n=c?ZN(g1(i.maxWait)||0,t):n,u="trailing"in i?!!i.trailing:u);function p(S){var A=r,b=s;return r=s=void 0,h=S,a=e.apply(b,A),a}function g(S){return h=S,o=setTimeout(v,t),d?p(S):a}function f(S){var A=S-l,b=S-h,E=t-A;return c?KN(E,n-b):E}function m(S){var A=S-l,b=S-h;return l===void 0||A>=t||A<0||c&&b>=n}function v(){var S=rf();if(m(S))return y(S);o=setTimeout(v,f(S))}function y(S){return o=void 0,u&&r?p(S):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function w(){return o===void 0?a:y(rf())}function _(){var S=rf(),A=m(S);if(r=arguments,s=this,l=S,A){if(o===void 0)return g(l);if(c)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),a}return _.cancel=x,_.flush=w,_}var pv=JN;function $N(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var eU=$N;function tU(e,t){return t.length<2?e:Z_(e,GB(t,0,-1))}var iU=tU;function rU(e,t){return jN(e,t)}var fv=rU;function sU(e,t){return t=Sl(t,e),e=iU(e,t),e==null||delete e[Gu(eU(t))]}var nU=sU;function aU(e){return kB(e)?void 0:e}var oU=aU,lU=1,hU=2,cU=4,dU=J_(function(e,t){var i={};if(e==null)return i;var r=!1;t=F_(t,function(n){return n=Sl(n,e),r||(r=n.length>1),n}),ac(e,sS(e),i),r&&(i=lS(i,lU|hU|cU,oU));for(var s=t.length;s--;)nU(i,t[s]);return i}),Em=dU;function uU(e,t,i,r){if(!ss(e))return e;t=Sl(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=Gu(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=a){var d=o[l];h=r?r(d,l,o):void 0,h===void 0&&(h=ss(d)?d:$g(t[s+1])?[]:{})}tv(o,l,h),o=o[l]}return e}var pU=uU;function fU(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=Z_(e,a);i(o,a)&&pU(n,Sl(a,e),o)}return n}var mU=fU;function gU(e,t){return mU(e,t,function(i,r){return XN(e,r)})}var vU=gU,yU=J_(function(e,t){return e==null?{}:vU(e,t)}),Gh=yU,xU="Expected a function";function wU(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(xU);return ss(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),pv(e,t,{leading:r,maxWait:t,trailing:s})}var bU=wU;function _U(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Va(e,t){return Object.setPrototypeOf(e,t),e}var SU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),AU=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),MU=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Hu&&"ontouchend"in document,EU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,CU=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,TU=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},PU=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},uW=SU(),Hu=AU(),dS=MU(),DU=EU(),gr=CU(),V1=TU(),H1=Number(PU());function uS(e){return Array.isArray(e)?e:[e]}function OU(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Qc(e){return Hu?e.metaKey:e.ctrlKey}var je=[],Kd={},fh={},Dd={};function pS(e){je.includes(e)||je.push(e)}function Wo(e){delete Kd[e.pointerId];for(let t=0;t<je.length;t++)if(je[t].pointerId===e.pointerId){je.splice(t,1);break}}function LU(){je.splice(0,je.length)}function Jd(e){if(e.pointerType!=="touch")return;let t=Kd[e.pointerId];t===void 0&&(t={x:0,y:0},Kd[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function sf(e){let t=e.pointerId===je[0].pointerId?je[1]:je[0];return Kd[t.pointerId]}function fS(e){fh[e.key]=!0,Dd[e.key]=Dd[e.key]===void 0?1:Dd[e.key]+1}function mS(e){if(Hu&&fh.Meta)for(let t in fh)fh[t]=!1;else fh[e.key]=!1;Dd={}}function RU(e){e.addEventListener("pointerdown",pS,!0),e.addEventListener("pointerdown",Jd,!0),e.addEventListener("pointermove",Jd,!0),e.addEventListener("pointerup",Wo,!0),e.addEventListener("pointercancel",Wo,!0),e.addEventListener("pointerleave",Wo,!0),window.addEventListener("keydown",fS,!0),window.addEventListener("keyup",mS,!0)}function IU(e){e.removeEventListener("pointerdown",pS,!0),e.removeEventListener("pointerdown",Jd,!0),e.removeEventListener("pointermove",Jd,!0),e.removeEventListener("pointerup",Wo,!0),e.removeEventListener("pointercancel",Wo,!0),e.removeEventListener("pointerleave",Wo,!0),window.removeEventListener("keydown",fS,!0),window.removeEventListener("keyup",mS,!0)}var gS,BU=new Promise(e=>{gS=e}),W1=!1;async function zU(){if(W1)return;let e="https://unpkg.com/@splinetool/navmesh-wasm@0.9.380/build",[t,i]=await Promise.all([import("./navmesh.js"),fetch(`${e}/navmesh.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});gS(s),W1=!0}var vS,NU=new Promise(e=>{vS=e}),q1=!1;async function UU(){if(q1)return;let e=await import("./physics.js");await e.init(),vS(e),q1=!0}var ti=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,ti.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:n}=e,a={...t,[s]:n};return Object.setPrototypeOf(a,ti.prototype),{data:a,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,ti.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function mv(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&mv(r)}return Object.freeze(e)}function FU(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var yS=class extends Error{};function nf(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Vn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let n=e;e=t,t=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=e+(t-e)*(n+.75+Math.random()*.5)*s;r.push(a)}return r}function gv(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function kU(){return typeof process<"u"}function xS(e,t){for(let i of e)t(i.id,i.data)!==!0&&xS(i.children,t)}function wS(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)wS(i,t)}var sr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,sr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)mv(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&wS(i,t)}}traverse(e){xS(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);if(s<0)throw new Error("not expected");let n=r[s];return r=[...r],r[s]={...n,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let n=r,a=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===a);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:n}}Object.setPrototypeOf(r,sr.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,d)=>h.fi-d.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===t);e.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...n,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new yS("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(c=>c.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=t,a=h.childrenArray(s);let d=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:e,reverse:{type:9,parent:n,fi:d,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>FU(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Vn(0,i,i);{let s=r[0].fi;return Vn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Vn(a,a+i,i)}else return Vn(s.fi,n.fi,i)}}},$d;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,n={},a=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");n[l]=a[h],a[h]=s[l],o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let s=r.props,n={},a={...i},o=!1;if(s)for(let l of Object.keys(s)){n[l]=a[l];let h=s[l];h===void 0?delete a[l]:a[l]=h,o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}}e.runOp=t})($d||($d={}));var it=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,it.prototype)}deepFreeze(){let e=0;for(;e<this.length;)mv(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,it.prototype);let t=e;return kU()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,n={fi:t,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(n=>n.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:t};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:n,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Vn(0,t,t);{let r=i[0].fi;return Vn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Vn(n,n+t,t)}else return Vn(r.fi,s.fi,t)}}};function ol(e){return e&&typeof e=="object"&&e instanceof Si}var Si=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!ol(i))return null;r+=1}i=i?nf(i):new Si;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=nf(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=nf(o);l[e.path[r-1]]=i,i=l}else{let l=new Si;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,Si.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},Ba;(e=>{function t(s,n){return Vh(s,n)??s}e.apply=t;function i(s,n){return yv(s,n)}e.merge=i;function r(s,n){let a=0,o=n.path,l=s;for(;a<o.length&&l!==void 0;){if(l=Os.zoomOnce(l,o[a]),l===void 0)return n;if(!ol(l))return;a+=1}if(l===void 0)return n;if(ol(l))if(n.type===0){let h={...n.props};for(let d of Object.keys(l))delete h[d];return{...n,props:h}}else if(n.type===1||n.type===4||n.type===7){let h=vv([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(Ba||(Ba={}));function vv(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Vh(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=vv(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}else return{...s,id:n,data:a}});if(i)return r}function jU(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Vh(s.data,t[n]);return i=i||a!==void 0,a===void 0&&(a=s.data),{...s,id:n,data:a}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function Vh(e,t){if(!ol(t))return t;if(e instanceof sr){let i=vv(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof it)return jU(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=Vh(s,t[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Si)return yv(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=Vh(n,t[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function yv(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!ol(t))return t;if(!ol(e))return Ba.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new Si;for(let s of i){let n=yv(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function GU(e,t){let i={cur:[],result:[],len:0};return e=Hh(e,t,i)??e,[e,i.result]}function eu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function tu(e){e&&(e.len-=1)}function VU(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function bS(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Hh(n.data,t,eu(i,a));tu(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=bS(n.children,t,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function HU(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Hh(n.data,t,eu(i,a));return tu(i),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function Hh(e,t,i){if(e instanceof sr){let r=bS(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof it)return HU(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=Hh(n,t,eu(i,a));return tu(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!gv(e)){let r={},s=!1;for(let[n,a]of Object.entries(e))if(n!=="name"&&n!=="text"){let o=t[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=Hh(a,t,eu(i,n));tu(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];if(r!==void 0){if(e.length!==36)throw new Error("for now you should only call this method when the key is a uuid");VU(i)}return r}else return}}var Cm;(e=>{function t(i,r){let s=Os.zoom(r,i.path);if(typeof s=="object"){let n={};for(let a of Object.keys(i.props))n[a]=s[a];return{...i,props:n}}else return{...i,props:{}}}e.replaceProps=t})(Cm||(Cm={}));var vr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let d=h.path;for(var c=[];;){let u;if(l instanceof Si&&h.type===0&&(u=l.runOp({...h,path:d.slice(c.length)}),u===null&&(u=void 0)),u===void 0&&c.length===d.length&&(l instanceof sr||l instanceof it||l instanceof ti?u=l.runOp(h):u=$d.runOp(l,h)),u!==void 0)if(u!==null){let f=u.data;for(let m=c.length-1;m>=0;m--){let v=d[m],y=c[m];if(y instanceof sr){if(typeof v=="number")throw new Error("illegal arg");f=y.modifyById(v,f)}else if(y instanceof it){if(typeof v=="number")throw new Error("illegal arg");f=y.modifyById(v,f)}else if(y instanceof ti){if(typeof v=="number")throw new Error("illegal arg");f=y.modifyById(v,f)}else if(y instanceof Si){let x={...y,[v]:f};f=Object.setPrototypeOf(x,Si.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let x=f;f=[...y],f[v]=x}else f={...y,[v]:f};else return null}return{data:f,actual:{...u.actual,path:d},reverse:{...u.reverse,path:d}}}else return null;let p=d[c.length],g;if(l instanceof sr){if(typeof p=="number")throw new Error("");g=l.get(p)?.data}else if(l instanceof it){if(typeof p=="number")throw new Error("");g=l.get(p)?.data}else l!==null&&(g=l[p]);if(g!==void 0)c.push(l),l=g;else return null}}e.apply=r;function s(l,h){for(let d=0;d<l.length&&d<h.length;d++)if(l[d]!==h[d])return!0;return!1}e.pathDisjoint=s;function n(l,h){if(l.length!==h.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==h[d])return!1;return!0}e.pathEq=n;function a(l,h){return s(l.path,h.path)}e.commutative=a;function o(l,h){return l.type===0&&h.type===0&&n(l.path,h.path)?Object.keys(l.props).every(d=>h.props[d]!==void 0):!1}e.subsumed=o})(vr||(vr={}));var X1;(e=>{function t(){return[]}e.empty=t;function i(h,d){let c=[];for(let u of h){let[p,...g]=u.path;p===d&&c.push({...u,path:g})}return c}e.removePrefix=i;function r(h,d){return h.map(c=>({...c,path:[d,...c.path]}))}e.addPrefix=r;function s(h,d){return[...h,...d]}e.concat=s;function n(h,d){return[...h.filter(c=>!d.some(u=>vr.subsumed(c,u))),...d]}e.compress=n;function a(h,d){return h.every(c=>d.every(u=>vr.commutative(c,u)))}e.commutative=a;function o(h,d){for(let c of d){let u=l(h,c);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,d){var c=h;let u=[],p=[];for(let g of d)try{if(g.type===3){let f=Os.zoom(c,[...g.path,g.id]),m=vr.apply(c,{...g,type:2});if(m!==null){c=m.data;let[v,y]=GU(c,{[g.id]:f});c=v;for(let x of y){let w=x[x.length-1];x.splice(x.length-1,1),u.push({type:0,path:x,props:{[w]:f}}),p.push({type:0,path:x,props:{[w]:g.id}})}p.push(m.reverse),u.push(m.actual)}}else{let f=vr.apply(c,g);f!==null&&(u.push(f.actual),c=f.data,p.push(f.reverse))}}catch(f){if(f instanceof yS)return null;throw f}return{data:c,actual:u,reverse:p.reverse()}}e.apply=l})(X1||(X1={}));var _S=Symbol(),WU=Symbol(),Wu=Symbol(),oc=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof AS);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Wu];i&&i(),delete this._children[e]}}}},qU=class extends oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,$d.runOp(this._current,e),e.path)}},XU=class extends oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,ti.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},SS={get(e,t){if(t===Wu)return()=>{e._parent=null};if(t===_S)return e._current;if(t===WU)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let n=i[t],a=qu(e,t,n);return a!==n?(r===void 0&&(r={},e._children=r),r[t]=a,a):n},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},YU={...SS,set(e,t,i){let r={type:0,props:{[t]:Ii(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},QU={...SS,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},xv=class extends oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Wu]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=qu(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},wv=class extends oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Wu]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=qu(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function af(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Os.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var AS=class extends oc{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){af(this.ts,t,e),af(this.actual,i,e),af(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function qu(e,t,i){return i instanceof sr?new xv(e,t,i):i instanceof it?new wv(e,t,i):i instanceof ti?new Proxy(new XU(e,t,i),QU):i!==null&&typeof i=="object"?gv(i)?i:new Proxy(new qU(e,t,i),YU):i}function MS(e){let t=new AS(e);return[qu(t,"",e),t]}function iu(e,t){let[i,r]=MS(e);return t(i),r.result()}function Ii(e){return e instanceof xv||e instanceof wv?e._current:e!==null&&typeof e=="object"?e[_S]:e}var Os;(e=>{function t(n,a){if(a.length===n.length)for(var o=0;o<n.length;){if(n[o]!==a[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(n,a,o){let l=s(o,n);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...a};return Object.keys(l).forEach(d=>{delete h[d]}),h}else return a}e.removeOverridden=i;function r(n,a){if((n instanceof sr||n instanceof xv)&&typeof a=="string"||(n instanceof it||n instanceof wv)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n)||typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}e.zoomOnce=r;function s(n,a,o=0){for(;o<a.length&&n!==void 0;)n=r(n,a[o]),o+=1;return n}e.zoom=s})(Os||(Os={}));function ZU(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Fn(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var ES=class{},Y1=class extends ES{constructor(e){super(),this.id=e}},Q1=class extends ES{constructor(e){super(),this.data=e}},Tm;try{Tm=new TextDecoder}catch{}var Ee,Qn,K=0,CS=[],Pm=CS,Dm=0,$i={},gt,Hn,Tr=0,Ms=0,ur,un,Hi=[],yt,Z1={useRecords:!1,mapsAsObjects:!0},TS=class{},PS=new TS;PS.name="MessagePack 0xC1";var ll=!1,ru=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Ee)return BS(()=>(Lm(),this?this.unpack(e,t):ru.prototype.unpack.call(Z1,e,t)));Qn=t>-1?t:e.length,K=0,Dm=0,Ms=0,Hn=null,Pm=CS,ur=null,Ee=e;try{yt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ee=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof ru){if($i=this,this.structures)return gt=this.structures,Zc();(!gt||gt.length>0)&&(gt=[])}else $i=Z1,(!gt||gt.length>0)&&(gt=[]);return Zc()}unpackMultiple(e,t){let i,r=0;try{ll=!0;let s=e.length,n=this?this.unpack(e,s):Yu.unpack(e,s);if(t){for(t(n);K<s;)if(r=K,t(Zc())===!1)return}else{for(i=[n];K<s;)r=K,i.push(Zc());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{ll=!1,Lm()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Zc(){try{if(!$i.trusted&&!ll){let t=gt.sharedLength||0;t<gt.length&&(gt.length=t)}let e=jt();if(K==Qn)gt.restoreStructures&&K1(),gt=null,Ee=null,un&&(un=null);else if(K>Qn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!ll)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw gt.restoreStructures&&K1(),Lm(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function K1(){for(let e in gt.restoreStructures)gt[e]=gt.restoreStructures[e];gt.restoreStructures=null}function jt(){let e=Ee[K++];if(e<160)if(e<128){if(e<64)return e;{let t=gt[e&63]||$i.getStructures&&DS()[e&63];return t?(t.read||(t.read=bv(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,$i.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[LS()]=jt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(jt(),jt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=jt();return t}else if(e<192){let t=e-160;if(Ms>=K)return Hn.slice(K-Tr,(K+=t)-Tr);if(Ms==0&&Qn<140){let i=t<16?_v(t):OS(t);if(i!=null)return i}return Om(t)}else{let t;switch(e){case 192:return null;case 193:return ur?(t=jt(),t>0?ur[1].slice(ur.position1,ur.position1+=t):ur[0].slice(ur.position0,ur.position0-=t)):PS;case 194:return!1;case 195:return!0;case 196:return of(Ee[K++]);case 197:return t=yt.getUint16(K),K+=2,of(t);case 198:return t=yt.getUint32(K),K+=4,of(t);case 199:return pa(Ee[K++]);case 200:return t=yt.getUint16(K),K+=2,pa(t);case 201:return t=yt.getUint32(K),K+=4,pa(t);case 202:if(t=yt.getFloat32(K),$i.useFloat32>2){let i=Sv[(Ee[K]&127)<<1|Ee[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=yt.getFloat64(K),K+=8,t;case 204:return Ee[K++];case 205:return t=yt.getUint16(K),K+=2,t;case 206:return t=yt.getUint32(K),K+=4,t;case 207:return $i.int64AsNumber?(t=yt.getUint32(K)*4294967296,t+=yt.getUint32(K+4)):t=yt.getBigUint64(K),K+=8,t;case 208:return yt.getInt8(K++);case 209:return t=yt.getInt16(K),K+=2,t;case 210:return t=yt.getInt32(K),K+=4,t;case 211:return $i.int64AsNumber?(t=yt.getInt32(K)*4294967296,t+=yt.getUint32(K+4)):t=yt.getBigInt64(K),K+=8,t;case 212:if(t=Ee[K++],t==114)return ix(Ee[K++]&63);{let i=Hi[t];if(i)return i.read?(K++,i.read(jt())):i.noBuffer?(K++,i()):i(Ee.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Ee[K],t==114?(K++,ix(Ee[K++]&63,Ee[K++])):pa(2);case 214:return pa(4);case 215:return pa(8);case 216:return pa(16);case 217:return t=Ee[K++],Ms>=K?Hn.slice(K-Tr,(K+=t)-Tr):JU(t);case 218:return t=yt.getUint16(K),K+=2,Ms>=K?Hn.slice(K-Tr,(K+=t)-Tr):$U(t);case 219:return t=yt.getUint32(K),K+=4,Ms>=K?Hn.slice(K-Tr,(K+=t)-Tr):eF(t);case 220:return t=yt.getUint16(K),K+=2,$1(t);case 221:return t=yt.getUint32(K),K+=4,$1(t);case 222:return t=yt.getUint16(K),K+=2,ex(t);case 223:return t=yt.getUint32(K),K+=4,ex(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var KU=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function bv(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>KU.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(jt);return e.highByte===0&&(e.read=J1(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=jt()}return r}return i.count=0,e.highByte===0?J1(t,i):i}var J1=(e,t)=>function(){let i=Ee[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=gt[r]||DS()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=bv(s,e)),s.read()};function DS(){let e=BS(()=>(Ee=null,$i.getStructures()));return gt=$i._mergeStructures(e,gt)}var Om=Xu,JU=Xu,$U=Xu,eF=Xu;function Xu(e){let t;if(e<16&&(t=_v(e)))return t;if(e>64&&Tm)return Tm.decode(Ee.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Ee[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Ee[K++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Ee[K++]&63,a=Ee[K++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Ee[K++]&63,a=Ee[K++]&63,o=Ee[K++]&63,l=(s&7)<<18|n<<12|a<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=mi.apply(String,r),r.length=0)}return r.length>0&&(t+=mi.apply(String,r)),t}function $1(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=jt();return t}function ex(e){if($i.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[LS()]=jt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(jt(),jt());return t}}var mi=String.fromCharCode;function OS(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Ee[K++];if((s&128)>0){K=t;return}i[r]=s}return mi.apply(String,i)}function _v(e){if(e<4)if(e<2){if(e===0)return"";{let t=Ee[K++];if((t&128)>1){K-=1;return}return mi(t)}}else{let t=Ee[K++],i=Ee[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return mi(t,i);let r=Ee[K++];if((r&128)>0){K-=3;return}return mi(t,i,r)}else{let t=Ee[K++],i=Ee[K++],r=Ee[K++],s=Ee[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return mi(t,i,r,s);{let n=Ee[K++];if((n&128)>0){K-=5;return}return mi(t,i,r,s,n)}}else if(e<8){let n=Ee[K++],a=Ee[K++];if((n&128)>0||(a&128)>0){K-=6;return}if(e<7)return mi(t,i,r,s,n,a);let o=Ee[K++];if((o&128)>0){K-=7;return}return mi(t,i,r,s,n,a,o)}else{let n=Ee[K++],a=Ee[K++],o=Ee[K++],l=Ee[K++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return mi(t,i,r,s,n,a,o,l);{let h=Ee[K++];if((h&128)>0){K-=9;return}return mi(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Ee[K++],d=Ee[K++];if((h&128)>0||(d&128)>0){K-=10;return}if(e<11)return mi(t,i,r,s,n,a,o,l,h,d);let c=Ee[K++];if((c&128)>0){K-=11;return}return mi(t,i,r,s,n,a,o,l,h,d,c)}else{let h=Ee[K++],d=Ee[K++],c=Ee[K++],u=Ee[K++];if((h&128)>0||(d&128)>0||(c&128)>0||(u&128)>0){K-=12;return}if(e<14){if(e===12)return mi(t,i,r,s,n,a,o,l,h,d,c,u);{let p=Ee[K++];if((p&128)>0){K-=13;return}return mi(t,i,r,s,n,a,o,l,h,d,c,u,p)}}else{let p=Ee[K++],g=Ee[K++];if((p&128)>0||(g&128)>0){K-=14;return}if(e<15)return mi(t,i,r,s,n,a,o,l,h,d,c,u,p,g);let f=Ee[K++];if((f&128)>0){K-=15;return}return mi(t,i,r,s,n,a,o,l,h,d,c,u,p,g,f)}}}}}function of(e){return $i.copyBuffers?Uint8Array.prototype.slice.call(Ee,K,K+=e):Ee.subarray(K,K+=e)}function pa(e){let t=Ee[K++];if(Hi[t])return Hi[t](Ee.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var tx=new Array(4096);function LS(){let e=Ee[K++];if(e>=160&&e<192){if(e=e-160,Ms>=K)return Hn.slice(K-Tr,(K+=e)-Tr);if(!(Ms==0&&Qn<180))return Om(e)}else return K--,jt();let t=(e<<5^(e>1?yt.getUint16(K):e>0?Ee[K]:0))&4095,i=tx[t],r=K,s=K+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=yt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Ee[r++],n!=i[a++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],tx[t]=i,i.bytes=e;r<s;)n=yt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Ee[r++],i.push(n);let o=e<16?_v(e):OS(e);return o!=null?i.string=o:i.string=Om(e)}var ix=(e,t)=>{var i=jt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=gt[e];return s&&s.isShared&&((gt.restoreStructures||(gt.restoreStructures=[]))[e]=s),gt[e]=i,i.read=bv(i,r),i.read()},RS=typeof self=="object"?self:global;Hi[0]=()=>{};Hi[0].noBuffer=!0;Hi[101]=()=>{let e=jt();return(RS[e[0]]||Error)(e[1])};Hi[105]=e=>{let t=yt.getUint32(K-4);un||(un=new Map);let i=Ee[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};un.set(t,s);let n=jt();return s.used?Object.assign(r,n):(s.target=n,n)};Hi[112]=e=>{let t=yt.getUint32(K-4),i=un.get(t);return i.used=!0,i.target};Hi[115]=()=>new Set(jt());var IS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Hi[116]=e=>{let t=e[0],i=IS[t];if(!i)throw new Error("Could not find typed array for code "+t);return new RS[i](Uint8Array.prototype.slice.call(e,1).buffer)};Hi[120]=()=>{let e=jt();return new RegExp(e[0],e[1])};Hi[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,ur=[jt(),jt()],ur.position0=0,ur.position1=0;let r=K;K=i;try{return jt()}finally{K=r}};Hi[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function BS(e){let t=Qn,i=K,r=Dm,s=Tr,n=Ms,a=Hn,o=Pm,l=un,h=ur,d=new Uint8Array(Ee.slice(0,Qn)),c=gt,u=gt.slice(0,gt.length),p=$i,g=ll,f=e();return Qn=t,K=i,Dm=r,Tr=s,Ms=n,Hn=a,Pm=o,un=l,ur=h,Ee=d,ll=g,gt=c,gt.splice(0,gt.length,...u),$i=p,yt=new DataView(Ee.buffer,Ee.byteOffset,Ee.byteLength),f}function Lm(){Ee=null,un=null,gt=null}function tF(e){e.unpack?Hi[e.type]=e.unpack:Hi[e.type]=e}var Sv=new Array(147);for(let e=0;e<256;e++)Sv[e]=+("1e"+Math.floor(45.15-e*.30103));var Yu=new ru({useRecords:!1}),pW=Yu.unpack,fW=Yu.unpackMultiple,mW=Yu.unpack,iF={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},rF=new Float32Array(1),gW=new Uint8Array(rF.buffer,0,4),Od;try{Od=new TextEncoder}catch{}var su,Av,Qu=typeof Buffer<"u",lf=Qu?Buffer.allocUnsafeSlow:Uint8Array,zS=Qu?Buffer:Uint8Array,rx=Qu?4294967296:2144337920,he,Wt,te=0,hs,cs=null,sF=/[\u0080-\uFFFF]/,ql=Symbol("record-id"),NS=class extends ru{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=zS.prototype.utf8Write?function(A,b,E){return he.utf8Write(A,b,E)}:Od&&Od.encodeInto?function(A,b){return Od.encodeInto(A,he.subarray(b)).written}:!1,h=this;e||(e={});let d=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),d&&!e.saveStructures&&(this.structures=[]);let g=u>32||p+u>64,f=u+64,m=u+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(A,b){if(he||(he=new lf(8192),Wt=new DataView(he.buffer,0,8192),te=0),hs=he.length-10,hs-te<2048?(he=new lf(he.length),Wt=new DataView(he.buffer,0,he.length),hs=he.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(cs=["",""],he[te++]=214,he[te++]=98,cs.position=te-i,te+=4):cs=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let E=r.sharedLength||0;if(E>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<E;C++){let T=r[C];if(!T)continue;let P,L=r.transitions;for(let D=0,j=T.length;D<j;D++){let W=T[D];P=L[W],P||(P=L[W]=Object.create(null)),L=P}L[ql]=C+64}o=E}d||(r.nextId=E+64)}s&&(s=!1),n=r||[];try{if(w(A),cs){Wt.setUint32(cs.position+i,te-cs.position-i);let E=cs;cs=null,w(E[0]),w(E[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>hs&&S(te),h.offset=te;let E=aF(he.subarray(i,te),a.idsToInsert);return a=null,E}return b&oF?(he.start=i,he.end=te,he):he.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let E=0,C=v.length;E<C;E++)v[E][ql]=0;v=[]}if(s&&h.saveStructures){let E=r.sharedLength||u;r.length>E&&(r=r.slice(0,E));let C=he.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(A)):(o=E,C)}}b&lF&&(te=i)}};let w=A=>{te>hs&&(he=S(te));var b=typeof A,E;if(b==="string"){let C=A.length;if(cs&&C>=8&&C<4096){let L=sF.test(A);cs[L?0:1]+=A,he[te++]=193,w(L?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let P=C*3;if(te+P>hs&&(he=S(te+P)),C<64||!l){let L,D,j,W=te+T;for(L=0;L<C;L++)D=A.charCodeAt(L),D<128?he[W++]=D:D<2048?(he[W++]=D>>6|192,he[W++]=D&63|128):(D&64512)===55296&&((j=A.charCodeAt(L+1))&64512)===56320?(D=65536+((D&1023)<<10)+(j&1023),L++,he[W++]=D>>18|240,he[W++]=D>>12&63|128,he[W++]=D>>6&63|128,he[W++]=D&63|128):(he[W++]=D>>12|224,he[W++]=D>>6&63|128,he[W++]=D&63|128);E=W-te-T}else E=l(A,te+T,P);E<32?he[te++]=160|E:E<256?(T<2&&he.copyWithin(te+2,te+1,te+1+E),he[te++]=217,he[te++]=E):E<65536?(T<3&&he.copyWithin(te+3,te+2,te+2+E),he[te++]=218,he[te++]=E>>8,he[te++]=E&255):(T<5&&he.copyWithin(te+5,te+3,te+3+E),he[te++]=219,Wt.setUint32(te,E),te+=4),te+=E}else if(b==="number")if(A>>>0===A)A<64?he[te++]=A:A<256?(he[te++]=204,he[te++]=A):A<65536?(he[te++]=205,he[te++]=A>>8,he[te++]=A&255):(he[te++]=206,Wt.setUint32(te,A),te+=4);else if(A>>0===A)A>=-32?he[te++]=256+A:A>=-128?(he[te++]=208,he[te++]=A+256):A>=-32768?(he[te++]=209,Wt.setInt16(te,A),te+=2):(he[te++]=210,Wt.setInt32(te,A),te+=4);else{let C;if((C=this.useFloat32)>0&&A<4294967296&&A>=-2147483648){he[te++]=202,Wt.setFloat32(te,A);let T;if(C<4||(T=A*Sv[(he[te]&127)<<1|he[te+1]>>7])>>0===T){te+=4;return}else te--}he[te++]=203,Wt.setFloat64(te,A),te+=8}else if(b==="object")if(!A)he[te++]=192;else{if(a){let T=a.get(A);if(T){if(!T.id){let P=a.idsToInsert||(a.idsToInsert=[]);T.id=P.push(T)}he[te++]=214,he[te++]=112,Wt.setUint32(te,T.id),te+=4;return}else a.set(A,{offset:te-i})}let C=A.constructor;if(C===Object)_(A,!0);else if(C===Array){E=A.length,E<16?he[te++]=144|E:E<65536?(he[te++]=220,he[te++]=E>>8,he[te++]=E&255):(he[te++]=221,Wt.setUint32(te,E),te+=4);for(let T=0;T<E;T++)w(A[T])}else if(C===Map){E=A.size,E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,Wt.setUint32(te,E),te+=4);for(let[T,P]of A)w(T),w(P)}else{for(let T=0,P=su.length;T<P;T++){let L=Av[T];if(A instanceof L){let D=su[T];if(D.write){D.type&&(he[te++]=212,he[te++]=D.type,he[te++]=0),w(D.write.call(this,A));return}let j=he,W=Wt,q=te;he=null;let z;try{z=D.pack.call(this,A,V=>(he=j,j=null,te+=V,te>hs&&S(te),{target:he,targetView:Wt,position:te-V}),w)}finally{j&&(he=j,Wt=W,te=q,hs=he.length-10)}z&&(z.length+te>hs&&S(z.length+te),te=nF(z,he,te,D.type));return}}_(A,!A.hasOwnProperty)}}else if(b==="boolean")he[te++]=A?195:194;else if(b==="bigint"){if(A<BigInt(1)<<BigInt(63)&&A>=-(BigInt(1)<<BigInt(63)))he[te++]=211,Wt.setBigInt64(te,A);else if(A<BigInt(1)<<BigInt(64)&&A>0)he[te++]=207,Wt.setBigUint64(te,A);else if(this.largeBigIntToFloat)he[te++]=203,Wt.setFloat64(te,Number(A));else throw new RangeError(A+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(b==="undefined")this.encodeUndefinedAsNil?he[te++]=192:(he[te++]=212,he[te++]=0,he[te++]=0);else if(b==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+b)},_=this.useRecords===!1?this.variableMapSize?A=>{let b=Object.keys(A),E=b.length;E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,Wt.setUint32(te,E),te+=4);let C;for(let T=0;T<E;T++)w(C=b[T]),w(A[C])}:(A,b)=>{he[te++]=222;let E=te-i;te+=2;let C=0;for(let T in A)(b||A.hasOwnProperty(T))&&(w(T),w(A[T]),C++);he[E+++i]=C>>8,he[E+i]=C&255}:A=>{let b=Object.keys(A),E,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let L=0,D=b.length;L<D;L++){let j=b[L];E=C[j],E||(E=C[j]=Object.create(null),T++),C=E}let P=C[ql];if(P)P>=96&&g?(he[te++]=((P-=96)&31)+96,he[te++]=P>>5):he[te++]=P;else{P=n.nextId,P||(P=64),P<f&&this.shouldShareStructure&&!this.shouldShareStructure(b)?(P=n.nextOwnId,P<m||(P=f),n.nextOwnId=P+1):(P>=m&&(P=f),n.nextId=P+1);let L=b.highByte=P>=96&&g?P-96>>5:-1;C[ql]=P,n[P-64]=b,P<f?(b.isShared=!0,n.sharedLength=P-63,s=!0,L>=0?(he[te++]=(P&31)+96,he[te++]=L):he[te++]=P):(L>=0?(he[te++]=213,he[te++]=114,he[te++]=(P&31)+96,he[te++]=L):(he[te++]=212,he[te++]=114,he[te++]=P),T&&(y+=x*T),v.length>=p&&(v.shift()[ql]=0),v.push(C),w(b))}for(let L=0,D=b.length;L<D;L++)w(A[b[L]])},S=A=>{let b;if(A>16777216){if(A-i>rx)throw new Error("Packed buffer would be larger than maximum buffer size");b=Math.min(rx,Math.round(Math.max((A-i)*(A>67108864?1.25:2),4194304)/4096)*4096)}else b=(Math.max(A-i<<2,he.length-1)>>12)+1<<12;let E=new lf(b);return Wt=new DataView(E.buffer,0,b),he.copy?he.copy(E,0,i,A):E.set(he.slice(i,A)),te-=i,i=0,hs=E.length-10,he=E}}useBuffer(e){he=e,Wt=new DataView(he.buffer,he.byteOffset,he.byteLength),te=0}};Av=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,TS];su=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:n,position:a}=t(6);s[a++]=214,s[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:s,targetView:n,position:a}=t(10);s[a++]=215,s[a++]=255,n.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:n,position:a}=t(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:n,position:a}=t(15);s[a++]=199,s[a++]=12,s[a++]=255,n.setUint32(a,e.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(s[n++]=212,s[n++]=115,s[n++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?sx(e,16,t):nx(Qu?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==zS&&this.structuredClone?sx(e,IS.indexOf(i.name),t):nx(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function sx(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:n,position:a}=i(4+s);n[a++]=199,n[a++]=s+1}else if(s+1<65536){var{target:n,position:a}=i(5+s);n[a++]=200,n[a++]=s+1>>8,n[a++]=s+1&255}else{var{target:n,position:a,targetView:o}=i(7+s);n[a++]=201,o.setUint32(a,s+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function nx(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:n}=t(i+5);r[s++]=198,n.setUint32(s,i),s+=4}r.set(e,s)}function nF(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function aF(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);i=t.pop();){let n=i.offset,a=i.id;e.copyWithin(n+r,n,s),r-=6;let o=n+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,s=n}return e}function Ml(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");Av.unshift(e.Class),su.unshift(e)}tF(e)}var US=new NS({useRecords:!1}),vW=US.pack,yW=US.pack,{NEVER:xW,ALWAYS:wW,DECIMAL_ROUND:bW,DECIMAL_FIT:_W}=iF,oF=512,lF=1024,ax=new NS({structuredClone:!0});Ml({Class:ti.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ti.prototype),e}});Ml({Class:it.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,it.prototype),e}});Ml({Class:sr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,sr.prototype),e}});Ml({Class:Y1.prototype.constructor,type:4,write(e){return e.id},read(e){return new Y1(e)}});Ml({Class:Q1.prototype.constructor,type:5,write(e){return e.data},read(e){return new Q1(e)}});Ml({Class:Si.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Si.prototype),e}});function hF(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function Rm(e){if(gv(e))return e;if(Array.isArray(e))return e.map(Rm);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Rm(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Im;(e=>{function t(s){return ax.pack(s)}e.serialize=t;function i(s){return ax.unpack(s)}e.deserialize=i;function r(s){return hF(t(Rm(s))).toString()}e.checksum=r})(Im||(Im={}));var En={LookAt:[],Follow:["Create"],DragDrop:["Transition","Audio","Create"],MouseHover:["Transition","Create","Destroy","SwitchCamera"],Scroll:["Transition","Create"],Start:["Transition","Audio","Video","Create","Destroy","SwitchCamera"],Conditional:["Transition","Audio","Video","Create","Destroy","SwitchCamera","Reset"],MouseDown:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],MouseUp:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],MousePress:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],KeyDown:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],KeyUp:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],KeyPress:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],GameControl:["Transition","Audio","Video","Create"],Collision:["Transition","Audio","Video","Create","Destroy","Reset"]},ox;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,toggle:!1,actions:new it}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new it}}e.defaultData=i})(ox||(ox={}));var nu;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(nu||(nu={}));var Bm;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:nu.propertyDefaultData(s),rOperand:{...nu.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,n){return{type:"State",object:s??null,state:n??null}}e.stateDefaultData=r})(Bm||(Bm={}));var lx;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new it,outActions:new it,condition:Bm.distanceDefaultData(r)}}e.defaultData=i})(lx||(lx={}));var hx;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new it,drop:new it}})(hx||(hx={}));var zm;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new it})(zm||(zm={}));var Nm;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Nm||(Nm={}));var cx;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new it}}e.defaultData=i})(cx||(cx={}));var dx;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new it}}e.defaultData=i})(dx||(dx={}));var ux;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new it}}e.defaultData=i})(ux||(ux={}));var px;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new it}}e.defaultData=i})(px||(px={}));var No;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n]}e.lerp=i})(No||(No={}));var za;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function n(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=n;function a(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=a;function o(l,h,d){return[l[0]+(h[0]-l[0])*d,l[1]+(h[1]-l[1])*d,l[2]+(h[2]-l[2])*d]}e.lerp=o})(za||(za={}));var au;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]}e.lerp=i})(au||(au={}));var hl;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,n){for(let a=0;a<16;a++)if(s[a]!==n[a])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,n){let a=n.slice(0);for(var o=0,l=n.length;o<l;o+=3){let h=s[3]*n[o]+s[7]*n[o+1]+s[11]*n[o+2]+s[15];a[o]=(s[0]*n[o]+s[4]*n[o+1]+s[8]*n[o+2]+s[12])/h,a[o+1]=(s[1]*n[o]+s[5]*n[o+1]+s[9]*n[o+2]+s[13])/h,a[o+2]=(s[2]*n[o]+s[6]*n[o+1]+s[10]*n[o+2]+s[14])/h}return a}e.applyMatrix4=r})(hl||(hl={}));var Oi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function n(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=n;function a(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=a;function o(l,h,d){return{r:l.r+(h.r-l.r)*d,g:l.g+(h.g-l.g)*d,b:l.b+(h.b-l.b)*d}}e.lerp=o})(Oi||(Oi={}));var Lr;(e=>{e.white={...Oi.white,a:1},e.transparent={...Oi.white,a:0};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}e.from0to1=t;function i(a,o){return{...Oi.fromHex(a),a:o}}e.fromHexAndA=i;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}e.toRgb255a1=r;function s(a,o){return Oi.equals(a,o)&&a.a===o.a}e.equals=s;function n(a,o,l){return{r:a.r+(o.r-a.r)*l,g:a.g+(o.g-a.g)*l,b:a.b+(o.b-a.b)*l,a:a.a+(o.a-a.a)*l}}e.lerp=n})(Lr||(Lr={}));var Um;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Um||(Um={}));var fx;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(fx||(fx={}));var mx;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(mx||(mx={}));var zn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(zn||(zn={}));var Ha;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Ha||(Ha={}));var Wh;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Wh||(Wh={}));var Wn;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(n=>n*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let n={...r};if(FS.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;kS.forEach(l=>{Object.assign(n.radial,{[l]:o[l]??a[l]})})}if(n.linear={...r.linear},s.linear){let a=r.linear,o=s.linear;jS.forEach(l=>{Object.assign(n.linear,{[l]:o[l]??a[l]})})}if(n.grid={...r.grid},s.grid){let a=r.grid,o=s.grid;GS.forEach(l=>{Object.assign(n.grid,{[l]:o[l]??a[l]})})}if(n.toObject={...r.toObject},s.toObject){let a=r.toObject,o=s.toObject;VS.forEach(l=>{Object.assign(n.toObject,{[l]:o[l]??a[l]})})}if(n.randomnessObject={...r.randomnessObject},s.randomnessObject){let a=r.randomnessObject,o=s.randomnessObject;HS.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(Wn||(Wn={}));var Fm;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of t){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}e.toOps=i})(Fm||(Fm={}));var FS=["count"],kS=["radius","start","end","position","scale","rotation"],jS=["position","scale","rotation"],GS=["count","size"],VS=["count","position","scale","rotation"],HS=["strength","scale","rotation","position","movement","seed","freqScale"],qh;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(qh||(qh={}));var km;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(km||(km={}));var jm;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Lr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(r==="SpotLight")return{type:r,color:Lr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Lr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(jm||(jm={}));var Gm;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Gm||(Gm={}));var Vm;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Vm||(Vm={}));var Hm;(e=>e.defaultData={...Vm.defaultData,...Gm.defaultData})(Hm||(Hm={}));var ou;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ou||(ou={}));var gx;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(gx||(gx={}));function cF(e){return e.type!=="displace"}var vx;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(vx||(vx={}));var WS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],dF=["wrapping","image","video"],Pr;(e=>{function t(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let h=n.texture;h&&Object.assign(h,o)}}e.patch=t;function i(n,a){return n==="light"&&a?r(a):s(n)}e.defaultData=i;function r(n){let a={mode:0,isMask:!1,visible:!0};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ou.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:Oi.fromHex(5526619)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Oi.fromHex(6710886),a:1},colorB:{...Oi.fromHex(6710886),a:1},colorC:{...Oi.fromHex(16777215),a:1},colorD:{...Oi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Lr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Lr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Lr.fromHexAndA(0,1),contourColor:Lr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Oi.fromHex(0),a:1},colorB:{...Oi.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}}}})(Pr||(Pr={}));var yr;(e=>{function t(h){return!h.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}e.isMergable=t;function i(h){let d="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([u,p])=>{d+=`${u}${p}`,Array.isArray(p)?p.forEach(g=>d+=`${g}`):typeof p=="object"?Object.values(p).forEach(g=>{typeof g=="number"?d+=`${g.toFixed(4)}`:d+=`${g}`}):d+=`${p}`})}),d}e.getHash=i;function r(){return{layers:new it}}e.defaultEmptyData=r;function s(h="layer1",d="layer2"){return a("phong",h,d)}e.defaultData=s;function n(h,d){return{...h,name:d}}e.withName=n;function a(h,d="layer1",c="layer2"){let u=new it;return u.push({fi:0,data:Pr.defaultData("light",h),id:d}),u.push({fi:1,data:Pr.defaultData("color"),id:c}),{layers:u}}e.defaultTwoLayerData=a;function o(h,d="phong",c="layer1",u="layer2"){let p=Pr.defaultData("texture");Object.assign(p.texture,{image:h});let g=new it;return g.push({fi:0,data:p,id:c}),g.push({fi:1,data:Pr.defaultData("light",d),id:u}),{layers:g}}e.defaultTwoLayerTextureData=o;function l(h,d="phong",c="layer1",u="layer2"){let p=Pr.defaultData("video");Object.assign(p.texture,{video:h});let g=new it;return g.push({fi:0,data:p,id:c}),g.push({fi:1,data:Pr.defaultData("light",d),id:u}),{layers:g}}e.defaultTwoLayerVideoTextureData=l})(yr||(yr={}));var lu;(e=>{function t(){return{points:new it,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(lu||(lu={}));var hu;(e=>{function t(){return{points:new it,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(hu||(hu={}));var qS={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0},Wm;(e=>{function t(i,r){let s={...i};return YS.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(Wm||(Wm={}));var XS={shape:qS,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},YS=["depth","offset","angle","twist","startScale","endScale"],cu;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(cu||(cu={}));var qm;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,Wm.merge(s.extrusion,r.extrusion))),s}e.merge=t})(qm||(qm={}));var qo;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:hu.defaultData(),extrusion:XS};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:lu.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}e.defaultData=t})(qo||(qo={}));var yx=["width","height","depth"],xx;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(xx||(xx={}));var cl;(e=>{e.identity={...Um.identity,hiddenMatrix:hl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,n){return{position:n?.position||s.position,rotation:n?.rotation||s.rotation,scale:n?.scale||s.scale,hiddenMatrix:n?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,n){return _U({position:za.isEqual(s.position,n.position)?void 0:n.position,rotation:za.isEqual(s.rotation,n.rotation)?void 0:n.rotation,scale:za.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:hl.isEqual(s.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})}e.diff=r})(cl||(cl={}));var wx;(e=>e.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(wx||(wx={}));var Ir;(e=>e.defaultData={states:new it,events:new it,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...cl.identity,cloner:null})(Ir||(Ir={}));var bx;(e=>e.defaultData={type:"Empty",...Ir.defaultData})(bx||(bx={}));var _x;(e=>e.defaultData={type:"Component",...Ir.defaultData})(_x||(_x={}));var Xo;(e=>e.defaultData={type:"Mesh",...Ir.defaultData,...Hm.defaultData})(Xo||(Xo={}));var du;(e=>e.defaultData={...Ir.defaultData,...cl.identity,...Wh.defaultData})(du||(du={}));var Xm;(e=>{function t(i){return{...Ir.defaultData,...jm.defaultData(i)}}e.defaultData=t})(Xm||(Xm={}));var uu;(e=>{function t(r,s,n=0){for(;n<s.length;){let a=r?r[s[n]]:void 0;if(s.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=t;function i(r,s,n=0){let a=t(r,s,n);if(a){let o=Object.keys(a);if(o.length===1&&o[0]==="descendants")return}return a}e.resolve=i})(uu||(uu={}));var dl;(e=>{e.rootOverrideProps=["physics"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Ir.defaultData,...s,component:r,overrides:new Si,physics:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=cl.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(dl||(dl={}));var Ym;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:hl.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new it,events:new it,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Wh.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Ir.defaultData,...Xo.defaultData,geometry:qo.defaultData("RectangleGeometry"),material:yr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Ir.defaultData,...Xo.defaultData,geometry:qo.defaultData("BooleanGeometry"),material:yr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Ir.defaultData,...Xo.defaultData,geometry:qo.defaultData("TextGeometry"),material:yr.defaultTwoLayerData("phong","layer1","layer2")}))(Ym||(Ym={}));var Ca;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new Si}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new Si})))):Ha.is(n.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(n,a){if(a===void 0)return n;let o={...n};return"material"in o&&"material"in a&&a.material&&(o.material=iu(o.material,l=>{if(typeof l!="string")for(let[h,d]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&Pr.patch(c,d)}}).data),o.materials&&a.materials&&(o.materials=iu(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let d=a.materials[h];if(typeof d!="string")for(let[c,u]of Object.entries(d.layers)){let p=l[h]?.layers?.data(c);p&&Pr.patch(p,u)}}}).data),o}function r(n,a){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function d(c,u){for(let[p,g]of Object.entries(u.layers)){let{texture:f,...m}=g;if(f!==void 0&&Object.keys(f).length>0){let v={path:[...c,"layers",p,"texture"],props:f,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,u]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...Fm.toOps(u,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:u.slide,offset:u.offset},type:0});else if(c==="material")d(["material"],u);else if(c==="materials")for(let[p,g]of Object.entries(u))d(["materials",p],g);else if(h[c]===0){if(c==="geometry"&&u.extrusion!==void 0){let p={path:[c,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[c],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=u;return l}e.toOps=r;function s(n,a){if(a===void 0)return n;let o={...n};if(Object.assign(o,cl.merge(o,a)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:a.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Ha.is(n.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=a;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(o,{geometry:qm.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Wn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Wn.merge(o.cloner,a.cloner)});else if(km.is(n.type)){let l=a;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Oi.clone(l.color))}return o}e.patch=s})(Ca||(Ca={}));var pu;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Oi.white,near:.1,far:2e3})(pu||(pu={}));var fu;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(fu||(fu={}));var ul;(e=>e.defaultData={orbitControls:fu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio: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,joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),gameControlObject:null,hdTransmission:!1})(ul||(ul={}));var Qm;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Qm||(Qm={}));var Zm;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Zm||(Zm={}));var Xh;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Qm.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Zm.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Xh||(Xh={}));var fr;(e=>e.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low",occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(fr||(fr={}));var Sx;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=new sr,a=Ym.defaultMeshObject;return s.withLight===!0&&n.push({fi:-1,data:{...Xm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]}),n}e.defaultData={backgroundColor:Lr.fromHexAndA(2960946,1),postprocessing:qh.defaultData,fog:pu.defaultData,objects:t(),environment:fr.defaultData,publish:ul.defaultData,styles:Xh.defaultData()},e.emptyData=function(s){return{backgroundColor:Lr.fromHexAndA(2960946,1),postprocessing:qh.defaultData,fog:pu.defaultData,objects:s?t(s):new sr,environment:fr.defaultData,publish:ul.defaultData,styles:Xh.defaultData()}};function i(s){return{...e.defaultData,objects:Va(s,sr.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(Sx||(Sx={}));var mu;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(mu||(mu={}));var Km;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Va(s,ti.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...mu.emptyImage,name:"AI generated image"}),Va(n,ti.prototype)}e.defaultImages=i;function r(){return{materials:new ti,images:new ti,videos:new ti,colors:new ti,audios:new ti,fonts:new ti,penumbraSize:[2,2,2]}}e.emptyData=r})(Km||(Km={}));var gu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new it,move:new it,jump:new it},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Lr.fromHexAndA(3728051,1)}}))(gu||(gu={}));function Ax(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...Gh(Ii(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Ii(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Uo(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Fo(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach(s=>{typeof s!="string"&&t(s)}):"material"in r&&typeof r.material!="string"&&t(r.material)})}function uF(e){Object.assign(e.scene.publish,{orbitControls:{...fu.defaultData,...Ii(e.scene.publish.orbitControls)}})}function pF(e){Object.assign(e.scene.publish.settings,{video:{...ul.defaultData.settings.video,...Ii(e.scene.publish.settings.video)}})}function fF(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,n]of Object.entries(r))if((WS.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(dF.includes(a)||typeof o=="boolean")&&delete n[a]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let n=s;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function mF(e){e.scene.publish.withBackground=!0}function gF(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function vF(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function yF(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function xF(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=Ii(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Ii(i).booleanExclude!==!0)}})}function wF(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function bF(e){function t(r){Object.setPrototypeOf(r,Si.prototype),r.texture&&Object.setPrototypeOf(r.texture,Si.prototype)}function i(r){Object.setPrototypeOf(r,Si.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(n=>{let a=n;if(a.material){let o=Ii(a.material).layers;i(o),a.material.layers=o}if(a.materials)for(let o=0;o<a.materials.length;o++){let l=a.materials[o],h=Ii(l).layers;i(h),l.layers=h}})})}function Mx(e){e.layers===void 0&&Object.assign(e,yr.defaultTwoLayerData("lambert"))}function hf(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...Ii(t),colors:i,steps:r};Object.assign(t,s)}})}function _F(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function Ex(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&hf(r)}):"material"in i&&typeof i.material!="string"&&hf(i.material)}),Object.values(e.shared.materials).forEach(t=>hf(t))}function SF(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function AF(e){e.shared.audios=Va({},ti.prototype)}function MF(e){e.shared.videos=Va({},ti.prototype)}function EF(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function CF(e){Object.entries(Ii(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Ii(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function TF(e){e.scene.publish.settings.web.preload=!1}function Cx(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function Tx(e){e.layers&&e.layers.forEach(t=>{cF(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 PF(e){e.shared.fonts=Va({},ti.prototype)}function DF(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function OF(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=yr.defaultTwoLayerData("phong"),a=typeof s.color=="string"?e.shared.colors[s.color]:s.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=s.alpha;let o=DF(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Ir.defaultData,...Xo.defaultData,flatShading:!1,wireframe:!1,geometry:{...qo.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:Ii(s.states),events:Ii(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Ii(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function LF(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new it,move:new it,jump:new it}});else{let n=new it;Object.assign(s,{actions:n}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&n.push({fi:0,id:st.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((a,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},d={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(d,Gh(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(d,{control1:{...a.control1},control2:{...a.control2}});let c={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},u={state:a.state,...c,...d},p={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new it({fi:0,id:st.generateUUID(),data:h},{fi:1,id:st.generateUUID(),data:u})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function RF(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new it,o=[];if(i.events.forEach((l,h,d)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...Gh(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...Gh(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&a.push({fi:d,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),a.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):i.events.insertBefore(null,[{id:st.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Px(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Pr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Dx(e){Uo(e,Px),Fo(e,Px)}function IF(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function BF(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function zF(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=yr.defaultTwoLayerData("phong"))})}function NF(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function UF(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function FF(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function kF(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function jF(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function GF(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function VF(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=gu.defaultDataThirdPerson.navmesh)})})}function HF(e){e.scene.styles||(e.scene.styles=Xh.defaultData())}function Ox(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function WF(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Fo(e,Ox),Uo(e,Ox)}var Lx=41;function qF(e){let t=e.schema??0;t!==Lx&&(console.warn("updating from ",t,"to ",Lx),t<1&&(Fo(e,Ax),Uo(e,Ax),e.schema=1),t<2&&(uF(e),e.schema=2),t<3&&(fF(e),e.schema=3),t<4&&(mF(e),e.schema=4),t<5&&(gF(e),e.schema=5),t<6&&(vF(e),e.schema=6),t<7&&(yF(e),e.schema=7),t<8&&(e.schema=8),t<9&&(Ex(e),e.schema=9),t<10&&(_F(e),e.schema=10),t<11&&(SF(e),e.schema=11),t<12&&(Ex(e),e.schema=12),t<13&&(AF(e),e.schema=13),t<14&&(EF(e),e.schema=14),t<15&&(CF(e),e.schema=15),t<16&&(TF(e),e.schema=16),t<17&&(Fo(e,Cx),Uo(e,Cx),e.schema=17),t<18&&(Fo(e,Mx),Uo(e,Mx),e.schema=18),t<19&&(pF(e),e.schema=19),t<20&&(PF(e),OF(e),e.schema=20),t<21&&(LF(e),RF(e),e.schema=21),t<22&&(Dx(e),e.schema=22),t<23&&(IF(e),e.schema=23),t<24&&(BF(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(MF(e),t<25&&(e.schema=25)),t<26&&(xF(e),e.schema=26),t<27&&(wF(e),e.schema=27),t<28&&(Dx(e),e.schema=28),t<29&&(bF(e),e.schema=29),t<30&&(zF(e),e.schema=30),t<31&&(NF(e),e.schema=31),t<33&&(UF(e),e.schema=33),t<34&&(FF(e),e.schema=34),t<35&&(kF(e),e.schema=35),t<36&&(jF(e),e.schema=36),t<37&&(GF(e),e.schema=37),t<38&&(Fo(e,Tx),Uo(e,Tx),e.schema=38),t<39&&(VF(e),e.schema=39),t<40&&(HF(e),e.schema=40),t<41&&(WF(e),e.schema=41))}function Ta(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),n={},a={},o=e[0].morphTargetsRelative,l=new He,h=0;for(let d=0;d<e.length;++d){let c=e[d],u=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,d),h+=p}}if(i){let d=0,c=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let g=0;g<p.count;++g)c.push(p.getX(g)+d);d+=e[u].attributes.position.count}l.setIndex(c)}for(let d in n){let c=Rx(n[d]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,c)}for(let d in a){let c=a[d][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let u=0;u<c;++u){let p=[];for(let f=0;f<a[d].length;++f)p.push(a[d][f][u]);let g=Rx(p);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(g)}}return l}function Rx(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let n=new t(s),a=0;for(let o=0;o<e.length;++o)n.set(e[o].array,a),a+=e[o].array.length;return new qe(n,i,r)}var XF=Math.pow(2,-24),Kc=class{constructor(){}};function Es(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function Ix(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function Bx(e,t){t.set(e)}function zx(e,t,i){let r,s;for(let n=0;n<3;n++){let a=n+3;r=e[n],s=t[n],i[n]=r<s?r:s,r=e[a],s=t[a],i[a]=r>s?r:s}}function Jc(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],n=t[e+2*r+1],a=s-n,o=s+n;a<i[r]&&(i[r]=a),o>i[r+3]&&(i[r+3]=o)}}function Xl(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function YF(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new qe(s,1));for(let n=0;n<i;n++)s[n]=n}}function QF(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,n)=>s-n);for(let s=0;s<r.length-1;s++){let n=r[s],a=r[s+1];t.push({offset:n/3,count:(a-n)/3})}return t}function cf(e,t,i,r,s=null){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0,c=1/0,u=1/0,p=1/0,g=-1/0,f=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let w=e[y+0],_=e[y+1],S=w-_,A=w+_;S<n&&(n=S),A>l&&(l=A),v&&w<c&&(c=w),v&&w>g&&(g=w);let b=e[y+2],E=e[y+3],C=b-E,T=b+E;C<a&&(a=C),T>h&&(h=T),v&&b<u&&(u=b),v&&b>f&&(f=b);let P=e[y+4],L=e[y+5],D=P-L,j=P+L;D<o&&(o=D),j>d&&(d=j),v&&P<p&&(p=P),v&&P>m&&(m=P)}r[0]=n,r[1]=a,r[2]=o,r[3]=l,r[4]=h,r[5]=d,v&&(s[0]=c,s[1]=u,s[2]=p,s[3]=g,s[4]=f,s[5]=m)}function ZF(e,t,i,r){let s=1/0,n=1/0,a=1/0,o=-1/0,l=-1/0,h=-1/0;for(let d=t*6,c=(t+i)*6;d<c;d+=6){let u=e[d+0];u<s&&(s=u),u>o&&(o=u);let p=e[d+2];p<n&&(n=p),p>l&&(l=p);let g=e[d+4];g<a&&(a=g),g>h&&(h=g)}r[0]=s,r[1]=n,r[2]=a,r[3]=o,r[4]=l,r[5]=h}function KF(e,t,i,r,s){let n=i,a=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;n<=a&&t[n*6+l]<o;)n++;for(;n<=a&&t[a*6+l]>=o;)a--;if(n<a){for(let h=0;h<3;h++){let d=e[n*3+h];e[n*3+h]=e[a*3+h],e[a*3+h]=d;let c=t[n*6+h*2+0];t[n*6+h*2+0]=t[a*6+h*2+0],t[a*6+h*2+0]=c;let u=t[n*6+h*2+1];t[n*6+h*2+1]=t[a*6+h*2+1],t[a*6+h*2+1]=u}n++,a--}else return n}}var en=32,JF=(e,t)=>e.candidate-t.candidate,Cn=new Array(en).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),$c=new Float32Array(6);function $F(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=Ix(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=Ix(e),a!==-1&&(o=e6(i,r,s,a));else if(n===2){let l=Xl(e),h=1.25*s,d=r*6,c=(r+s)*6;for(let u=0;u<3;u++){let p=t[u],g=(t[u+3]-p)/en;if(s<en/4){let f=[...Cn];f.length=s;let m=0;for(let y=d;y<c;y+=6,m++){let x=f[m];x.candidate=i[y+2*u],x.count=0;let{bounds:w,leftCacheBounds:_,rightCacheBounds:S}=x;for(let A=0;A<3;A++)S[A]=1/0,S[A+3]=-1/0,_[A]=1/0,_[A+3]=-1/0,w[A]=1/0,w[A+3]=-1/0;Jc(y,i,w)}f.sort(JF);let v=s;for(let y=0;y<v;y++){let x=f[y];for(;y+1<v&&f[y+1].candidate===x.candidate;)f.splice(y+1,1),v--}for(let y=d;y<c;y+=6){let x=i[y+2*u];for(let w=0;w<v;w++){let _=f[w];x>=_.candidate?Jc(y,i,_.rightCacheBounds):(Jc(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=f[y],w=x.count,_=s-x.count,S=x.leftCacheBounds,A=x.rightCacheBounds,b=0;w!==0&&(b=Xl(S)/l);let E=0;_!==0&&(E=Xl(A)/l);let C=1+1.25*(b*w+E*_);C<h&&(a=u,h=C,o=x.candidate)}}else{for(let v=0;v<en;v++){let y=Cn[v];y.count=0,y.candidate=p+g+v*g;let x=y.bounds;for(let w=0;w<3;w++)x[w]=1/0,x[w+3]=-1/0}for(let v=d;v<c;v+=6){let y=~~((i[v+2*u]-p)/g);y>=en&&(y=en-1);let x=Cn[y];x.count++,Jc(v,i,x.bounds)}let f=Cn[en-1];Bx(f.bounds,f.rightCacheBounds);for(let v=en-2;v>=0;v--){let y=Cn[v],x=Cn[v+1];zx(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<en-1;v++){let y=Cn[v],x=y.count,w=y.bounds,_=Cn[v+1].rightCacheBounds;x!==0&&(m===0?Bx(w,$c):zx(w,$c,$c)),m+=x;let S=0,A=0;m!==0&&(S=Xl($c)/l);let b=s-m;b!==0&&(A=Xl(_)/l);let E=1+1.25*(S*m+A*b);E<h&&(a=u,h=E,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function e6(e,t,i,r){let s=0;for(let n=t,a=t+i;n<a;n++)s+=e[n*6+r*2];return s/i}function t6(e,t){let i=e.attributes.position,r=i.array,s=e.index.array,n=s.length/3,a=new Float32Array(n*6),o=i.offset||0,l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);for(let h=0;h<n;h++){let d=h*3,c=h*6,u=s[d+0]*l+o,p=s[d+1]*l+o,g=s[d+2]*l+o;for(let f=0;f<3;f++){let m=r[u+f],v=r[p+f],y=r[g+f],x=m;v<x&&(x=v),y<x&&(x=y);let w=m;v>w&&(w=v),y>w&&(w=y);let _=(w-x)/2,S=f*2;a[c+S+0]=x+_,a[c+S+1]=_+(Math.abs(x)+_)*XF,x<t[f]&&(t[f]=x),w>t[f+3]&&(t[f+3]=w)}}return a}function i6(e,t){function i(v){u&&u(v/p)}function r(v,y,x,w=null,_=0){if(!g&&_>=l&&(g=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=d||_>=l)return i(y+x),v.offset=y,v.count=x,v;let S=$F(v.boundingData,w,a,y,x,c);if(S.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let A=KF(o,a,y,x,S);if(A===y||A===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=S.axis;let b=new Kc,E=y,C=A-y;v.left=b,b.boundingData=new Float32Array(6),cf(a,E,C,b.boundingData,n),r(b,E,C,n,_+1);let T=new Kc,P=A,L=x-C;v.right=T,T.boundingData=new Float32Array(6),cf(a,P,L,T.boundingData,n),r(T,P,L,n,_+1)}return v}YF(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=t6(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,d=t.maxLeafTris,c=t.strategy,u=t.onProgress,p=e.index.count/3,g=!1,f=[],m=QF(e);if(m.length===1){let v=m[0],y=new Kc;y.boundingData=s,ZF(a,v.offset,v.count,n),r(y,v.offset,v.count,n),f.push(y)}else for(let v of m){let y=new Kc;y.boundingData=new Float32Array(6),cf(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),f.push(y)}return f}function r6(e,t){let i=i6(e,t),r,s,n,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let d=0;d<i.length;d++){let c=i[d],u=l(c),p=new o(32*u);r=new Float32Array(p),s=new Uint32Array(p),n=new Uint16Array(p),h(0,c),a.push(p)}return a;function l(d){return d.count?1:1+l(d.left)+l(d.right)}function h(d,c){let u=d/4,p=d/2,g=!!c.count,f=c.boundingData;for(let m=0;m<6;m++)r[u+m]=f[m];if(g){let m=c.offset,v=c.count;return s[u+6]=m,n[p+14]=v,n[p+15]=65535,d+32}else{let m=c.left,v=c.right,y=c.splitAxis,x;if(x=h(d+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=x/4,x=h(x,v),s[u+7]=y,x}}}var zs=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,n=e.length;s<n;s++){let a=e[s][t];i=a<i?a:i,r=a>r?a:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,n=t.length;s<n;s++){let a=t[s],o=e.dot(a);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};zs.prototype.setFromBox=function(){let e=new M;return function(t,i){let r=i.min,s=i.max,n=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let d=t.dot(e);n=Math.min(d,n),a=Math.max(d,a)}this.min=n,this.max=a}}();var SW=function(){let e=new zs;return function(t,i){let r=t.points,s=t.satAxes,n=t.satBounds,a=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let d=n[h],c=s[h];if(e.setFromPoints(c,a),d.isSeparated(e))return!1}for(let h=0;h<3;h++){let d=l[h],c=o[h];if(e.setFromPoints(c,r),d.isSeparated(e))return!1}}}(),s6=function(){let e=new M,t=new M,i=new M;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,s.start),t.subVectors(s.end,s.start);let d=i.dot(h),c=h.dot(o),u=h.dot(h),p=i.dot(o),g=o.dot(o)*u-c*c,f,m;g!==0?f=(d*c-p*u)/g:f=0,m=(d+f*c)/u,n.x=f,n.y=m}}(),Mv=function(){let e=new k,t=new M,i=new M;return function(r,s,n,a){s6(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,n),s.at(l,a);return}else if(o>=0&&o<=1){l<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,n);return}else if(l>=0&&l<=1){o<0?r.at(0,n):r.at(1,n),s.closestPointToPoint(n,!0,a);return}else{let h;o<0?h=r.start:h=r.end;let d;l<0?d=s.start:d=s.end;let c=t,u=i;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(d)<=u.distanceToSquared(h)){n.copy(c),a.copy(d);return}else{n.copy(h),a.copy(u);return}}}}(),n6=function(){let e=new M,t=new M,i=new pr,r=new Rr;return function(s,n){let{radius:a,center:o}=s,{a:l,b:h,c:d}=n;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a||(r.start=l,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a)||(r.start=h,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a))return!0;let c=n.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=a){let u=c.projectPoint(o,t);if(n.containsPoint(u))return!0}return!1}}(),a6=1e-15;function vo(e){return Math.abs(e)<a6}var mn=class extends Ji{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M),this.satBounds=new Array(4).fill().map(()=>new zs),this.points=[this.a,this.b,this.c],this.sphere=new Nr,this.plane=new pr,this.needsUpdate=!0}intersectsSphere(e){return n6(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,n=this.satBounds,a=s[0],o=n[0];this.getNormal(a),o.setFromPoints(a,r);let l=s[1],h=n[1];l.subVectors(e,t),h.setFromPoints(l,r);let d=s[2],c=n[2];d.subVectors(t,i),c.setFromPoints(d,r);let u=s[3],p=n[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};mn.prototype.closestPointToSegment=function(){let e=new M,t=new M,i=new Rr;return function(r,s=null,n=null){let{start:a,end:o}=r,l=this.points,h,d=1/0;for(let c=0;c<3;c++){let u=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[u]),Mv(i,r,e,t),h=e.distanceToSquared(t),h<d&&(d=h,s&&s.copy(e),n&&n.copy(t))}return this.closestPointToPoint(a,e),h=a.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),n&&n.copy(a)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),n&&n.copy(o)),Math.sqrt(d)}}();mn.prototype.intersectsTriangle=function(){let e=new mn,t=new Array(3),i=new Array(3),r=new zs,s=new zs,n=new M,a=new M,o=new M,l=new M,h=new Rr,d=new Rr,c=new Rr;return function(u,p=null){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let g=this.plane,f=u.plane;if(Math.abs(g.normal.dot(f.normal))>1-1e-10){let m=this.satBounds,v=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let w=0;w<4;w++){let _=m[w],S=v[w];if(r.setFromPoints(S,i),_.isSeparated(r))return!1}let y=u.satBounds,x=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let _=y[w],S=x[w];if(r.setFromPoints(S,t),_.isSeparated(r))return!1}for(let w=0;w<4;w++){let _=v[w];for(let S=0;S<4;S++){let A=x[S];if(n.crossVectors(_,A),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let m=this.points,v=!1,y=0;for(let P=0;P<3;P++){let L=m[P],D=m[(P+1)%3];h.start.copy(L),h.end.copy(D),h.delta(a);let j=v?d.start:d.end,W=vo(f.distanceToPoint(L));if(vo(f.normal.dot(a))&&W){d.copy(h),y=2;break}if((f.intersectLine(h,j)||W)&&!vo(j.distanceTo(D))){if(y++,v)break;v=!0}}if(y===1&&this.containsPoint(d.start))return p&&(p.start.copy(d.start),p.end.copy(d.start)),!0;if(y!==2)return!1;let x=u.points,w=!1,_=0;for(let P=0;P<3;P++){let L=x[P],D=x[(P+1)%3];h.start.copy(L),h.end.copy(D),h.delta(o);let j=w?c.start:c.end,W=vo(g.distanceToPoint(L));if(vo(g.normal.dot(o))&&W){c.copy(h),_=2;break}if((g.intersectLine(h,j)||W)&&!vo(j.distanceTo(D))){if(_++,w)break;w=!0}}if(_===1&&this.containsPoint(c.start))return p&&(p.start.copy(c.start),p.end.copy(c.start)),!0;if(_!==2)return!1;if(d.delta(a),c.delta(o),a.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let S=d.start.dot(a),A=d.end.dot(a),b=c.start.dot(a),E=c.end.dot(a),C=A<b,T=S<E;return S!==E&&b!==A&&C===T?!1:(p&&(l.subVectors(d.start,c.start),l.dot(a)>0?p.start.copy(d.start):p.start.copy(c.start),l.subVectors(d.end,c.end),l.dot(a)<0?p.end.copy(d.end):p.end.copy(c.end)),!0)}}}();mn.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();mn.prototype.distanceToTriangle=function(){let e=new M,t=new M,i=["a","b","c"],r=new Rr,s=new Rr;return function(n,a=null,o=null){let l=a||o?r:null;if(this.intersectsTriangle(n,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let d=0;d<3;d++){let c,u=i[d],p=n[u];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,a&&a.copy(e),o&&o.copy(p));let g=this[u];n.closestPointToPoint(g,e),c=g.distanceToSquared(e),c<h&&(h=c,a&&a.copy(g),o&&o.copy(e))}for(let d=0;d<3;d++){let c=i[d],u=i[(d+1)%3];r.set(this[c],this[u]);for(let p=0;p<3;p++){let g=i[p],f=i[(p+1)%3];s.set(n[g],n[f]),Mv(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Ns=class extends si{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new me,this.invMatrix=new me,this.points=new Array(8).fill().map(()=>new M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new zs),this.alignedSatBounds=new Array(3).fill().map(()=>new zs),this.needsUpdate=!1}set(e,t,i){super.set(e,t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Ns.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){let c=1*l|2*h|4*d,u=r[c];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=d?i.z:t.z,u.applyMatrix4(e)}let s=this.satBounds,n=this.satAxes,a=r[0];for(let l=0;l<3;l++){let h=n[l],d=s[l],c=1<<l,u=r[c];h.subVectors(a,u),d.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Ns.prototype.intersectsBox=function(){let e=new zs;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,n=this.satAxes,a=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,a[0].isSeparated(e)||(e.min=i.y,e.max=r.y,a[1].isSeparated(e))||(e.min=i.z,e.max=r.z,a[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=n[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Ns.prototype.intersectsTriangle=function(){let e=new mn,t=new Array(3),i=new zs,r=new zs,s=new M;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);let a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let c=0;c<3;c++){let u=a[c],p=o[c];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=n.satBounds,h=n.satAxes,d=this.points;for(let c=0;c<3;c++){let u=l[c],p=h[c];if(i.setFromPoints(p,d),u.isSeparated(i))return!1}for(let c=0;c<3;c++){let u=o[c];for(let p=0;p<4;p++){let g=h[p];if(s.crossVectors(u,g),i.setFromPoints(s,t),r.setFromPoints(s,d),i.isSeparated(r))return!1}}return!0}}();Ns.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Ns.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ns.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Rr),i=new Array(12).fill().map(()=>new Rr),r=new M,s=new M;return function(n,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(s),this.closestPointToPoint(s,r),n.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=a*a,d=n.min,c=n.max,u=this.points,p=1/0;for(let f=0;f<8;f++){let m=u[f];s.copy(m).clamp(d,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let g=0;for(let f=0;f<3;f++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(f+1)%3,x=(f+2)%3,w=m<<y|v<<x,_=1<<f|m<<y|v<<x,S=u[w],A=u[_];t[g].set(S,A);let b=e[f],E=e[y],C=e[x],T=i[g],P=T.start,L=T.end;P[b]=d[b],P[E]=m?d[E]:c[E],P[C]=v?d[C]:c[E],L[b]=c[b],L[E]=m?d[E]:c[E],L[C]=v?d[C]:c[E],g++}for(let f=0;f<=1;f++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=f?c.x:d.x,s.y=m?c.y:d.y,s.z=v?c.z:d.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let f=0;f<12;f++){let m=t[f];for(let v=0;v<12;v++){let y=i[v];Mv(m,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var ed=new M,td=new M,id=new M,Nx=new k,Ux=new k,Fx=new k,kx=new M;function o6(e,t,i,r,s,n){let a;return n===gi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==mr,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function l6(e,t,i,r,s,n,a){ed.fromBufferAttribute(t,r),td.fromBufferAttribute(t,s),id.fromBufferAttribute(t,n);let o=o6(e,ed,td,id,kx,a);if(o){i&&(Nx.fromBufferAttribute(i,r),Ux.fromBufferAttribute(i,s),Fx.fromBufferAttribute(i,n),o.uv=Ji.getUV(kx,ed,td,id,Nx,Ux,Fx,new k));let l={a:r,b:s,c:n,normal:new M,materialIndex:0};Ji.getNormal(ed,td,id,l.normal),o.face=l,o.faceIndex=r}return o}function QS(e,t,i,r,s){let n=r*3,a=e.index.getX(n),o=e.index.getX(n+1),l=e.index.getX(n+2),h=l6(i,e.attributes.position,e.attributes.uv,a,o,l,t);return h?(h.faceIndex=r,s&&s.push(h),h):null}function h6(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)QS(e,t,i,a,n)}function c6(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=QS(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function ZS(e,t,i){return e===null||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far)?null:e}function Ss(e,t,i,r){let s=e.a,n=e.b,a=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),n.x=r.getX(l),n.y=r.getY(l),n.z=r.getZ(l),a.x=r.getX(h),a.y=r.getY(h),a.z=r.getZ(h)}function jx(e,t,i,r,s,n,a){let o=i.index,l=i.attributes.position;for(let h=e,d=t+e;h<d;h++)if(Ss(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var KS=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function kn(e,t){return t[e+15]===65535}function Yo(e,t){return t[e+6]}function Yh(e,t){return t[e+14]}function Qh(e){return e+8}function Zh(e,t){return t[e+6]}function d6(e,t){return t[e+7]}var ko=new si,vu=new M,u6=["x","y","z"];function Jm(e,t,i,r,s){let n=e*2,a=El,o=Zn,l=Kn;if(kn(n,o)){let h=Yo(e,l),d=Yh(n,o);h6(t,i,r,h,d,s)}else{let h=Qh(e);yu(h,a,r,vu)&&Jm(h,t,i,r,s);let d=Zh(e,l);yu(d,a,r,vu)&&Jm(d,t,i,r,s)}}function $m(e,t,i,r){let s=e*2,n=El,a=Zn,o=Kn;if(kn(s,a)){let l=Yo(e,o),h=Yh(s,a);return c6(t,i,r,l,h)}else{let l=d6(e,o),h=u6[l],d=r.direction[h]>=0,c,u;d?(c=Qh(e),u=Zh(e,o)):(c=Zh(e,o),u=Qh(e));let p=yu(c,n,r,vu)?$m(c,t,i,r):null;if(p){let f=p.point[h];if(d?f<=n[u+l]:f>=n[u+l+3])return p}let g=yu(u,n,r,vu)?$m(u,t,i,r):null;return p&&g?p.distance<=g.distance?p:g:p||g||null}}var p6=function(){let e,t,i=[],r=new KS(()=>new si);return function(...n){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let a=s(...n);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),a};function s(n,a,o,l,h=null,d=0,c=0){function u(y){let x=y*2,w=Zn,_=Kn;for(;!kn(x,w);)y=Qh(y),x=y*2;return Yo(y,_)}function p(y){let x=y*2,w=Zn,_=Kn;for(;!kn(x,w);)y=Zh(y,_),x=y*2;return Yo(y,_)+Yh(x,w)}let g=n*2,f=El,m=Zn,v=Kn;if(kn(g,m)){let y=Yo(n,v),x=Yh(g,m);return Es(n,f,e),l(y,x,!1,c,d+n,e)}else{let y=Qh(n),x=Zh(n,v),w=y,_=x,S,A,b,E;if(h&&(b=e,E=t,Es(w,f,b),Es(_,f,E),S=h(b),A=h(E),A<S)){w=x,_=y;let W=S;S=A,A=W,b=E}b||(b=e,Es(w,f,b));let C=kn(w*2,m),T=o(b,C,S,c+1,d+w),P;if(T===2){let W=u(w),q=p(w)-W;P=l(W,q,!0,c+1,d+w,b)}else P=T&&s(w,a,o,l,h,d,c+1);if(P)return!0;E=t,Es(_,f,E);let L=kn(_*2,m),D=o(E,L,A,c+1,d+_),j;if(D===2){let W=u(_),q=p(_)-W;j=l(W,q,!0,c+1,d+_,E)}else j=D&&s(_,a,o,l,h,d,c+1);return!!j}}}(),f6=function(){let e=new mn,t=new mn,i=new me,r=new Ns,s=new Ns;return function n(a,o,l,h,d=null){let c=a*2,u=El,p=Zn,g=Kn;if(d===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),d=r),kn(c,p)){let f=o,m=f.index,v=f.attributes.position,y=l.index,x=l.attributes.position,w=Yo(a,g),_=Yh(c,p);if(i.copy(h).invert(),l.boundsTree)return Es(a,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>s.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(h),S.b.applyMatrix4(h),S.c.applyMatrix4(h),S.needsUpdate=!0;for(let A=w*3,b=(_+w)*3;A<b;A+=3)if(Ss(t,A,m,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let S=w*3,A=_+w*3;S<A;S+=3){Ss(e,S,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let b=0,E=y.count;b<E;b+=3)if(Ss(t,b,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let f=a+8,m=g[a+6];return Es(f,u,ko),!!(d.intersectsBox(ko)&&n(f,o,l,h,d)||(Es(m,u,ko),d.intersectsBox(ko)&&n(m,o,l,h,d)))}}}();function yu(e,t,i,r){return Es(e,t,ko),i.intersectBox(ko,r)}var eg=[],Ld,El,Zn,Kn;function mh(e){Ld&&eg.push(Ld),Ld=e,El=new Float32Array(e),Zn=new Uint16Array(e),Kn=new Uint32Array(e)}function rd(){Ld=null,El=null,Zn=null,Kn=null,eg.length&&mh(eg.pop())}var df=Symbol("skip tree generation"),uf=new si,pf=new si,yo=new me,fa=new Ns,Yl=new Ns,Ql=new M,sd=new M,m6=new M,g6=new M,v6=new M,Gx=new si,ds=new KS(()=>new mn),Ai=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ai.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),n;return t.cloneBuffers?n={roots:r.map(a=>a.slice()),index:s.array.slice()}:n={roots:r,index:s.array},n}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ai.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,n=new Ai(t,{...i,[df]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new qe(e.index,1,!1);t.setIndex(o)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return n}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[df]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[df]||(this._roots=r6(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new si))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s=r.array,n=r.offset||0,a=3;r.isInterleavedBufferAttribute&&(a=r.data.stride);let o,l,h,d,c=0,u=this._roots;for(let g=0,f=u.length;g<f;g++)o=u[g],l=new Uint32Array(o),h=new Uint16Array(o),d=new Float32Array(o),p(0,c),c+=o.byteLength;function p(g,f,m=!1){let v=g*2;if(h[v+15]===65535){let y=l[g+6],x=h[v+14],w=1/0,_=1/0,S=1/0,A=-1/0,b=-1/0,E=-1/0;for(let C=3*y,T=3*(y+x);C<T;C++){let P=i[C]*a+n,L=s[P+0],D=s[P+1],j=s[P+2];L<w&&(w=L),L>A&&(A=L),D<_&&(_=D),D>b&&(b=D),j<S&&(S=j),j>E&&(E=j)}return d[g+0]!==w||d[g+1]!==_||d[g+2]!==S||d[g+3]!==A||d[g+4]!==b||d[g+5]!==E?(d[g+0]=w,d[g+1]=_,d[g+2]=S,d[g+3]=A,d[g+4]=b,d[g+5]=E,!0):!1}else{let y=g+8,x=l[g+6],w=y+f,_=x+f,S=m,A=!1,b=!1;e?S||(A=e.has(w),b=e.has(_),S=!A&&!b):(A=!0,b=!0);let E=S||A,C=S||b,T=!1;E&&(T=p(y,f,S));let P=!1;C&&(P=p(x,f,S));let L=T||P;if(L)for(let D=0;D<3;D++){let j=y+D,W=x+D,q=d[j],z=d[j+3],V=d[W],F=d[W+3];d[g+D]=q<V?q:V,d[g+D+3]=z>F?z:F}return L}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);n(0);function n(a,o=0){let l=a*2,h=s[l+15]===65535;if(h){let d=r[a+6],c=s[l+14];e(o,h,new Float32Array(i,a*4,6),d,c)}else{let d=a+8,c=r[a+6],u=r[a+7];e(o,h,new Float32Array(i,a*4,6),u)||(n(d,o+1),n(c,o+1))}}}raycast(e,t=rs){let i=this._roots,r=this.geometry,s=[],n=t.isMaterial,a=Array.isArray(t),o=r.groups,l=n?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=a?t[o[h].materialIndex].side:l,u=s.length;if(mh(i[h]),Jm(0,r,c,e,s),rd(),a){let p=o[h].materialIndex;for(let g=u,f=s.length;g<f;g++)s[g].face.materialIndex=p}}return s}raycastFirst(e,t=rs){let i=this._roots,r=this.geometry,s=t.isMaterial,n=Array.isArray(t),a=null,o=r.groups,l=s?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=n?t[o[h].materialIndex].side:l;mh(i[h]);let u=$m(0,r,c,e);rd(),u!=null&&(a==null||u.distance<a.distance)&&(a=u,n&&(u.face.materialIndex=o[h].materialIndex))}return a}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(mh(s),r=f6(0,i,e,t),rd(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(u,p,g,f)=>{let m=p*3;return c(u,m,m+1,m+2,g,f)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=ds.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(u,p,g,f,m)=>c(u,p,g,f,m)?!0:jx(u,p,r,l,g,f,s)}else o||(l?o=(c,u,p,g)=>jx(c,u,r,l,p,g,s):o=(c,u,p)=>p);let h=!1,d=0;for(let c of this._roots){if(mh(c),h=p6(0,r,a,o,n,d),rd(),h)break;d+=c.byteLength}return ds.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,n=this.geometry.index,a=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;yo.copy(t).invert();let h=ds.getPrimitive(),d=ds.getPrimitive();if(s){let u=function(p,g,f,m,v,y,x,w){for(let _=f,S=f+m;_<S;_++){Ss(d,_*3,o,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=p,b=p+g;A<b;A++)if(Ss(h,A*3,n,a),h.needsUpdate=!0,s(h,d,A,_,v,y,x,w))return!0}return!1};if(r){let p=r;r=function(g,f,m,v,y,x,w,_){return p(g,f,m,v,y,x,w,_)?!0:u(g,f,m,v,y,x,w,_)}}else r=u}e.getBoundingBox(pf),pf.applyMatrix4(t);let c=this.shapecast({intersectsBounds:u=>pf.intersectsBox(u),intersectsRange:(u,p,g,f,m,v)=>(uf.copy(v),uf.applyMatrix4(yo),e.shapecast({intersectsBounds:y=>uf.intersectsBox(y),intersectsRange:(y,x,w,_,S)=>r(u,p,y,x,f,m,_,S)}))});return ds.releasePrimitive(h),ds.releasePrimitive(d),c}intersectsBox(e,t){return fa.set(e.min,e.max,t),fa.needsUpdate=!0,this.shapecast({intersectsBounds:i=>fa.intersectsBox(i),intersectsTriangle:i=>fa.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,n=1/0){e.boundingBox||e.computeBoundingBox(),fa.set(e.boundingBox.min,e.boundingBox.max,t),fa.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,d=e.index,c=ds.getPrimitive(),u=ds.getPrimitive(),p=sd,g=m6,f=null,m=null;r&&(f=g6,m=v6);let v=1/0,y=null,x=null;return yo.copy(t).invert(),Yl.matrix.copy(yo),this.shapecast({boundsTraverseOrder:w=>fa.distanceToBox(w),intersectsBounds:(w,_,S)=>S<v&&S<n?(_&&(Yl.min.copy(w.min),Yl.max.copy(w.max),Yl.needsUpdate=!0),!0):!1,intersectsRange:(w,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>Yl.distanceToBox(S),intersectsBounds:(S,A,b)=>b<v&&b<n,intersectsRange:(S,A)=>{for(let b=S*3,E=(S+A)*3;b<E;b+=3){Ss(u,b,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=w*3,T=(w+_)*3;C<T;C+=3){Ss(c,C,l,o),c.needsUpdate=!0;let P=c.distanceToTriangle(u,p,f);if(P<v&&(g.copy(p),m&&m.copy(f),v=P,y=C/3,x=b/3),P<s)return!0}}}});{let S=d?d.count:h.count;for(let A=0,b=S;A<b;A+=3){Ss(u,A,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let E=w*3,C=(w+_)*3;E<C;E+=3){Ss(c,E,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(u,p,f);if(T<v&&(g.copy(p),m&&m.copy(f),v=T,y=E/3,x=A/3),T<s)return!0}}}}}),ds.releasePrimitive(c),ds.releasePrimitive(u),v===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(yo),g.applyMatrix4(yo),r.distance=g.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,n=r*r,a=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Ql.copy(e).clamp(h.min,h.max),Ql.distanceToSquared(e)),intersectsBounds:(h,d,c)=>c<a&&c<n,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Ql);let c=e.distanceToSquared(Ql);return c<a&&(sd.copy(Ql),a=c,o=d),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(sd):t.point=sd.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Es(0,new Float32Array(t),Gx),e.union(Gx)}),e}},Vx=Ai.prototype.raycast;Ai.prototype.raycast=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,i,r,s]=e;return Vx.call(this,r,t.material).forEach(n=>{n=ZS(n,t,i),n&&s.push(n)}),s}else return Vx.apply(this,e)};var Hx=Ai.prototype.raycastFirst;Ai.prototype.raycastFirst=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,i,r]=e;return ZS(Hx.call(this,r,t.material),t,i)}else return Hx.apply(this,e)};var Wx=Ai.prototype.closestPointToPoint;Ai.prototype.closestPointToPoint=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),e.unshift();let t=e[1],i={};return e[1]=i,Wx.apply(this,e),t&&t.copy(i.point),i.distance}else return Wx.apply(this,e)};var qx=Ai.prototype.closestPointToGeometry;Ai.prototype.closestPointToGeometry=function(...e){let t=e[2],i=e[3];if(t&&t.isVector3||i&&i.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let r={},s={},n=e[1];return e[2]=r,e[3]=s,qx.apply(this,e),t&&t.copy(r.point),i&&i.copy(s.point).applyMatrix4(n),r.distance}else return qx.apply(this,e)};var Xx=Ai.prototype.refit;Ai.prototype.refit=function(...e){let t=e[0],i=e[1];if(i&&(i instanceof Set||Array.isArray(i))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let r=new Set;i.forEach(s=>r.add(s)),t&&t.forEach(s=>r.add(s)),Xx.call(this,r)}else Xx.apply(this,e)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(e=>{let t=Ai.prototype[e];Ai.prototype[e]=function(...i){return(i[0]===null||i[0].isMesh)&&(i.shift(),console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,i)}});var Zl=$h(XM()),y6=.5*(Math.sqrt(3)-1),Kl=(3-Math.sqrt(3))/6,x6=1/3,us=1/6,AW=(Math.sqrt(5)-1)/4,MW=(5-Math.sqrt(5))/20,Eh=e=>Math.floor(e)|0,Yx=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]),ff=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 mf(e=Math.random){let t=JS(e),i=new Float64Array(t).map(s=>Yx[s%12*2]),r=new Float64Array(t).map(s=>Yx[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*y6,d=Eh(s+h),c=Eh(n+h),u=(d+c)*Kl,p=d-u,g=c-u,f=s-p,m=n-g,v,y;f>m?(v=1,y=0):(v=0,y=1);let x=f-v+Kl,w=m-y+Kl,_=f-1+2*Kl,S=m-1+2*Kl,A=d&255,b=c&255,E=.5-f*f-m*m;if(E>=0){let P=A+t[b],L=i[P],D=r[P];E*=E,a=E*E*(L*f+D*m)}let C=.5-x*x-w*w;if(C>=0){let P=A+v+t[b+y],L=i[P],D=r[P];C*=C,o=C*C*(L*x+D*w)}let T=.5-_*_-S*S;if(T>=0){let P=A+1+t[b+1],L=i[P],D=r[P];T*=T,l=T*T*(L*_+D*S)}return 70*(a+o+l)}}function w6(e=Math.random){let t=JS(e),i=new Float64Array(t).map(n=>ff[n%12*3]),r=new Float64Array(t).map(n=>ff[n%12*3+1]),s=new Float64Array(t).map(n=>ff[n%12*3+2]);return function(n,a,o){let l,h,d,c,u=(n+a+o)*x6,p=Eh(n+u),g=Eh(a+u),f=Eh(o+u),m=(p+g+f)*us,v=p-m,y=g-m,x=f-m,w=n-v,_=a-y,S=o-x,A,b,E,C,T,P;w>=_?_>=S?(A=1,b=0,E=0,C=1,T=1,P=0):w>=S?(A=1,b=0,E=0,C=1,T=0,P=1):(A=0,b=0,E=1,C=1,T=0,P=1):_<S?(A=0,b=0,E=1,C=0,T=1,P=1):w<S?(A=0,b=1,E=0,C=0,T=1,P=1):(A=0,b=1,E=0,C=1,T=1,P=0);let L=w-A+us,D=_-b+us,j=S-E+us,W=w-C+2*us,q=_-T+2*us,z=S-P+2*us,V=w-1+3*us,F=_-1+3*us,N=S-1+3*us,B=p&255,H=g&255,X=f&255,Q=.6-w*w-_*_-S*S;if(Q<0)l=0;else{let $=B+t[H+t[X]];Q*=Q,l=Q*Q*(i[$]*w+r[$]*_+s[$]*S)}let U=.6-L*L-D*D-j*j;if(U<0)h=0;else{let $=B+A+t[H+b+t[X+E]];U*=U,h=U*U*(i[$]*L+r[$]*D+s[$]*j)}let ne=.6-W*W-q*q-z*z;if(ne<0)d=0;else{let $=B+C+t[H+T+t[X+P]];ne*=ne,d=ne*ne*(i[$]*W+r[$]*q+s[$]*z)}let G=.6-V*V-F*F-N*N;if(G<0)c=0;else{let $=B+1+t[H+1+t[X+1]];G*=G,c=G*G*(i[$]*V+r[$]*F+s[$]*N)}return 32*(l+h+d+c)}}function JS(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Wr=new Ji,b6=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Wr.a.fromBufferAttribute(e,r),Wr.b.fromBufferAttribute(e,r+1),Wr.c.fromBufferAttribute(e,r+2),s*=Wr.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||t[n-1]<=e&&t[n]>e){s=n;break}else e<t[n]?r=n-1:i=n+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Wr.a.fromBufferAttribute(this.positionAttribute,e*3),Wr.b.fromBufferAttribute(this.positionAttribute,e*3+1),Wr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Wr.a,r).addScaledVector(Wr.b,s).addScaledVector(Wr.c,1-(r+s)),Wr.getNormal(i),this}},_6=$h(Wb()),S6=new me,A6=new me,M6=new me,xu;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(xu||(xu={}));var Ev=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new me,this.copyPreviousMatrix=!0,this.hiddenMatrix=new me,this.matrixWorldRigid=new me,this.shearScale=new me,this.shearScaleInv=new me}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Et&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)xu.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:n}=(0,_6.SVD)(i),a=S6.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=A6.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=M6.copy(o).transpose();this.shearScale.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,l).copyPosition(this.matrixWorld),n.every(h=>Math.abs(n[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof me?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},E6=class extends Ev(Et){},C6=e=>e.type==="Mesh",Gi=class extends E6{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Gi(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return C6(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}},Sa=new M,Aa=new M,Qo=new me,$S=[new M(-1,1,1),new M(-1,-1,1),new M(1,-1,1),new M(1,1,1),new M(-1,1,-1),new M(-1,-1,-1),new M(1,-1,-1),new M(1,1,-1)],T6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],P6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Qx=(e,t,i)=>{e.updateEntityBoxSize(Sa,Aa),Qo.copy(t).multiply(e.matrixWorld),Aa.x===0&&Aa.y===0&&Aa.z===0?i.push(new M(Sa.x,Sa.y,Sa.z).applyMatrix4(Qo)):$S.forEach(r=>{i.push(r.clone().multiply(Aa).add(Sa).applyMatrix4(Qo))})},Zx=class extends si{constructor(){super(...arguments),this.matrix=new me,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new me().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new M);return}Qx(s,t,r)}}):Qx(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Qo.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Aa).multiplyScalar(.5),this.getCenter(Sa),Qo.copy(this.matrix).setPosition(Sa),this.vertices=$S.map(e=>e.clone().multiply(Aa).applyMatrix4(Qo))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=T6.map(([e,t])=>new Rr(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new M))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=P6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},qn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},D6=class extends g_{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(e*l/s),d=o.getPoints(h);for(let c=0;c<d.length;c++){let u=d[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},tg=.001;function ig(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=tg}function gf(e,t){let i=new M(...e.position),r=new M(...e.controlNext.position),s=new M(...t.controlPrevious.position),n=new M(...t.position);return ig(i,r,n)&&ig(i,s,n)}function e2(e){let t=e.points.map(d=>new M(...d.data.position)),i=[e.points[0]],r=new M(...i[0].data.position);for(let d=0;d<e.points.length-1;d++)ig(r,t[d],t[d+1])||(i.push(e.points[d]),r=t[d]);i.push(e.points[e.points.length-1]);let s=e.isClosed,n=i.length-(s?0:1),a=i.length,o=[];for(let d=0;d<a;d++){let c=i[d].data,u=new M(...c.position),p=new M(...c.controlPrevious.position),g=new M(...c.controlNext.position),f={position:u,baseRoundness:c.roundness,controlPrevious:p,controlNext:g};if(c.roundness===0||!e.isClosed&&(d===0||d===a-1)){o[d]={...f,removedLength:0};continue}let m=s&&d==0?a-1:d-1,v=s&&d==a-1?0:d+1,y=i[m].data,x=i[v].data,w=new M(...y.position),_=new M(...x.position),S=w.clone().sub(u).normalize(),A=_.clone().sub(u).normalize();Object.assign(f,{prevDir:S,nextDir:A});let b=gf(y,c),E=gf(c,x);if(!b||!E)o[d]={...f,removedLength:0};else{let C=S.clone().add(A).normalize(),T=C.clone().cross(S).length()/S.dot(C);o[d]={...f,tan:T,removedLength:c.roundness/T}}}for(let d=0;d<n;d++){let c=d,u=s&&d===a-1?0:d+1,p=o[c],g=o[u];if(p.removedLength!==0||g.removedLength!==0){let f=p.position.distanceTo(g.position);p.removedLength=Math.min(p.removedLength,f/2),g.removedLength=Math.min(g.removedLength,f/2)}}let l=[];for(let d=0;d<n;d++){let c=d,u=s&&d===a-1?0:d+1,p=o[c],g=o[u],f=null;if(!gf(i[c].data,i[u].data))p.position.distanceTo(g.position)>tg&&(f=new Cd(p.position,p.controlNext,g.controlPrevious,g.position));else{let m=p.position.clone(),v=g.position.clone();(p.removedLength!==0||g.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),g.prevDir&&v.add(g.prevDir.clone().setLength(g.removedLength))),m.distanceTo(v)>tg&&(f=new Cd(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*d+1]=f}for(let d=0;d<a;d++){let c=o[d];if(c.removedLength===0){l[2*d]=null;continue}let u=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(u),g=c.nextDir.clone().multiplyScalar(c.removedLength).add(u),f=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(g,.5),y=p.distanceTo(g)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(f,2)-Math.pow(y,2))).add(v),w=m.clone().multiplyScalar(-f).add(x),_=u.distanceTo(w)/u.distanceTo(v),S=c.prevDir.clone().multiplyScalar(_*u.distanceTo(p)).add(u),A=S.clone().lerp(w,2),b=p.clone().lerp(S,4/3),E=g.clone().lerp(A,4/3);l[2*d]=new Cd(p,b,E,g)}let h=new D6;return l.forEach(d=>{d&&h.add(d)}),h}var bt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(bt||(bt={}));var jn=e=>bt.is(e),O6={type:"completeState",isfromEntity:!0},t2=e=>class extends Ev(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new Zx,this._recursiveBBox=new Zx,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(bt.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(bt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)Ca.toOps(this.data,s.data).forEach(n=>{let a=Cm.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Ca.patch(this.data,s),Ca.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{jn(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(bt.is(i[r]))return i[r];if(bt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&bt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)jn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{bt.is(i)&&t(i)})}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)jn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)jn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>jn(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Em(i,t)}updateTransformState(t){let i=!1;return t.position&&(this.position.fromArray(t.position),i=!0),t.rotation&&(this.rotation.fromArray(t.rotation),i=!0),t.scale&&(i=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??hl.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)bt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{bt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Em(i,t)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=Fn(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let c=Os.zoom(d,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(h[u]=c[u])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:d,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:d,...c}=l;l=c}let h=Os.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Ca.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Fn(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let d of Object.keys(t.props)){l[l.length-1]=d;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[d],c.updateState(Ba.apply(c.component.data,c.overrideData),r))}}else{let d=r.scene.findInstance([this.uuid,...l]);if(d){let c=Os.zoom(d.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(c)for(let[p,g]of Object.entries(t.props))g===void 0&&(u===t.props&&(u={...t.props}),u[p]=c[p]);t={...t,props:u}}d.overrideData=uu.resolve(i.overrides,l),d.updateByOp(t,vr.applySimple(d.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let d of dl.rootOverrideProps)d in t.props&&(h===void 0&&(h={}),h[d]=t.props[d]);h&&(l={...t,props:h})}else for(let h of dl.rootOverrideProps)if(Fn(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Ba.filterOp(h.overrideData,l);d&&h.updateByOp(d,vr.applySimple(h.data,d),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Ba.filterOp(h.overrideData,t);if(d){let c;n===h.data&&t===d?c=i:c=vr.applySimple(h.data,d),h.updateByOp(d,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ha.is(t.props.type)&&qn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){qn.changeEntityProptotype(this,i,r);for(let s of this.children)bt.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Fn(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Fn(t.path,["cloner"])!==null){let s=vr.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=a.data,l=e2(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let d=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new me;a.updateMatrixWorld();let u=new me().multiplyMatrices(c.clone().invert(),a.matrixWorld);d.applyMatrix4(u);let p={position:d.toArray(),rotation:o.rotation};if(n==="tangential"){let g=new me().extractRotation(a.matrixWorld),f=l.getTangentAt(h).applyMatrix4(g).add(d),m=new me().lookAt(d,f,new M(0,1,0)),v=new bi().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(O6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof qn.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new qn.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}},i2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters),r=i.width/2,s=i.radiusTop??r,n=i.radiusBottom??r;return s===n?(s=r,n=r):s>n?(s=r,n=n*r/s):(s=s*r/n,n=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:n})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:u,hollow:p}=e.parameters,g;return c||p?g=new r2(h,d,r,s,n,a,o,l*Math.PI/180,c,c,u,p):g=new Gg(h,d,r,s,n,a,o,l*Math.PI/180),g.scale(1,1,i/t),Object.assign(g,{userData:{...e,type:"CylinderGeometry"}})}};function Tn(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Kx(e){return new k(e.y,-e.x)}var r2=class extends He{constructor(e,t,i,r,s,n,a,o,l,h,d,c,u=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,o=o!==void 0?o:Math.PI*2,n&&(l=0,h=0);let p=[],g=[],f=[],m=[],v=0,y=i/2,x=new M,w=new M;u&&e==0&&(e=l),u&&t==0&&(t=h);let _=new k(e,y),S=new k(t,-y),A=null,b=null,E=null,C=null,T=_.clone().sub(S),P=0,L=0,D=0;c>0&&(P=Math.min(e,t)*(1-c),L=e-P,D=t-P);let j=_.clone();j.x-=P;let W=Math.PI-T.angle(),q=T.angle(),z=Math.tan(q/2),V=Math.tan(W/2),F=z+V,N=c?F:V,B=c?F:z;if(l=Math.min(l,(e-L)/N,T.length()/F),h=Math.min(h,(t-D)/B,T.length()/F),l>0){let G=l/z;A=_.clone().sub(new k(G,l)),c&&(E=A.clone(),E.x-=P-F*l),_.sub(T.clone().setLength(G))}if(h>0){let G=h/V;b=S.clone().sub(new k(G,-h)),S.add(T.clone().setLength(G)),c&&(C=b.clone(),C.x-=P-F*h,j.sub(T.clone().setLength(G)))}T=_.clone().sub(S);let H=T.length()<.5,X=[];for(let G=0;G<=r;G++){let $=[],Z=G/r,ve=Z*o+a,re=new k(Math.sin(ve),Math.cos(ve));C&&b?(Q($,Z,re,W,h,C,-1,!0),Q($,Z,re,q,h,b,-1,!1)):b?(U($,re,b.x,0,-1),Q($,Z,re,q,h,b,-1,!1)):n||U($,re,t,D,-1);let oe=Kx(T).normalize();if(Tn(oe,re,x),!H)for(let ue=0;ue<=s;ue++){let be=ue/s,Oe=T.clone().multiplyScalar(be).add(S);Tn(Oe,re,w),g.push(w.x,w.y,w.z),f.push(x.x,x.y,x.z),m.push(Z,.5+w.y/i),$.push(v++)}if(E&&A?(Q($,Z,re,W,l,A,1,!1),Q($,Z,re,q,l,E,1,!0)):A?(Q($,Z,re,W,l,A,1,!1),U($,re,A.x,0,1)):n||U($,re,e,L,1),c&&!H){let ue=Kx(T).multiplyScalar(-1).normalize();Tn(ue,re,x);for(let be=0;be<=s;be++){let Oe=be/s,_e=T.clone().multiplyScalar(-Oe).add(j);Tn(_e,re,w),g.push(w.x,w.y,w.z),f.push(x.x,x.y,x.z),m.push(Z,.5+w.y/i),$.push(v++)}}c&&!n&&$.push($[0]),X.push($)}for(let G=0;G<X.length-1;G++)for(let $=0;$<X[0].length-1;$++){if(n&&c&&$==s)continue;let Z=X[G][$],ve=X[G+1][$],re=X[G+1][$+1],oe=X[G][$+1],ue=g[re*3+0],be=g[re*3+2];p.push(Z,ve,oe),(ue!=0||be!=0)&&p.push(ve,re,oe)}o<Math.PI*2&&(ne(-1,X[0],a),ne(1,X[X.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new De(g,3)),this.setAttribute("normal",new De(f,3)),this.setAttribute("uv",new De(m,2));function Q(G,$,Z,ve,re,oe,ue,be){for(let Oe=0;Oe<d+1;Oe++){let _e=Oe/d,Se=ue<0?_e:1-_e;be&&(Se-=1),Se*=ve;let Ie=new k(Math.sin(Se),Math.cos(Se)*ue),Xe=Ie.clone().multiplyScalar(re).add(oe);Tn(Xe,Z,w),g.push(w.x,w.y,w.z),Tn(Ie,Z,x),f.push(x.x,x.y,x.z),m.push($,.5+w.y/i),G.push(v++)}}function U(G,$,Z,ve,re){let oe=new M,ue=new k,be=[Z,ve];re<0&&be.reverse();for(let Oe of be)ue.set(Oe,y*re),Tn(ue,$,oe),g.push(oe.x,oe.y,oe.z),f.push(0,re,0),m.push(.5,.5),G.push(v++)}function ne(G,$,Z){let ve=new k(Math.sin(Z),Math.cos(Z)),re=new k(-Math.cos(Z),Math.sin(Z)),oe=new M,ue=G<0?(_e,Se,Ie)=>p.push(_e,Se,Ie):(_e,Se,Ie)=>p.push(_e,Ie,Se),be=new k((e+t+L+D)/4,0);Tn(be,ve,oe),g.push(oe.x,oe.y,oe.z),f.push(re.x,0,re.y),m.push(.5,.5);let Oe=v++;for(let _e of $){let Se=g.slice(_e*3,_e*3+3);g.push(...Se),f.push(re.x,0,re.y);let Ie=m.slice(_e*2,_e*2+2);m.push(...Ie),v++}for(let _e=Oe+1;_e<v-1;_e++)ue(Oe,_e,_e+1);ue(Oe,v-1,Oe+1)}}},L6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=e.parameters,u;return h>0||d>0||l<360?u=new r2(0,t/2,r,s,n,a,o,l*Math.PI/180,h,d,c,0,!0):u=new y_(t/2,r,s,n,a),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},R6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Is(t,i,r,s,n,a):h=new I6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},vf=Math.PI/2,I6=class extends He{constructor(e=1,t=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o),a=Math.min(a,e/2,t/2,i/2);let h=[],d=[],c=[],u=[],p=0,g=0;f("z","y","x",-1,-1,i,t,e,n,s,0),f("z","y","x",1,-1,i,t,-e,n,s,1),f("x","z","y",1,1,e,i,t,r,n,2),f("x","z","y",1,-1,e,i,-t,r,n,3),f("x","y","z",1,-1,e,t,i,r,s,4),f("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("y","x","z",-1,1,-1,t,e,i,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function f(y,x,w,_,S,A,b,E,C,T,P){let L=(A-2*a)/C,D=(b-2*a)/T,j=A/2-a,W=b/2-a,q=E/2,z=C+1,V=T+1,F=0,N=0,B=new M;for(let H=0;H<V;H++){let X=H*D-W;for(let Q=0;Q<z;Q++){let U=Q*L-j;B[y]=U*_,B[x]=X*S,B[w]=q,d.push(B.x,B.y,B.z),B[y]=0,B[x]=0,B[w]=E>0?1:-1,c.push(B.x,B.y,B.z),u.push(Q/C),u.push(1-H/T),F+=1}}for(let H=0;H<T;H++)for(let X=0;X<C;X++){let Q=p+X+z*H,U=p+X+z*(H+1),ne=p+(X+1)+z*(H+1),G=p+(X+1)+z*H;h.push(Q,U,G),h.push(U,ne,G),N+=6}l.addGroup(g,N,P),g+=N,p+=F}function m(y,x,w,_,S,A,b,E,C,T,P){let L=(b-2*a)/T,D=b/2-a,j=E/2-a,W=C/2,q=T+1,z=0,V=0,F=new M,N=new M;for(let B=0;B<o+1;B++){let H=B/o*vf,X=Math.sin(H)*a,Q=(1-Math.cos(H))*a,U=Math.sin(H),ne=Math.cos(H);F[x]=(j+X)*S,F[w]=(W-Q)*A,N[y]=0,N[x]=U*Math.sign(F[x]),N[w]=ne*Math.sign(F[w]);for(let G=0;G<q;G++){let $=G*L-D;F[y]=$*_,d.push(F.x,F.y,F.z),c.push(N.x,N.y,N.z),u.push(G/T),u.push(0),z+=1}}for(let B=0;B<o;B++)for(let H=0;H<T;H++){let X=p+H+q*B,Q=p+H+q*(B+1),U=p+(H+1)+q*(B+1),ne=p+(H+1)+q*B;h.push(X,Q,ne),h.push(Q,U,ne),V+=6}l.addGroup(g,V,P),g+=V,p+=z}function v(y,x,w){let _=new M,S=new M(e/2,t/2,i/2);S.subScalar(a);let A=[],b=y*x*w>0?(C,T,P)=>h.push(C,T,P):(C,T,P)=>h.push(C,P,T);for(let C=0;C<=o;C++){let T=[],P=vf*(1-C/o),L=Math.cos(P),D=Math.sin(P),j=0;for(let W=0;W<=C;W++){let q=Math.cos(j),z=Math.sin(j);_.x=L*q,_.y=D,_.z=L*z;let V=S.clone().addScaledVector(_,a);d.push(y*V.x,x*V.y,w*V.z),c.push(y*_.x,x*_.y,w*_.z),u.push(0,0),T.push(p++),j+=vf/C}A.push(T)}let E=A.length-1;for(let C=0;C<E;C++){let T=A[C],P=A[C+1],L=T.length-1;b(T[0],P[1],P[0]);for(let D=1;D<=L;D++)b(T[D-1],T[D],P[D]),b(T[D],P[D+1],P[D])}}}},Cv=class extends He{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),d(),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(n=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new M,p=u.clone(),g=new Ji,f=s*r,m=r-f,v=n+1,y=new M,x=(q,z)=>y.subVectors(q,z).normalize(),w=(q,z)=>Array(q).fill(void 0).map(z),_=w(e.length/3,(q,z)=>new M().fromArray(e,z*3).setLength(r)),S=[],A=1e6;for(let q=0;q<_.length;q++){let z=_[q],V=[],F,N,B,H=1e10,X=-1;for(;(X=t.indexOf(q,X+1))!=-1;){let G=X-X%3;F=t[G+(X+1)%3],N=t[G+(X+2)%3],B=z.distanceToSquared(_[F]),H=Math.min(H,B),V.push([F,N,B])}H+=1e-6;let Q=[],U=0,ne=V.length;for(let G=0;G<ne;G++){[F,N,B]=V[U];let $=S[F]?.includes(q)==!0;B<=H&&Q.push(F+ +$*A),U=V.findIndex(Z=>Z[0]==N)}S.push(Q)}let b=[];{let q=0,z=0,V,F,N=c==3;for(let B=0;B<=n;B++){V=B*(B+1)/2,F=(B+1)*(B+2)/2;for(let H=0;H<n-B;H++)[q,z]=[V+H+B+2,F+H+B+3],b.push(V,F,...N?[z,V]:[q,F],z,q),[V,F]=[q,z];b.push(V,F,V+n+2)}}let E=u.clone(),C=u.clone(),T=u.clone(),P=u.clone(),L=u.clone(),D=[],j=w(_.length,()=>w(c,()=>u.clone()));for(let q=0;q<_.length;q++){u.copy(_[q]).normalize(),E.copy(u).multiplyScalar(m);let z=S[q];for(let Q=0;Q<z.length;Q++){let U=z[Q],ne=z[(Q+1)%c];g.setFromPointsAndIndices(_,q,U%A,ne%A),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(E,j[q][Q])}let V=[],F=[],N=[],B=new M;n==0&&[...j[q]].reduce((Q,U)=>Q.add(U),B).multiplyScalar(1/c);for(let Q=0;Q<c;Q++){let U=[],ne=(Q-1+c)%c,G=j[q][ne],$=j[q][Q];u.copy(G).sub(E),p.copy($).sub(E);let Z=E.angleTo(u),ve=u.angleTo(p),re=Math.cos(Z)*f;n==0?C.copy(B):C.copy(E).setLength(m+re),F.push(re);let oe=[C,G,$];for(let ue=0;ue<2;ue++){let be=oe[ue],Oe=oe[ue+1];P.subVectors(be,E),L.subVectors(Oe,E),T.crossVectors(P,L).normalize();for(let _e=0;_e<v;_e++){let Se=[Z,ve][ue]*_e/v;u.copy(P).applyAxisAngle(T,Se).add(E),V.push(u.clone()),ue&&(x(u,E),U.push([_e==0?be:u.clone(),y.clone()]))}ue&&(x(Oe,E),U.push([Oe,y.clone()]))}N.push(U)}D.push(N);let H=2*v,X=2;for(let Q=0;Q<c;Q++){let U=H*Q,ne=H*((Q+1)%c),G=[V[U]];for(let Z=1;Z<v;Z++){P=V[U+Z],L=V[ne+Z],G.push(P);for(let ve=1,re=Z-X+1;ve<=re;ve++)u.lerpVectors(P,L,ve/(re+1)),u.sub(E).setLength(F[Q]).add(E),G.push(u.clone());G.push(L)}for(let Z=0;Z<v;Z++)G.push(V[Z+v+U]);G.push(V[ne+v]);let $=b.map(Z=>G[Z]);a.push(...$.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...$.map(Z=>(x(Z,E),[y.x,y.y,y.z])).flat())}}let W=[];for(let q=0;q<S.length;q++)for(let z=0;z<c;z++){let V=S[q][z];if(V<A){let F=S[V].findIndex(H=>H%A==q),N=D[q][z],B=D[V][F];for(let H=0;H<v;H++){let X=N[H],Q=B[v-H],U=N[H+1],ne=B[v-(H+1)];[X,Q,U,U,Q,ne].forEach(G=>{a.push(G[0].x,G[0].y,G[0].z),l.push(G[1].x,G[1].y,G[1].z)})}W.push(N[0][0],B[v][0],N[v][0],B[0][0])}}for(;W.length;){let q,z,V,F;[q,z]=W.splice(0,2);let N=[q];for(;q!=z;)N.push(z),V=W.indexOf(z),F=V%2,z=W.splice(V-F,2)[1-F];y.subVectors(N[0],N[1]).cross(u.subVectors(N[0],N[2])).normalize();let B=y.dot(N[0])<0;B&&y.negate();for(let H=1;H<=N.length-2;H++)[N[H+ +B],N[H+1-+B],N[0]].forEach(X=>{a.push(X.x,X.y,X.z),l.push(y.x,y.y,y.z)})}}function d(){let c=new M;for(let S=0;S<a.length;S+=3){c.x=a[S+0],c.y=a[S+1],c.z=a[S+2];let A=w(c)/2/Math.PI+.5,b=_(c)/Math.PI+.5;o.push(A,1-b)}let u=new M,p=new M,g=new M,f=new M,m=new k,v=new k,y=new k,x=(S,A,b,E)=>{E<0&&S.x===1&&(o[A]=S.x-1),b.x===0&&b.z===0&&(o[A]=E/2/Math.PI+.5)};for(let S=0,A=0;S<a.length;S+=9,A+=6){u.set(a[S+0],a[S+1],a[S+2]),p.set(a[S+3],a[S+4],a[S+5]),g.set(a[S+6],a[S+7],a[S+8]),m.set(o[A+0],o[A+1]),v.set(o[A+2],o[A+3]),y.set(o[A+4],o[A+5]),f.copy(u).add(p).add(g).divideScalar(3);let b=w(f);x(m,A+0,u,b),x(v,A+2,p,b),x(y,A+4,g,b)}for(let S=0;S<o.length;S+=6){let A=o[S+0],b=o[S+2],E=o[S+4],C=Math.max(A,b,E),T=Math.min(A,b,E);C>.9&&T<.1&&(A<.2&&(o[S+0]+=1),b<.2&&(o[S+2]+=1),E<.2&&(o[S+4]+=1))}function w(S){return Math.atan2(S.z,-S.x)}function _(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}}static fromJSON(e){return new Cv(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},B6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new s2(t*.5,n,a):new x_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},s2=class extends Cv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(n,a,o,e,t,i),this.type=o}static fromJSON(e){return new s2(e.radius,e.corner,e.cornerSides)}},Jl=1e-12,Tv=class{constructor(e){this.position=new k,this.startPosition=new k,this.uuid=st.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Tv(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},rg=class extends Tv{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new rg(this.parent).copy(this)}},Zo=class extends Tv{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new rg(this),new rg(this))}static create(e,t){let i=new Zo(e,new k(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Zo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new k,t=new k){let[i,r]=this.computeTangents();return i&&r&&(Jx(i,e),Jx(r,t)),[e,t]}computeTangent(e=new k){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new k){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Jx(e,t=new k){let i=e.length();return t.set(-e.y/i,e.x/i)}var Pv=e=>e,Cl=new k,Zu=new k,z6=new k,N6=new k,U6=new k,F6=new k,n2=new M,a2=new M;function k6(e){let t=new k;t.addVectors(e.v0,Cl.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new k;return i.addVectors(e.v2,Zu.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Jr(e.v0,t,i,e.v2)}function gh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function j6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function G6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function o2(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function V6(e,t,i){return ew(e,t)&&ew(t,i)&&sg(e.position,t.position,i.position)}function sg(e,t,i){return Cl.copy(t).sub(e).cross(Zu.copy(i).sub(e))===0}function H6(e,t,i,r,s){let n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.y-t.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.x-e.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function W6(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function q6(e,t,i,r,s,n){let a=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,d=Math.sqrt((a+l)*(a+l)+(o+h)*(o+h)),c;return o2(t,e,i)>Math.PI&&(d*=-1),gh(h,o)?c=(o+h)*(r/d-.5)*8/3/(a-l):c=(a+l)*(r/d-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*a),n.set(i.x+c*h,i.y-c*l),[s,n]}function $x(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function ew(e,t){return sg(e.position,e.controls[1].position,t.position)&&sg(e.position,t.controls[0].position,t.position)}function X6(e,t,i,r,s=.5){let n=Cl.subVectors(t,e).multiplyScalar(s).add(e),a=Zu.subVectors(i,t).multiplyScalar(s).add(t),o=z6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=N6.subVectors(a,n).multiplyScalar(s).add(n),d=U6.subVectors(o,a).multiplyScalar(s).add(a),c=o,u=F6.subVectors(d,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,d.x,d.y,c.x,c.y,r.x,r.y]}function Y6(e,t,i=12,r=!0){let s=a2.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=Pv(t[l]),d=Cl,c=Na(h,i);o.push(c);for(let u=0;u<=c;u++)if(h instanceof Jr||h instanceof Jn||h instanceof is){if(h.getPoint(u/c,d),s.set(d.x,d.y,0),n!==void 0&&G6(n,s))continue;n===void 0&&(n=n2),n.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}return r&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),e}function Q6(e,t,i,r=12,s=!0){let n=a2.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,d=Pv(t[l]),c=Cl,u=Na(d,r);o.push(u);for(let p=0;p<=u;p++)if(d instanceof Jr||d instanceof Jn||d instanceof is){if(d.getPoint(p/u,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=n2:(e.setXYZ(a,h.x,h.y,h.z),a++,e.setXYZ(a,n.x,n.y,n.z),a++),h.copy(n)}}return s&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),o}function tw(e,t=12,i=!1){let r=[];for(let s=0,n=e.length;s<n;s++){let a=e[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=Na(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Na(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Na(e[0].roundedCurveCorner,t)*.5),r}function Na(e,t=12){return e&&e instanceof Iu?t*2:e&&(e instanceof is||e instanceof m_)?1:e&&e instanceof jg?t*e.points.length:t}function Z6(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=Pv(t[a]),l=Na(o,i),h=Cl;for(let d=0;d<=l;d++)if(o instanceof Jr||o instanceof Jn||o instanceof is){if(o.getPoint(d/l,h),s!==void 0&&j6(s,h,Jl))continue;s===void 0&&(s=Zu),s.copy(h),e.push(h.x,h.y),n++}}return gh(e[0],e[e.length-2],Jl)&&gh(e[1],e[e.length-1],Jl)&&(e.pop(),e.pop()),r&&n>1&&!(gh(e[n-1],e[1],Jl)&&gh(e[n-2],e[0],Jl))&&(e.push(e[0],e[1]),n++),e}var yf=new k,K6=new k,J6=new k,$6=new k,ek=new k,tk=new k,Gt=class extends Hd{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new pr(new M(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=st.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Gt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Zo.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Gt.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=e-t;if(n<=s.points.length-1)return s.points[n];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=yf.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=st.generateUUID()){let r;e instanceof k?r=e:r=new k(e,t);let s=new Zo(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return Y6(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=tw(this.points,e,!1),this.roundedCurveDivisions=tw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return Q6(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Z6(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Na(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if($x(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(yf.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=n[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){$x(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&V6(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,d=s.curveAfter;if(h===void 0||d===void 0)continue;let c=s.roundedCurveBefore,u=s.roundedCurveAfter,p=h.getLength(),g=d.getLength(),f=Math.min(o,p*.499),m=Math.min(o,g*.499),v=Math.min(f,m),y=1-v/p,x=v/g,w=h.getPointAt(y,yf),_=d.getPointAt(x,K6);this._subSplitCurve(h,c,y,w,void 0),this._subSplitCurve(d,u,x,void 0,_);let S;if(this.useCubicForRoundedCorners){let A=o2(w,s.position,_)/2,b=Math.tan(A)*w.distanceTo(s.position),[E,C]=H6(w,_,b,J6,$6),T=W6(E,C,s.position),[P,L]=q6(T,w,_,b,ek,tk);S=new Jr(w.clone(),P.clone(),L.clone(),_.clone())}else S=new Jn(w.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=S,this.roundedCurves.splice(i+t,0,S),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof is)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,o=n.getUtoTmapping(i,0),l=X6(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return t}clone(){let e=new Gt(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],n=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],d=e.points[r+6],c=new Zo(st.generateUUID(),new k(s,n));c.controls[0].position.set(a,o),c.controls[1].position.set(l,h),c.roundness=d,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Gt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof Jr&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)},i=r=>{let s=[],n,a;for(n=0,a=r.length;n<a;n++)r[n]instanceof Jn&&(r[n]=k6(r[n]));for(n=0,a=r.length;n<a;n++){let h=r[n],d=n>0?r[n-1]:null,c;h instanceof Jr?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof is&&(c=this.createPoint(h.v1)),c!==void 0&&(d!==null&&t(c,d),s.push(c))}let o=r[r.length-1],l=!1;return o instanceof Jr?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof is&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof Hd&&(this.shapeHoles=e.holes.map(r=>{let s=new Gt;return s.fromShape(r),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},ng=Math.PI*2;function xf({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function ik(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),n=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function iw(e,t,i,r){let s=e*r-t*i<0?-1:1,n=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(n)}function rk(e,t,i,r,s,n,a,o,l,h){let d=Math.pow(s,2),c=Math.pow(n,2),u=Math.pow(a,2),p=Math.pow(o,2),g=d*c-d*p-c*u;g<0&&(g=0),g/=d*p+c*u,g=Math.sqrt(g)*(l===h?-1:1);let f=g*s/n*o,m=g*-n/s*a,v=f+(e+i)/2,y=m+(t+r)/2,x=(a-f)/s,w=(o-m)/n,_=(-a-f)/s,S=(-o-m)/n,A=iw(1,0,x,w),b=iw(x,w,_,S);return!h&&b>0&&(b-=ng),h&&b<0&&(b+=ng),{centerx:v,centery:y,ang1:A,ang2:b}}function sk({px:e,py:t,cx:i,cy:r,rx:s,ry:n,largeArcFlag:a,sweepFlag:o}){let l=[];if(s===0||n===0)return[];let h=(e-i)/2,d=(t-r)/2;if(h===0&&d===0)return[];s=Math.abs(s),n=Math.abs(n);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(d,2)/Math.pow(n,2);c>1&&(s*=Math.sqrt(c),n*=Math.sqrt(c));let u=rk(e,t,i,r,s,n,h,d,a,o),{ang1:p,ang2:g}=u,{centerx:f,centery:m}=u,v=Math.abs(g)/(ng/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);g/=y;for(let x=0;x<y;x++)l.push(ik(p,g)),p+=g;return l.map(x=>{let{x:w,y:_}=xf(x[0],s,n,f,m),{x:S,y:A}=xf(x[1],s,n,f,m),{x:b,y:E}=xf(x[2],s,n,f,m);return{x1:w,y1:_,x2:S,y2:A,x:b,y:E}})}var _t;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(_t||(_t={}));var ii;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ii||(ii={}));function Ge(e,t){if(!e)throw t||"Assertion Failed!"}var Be=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Ge(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?s<n?i.t-t.t+(t.t-r.t)*(s/(s+n)):i.t-r.t+(r.t-t.t)*(n/(s+n)):0},e.edgeSign=function(t,i,r){Ge(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?(i.t-r.t)*s+(i.t-t.t)*n:0},e.transEval=function(t,i,r){Ge(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?s<n?i.s-t.s+(t.s-r.s)*(s/(s+n)):i.s-r.s+(r.s-t.s)*(n/(s+n)):0},e.transSign=function(t,i,r){Ge(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?(i.s-r.s)*s+(i.s-t.s)*n:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,n){var a,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(a=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,i.s)):(a=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,s.s)):n.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(a=e.transEval(t,r,i),o=e.transEval(r,i,s),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,i.t)):(a=e.transSign(t,r,i),o=-e.transSign(t,s,i),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,s.t)):n.t=(r.t+i.t)/2},e}(),$l=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),nd=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Oo=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),rw=function(){function e(){var t=new Oo,i=new $l,r=new nd(0),s=new nd(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new nd(0),r=new nd(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;Ge(s,"Vertex can't be null!");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i;var a=i;do a.Org=s,a=a.Onext;while(a!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Ge(s,"Face can't be null");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var a=i;do a.Lface=s,a=a.Lnext;while(a!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.makeEdge=function(){var t=new Oo,i=new Oo,r=new $l,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var n=new Oo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new $l;this.makeFace_(a,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new $l;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new Oo;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),n=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(n,i),s.Org=t.Dst,n.Org=i.Org,s.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new $l;this.makeFace_(a,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,n,a,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=i);a=t.prev,o=t.next,o.prev=a,a.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,n,a,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,a=r.Org;s=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(n.Lface),o+l-2<=t&&Be.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Be.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(s=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,n,a,o,l,h;for(n=t,n=t;(s=n.next)!==t;n=s){Ge(s.prev===n),l=s.anEdge;do Ge(l.Sym!==l),Ge(l.Sym.Sym===l),Ge(l.Lnext.Onext.Sym===l),Ge(l.Onext.Sym.Lnext===l),Ge(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Ge(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){Ge(a.prev===o),l=a.anEdge;do Ge(l.Sym!==l),Ge(l.Sym.Sym===l),Ge(l.Lnext.Onext.Sym===l),Ge(l.Onext.Sym.Lnext===l),Ge(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Ge(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Ge(l.Sym.next===h.Sym),Ge(l.Sym!==l),Ge(l.Sym.Sym===l),Ge(l.Org!==null),Ge(l.Dst!==null),Ge(l.Lnext.Onext.Sym===l),Ge(l.Onext.Sym.Lnext===l);Ge(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),sw=function(){function e(){this.handle=null}return e}(),nw=function(){function e(){this.key=null,this.node=0}return e}(),nk=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new sw,this.handles[r]=new nw;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[i[a+1].handle].key,r[i[a].handle].key)&&++a,Ge(a<=this.max),n=i[a].handle,a>this.size||this.leq(r[s].key,r[n].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t>>1,n=i[a].handle,a===0||this.leq(r[n].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,n;for(n=this.nodes.length,this.nodes.length=this.max+1,s=n;s<this.nodes.length;s++)this.nodes[s]=new sw;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new nw}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;Ge(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),wf=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),aw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),ak=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new aw,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new aw;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),ok=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,n=i.eUp,a=r.eUp;if(n.Dst===s)return a.Dst===s?Be.vertLeq(n.Org,a.Org)?Be.edgeSign(a.Dst,n.Org,a.Org)<=0:Be.edgeSign(n.Dst,a.Org,n.Org)>=0:Be.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Be.edgeSign(n.Dst,s,n.Org)>=0;var o=Be.edgeEval(n.Dst,s,n.Org),l=Be.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Ge(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Ge(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new wf;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case _t.ODD:return(i&1)!==0;case _t.NONZERO:return i!==0;case _t.POSITIVE:return i>0;case _t.NEGATIVE:return i<0;case _t.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,n=null,a=i,o=i.eUp;a!==r;){if(a.fixUpperEdge=!1,n=e.regionBelow(a),s=n.eUp,s.Org!=o.Org){if(!n.fixUpperEdge){e.finishRegion(t,a);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,n,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,a),o=n.eUp,a=n}return o},e.addRightEdges=function(t,i,r,s,n,a){var o,l,h,d,c=!0;h=r;do Ge(Be.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(n===null&&(n=e.regionBelow(i).eUp.Rprev),l=i,d=n;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(d.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,d),e.deleteRegion(t,l),t.mesh.delete(d)),c=!1,l=o,d=h;l.dirty=!0,Ge(l.windingNumber-h.winding===o.windingNumber),a&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Be.vertL1dist(i,t),n=Be.vertL1dist(r,t),a=.5*n/(s+n),o=.5*s/(s+n);t.coords[0]+=a*i.coords[0]+o*r.coords[0],t.coords[1]+=a*i.coords[1]+o*r.coords[1],t.coords[2]+=a*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,n,a){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,n,a)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp;if(Be.vertLeq(s.Org,n.Org)){if(Be.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Be.vertEq(s.Org,n.Org)?s.Org!==n.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,n.Oprev,s)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(s,n.Oprev),i.dirty=r.dirty=!0)}else{if(Be.edgeSign(s.Dst,n.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a;if(Ge(!Be.vertEq(s.Dst,n.Dst)),Be.vertLeq(s.Dst,n.Dst)){if(Be.edgeSign(s.Dst,n.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,a=t.mesh.splitEdge(s),t.mesh.splice(n.Sym,a),a.Lface.inside=i.inside}else{if(Be.edgeSign(n.Dst,s.Dst,n.Org)>0)return!1;i.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(s.Lnext,n.Sym),a.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a=s.Org,o=n.Org,l=s.Dst,h=n.Dst,d,c,u=new Oo,p,g;if(Ge(!Be.vertEq(h,l)),Ge(Be.edgeSign(l,t.event,a)<=0),Ge(Be.edgeSign(h,t.event,o)>=0),Ge(a!==t.event&&o!==t.event),Ge(!i.fixUpperEdge&&!r.fixUpperEdge),a===o||(d=Math.min(a.t,l.t),c=Math.max(o.t,h.t),d>c))return!1;if(Be.vertLeq(a,o)){if(Be.edgeSign(h,a,o)>0)return!1}else if(Be.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Be.intersect(l,a,h,o,u),Ge(Math.min(a.t,l.t)<=u.t),Ge(u.t<=Math.max(o.t,h.t)),Ge(Math.min(h.s,l.s)<=u.s),Ge(u.s<=Math.max(o.s,a.s)),Be.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Be.vertLeq(a,o)?a:o,Be.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Be.vertEq(u,a)||Be.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Be.vertEq(l,t.event)&&Be.edgeSign(l,t.event,u)>=0||!Be.vertEq(h,t.event)&&Be.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Lnext,n.Oprev),r=i,i=e.topRightRegion(i),g=e.regionBelow(i).eUp.Rprev,r.eUp=n.Oprev,n=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,n.Onext,s.Rprev,g,!0),!0):(Be.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Be.edgeSign(h,t.event,u)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,s),s.Org.s=u.s,s.Org.t=u.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,a,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,n;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,n=r.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(n),r=e.regionBelow(i),n=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==n.Org)if(s.Dst!==n.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||n.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,n=r.Onext,a=e.regionBelow(i),o=i.eUp,l=a.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Be.vertEq(o.Org,t.event)&&(t.mesh.splice(n.Oprev,o),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),h=!0),Be.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,a,null),h=!0),h){e.addRightEdges(t,i,r.Onext,n,n,!0);return}Be.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,n,a,o,l;if(s=i.eUp,Be.vertEq(s.Org,r)){Ge(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Be.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}Ge(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(Ge(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Be.edgeGoesLeft(n)||(n=null),e.addRightEdges(t,i,a.Onext,o,n,!0)},e.connectLeftVertex=function(t,i){var r,s,n,a,o,l,h=new wf;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Be.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Be.vertLeq(o.Dst,a.Dst)?r:s,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(i.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(o.Dnext,i.anEdge);l=d.Sym}n.fixUpperEdge?e.fixUpperEdge(t,n,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);Ge(s!==null);var n=e.regionBelow(s),a=n.eUp,o=e.finishLeftRegions(t,n,null);o.Onext===a?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,a,a,!0)},e.addSentinel=function(t,i,r,s){var n=new wf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=s,a.Dst.s=i,a.Dst.t=s,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new ak(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,n=t.bmax[0]+i,a=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,n,a),e.addSentinel(t,s,n,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Ge(i.fixUpperEdge),Ge(++r===1)),Ge(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,n=t.mesh.eHead;for(i=n.next;i!==n;i=r)r=i.next,s=i.Lnext,Be.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,n=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)n++;for(n+=8,i=t.pq=new nk(n,Be.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,n;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,n=r.anEdge,Ge(n.Lnext!==n),n.Lnext.Lnext===n&&(e.addWinding(n.Onext,n),t.mesh.delete(n));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Be.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),lk=function(){function e(){this.mesh=new rw,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=_t.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,n,a,o,l=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],u=[0,0,0],p=[null,null,null],g=[null,null,null],f=this.mesh.vHead;i=f.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,g[m]=i,l[m]=n,p[m]=i;for(i=f.next;i!==f;i=i.next)for(var v=0;v<3;++v)n=i.coords[v],n<h[v]&&(h[v]=n,g[v]=i),n>l[v]&&(l[v]=n,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=g[y],s=p[y],d[0]=r.coords[0]-s.coords[0],d[1]=r.coords[1]-s.coords[1],d[2]=r.coords[2]-s.coords[2],i=f.next;i!==f;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],u[0]=d[1]*c[2]-d[2]*c[1],u[1]=d[2]*c[0]-d[0]*c[2],u[2]=d[0]*c[1]-d[1]*c[0],a=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],a>o&&(o=a,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,n=0,a=t.next;a!==t;a=a.next)if(s=a.anEdge,!(s.winding<=0))do n+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==a.anEdge);if(n<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),n=!0),r=this.sUnit,s=this.tUnit;var a=this.longAxis_(i);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,s[a]=0,s[(a+1)%3]=0,s[(a+2)%3]=i[a]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);n&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Be.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Be.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Be.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Be.edgeGoesLeft(s.Lnext)||Be.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)n=t.connect(s.Lnext,s),s=n.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Be.edgeGoesRight(r.Lprev)||Be.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)n=t.connect(s.Lnext,s),s=n.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,n=t.eHead.next;n!==t.eHead;n=s)s=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?i:-i:r?t.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var n,a=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){n=d.anEdge,l=0;do{var h=n.Org;h.n===-1&&(h.n=o,o++),l++,n=n.Lnext}while(n!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,i===ii.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var u=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(d.inside){n=d.anEdge,l=0;do{var h=n.Org;this.elements[u++]=h.n,l++,n=n.Lnext}while(n!==d.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===ii.CONNECTED_POLYGONS){n=d.anEdge;do this.elements[u++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==d.anEdge);for(var g=l;g<r;++g)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,d=0;n=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==s);this.elements[d++]=n,this.elements[d++]=a,n+=a}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new rw),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,n,a){if(t===void 0&&(t=_t.ODD),i===void 0&&(i=ii.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),ok.computeInterior(this,a);var o=this.mesh;return i===ii.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===ii.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Xn(e){var t=e.windingRule,i=t===void 0?_t.ODD:t,r=e.elementType,s=r===void 0?ii.POLYGONS:r,n=e.polySize,a=n===void 0?3:n,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,d=h===void 0?[0,0,1]:h,c=e.contours,u=c===void 0?[]:c,p=e.strict,g=p===void 0?!0:p,f=e.debug,m=f===void 0?!1:f;if(!u&&g)throw new Error("Contours can't be empty");if(u){var v=new lk;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<u.length;y++)v.addContour(l||2,u[y]);return v.tesselate(i,s,a,l,d,g),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}var EW=_t.ODD,CW=_t.NONZERO,TW=_t.POSITIVE,PW=_t.NEGATIVE,DW=_t.ABS_GEQ_TWO,OW=ii.POLYGONS,LW=ii.CONNECTED_POLYGONS,RW=ii.BOUNDARY_CONTOURS,ag=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*ag.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*ag.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(r,n*s,3*e);n+=3*e;let o=new Float32Array(r,n*s,3*e);n+=3*e;let l=new Float32Array(r,n*s,2*e);a.set(this.positions.slice(0,this.size*3)),o.set(this.normals.slice(0,this.size*3)),l.set(this.uvs.slice(0,this.size*2)),this.buffer=r,this.positions=a,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},l2=ag;l2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Dv={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},h2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},c2={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},bf=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),d2=class extends He{constructor(e,t,i=0,r=12,s=3,n=_t.ODD){super(),this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,t/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],r),o=this._shape.shapeHoles.map(_=>{let S=_.extractShapePointsToFlatArray([],r),A=[];for(let b=S.length-1;b>=1;b-=2){let E=S[b-1],C=S[b-0];A.push(E,C)}return A}),l;try{l=Xn({windingRule:n,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]})}catch{l=Dv}let h;try{h=Xn({windingRule:_t.ODD,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{h=h2}if(!l)throw new Error("error generating geometry");let d=l.elementCount;if(h){l.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let S=h.elements[_],A=_%2===0?l.vertexCount:0;l.elements.push(S+A)}for(let _=0;_<h.vertexIndices.length;_++){let S=h.vertexIndices[_],A=l.vertexCount;l.vertexIndices.push(S+A)}for(let _=0;_<h.vertices.length;_++){let S=h.vertices[_];l.vertices.push(S)}}let c=1/0,u=-1/0,p=1/0,g=-1/0;for(let _=0,S=l.vertexCount;_<S;_++){let A=_*2,b=l.vertices[A+0],E=l.vertices[A+1];b<c&&(c=b),b>u&&(u=b),E<p&&(p=E),E>g&&(g=E)}this._minX=c,this._minY=p,this._width=u-c,this._height=g-p,this._buffer=new l2(this._computeBufferEstimatedSize(l));let f=[],m=[];for(let _=l.elementCount-1;_>=0;_--){let S=_>=d,A=_*2,b=l.elements[A+0],E=l.elements[A+1],C=b+E,T={start:b,count:E,normals:[],continuous:[],concave:[]},P=b,L=C-1,D=b+1,j=this._shape.roundedCurves.length;do{let V=P-b,F=l.vertices[L*2+0],N=l.vertices[L*2+1],B=l.vertices[P*2+0],H=l.vertices[P*2+1],X=l.vertices[D*2+0],Q=l.vertices[D*2+1],U=B-F,ne=H-N,G=Math.sqrt(U*U+ne*ne);U/=G,ne/=G;let $=B-X,Z=H-Q,ve=Math.sqrt($*$+Z*Z);$/=ve,Z/=ve,T.normals[V*2+0]=-Z,T.normals[V*2+1]=$,T.concave[V]=U*Z-ne*$>0;let re=l.vertexIndices[P];if(Array.isArray(re))T.continuous[V]=!1;else{let[oe,ue]=this._shape.getCurveIndexFromVertexId(re-1,!0);if(ue>0&&ue<1)T.continuous[V]=!0;else{let be=ue===1?oe+1:oe-1;be=(be+j)%j;let Oe=ue===1?0:1,_e=this._shape.roundedCurves[oe].getTangent(ue),Se=this._shape.roundedCurves[be].getTangent(Oe);T.continuous[V]=_e.dot(Se)>.95}}S&&(T.normals[V*2+0]*=-1,T.normals[V*2+1]*=-1),[L,P,D]=[P,D,D+1],D>=C&&(D-=E)}while(D!==b+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(b*2,C*2),vertexCount:E,vertexIndices:new Array(E).fill(!0).map((V,F)=>[F,F]),elements:[0,E],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(b*2,C*2)});for(let V=1;V<=this._bevelSegments;V++){let F=V/this._bevelSegments*Math.PI/2,N=(1-Math.cos(F))*this._bevelSize,B=[],H=[],X=[],Q=[],U=0;for(let G=0;G<E;G++){let $=G*2,Z=(G-1+E)%E*2,ve=l.vertices[T.start*2+$+0],re=l.vertices[T.start*2+$+1],oe=-T.normals[Z+0]*N,ue=-T.normals[Z+1]*N,be=-T.normals[$+0]*N,Oe=-T.normals[$+1]*N;if(T.concave[G]||!T.concave[G]&&S){let _e=Math.atan2(ue,oe),Se=Math.atan2(Oe,be);Se>_e&&(Se-=Math.PI*2);let Ie=Se-_e;if(T.continuous[G]||S){let Xe=_e+Ie/2,ct=Math.cos(Xe)*N,R=Math.sin(Xe)*N;B[2*U+0]=ve+ct*(S?-1:1),B[2*U+1]=re+R*(S?-1:1),Q[U]=G,U++}else{let Xe=Math.max(1,Math.floor(r/4*Math.abs(Ie)/Math.PI));for(let ct=0;ct<=Xe;ct++){let R=_e+Ie*(ct/Xe),O=Math.cos(R)*N,ie=Math.sin(R)*N;B[2*U+0]=ve+O,B[2*U+1]=re+ie,Q[U]=G,U++}}}else B[2*U+0]=ve+oe,B[2*U+1]=re+ue,Q[U]=G,H[G]=U,U++,B[2*U+0]=ve,B[2*U+1]=re,Q[U]=G,U++,B[2*U+0]=ve+be,B[2*U+1]=re+Oe,Q[U]=G,X[G]=U,U++}let ne=Xn({windingRule:_t.POSITIVE,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[B],edgeCreateCallback:G=>{let $=G.Org.idx,Z=Q[$],ve=Q[($+1)%Q.length];G.idx=[Z,ve],G.Sym.idx=[ve,Z]},vertexIdCallback:G=>{let $=G.Lprev.idx;return[$?$[1]:0,G.idx?G.idx[0]:0]}});if(!ne)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!ne.vertexCount)break;for(let G=0;G<ne.vertexIndices.length;G++){let[$,Z]=ne.vertexIndices[G];if($===Z)continue;let ve=Z;Z<$&&(ve+=E);for(let re=$;re<ve;re++){let oe=re%E,ue=(re+1)%E;if(!T.continuous[oe]||!T.continuous[ue]){ne.vertexIndices[G]=[$,oe],ne.vertexIndices.splice(G+1,0,[ue,Z]),ne.vertices.splice((G+1)*2,0,ne.vertices[G*2],ne.vertices[G*2+1]);break}}}W.push({bevelI:V,angle:F,size:N,boundary:ne,reverseMap:Q,insetPoints:B})}let q=(V,F,N)=>{let B=0,H=V.boundary.vertexIndices.length;for(;B<H&&N(V.boundary.vertexIndices[F]);)F=(F+1)%H,B++;return B},z=f.length;for(let V=1;V<W.length;V++){let F=W[V-1],N=W[V],B=F.boundary.vertexIndices.length,H=N.boundary.vertexIndices.length;if(!B||!H)break;let X=T.concave.length,Q=0,U=bf(Q,E);for(;!F.boundary.vertexIndices.filter(U).length||!N.boundary.vertexIndices.filter(U).length;)Q++,U=bf(Q,E);let ne=F.boundary.vertexIndices.findIndex(U),G=N.boundary.vertexIndices.findIndex(U);do ne=(ne+1)%B;while(U(F.boundary.vertexIndices[ne]));do G=(G+1)%H;while(U(N.boundary.vertexIndices[G]));Q=(Q+1)%E;let $=Q,Z=this._buildBevelVert(T,F,(ne-1+B)%B),ve=this._buildBevelVert(T,N,(G-1+H)%H),re=Z,oe=ve,ue,be,Oe=!1;do{U=bf(Q,E);let _e=q(F,ne,U),Se=q(N,G,U),Ie=Oe;if(Oe=!1,_e&&!Se){for(let Xe=0;Xe<_e;Xe++)ue=this._buildBevelVert(T,F,(ne+Xe)%B,Xe/(_e-1)),f.push(re.topN,ue.topP,oe.topN),f.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue;Oe=!0}else if(!_e&&Se)for(let Xe=0;Xe<Se;Xe++)be=this._buildBevelVert(T,N,(G+Xe)%H,Xe/(Se-1)),f.push(oe.topN,re.topP,be.topP),f.push(re.bottomP,oe.bottomN,be.bottomP),oe=be;else if(_e&&Se)if(ue=this._buildBevelVert(T,F,ne,0),be=this._buildBevelVert(T,N,G,0),Ie?(f.push(re.topN,be.topP,oe.topN),f.push(re.topN,ue.topP,be.topP),f.push(be.bottomP,re.bottomN,oe.bottomN),f.push(be.bottomP,ue.bottomP,re.bottomN)):(f.push(oe.topN,re.topN,ue.topP),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,re.bottomN,oe.bottomN),f.push(ue.bottomP,oe.bottomN,be.bottomP)),re=ue,oe=be,_e===Se)for(let Xe=1;Xe<_e;Xe++)ue=this._buildBevelVert(T,F,(ne+Xe)%B,Xe/(_e-1)),be=this._buildBevelVert(T,N,(G+Xe)%H,Xe/(Se-1)),f.push(re.topN,ue.topP,oe.topN),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,re.bottomN,oe.bottomN),f.push(ue.bottomP,oe.bottomN,be.bottomP),re=ue,oe=be;else if(_e>Se){let Xe=_e/Se,ct=0;for(let R=1;R<_e;R++)ue=this._buildBevelVert(T,F,(ne+R)%B,R/(_e-1)),f.push(re.topN,ue.topP,oe.topN),f.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue,R>(ct+1)*Xe&&(ct++,be=this._buildBevelVert(T,N,(G+ct)%H,ct/(Se-1)),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,oe.bottomN,be.bottomP),oe=be)}else{let Xe=Se/_e,ct=0;for(let R=1;R<Se;R++)be=this._buildBevelVert(T,N,(G+R)%H,R/(Se-1)),f.push(oe.topN,ue.topP,be.topP),f.push(ue.bottomP,oe.bottomN,be.bottomP),oe=be,R>(ct+1)*Xe&&(ct++,ue=this._buildBevelVert(T,F,(ne+ct)%B,ct/(_e-1)),f.push(re.topN,ue.topP,oe.topN),f.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue)}ne=(ne+_e)%B,G=(G+Se)%H,Q=(Q+1)%X}while(Q!==$)}if(this._depth>this._bevel*2&&this._buildWall(W,T,f),S){let V=[];for(let F=f.length-1;F>=z+2;F-=3){let N=f[F-2],B=f[F-1],H=f[F-0];V.push(H,B,N)}f.splice(z,f.length-z,...V)}if(S){let V=[];for(let F=W[W.length-1].boundary.vertices.length-1;F>=1;F-=2){let N=W[W.length-1].boundary.vertices[F-1],B=W[W.length-1].boundary.vertices[F-0];V.push(N,B)}m.push(V)}if(!S){let V=W[W.length-1],F;try{F=Xn({windingRule:W.length>1?_t.POSITIVE:_t.ODD,elementType:ii.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...m]})}catch{F=c2}if(!F)throw new Error("Error generating geometry for surface");o.length===0&&Object.assign(this,{capStartIndex:f.length});for(let N=0;N<F.elementCount*3;N+=3){let B=this._buildSurfaceVert(F,F.elements[N+0]),H=this._buildSurfaceVert(F,F.elements[N+1]),X=this._buildSurfaceVert(F,F.elements[N+2]);f.push(B.top,H.top,X.top),f.push(X.bottom,H.bottom,B.bottom)}}this.vertexCache={}}this._buffer.shrink();let v=new qe(Uint32Array.from(f),1),y=new qe(this._buffer.positions,3),x=new qe(this._buffer.normals,3),w=new qe(this._buffer.uvs,2);y.needsUpdate=!0,x.needsUpdate=!0,w.needsUpdate=!0,v.needsUpdate=!0,this.setAttribute("position",y),this.setAttribute("normal",x),this.setAttribute("uv",w),this.setIndex(v)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(e,t){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let r=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(r-this._minX)/this._width,a=(s-this._minY)/this._height,o=this._buffer.get(2),l=o*3,h=o*2,d={top:o+0,bottom:o+1};return this._buffer.positions[l+0]=r,this._buffer.positions[l+1]=s,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[h+0]=n,this._buffer.uvs[h+1]=a,this._buffer.positions[l+3]=r,this._buffer.positions[l+4]=s,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[h+2]=n,this._buffer.uvs[h+3]=a,this.vertexCache[i]=d,d}_buildBevelVert(e,t,i,r=1){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[n,a]=t.boundary.vertexIndices[i],o,l,h,d;n!==a?(l=n,o=a,d=!1,h=e.continuous[l]&&e.continuous[o]):(o=n,l=(o-1+e.count)%e.count,d=e.concave[o]&&t.bevelI>0,h=e.continuous[o]||d);let c=Math.cos(t.angle),u=Math.sin(t.angle),p=i*2,g=o*2,f=l*2,m=t.boundary.vertices[p+0],v=t.boundary.vertices[p+1],y=(1-u)*this._bevelSize,x=(m-this._minX)/this._width,w=(v-this._minY)/this._height,_=e.normals[g+0],S=e.normals[g+1],A=e.normals[f+0],b=e.normals[f+1];if(d){let L=A-_,D=b-S;_=_+L*(1-r),S=S+D*(1-r);let j=Math.sqrt(_*_+S*S);_/=j,S/=j}let E=this._buffer.get(h?2:4),C=E*3,T=E*2,P={i,fi:o,topP:E+0,topN:E+0,bottomP:E+1,bottomN:E+1};return this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=_*c,this._buffer.normals[C+1]=S*c,this._buffer.normals[C+2]=u,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=_*c,this._buffer.normals[C+4]=S*c,this._buffer.normals[C+5]=-u,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x,h||(E+=2,C+=6,T+=4,P.topP=E+0,P.bottomP=E+1,this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=A*c,this._buffer.normals[C+1]=b*c,this._buffer.normals[C+2]=u,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=A*c,this._buffer.normals[C+4]=b*c,this._buffer.normals[C+5]=-u,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x),this.vertexCache[s]=P,P}clone(){let e=new d2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vu(this.userData),e}},u2=class extends He{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=_t.ODD,this.elementType=ii.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:_t.ODD,elementType:ii.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),n,a=!0,o=!0,l,h;for(let u=0,p=r.length/2;u<p;u++){let g=u*2,f=r[g+0],m=r[g+1];if(l!==void 0&&f!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=f,h=m,!a&&!o)break}if(!a&&!o)try{n=Xn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=Dv}let d=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new qe(new Float32Array(d*3),3),this._normalAttribute=new qe(new Float32Array(d*3),3),this._uvAttribute=new qe(new Float32Array(d*2),2),this._indexAttribute=new qe(new Uint32Array(c*3),1),n){let u=1/0,p=-1/0,g=1/0,f=-1/0;for(let y=0,x=d;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1];_<u&&(u=_),_>p&&(p=_),S<g&&(g=S),S>f&&(f=S)}let m=p-u,v=f-g;for(let y=0,x=d;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1],A=(_-u)/m,b=(S-g)/v;this._positionAttribute.setXYZ(y,_,S,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,A,b)}for(let y=0,x=c;y<x;y++){let w=y*3,_=n.elements[w+0],S=n.elements[w+1],A=n.elements[w+2];this._indexAttribute.setX(w+0,_),this._indexAttribute.setX(w+1,S),this._indexAttribute.setX(w+2,A)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(n?.elementCount??1)*3)}clone(){let e=new u2(this._shape,this._curveSegments);return e.userData=Vu(this.userData),e}},p2=class extends d2{constructor(e,t,i=0,r=12,s=3,n=_t.ODD){super(e,t,i,r,s,n),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let e=new p2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vu(this.userData),e}},Qa=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:_t.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=e.shape??t?.shape,o=a?.roundness??i.roundness;a!==void 0&&(a instanceof Gt?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Gt(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Gt(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:n,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:n,windingRule:a}=e.parameters;e.shape.roundness=n;let o;return t<=0?o=new u2(e.shape,s,{windingRule:a}):o=new p2(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},f2=Math.PI*2,Ov=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,d=t*.5,c=i*.5,u=hk(h,d,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=Qa.create({shape:h,parameters:{subdivisions:u,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function hk(e,t,i,r,s,n){if(r>=f2)return s>30||s%4===0?(dk(e,t,i,n),Math.round(s/4)):ow(e,r,s,t,i,n);r=Math.max(r,.001);let a={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=sk({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?ck(e,a.x,a.y,h,s,t,i,n):ow(e,r,s,t,i,n)}function ck(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(Ko(t,i));for(let h=0,d=r.length;h<d;h++){let c=r[h],u=e.points[h],p=Ko(c.x,c.y);u.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?m2(e,n,a,o):e.addPoint(Ko(0,0)),l}function ow(e,t,i,r,s,n){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,d=Math.cos(l)*s;e.addPoint(Ko(h,d))}return t<f2?n>0?m2(e,r,s,n):e.addPoint(Ko(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&g2(e,r,s,n)),1}function dk(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(ad(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(ad(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(ad(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(ad(s,n-i,s+o,n-i,s-o,n-i)),r>0&&g2(e,t,i,r)}function Ko(e,t){return new Zo(st.generateUUID(),new k(e,t))}function ad(e,t,i,r,s,n){let a=Ko(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function m2(e,t,i,r){v2(e,t,i,r).forEach(s=>e.addPoint(s))}function g2(e,t,i,r){let s=v2(e,t,i,r),n=new Gt;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function v2(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new k(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=st.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),d=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(d),l.controls[1].position.copy(h)}),o}var uk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:d,cornerSegments:c}=e.parameters,u=new y2(!1,t,i,r,s,n,a,o,l,h,d,c);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},_f=new Ho([0,0,0],1),y2=class extends He{constructor(e=!0,t=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,d=1,c=1){if(super(),n===0)return;let u=e&&n===1;u&&(c=0),d>100&&(d=100),d===0&&(c=0);let p=()=>new M,g=new M,f=p(),m=p(),v=p(),y,x,w,_,S,A,b,E,C=p(),T=p(),P=p(),L=p(),D=p(),j=p(),W=p(),q=p(),z=i-2*o+.001,V=z/n,F=Math.ceil(a*n),N=F+1,B=z/F,H=-z/2,X=h+1,Q=2*Math.PI/h,U=Math.PI/2/c,ne=.01,G=Math.min((1-d/100)*o,o-ne),$=o-G,Z=0,ve=2,re=c*ve+ve,oe=X*re/ve,ue=oe+X*N,be=X*(N+re),[Oe,_e,Se]=[3,3,2].map(Te=>Array(be*Te).fill(0)),Ie=[],Xe=s-o;function ct(Te,Le){let Pe=Math.PI/2;A=Le*B,E=2*Math.PI*(A%V)/V+Pe,A+=H,b=Math.sin(E)*Xe,S=Math.cos(E)*Xe,e?Te.set(S,b,A):Te.set(S,A,b)}ct(g,-1e-10),ct(f,0),C.copy(g),ct(g,1);let R=g.distanceTo(f),O=u?0:$+G,ie=R*F+2*O,fe=G,ge=ie-O;for(let Te=0;Te<=F;Te++){ct(m,Te),q.subVectors(m,C).normalize(),C.copy(m),j.copy(m).setComponent(+e+1,0).normalize(),W.crossVectors(q,j).normalize();let Le=Te===0,Pe=Te===F,We=Le?3*Math.PI/2:U,ze=Le?fe:ge,dt=Le?X:ue,Ot=Le?0:be-X,Kt=q.clone().multiplyScalar(Le?-$:$).add(m),Y=q.clone().multiplyScalar(Le?-1:1).normalize();for(let se=0;se<X;se++){let pe=se*Q;if(T.addVectors(g.copy(j).multiplyScalar(o*Math.cos(pe)),f.copy(W).multiplyScalar(o*Math.sin(pe))),P.copy(T).normalize(),Le||Pe){u||(Z=Ot+se,[0,1,2].forEach(xe=>{Oe[Z*3+xe]=Kt.getComponent(xe),_e[Z*3+xe]=Y.getComponent(xe)}),Se[Z*2]=+Pe,Se[Z*2+1]=se/h),f.copy(P).multiplyScalar(G),v.addVectors(m,f);for(let xe=0;xe<c;xe++){let ke=xe*U+We;L.addVectors(g.copy(q).multiplyScalar($*Math.sin(ke)),f.copy(P).multiplyScalar($*Math.cos(ke))),D.copy(L).normalize(),f.addVectors(v,L),L.normalize(),Z=dt+xe*X+se,[0,1,2].forEach(Ut=>{Oe[Z*3+Ut]=f.getComponent(Ut),_e[Z*3+Ut]=D.getComponent(Ut)});let ft=+Le+Math.sin(ke);Se[Z*2]=(ze+$*ft)/ie,Se[Z*2+1]=se/h}}f.addVectors(m,T),Z=oe+Te*X+se,[0,1,2].forEach(xe=>{Oe[Z*3+xe]=f.getComponent(xe),_e[Z*3+xe]=P.getComponent(xe)}),Se[Z*2]=(O+Te*R)/ie,Se[Z*2+1]=se/h}}let Ae=N+2*c+ve,Ye=1,[Me,ce]=[+u,Ae-1];for(let Te=Me;Te<=ce-1;Te++){let Le=u&&Te===ce-1;for(let Pe=0;Pe<X-1;Pe++)y=Te*X+Pe,x=y+1,w=(Le?Pe:y)+X,_=(Le?Pe+1:x)+X,Te===0?Ie.push(x,_,w):Te===Ae-2?Ie.push(y,x,w):Ie.push(y,x,w,x,_,w)}this.setIndex(Ie),this.setAttribute("position",new De(Oe,3)),this.setAttribute("normal",new De(_e,3)),this.setAttribute("uv",new De(Se,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,n,a,o,l=6*(t-1)*e.radialSegments,h=t,d=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,n=s+1,a=(d?c:s)+i,o=(d?c+1:n)+i,r[l++]=s,r[l++]=n,r[l++]=a,r[l++]=n,r[l++]=o,r[l++]=a;return r.length=l,_f.array=r,_f.count=r.length,_f}},pk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new x2(t*.5,n,a):new A_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},x2=class extends Cv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,n,a,e,t,i),this.type=a}static fromJSON(e){return new x2(e.radius,e.corner,e.cornerSides)}},fk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new Hd;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new v_(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ps=new me,Sf=new Et,od=new M,wu=class extends Wi{constructor(){super(),this.uuid=st.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new _i().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let n=0,a=s.vertexNormals.length;n<a;n++)s.vertexNormals[n].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ps.makeRotationX(e),this.applyMatrix4(ps),this}rotateY(e){return ps.makeRotationY(e),this.applyMatrix4(ps),this}rotateZ(e){return ps.makeRotationZ(e),this.applyMatrix4(ps),this}translate(e,t,i){return ps.makeTranslation(e,t,i),this.applyMatrix4(ps),this}scale(e,t,i){return ps.makeScale(e,t,i),this.applyMatrix4(ps),this}lookAt(e){return Sf.lookAt(e),Sf.updateMatrix(),this.applyMatrix4(Sf.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,n=r.normal,a=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<s.count;c++)t.vertices.push(new M().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new Fe().fromBufferAttribute(a,c));function h(c,u,p,g){let f=a===void 0?[]:[t.colors[c].clone(),t.colors[u].clone(),t.colors[p].clone()],m=n===void 0?[]:[new M().fromBufferAttribute(n,c),new M().fromBufferAttribute(n,u),new M().fromBufferAttribute(n,p)],v=new og(c,u,p,m,f,g);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new k().fromBufferAttribute(o,c),new k().fromBufferAttribute(o,u),new k().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new k().fromBufferAttribute(l,c),new k().fromBufferAttribute(l,u),new k().fromBufferAttribute(l,p)])}let d=e.groups;if(d.length>0)for(let c=0;c<d.length;c++){let u=d[c],p=u.start,g=u.count;for(let f=p,m=p+g;f<m;f+=3)i!==void 0?h(i.getX(f),i.getX(f+1),i.getX(f+2),u.materialIndex):h(f,f+1,f+2,u.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(od).negate(),this.translate(od.x,od.y,od.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new me;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new M,t=new M;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=this.vertices[s.a],a=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,a),t.subVectors(n,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new M;if(e){let i=new M,r=new M;for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=this.vertices[a.a],l=this.vertices[a.b],h=this.vertices[a.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[a.a].add(i),t[a.b].add(i),t[a.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=s.vertexNormals;n.length===3?(n[0].copy(t[s.a]),n[1].copy(t[s.b]),n[2].copy(t[s.c])):(n[0]=t[s.a].clone(),n[1]=t[s.b].clone(),n[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,n=r.vertexNormals.length;s<n;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new wu;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let a=0,o=this.faces.length;a<o;a++){let l=new M,h={a:new M,b:new M,c:new M};s.push(l),n.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(a.normal),l.a.copy(a.vertexNormals[0]),l.b.copy(a.vertexNormals[1]),l.c.copy(a.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new si),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Nr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,n=this.vertices,a=e.vertices,o=this.faces,l=e.faces,h=this.colors,d=e.colors;t!==void 0&&(r=new _i().getNormalMatrix(t));for(let c=0,u=a.length;c<u;c++){let p=a[c].clone();t!==void 0&&p.applyMatrix4(t),n.push(p)}for(let c=0,u=d.length;c<u;c++)h.push(d[c].clone());for(let c=0,u=l.length;c<u;c++){let p=l[c],g,f,m=p.vertexNormals,v=p.vertexColors,y=new og(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,w=m.length;x<w;x++)g=m[x].clone(),r!==void 0&&g.applyMatrix3(r).normalize(),y.vertexNormals.push(g);y.color.copy(p.color);for(let x=0,w=v.length;x<w;x++)f=v[x],y.vertexColors.push(f.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let g=0,f=p.length;g<f;g++){let m=p[g],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[y].clone());this.faceVertexUvs[c].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],d=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[d]===void 0?(t[d]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[d]]}let n=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let d=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(d[c]===d[(c+1)%3]){n.push(o);break}}for(let o=n.length-1;o>=0;o--){let l=n[o];this.faces.splice(l,1);for(let h=0,d=this.faceVertexUvs.length;h<d;h++)this.faceVertexUvs[h].splice(l,1)}let a=this.vertices.length-i.length;return this.vertices=i,a}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new M(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],n,a;r&&r.length===t&&(n=[]),s&&s.length===t&&(a=[]);for(let o=0;o<t;o++){let l=e[o]._id;n&&n.push(r[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let g in p)p[g]!==void 0&&(e[g]=p[g]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let g=this.vertices[p];t.push(g.x,g.y,g.z)}let i=[],r=[],s={},n=[],a={},o=[],l={};for(let p=0;p<this.faces.length;p++){let g=this.faces[p],f=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=g.normal.length()>0,x=g.vertexNormals.length>0,w=g.color.r!==1||g.color.g!==1||g.color.b!==1,_=g.vertexColors.length>0,S=0;if(S=h(S,0,0),S=h(S,1,f),S=h(S,2,m),S=h(S,3,v),S=h(S,4,y),S=h(S,5,x),S=h(S,6,w),S=h(S,7,_),i.push(S),i.push(g.a,g.b,g.c),i.push(g.materialIndex),v){let A=this.faceVertexUvs[0][p];i.push(u(A[0]),u(A[1]),u(A[2]))}if(y&&i.push(d(g.normal)),x){let A=g.vertexNormals;i.push(d(A[0]),d(A[1]),d(A[2]))}if(w&&i.push(c(g.color)),_){let A=g.vertexColors;i.push(c(A[0]),c(A[1]),c(A[2]))}}function h(p,g,f){return f?p|1<<g:p&~(1<<g)}function d(p){let g=p.x.toString()+p.y.toString()+p.z.toString();return s[g]!==void 0||(s[g]=r.length/3,r.push(p.x,p.y,p.z)),s[g]}function c(p){let g=p.r.toString()+p.g.toString()+p.b.toString();return a[g]!==void 0||(a[g]=n.length,n.push(p.getHex())),a[g]}function u(p){let g=p.x.toString()+p.y.toString();return l[g]!==void 0||(l[g]=o.length/2,o.push(p.x,p.y)),l[g]}return e.data={},e.data.vertices=t,e.data.normals=r,n.length>0&&(e.data.colors=n),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new wu().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,u=t.length;c<u;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,u=i.length;c<u;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,u=r.length;c<u;c++)this.faces.push(r[c].clone());for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let g=0,f=p.length;g<f;g++){let m=p[g],v=[];for(let y=0,x=m.length;y<x;y++){let w=m[y];v.push(w.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,u=s.length;c<u;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let g=0,f=s[c].vertices.length;g<f;g++)p.vertices.push(s[c].vertices[g].clone())}if(s[c].normals!==void 0){p.normals=[];for(let g=0,f=s[c].normals.length;g<f;g++)p.normals.push(s[c].normals[g].clone())}this.morphTargets.push(p)}let n=e.morphNormals;for(let c=0,u=n.length;c<u;c++){let p={};if(n[c].vertexNormals!==void 0){p.vertexNormals=[];for(let g=0,f=n[c].vertexNormals.length;g<f;g++){let m=n[c].vertexNormals[g],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let g=0,f=n[c].faceNormals.length;g<f;g++)p.faceNormals.push(n[c].faceNormals[g].clone())}this.morphNormals.push(p)}let a=e.skinWeights;for(let c=0,u=a.length;c<u;c++)this.skinWeights.push(a[c].clone());let o=e.skinIndices;for(let c=0,u=o.length;c<u;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,u=l.length;c<u;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let d=e.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new mk().fromGeometry(this),t=new He,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",ld.call(new qe(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",ld.call(new qe(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",lw.call(new qe(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",hw.call(new qe(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",hw.call(new qe(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],n=e.morphTargets[r];for(let a=0,o=n.length;a<o;a++){let l=n[a],h=new De(l.data.length*3,3);h.name=l.name,s.push(ld.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new De(e.skinIndices.length*4,4);t.setAttribute("skinIndex",cw.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new De(e.skinWeights.length*4,4);t.setAttribute("skinWeight",cw.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new He,i=e.geometry;if(e.isPoints||e.isLine){let r=new De(i.vertices.length*3,3),s=new De(i.colors.length*3,3);if(t.setAttribute("position",ld.call(r,i.vertices)),t.setAttribute("color",lw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new De(i.lineDistances.length,1);t.setAttribute("lineDistance",gk.call(n,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};wu.prototype.isGeometry=!0;var mk=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,n=e.faces;for(r=0;r<n.length;r++){let a=n[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,n=r[1]&&r[1].length>0,a=e.morphTargets,o=a.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,d=h.length,c;if(d>0){c=[];for(let m=0;m<d;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let u=e.skinIndices,p=e.skinWeights,g=u.length===i.length,f=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let w=v.normal;this.normals.push(w,w,w)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][m];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new k,new k,new k))}if(n===!0){let w=r[1][m];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new k,new k,new k))}for(let w=0;w<o;w++){let _=a[w].vertices;l[w].data.push(_[v.a],_[v.b],_[v.c])}for(let w=0;w<d;w++){let _=h[w].vertexNormals[m];c[w].data.push(_.a,_.b,_.c)}g&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),f&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},og=class{constructor(e,t,i,r,s,n=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new M,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Fe,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=n}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function gk(e){return this.array.set(e),this}function lw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new Fe),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function hw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new k),t[i++]=n.x,t[i++]=n.y}return this}function ld(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new M),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function cw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new tt),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var vk=["a","b","c"];function yk(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Af(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function Mf(e,t,i,r,s,n){let a=Math.min(e,t),o=Math.max(e,t),l=a+"_"+o,h;if(r.has(l))h=r.get(l);else{let d=i[a],c=i[o];h={a:d,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),n[e].edges.push(h),n[t].edges.push(h)}function xk(e,t,i,r){let s,n,a;for(s=0,n=e.length;s<n;s++)i[s]={edges:[]};for(s=0,n=t.length;s<n;s++)a=t[s],Mf(a.a,a.b,e,r,a,i),Mf(a.b,a.c,e,r,a,i),Mf(a.c,a.a,e,r,a,i)}function hd(e,t,i,r,s){e.push(new og(t,i,r,void 0,void 0,s))}function xo(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function cd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var wk=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof He?e=new wu().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new M,i,r,s,n,a,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],d=h!==void 0&&h.length>0,c=[],u=new Map;xk(o,l,c,u);let p=[],g,f,m,v,y,x,w;for(let ne of Array.from(u.keys())){for(f=u.get(ne),m=new M,y=3/8,x=1/8,w=f.faces.length,w!=2&&(y=.5,x=0,w!=1),m.addVectors(f.a,f.b).multiplyScalar(y),t.set(0,0,0),n=0;n<w;n++){for(v=f.faces[n],a=0;a<3&&(g=o[yk(v,vk[a])],!(g!==f.a&&g!==f.b));a++);g&&t.add(g)}t.multiplyScalar(x),m.add(t),f.newEdge=p.length,p.push(m)}let _,S,A,b,E,C,T,P=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],E=c[r].edges,i=E.length,i==3?_=3/16:i>3&&(_=3/(8*i)),S=1-i*Number(_),A=_,i<=2&&(i==2?(S=3/4,A=1/8):i==1||i==0),T=C.clone().multiplyScalar(S),t.set(0,0,0),n=0;n<i;n++)b=E[n],g=b.a!==C?b.a:b.b,t.add(g);t.multiplyScalar(Number(A)),T.add(t),P.push(T)}let L=P.concat(p),D=P.length,j,W,q,z=[],V=[],F,N,B,H,X=new k,Q=new k,U=new k;for(r=0,s=l.length;r<s;r++)v=l[r],j=Number(Af(v.a,v.b,u).newEdge)+D,W=Number(Af(v.b,v.c,u).newEdge)+D,q=Number(Af(v.c,v.a,u).newEdge)+D,hd(z,j,W,q,v.materialIndex),hd(z,v.a,j,q,v.materialIndex),hd(z,v.b,W,j,v.materialIndex),hd(z,v.c,q,W,v.materialIndex),d&&(F=h[r],N=F[0],B=F[1],H=F[2],X.set(xo(N.x,B.x),xo(N.y,B.y)),Q.set(xo(B.x,H.x),xo(B.y,H.y)),U.set(xo(N.x,H.x),xo(N.y,H.y)),cd(V,X,Q,U),cd(V,N,X,U),cd(V,B,Q,X),cd(V,H,U,Q));e.vertices=L,e.faces=z,d&&(e.faceVertexUvs[0]=V)}},ai=new M,bk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new He().copy(new Is(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ai),r={width:ai.x,height:ai.y,depth:ai.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,n=e.geometry??new He().copy(new Is(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ai)):ai.set(a.width,a.height,a.depth),(t!==ai.x||i!==ai.y||r!==ai.z)&&n.scale(ai.x===0?1:t/ai.x,ai.y===0?1:i/ai.y,ai.z===0?1:r/ai.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new wk(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new T_(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ai);let n=100/ai.x;Object.assign(s.parameters,{width:100,height:ai.y*n,depth:ai.z*n}),t(this.build(s))})}},w2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5,c=0,u=0,p=2*Math.PI/r;for(let f=0;f<r;f++){let m=p*f,v=c+Math.sin(m)*h,y=u+Math.cos(m)*d;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let f=0,m=l.points.length;f<m;f++)l.points[f].roundness=s;l.roundness=s,l.update();let g=Qa.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(g,{userData:{...e,type:"PolygonGeometry"}})}},_k=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new Ak(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function eh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Ef(e,t,i,r,s,n){let a=t.clone().sub(e),o=i.clone().sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(e),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function Sk(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var Ak=class extends He{constructor(e=.5,t=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],d=[],c=0,u=t/2,p=Math.PI/i,g=e*Math.cos(Math.PI/i),f=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new M(0,-u,0),x=new M(0,u,0),w=new k(e,-u),_=new k(g,-u),S=new k(0,x.y).sub(_),A=new k(0,x.y).sub(w),b=new k(S.y,-S.x).normalize(),E=new k(A.y,-A.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new M(b.x,b.y,0),V=new M(Math.cos(f)*z.x,z.y,Math.sin(f)*z.x);T=z.angleTo(V)}let P=n/Math.tan((Math.PI-S.angle())/2),L=n/Math.tan((Math.PI-T)/2),D=new M;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),d.push(0,0);let z=c++,V=[],F=w.clone(),N=P/Math.cos(Math.PI/i);F.x-=N;for(let B=0;B<i;B++){let H=B/i*Math.PI*2+p,X=new k(Math.sin(H),Math.cos(H));eh(F,X,D),l.push(D.x,D.y,D.z),h.push(0,-1,0),d.push(0,0),V.push(c++)}for(let B=0;B<V.length;B++)o.push(V[B],z,V[(B+1)%V.length])}let j=[];{let z=new M,V=new M,F=new M,N=new M,B=new M,H=new M;for(let X=0;X<i;X++){let Q=X/i*Math.PI*2+p,U=(X+.5)/i*Math.PI*2+p,ne=(X+1)/i*Math.PI*2+p,G=new k(Math.sin(Q),Math.cos(Q)),$=new k(Math.sin(U),Math.cos(U)),Z=new k(Math.sin(ne),Math.cos(ne));eh(w,G,V),eh(w,Z,F),eh(b,$,z),Ef(x,V,F,L,L,N),l.push(N.x,N.y,N.z),Ef(V,x,F,L,P,B),l.push(B.x,B.y,B.z),Ef(F,V,x,P,L,H),l.push(H.x,H.y,H.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),d.push(0,0),d.push(0,0),d.push(0,0);let ve=c++,re=c++,oe=c++;if(o.push(ve,re,oe),n>0){{let Oe=V.clone().add(F).multiplyScalar(.5),_e=x.clone().sub(Oe).normalize(),Se=y.clone().sub(Oe).normalize().add(_e).normalize().multiplyScalar(-1),Ie=H.clone().sub(B);W(Oe,Ie,Se,S.angle())}let ue,be;{let Oe=new M;eh(E,Z,Oe);let _e=H.clone().add(N).multiplyScalar(.5);_e=Sk(_e,F,x);let Se=H.clone().sub(N);[ue,be]=W(_e,Se,Oe,T,N.y)}{let Oe=ue,_e=Oe.clone().setY(0).normalize(),Se=new M(0,-1,0),Ie=_e.clone().cross(Se);q(Oe,_e,Se,Ie)}j.concat(be);{let Oe=S.angle(),_e=Math.PI-Oe,Se=x.clone();Se.y-=n/Math.sin(Oe-Math.PI/2);let Ie=new M,Xe=[];for(let R=0;R<a;R++){let O=[],ie=Math.PI/2-_e*R/a,fe=Math.cos(ie),ge=Math.sin(ie),Ae=U;for(let Ye=0;Ye<=R;Ye++){let Me=Math.cos(Ae),ce=Math.sin(Ae);z.x=fe*ce,z.y=ge,z.z=fe*Me,Ie.copy(Se).addScaledVector(z,n),l.push(Ie.x,Ie.y,Ie.z),h.push(z.x,z.y,z.z),d.push(0,0),O.push(c++),Ae+=Math.PI*2/R/i}Xe.push(O)}be.reverse(),Xe.push(be);let ct=Xe.length-1;for(let R=0;R<ct;R++){let O=Xe[R],ie=Xe[R+1],fe=O.length-1;o.push(ie[1],O[0],ie[0]);for(let ge=1;ge<=fe;ge++)o.push(O[ge],O[ge-1],ie[ge]),o.push(ie[ge+1],O[ge],ie[ge])}}}}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(d,2));function W(z,V,F,N,B){let H=-N/2,X=(Math.PI-N)/2,Q=V.clone().normalize().cross(F);z.addScaledVector(F,-n/Math.sin(X));let U=new M,ne=new M,G=1,$=c,Z=[];for(let ve=0;ve<=a;ve++){let re=H+ve/a*N;ne.set(0,0,0),ne.addScaledVector(Q,Math.sin(re)),ne.addScaledVector(F,Math.cos(re));for(let oe=0;oe<=G;oe++){let ue=oe/G-.5;if(U.copy(z),U.addScaledVector(V,ue),U.addScaledVector(ne,n),B!=null){let be=Math.max(0,U.y-B);U.addScaledVector(V,-be/V.y)}l.push(U.x,U.y,U.z),h.push(ne.x,ne.y,ne.z),d.push(0,0),oe===0&&Z.push(c),c++}}for(let ve=0;ve<a;ve++)for(let re=0;re<G;re++){let oe=$+re+(G+1)*ve,ue=oe+(G+1),be=ue+1,Oe=oe+1;o.push(oe,ue,Oe),o.push(ue,be,Oe)}return[z.clone().addScaledVector(V,.5),Z]}function q(z,V,F,N){let B=Math.PI/2,H=A.angle()-B,X=[],Q=new M,U=new M;for(let G=0;G<=a;G++){let $=[],Z=G/a;for(let ve=0;ve<=G;ve++){let re=((G?ve/G:0)-.5)*v,oe=Math.cos(re),ue=Math.sin(re),be=Math.atan(Math.tan(H)*oe),Oe=(B+be)*Z,_e=Math.cos(Oe),Se=Math.sin(Oe);Q.set(0,0,0),Q.addScaledVector(V,Se*oe),Q.addScaledVector(F,_e),Q.addScaledVector(N,Se*ue),U.copy(z).addScaledVector(Q,n),l.push(U.x,U.y,U.z),h.push(Q.x,Q.y,Q.z),d.push(0,0),$.push(c++)}X.push($)}let ne=X.length-1;for(let G=0;G<ne;G++){let $=X[G],Z=X[G+1],ve=$.length-1;o.push($[0],Z[1],Z[0]);for(let re=1;re<=ve;re++)o.push($[re-1],$[re],Z[re]),o.push($[re],Z[re+1],Z[re])}}}},b2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},d={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function u(w,_,S){return _>i&&S>r?Math.min(w*i/_,w*r/S):_>i?w*i/_:S>r?w*r/S:w}let p=[];p[0]=s[0]===0?0:u(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:u(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:u(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:u(s[3],s[3]+s[0],s[3]+s[2]);let g=d.x,f=c.x,m=c.y,v=d.y;t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(f,v)),t.addPoint(t.createPoint(g,v)),t.isClosed=!0;let y=!0;for(let w=0,_=t.points.length;w<_;w++)t.points[w].roundness=p[w],w>0&&p[w]!==p[w-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=Qa.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},Mk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:n=64,phiStart:a,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,d=new Hg(.5*t,s,n,a,o,l,h);return d.scale(1,i/t,r/t),Object.assign(d,{userData:{...e,type:"SphereGeometry"}})}},Ek=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,n=new Lu(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},Ck=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=e.parameters,o=new Tk(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},Tk=class extends He{constructor(e=1,t=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let d=[],c=Math.PI/2,u=(ne=0,G=0,$=0)=>new M(ne,G,$),p=u(),g=u(),[f,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[w,_,S]=[u(y,-f,+v),u(y,-f,-v),u(y,+f,-v)],A=(ne,G=!1)=>Math.sin(ne-Math.PI/(1+ +G)),b=(ne,G=!1)=>Math.cos(ne-Math.PI/(1+ +G));S.y=Math.sin(r)*t-f;let E=Math.cos(r)*t-v,C=w.z-h;r<=c?(S.z=Math.min(E,C),S.z==C&&(S.y-=(E-C)/Math.tan(c-r))):_.z=Math.min(_.z-E-v,w.z-h),p.subVectors(w,_),g.subVectors(S,_);let T=Math.min(p.length(),g.length())*s/100,P=T*Math.tan(r/2),L=T/Math.cos(r/2),D=p.clone().normalize().add(g.normalize()).setLength(L).add(_);p.set(0,A(r,!0),b(r,!0)),d.push([S,p.clone()]);let j=(Math.PI-r)/n;for(let ne=0;ne<=n;ne++){let G=c+r+ne*j;p.set(0,Math.sin(G)*P,Math.cos(G)*P),p.add(D),g.set(0,A(G),b(G)),d.push([p.clone(),g.clone()])}d.push([w,u(0,1,0)]);let W=Math.sin(j/2)*P*2,q=d.length-1,z=d[0][0].distanceTo(d[1][0]),V=d[q-1][0].distanceTo(d[q][0]),F=z+W*n+V;d[0].push(1);for(let ne=0;ne<=n;ne++)d[ne+1].push(1-(z+ne*W)/F);d[q].push(0);let[N,B,H]=d[0],X,Q,U;for(let ne=1;ne<d.length;ne++)[X,Q,U]=d[ne],a.push(y,N.y,N.z,y,X.y,X.z,x,N.y,N.z,x,N.y,N.z,y,X.y,X.z,x,X.y,X.z),o.push(0,B.y,B.z,0,Q.y,Q.z,0,B.y,B.z,0,B.y,B.z,0,Q.y,Q.z,0,Q.y,Q.z),l.push(0,H,0,U,1,H,1,H,0,U,1,U),[N,B,H]=[X,Q,U];this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}},_2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,d=e.shape,c=t*.5,u=i*.5,p=0,g=0,f=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=u*r/100;if(s===3&&r===50){f=2*Math.PI/s;for(let w=0;w<s;w++){let _=f*w,S=p+Math.sin(_)*c,A=g+Math.cos(_)*u;d.addPoint(d.createPoint(S,A))}}else for(let w=0;w<s;w++){let _=p+Math.cos(m)*c,S=g+Math.sin(m)*u;d.addPoint(d.createPoint(_,S)),m+=f,_=p+Math.cos(m)*v,S=g+Math.sin(m)*y,w<=s,d.addPoint(d.createPoint(_,S)),m+=f}d.isClosed=!0;for(let w=0,_=d.points.length;w<_;w++)d.points[w].roundness=n;d.roundness=n,d.update();let x=Qa.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},Pk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new Lu(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},Dk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=Ok(t,i,r,t*.5,a,n,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function Ok(e,t,i,r,s,n,a,o,l,h,d){return[t,i]=[i,t],a=t/2,s/=2*Math.PI,s==1&&(h=0),new y2(!0,e,t,i,r,s,n,a,o,l,h,d)}var Lk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new M_(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},Rk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof Gt?e.shape:new Gt,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5;o?(l.addPoint(l.createPoint(-h,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))),l.isClosed=!0;for(let u=0,p=l.points.length;u<p;u++)l.points[u].roundness=r;l.roundness=r,l.update();let c=Qa.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function Ik(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function Bk(e,t,i){let r=[new M,new M,new M],s=[new M,new M,new M];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((n,a)=>{let o=s[a],l=st.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new me().makeBasis(r[0],r[1],r[2])}var zk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=t?.shapeData??Ov.create({parameters:qS}).userData.shape;return{path:e.path??hu.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...XS,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new Nk(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new He,{userData:{...e,type:"PathGeometry"}})}},Nk=class extends He{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)||!Ik(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,n=Math.floor(r*s),a=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,a-n+1),s+2),l=[],h=[];for(let C=0;C<o;C++){let T=this.inputs.path.isClosed?(C+n)%e.length:Math.min(C+n,e.length-1);l.push(e[T].clone()),h.push(t[T].clone())}let d=(C,T,P)=>{l[C]=l[C].clone().lerp(l[T],P),h[C]=Bk(h[C],h[T],P)},c=0,u=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(u||r===0)&&(c=u,d(0,1,c));let p=0,g=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&g&&(p=g,d(l.length-1,l.length-2,1-p)),i===0){let C=l.length-1;l[C].copy(l[0]),h[C].copy(h[0])}this._applyPathModifiers(h,c,p);let{regions:f,infos:m,vertices:v}=this._computeShapePoints(5),y=0,x=0;m.sort((C,T)=>C.start-T.start),m.forEach(C=>{C.verticesStart=y,C.verticesCount=C.continuous.reduce((T,P,L)=>T+(L===0||!P?2:1),0),x+=C.verticesCount,y=x});let w=x*o,_,S=0;if(this._isOpenEnded()){try{_=Xn({windingRule:_t.ODD,elementType:ii.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:f})}catch{_=c2}S=_.vertexCount}let A=w+2*S,b={positions:new Float32Array(A*3),normals:new Float32Array(A*3),uvs:new Float32Array(A*2)},E=[];m.forEach(C=>{this._extrudeRegion(C,v,h,l,b,E,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,w,E,b,h[0],l[0],!1),this._closeEnd(_,w+S,E,b,h[h.length-1],l[l.length-1],!0)),this.setAttribute("position",new qe(b.positions,3)),this.setAttribute("normal",new qe(b.normals,3)),this.setAttribute("uv",new qe(b.uvs,2)),this.setIndex(E)}_extractPathPoints(){let e=e2(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new M,n=new M,a=new M,o=new M,l=new M(0,1,0);for(let g=0;g<i;g++){let f=e[g],m;g===0?m=r?e[e.length-2]:f.clone().multiplyScalar(2).sub(e[1]):m=e[g-1];let v;g===i-1?v=r?e[1]:f.clone().multiplyScalar(2).sub(e[g-1]):v=e[g+1];let y=f.clone().sub(m).normalize(),x=v.clone().sub(f).normalize(),w=y.clone().add(x).normalize();a.copy(w),g===0&&(w.equals(l)||w.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(w).normalize(),S=w.clone().cross(_).normalize();l.copy(S),o.copy(_),g===0&&(s.copy(S),n.copy(w));let A=new me().makeBasis(_,S,w);t.push(A)}let h=r?n:a,d=r?s:new M(0,1,0),c=h.clone().cross(o).normalize(),u=Math.acos(d.dot(c));if(isNaN(u))return t;let p=d.clone().cross(c);h.dot(p)>0&&(u*=-1);for(let g=1;g<t.length;g++){let f=new me().makeRotationZ(u*g/t.length);t[g].multiply(f)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new me,h=new me;return e.forEach((d,c)=>{let u=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(st.lerp(s,s+n,u));let p=st.lerp(a,o,u);h.makeScale(p,p,p),d.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=_t.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let g=p.extractShapePointsToFlatArray([],e),f=[];for(let m=g.length-1;m>=1;m-=2){let v=g[m-1],y=g[m-0];f.push(v,y)}return f}),n;try{n=Xn({windingRule:t,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=Dv}let a;try{a=Xn({windingRule:_t.ODD,elementType:ii.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=h2}if(!n)throw new Error("error generating geometry");let o=n.elementCount;if(a){n.elementCount+=a.elementCount;for(let p=0;p<a.elements.length;p++){let g=a.elements[p],f=p%2===0?n.vertexCount:0;n.elements.push(g+f)}for(let p=0;p<a.vertexIndices.length;p++){let g=a.vertexIndices[p],f=n.vertexCount;n.vertexIndices.push(g+f)}for(let p=0;p<a.vertices.length;p++){let g=a.vertices[p];n.vertices.push(g)}}let l=1/0,h=-1/0,d=1/0,c=-1/0;for(let p=0,g=n.vertexCount;p<g;p++){let f=p*2,m=n.vertices[f+0],v=n.vertices[f+1];m<l&&(l=m),m>h&&(h=m),v<d&&(d=v),v>c&&(c=v)}let u=[];for(let p=n.elementCount-1;p>=0;p--){let g=p>=o,f=p*2,m=n.elements[f+0],v=n.elements[f+1],y=m+v,x={start:m,count:v,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};u.push(x);let w=m,_=y-1,S=m+1,A=i.roundedCurves.length;do{let b=w-m,E=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[w*2+0],P=n.vertices[w*2+1],L=n.vertices[S*2+0],D=n.vertices[S*2+1],j=T-E,W=P-C,q=Math.sqrt(j*j+W*W);j/=q,W/=q;let z=T-L,V=P-D,F=Math.sqrt(z*z+V*V);z/=F,V/=F,x.normals[b*2+0]=-V,x.normals[b*2+1]=z;let N=n.vertexIndices[w];if(Array.isArray(N))x.continuous[b]=!1;else{let[B,H]=i.getCurveIndexFromVertexId(N-1,!0);if(H>0&&H<1)x.continuous[b]=!0;else{let X=H===1?B+1:B-1;X=(X+A)%A;let Q=H===1?0:1,U=i.roundedCurves[B].getTangent(H),ne=i.roundedCurves[X].getTangent(Q);x.continuous[b]=U.dot(ne)>.95}}g&&(x.normals[b*2+0]*=-1,x.normals[b*2+1]*=-1),[_,w,S]=[w,S,S+1],S>=y&&(S-=v)}while(S!==m+1)}return{regions:[r,...s],infos:u,vertices:n.vertices}}_insertVertex(e,t,i,r,s){let n=t*2,a=t*3;e.positions[a+0]=i.x,e.positions[a+1]=i.y,e.positions[a+2]=i.z,e.normals[a+0]=r.x,e.normals[a+1]=r.y,e.normals[a+2]=r.z,e.uvs[n+0]=s.x,e.uvs[n+1]=s.y}_extrudeRegion(e,t,i,r,s,n,a){let o=new M,l=new M,h=new M,d=new M,c=new k;i.forEach((p,g)=>{let f=r[g],m=e.verticesStart*i.length+e.verticesCount*g;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(f),e.continuous[v])d.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v==0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),d.copy(o).sub(l),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,g/(i.length-1)),this._insertVertex(s,m,h,d,c),m++,!e.continuous[v]||v===0){if(v===0)d.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,g/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),d.copy(l).sub(o),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,d,c),m++}}});let u=i.length-1;for(let p=0;p<u;p++){let g=e.verticesStart*i.length+e.verticesCount*p,f=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=g+m,w=g+y,_=f+y,S=f+m;e.isHole?n.push(x,_,w,x,S,_):n.push(x,w,_,x,_,S),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new M(0,0,a?-1:1).applyMatrix4(s),h=new M,d=new k;for(let u=0;u<o;u++){let p=2*u;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(n),this._insertVertex(r,t+u,h,l,d)}let c=e.elements;for(let u=0;u<e.elementCount;u++){let p=3*u,g=c[p+0]+t,f=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(g,f,m)}}};function S2(){let e=new He;return e.setAttribute("position",new qe(new Float32Array([]),3)),e.setIndex(new qe(new Uint16Array([]),1)),e}var Uk=S2().attributes,Fk=12,kk=1,A2=class extends He{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,Uk),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,text:o,textTransform:l}=e,h=l===2?o.toUpperCase():l===3?o.toLowerCase():o,d=jk(e,t,h),{shapes:c,charWidths:u,charCoords:p}=t.generateShapes(d,e),g=i*.5,f=r*.5,m=c.map(x=>new Gt().fromShape(x));this.vectorShapes=m;let v=m.map(x=>Qa.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?_t.NONZERO:_t.ODD,subdivisions:this.isLowResolution&&s>0?kk:Fk}})),y=v.length?Ta(v):S2();y.translate(-g,f,0),this.dispose(),this.wrappedText=d,this.charCoords=p,this.charWidths=u,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,w])=>{this.setAttribute(x,w)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Va(new He,A2.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function jk(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
3139
3139
  `?(r[r.length-1]+=s,s="",n===`
3140
- `&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var M2,Lv=new Promise(e=>{M2=e}),dw=!1;async function Gk(){if(dw)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.378/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});M2(s),dw=!0}function bu(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Gt.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new T_().parse(e);else{if(e.type==="SubdivGeometry")return new ki(e,i);if(e.type==="TextGeometry")return new A2(e,t)}let s;try{s=vw(r)}catch(n){console.error(n)}if(!s){let n=Gt.createFromState(lu.defaultData(),100,100);r.shape=n,s=vw(r)}return s}var Vk=new me;function lg(e,t,i,r){let s=e.position.array,n=e.normal.array,a=Vk.makeScale(t,i,r).invert().elements,o,l,h;for(var d=0,c=s.length;d<c;d+=3)s[d]*=t,s[d+1]*=i,s[d+2]*=r,o=n[d],l=n[d+1],h=n[d+2],n[d]=a[0]*o+a[4]*l+a[8]*h,n[d+1]=a[1]*o+a[5]*l+a[9]*h,n[d+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var dd=new si,wo=new M,Ne;Lv.then(e=>{Ne=e});var uw=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),pw=new Uint32Array([0,1,2,3]),fw=new Uint8Array([4]),ki=class extends He{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=za.div(t,i);this.subdividedGeometry&&lg(this.subdividedGeometry.attributes,...r),this.originalGeometry&&lg(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(wo.fromArray(r));let n=wo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=ki.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Is(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ki.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Nr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;dd.setFromBufferAttribute(t),dd.getCenter(i),e.boundingSphere.radius=i.distanceTo(dd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),dd.getSize(wo);let r={width:wo.x,height:wo.y,depth:wo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Ne.free_bvh(t),Ne.free_subdivision_surface(t));try{s=ki.allocate(e,r)}catch(l){console.error(l,e),s=ki.allocate({positionWASM:uw,indexWASM:pw,verticesPerFaceWASM:fw},r)}if(Ne.set_destination_refinement_level(s,0),n=ki.buildLevel(s,!0,o),e.subdivisions>0)try{Ne.set_destination_refinement_level(s,e.subdivisions),a=ki.buildLevel(s,!1,o)}catch{try{Ne.set_destination_refinement_level(s,e.subdivisions-1),a=ki.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0?t.geometry:bu(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let n,a,o,l;({positions:n,triIndices:l}=Ku(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,c=d+e.radialSegments*3;h=[d,c]}return{indices:a,verticesPerFace:o}=E2(n,l,r,h),{positions:n,indices:a,verticesPerFace:o}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=uw,r=pw,s=fw);let o=i.length,l=r.length,h=s.length,d=i.length+n.length+a.length,c=r.length+s.length,u=d*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,g=c*Uint32Array.BYTES_PER_ELEMENT,f=Ne._malloc(u),m=new Float32Array(Ne.HEAPF32.buffer,f,d),v=new Uint32Array(Ne.HEAPU32.buffer,f+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(w=>w!==1)&&(y=new me().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Ne.alloc_subdivision_surface2(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ne.alloc_subdivision_surface(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ne._free(f),x}static buildLevel(e,t,i,r,s){let n=s?Ne.get_mesh_data2(e,t?Ne.Level.CONTROL:Ne.Level.REFINED,i,s.elements):Ne.get_mesh_data(e,t?Ne.Level.CONTROL:Ne.Level.REFINED,i),a=8,o=Ne.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,d=Ne.HEAPU32[o[h]>>2],c=Ne.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=Ne.HEAPU32[o[h]>>2],p=Ne.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let g=Ne.HEAPU32[o[h]>>2],f=Ne.HEAPU32.subarray(g>>2,(g>>2)+l[h]);h++;let m=Ne.HEAPU32[o[h]>>2],v=Ne.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new He;if(y.setIndex(new Ho(v,1)),y.setAttribute("position",new De(c,3)),y.setAttribute("normal",new De(p,3)),t){y.setAttribute("faceMap",new Ho(f,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new qe(x,4))}return Ne.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Ne.free_mesh_data(n)}static freeSubdivPointer(e){Ne.free_bvh(e),Ne.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ne.get_wireframe_data_for_base_level(e),s=4,n=Ne.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Ne.HEAPU32[n[o]>>2],h=Ne.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let d=Ne.HEAPU32[n[o]>>2],c=Ne.HEAPU32.subarray(d>>2,(d>>2)+a[o]);if(t===void 0){let u=new He;u.setAttribute("position",new De(h,3));let p=new Float32Array(h.length);for(let g=0,f=h.length;g<f;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return u.setAttribute("color",new qe(p,3)),u.setIndex(new Ho(c,1)),Ne.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ne.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ne.set_destination_refinement_level(e,t);let s=i?Ne.get_topological_data2(e,r?Ne.Level.CONTROL:Ne.Level.REFINED,i.elements):Ne.get_topological_data(e,r?Ne.Level.CONTROL:Ne.Level.REFINED),n=6,a=Ne.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Ne.HEAPU32[a[l]>>2],d=new Float32Array(Ne.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ne.HEAPU32[a[l]>>2],u=new Uint32Array(Ne.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ne.HEAPU32[a[l]>>2],g=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ne.free_topological_data(s),{positions:d,indices:u,verticesPerFace:g}}},mw=["getX","getY","getZ"];function Ku(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let d=t?t.getX(h):h,c="";for(let u=0;u<3;u++)c+=`${~~(e[mw[u]](d)*o)},`;if(c in i)n.push(i[c]);else{for(let u=0;u<3;u++)a.push(e[mw[u]](d));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var ud=new M,Cf=new M,Tf=new M,Pf=new M;function E2(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let d=a.length/2/o;a=a.filter((c,u)=>Math.floor(u/2)%d===0)}let l=0;for(let d=0;d<a.length;d+=2)l+=(a[d]-a[(d===0?a.length:d)-2])*(a[d+1]+a[(d===0?a.length:d)-1]);e.length=0;let h=0;if(l<0)for(let d=0;d<a.length;d+=2)e.push(a[d],a[d+1],0),s.push(h++);else for(let d=a.length-2;d>=0;d-=2)e.push(a[d],a[d+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){ud.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),Cf.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),Tf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),Pf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),Cf.sub(ud).normalize(),Tf.sub(ud).normalize(),Pf.sub(ud).normalize();let l=Cf.cross(Tf).dot(Pf);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:a>=r[d]&&a<r[d+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let d=0,c=0;d<e.length;d+=3,c++)e[d+2]===0&&(a.push(c),l++),e[d+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let d=o[0];o[0]=o[1],o[1]=d}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var Nn={};WM(Nn,{calcBoolean:()=>Yk,calcBooleanTopological:()=>Xk,freeMeshSet:()=>Kk,getMeshSet:()=>Qk,transformMeshSet:()=>Zk});var C2,Hk=new Promise(e=>{C2=e}),gw=!1;async function Wk(){if(gw)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.378/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});C2(s),gw=!0}var ot,Jo;Hk.then(e=>ot=e);function qk(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:n,triIndices:a}=Ku(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=E2(n,a,e);o=h.length,r=[];for(let d=0,c=0;d<o;d++){r.push(h[d]);for(let u=0;u<h[d];u++)r.push(l[c++])}}else{let l=a.length;r=Array(l+l/3),o=0;for(let h=0,d=0;d<r.length;)r[d++]=3,o++,r[d++]=a[h++],r[d++]=a[h++],r[d++]=a[h++]}return{positions:n,faceIndices:r,nFaces:o}}function T2(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=ot._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(ot.HEAPU32.buffer,n,t):new Float32Array(ot.HEAPF32.buffer,n,t)).set(e,0),n}function P2(e){switch(e){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function Xk(e,t){Jo===void 0&&(Jo=ot.init_csg());let i=T2(e),r=ot.csg_calc_topological(Jo,i,e.length,P2(t));ot._free(i);let s=6,n=ot.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=ot.HEAPU32[n[o]>>2],h=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let d=ot.HEAPU32[n[o]>>2],c=new Uint32Array(ot.HEAPU32.subarray(d>>2,(d>>2)+a[o]));o++;let u=ot.HEAPU32[n[o]>>2],p=new Uint8Array(ot.HEAPU32.subarray(u>>2,(u>>2)+a[o]));return ot.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function Yk(e,t,i,r){Jo===void 0&&(Jo=ot.init_csg());let s=T2(e),n=ot.csg_calc(Jo,s,e.length,r,P2(t));ot._free(s);let a=5,o=ot.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,d=ot.HEAPU32[o[h]>>2],c=ot.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=ot.HEAPU32[o[h]>>2],p=ot.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let g=l[h];i.setAttribute("position",new De(c,3)),i.setAttribute("normal",new De(p,3));let f=ot.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Nr),i.boundingSphere.center.set(f[0],f[1],f[2]),i.boundingSphere.radius=(f[3]**2+f[4]**2+f[5]**2)**.5,i.userData.parameters={width:f[3]*2,height:f[4]*2,depth:f[5]*2},ot.free_mesh_data(n),g}function Qk(e,t,i){if(ot===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let w=0;w<m.verticesPerFace[v];w++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=qk(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,d=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=ot._malloc(d),g=new Float32Array(ot.HEAPF32.buffer,p,l),f=new Uint32Array(ot.HEAPU32.buffer,p+c,h);return g.set(r,0),f.set(s,0),ot.get_csg_mesh(p,a,p+c,o,n)}function Zk(e,t){ot.transform_csg_mesh(e,t.elements)}function Kk(e){ot.free_csg_mesh(e)}var Jk={ConeGeometry:L6,CubeGeometry:R6,CylinderGeometry:i2,DodecahedronGeometry:B6,EllipseGeometry:Ov,HelixGeometry:uk,IcosahedronGeometry:pk,LatheGeometry:fk,NonParametricGeometry:bk,PolygonGeometry:w2,PyramidGeometry:_k,RectangleGeometry:b2,SphereGeometry:Mk,PlaneGeometry:Ek,BackdropGeometry:Ck,StarGeometry:_2,TextFrameGeometry:Pk,TorusGeometry:Dk,TorusKnotGeometry:Lk,TriangleGeometry:Rk,PathGeometry:zk,VectorGeometry:Qa},vw=e=>Jk[e.type].create(e);function th(e){return e!==null&&"booleanOp"in e}var D2=class extends t2(tr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new me}updateVisible(){super.updateVisible(),this.visible=!th(this.parent)&&this.visible,th(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Nn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),th(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof D2&&(e.freeBooleanPointer(),th(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&th(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},pd=new si;function Rv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0;for(let c=t;c<i;c++){let u=e.getX(c),p=e.getY(c),g=e.getZ(c);u<n&&(n=u),p<a&&(a=p),g<o&&(o=g),u>l&&(l=u),p>h&&(h=p),g>d&&(d=g)}pd.min.set(n,a,o),pd.max.set(l,h,d),pd.getCenter(r),pd.getSize(s).multiplyScalar(.5)}var $k=new He,e8=new gl,ar=class extends D2{constructor(e,t){super($k,e8),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?Rv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},yw=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},ia=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=st.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof ia&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},t8=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},er=new t8,At=class extends ia{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=st.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},or=class extends At{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},Di=class extends or{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof k?e:new k(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Er=class extends or{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof M?e:new M(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},nr=class extends Fe{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},sn=class extends or{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof nr?e:new nr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},i8=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,xw=/[a-z_0-9]+/gi,we=class extends At{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=xw.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let d=l[h],c=d[0],u=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&u&&er.containsKeyword(c)){let g=this.keywords[c];if(!g){let f=er.getKeywordData(c);f.cache&&(g=e.keywords[c]),g=g||er.getKeyword(c,e),f.cache&&(e.keywords[c]=g)}p=g.build(e)}c!==p&&o[d.index+a-1]!=="."&&(o=o.substring(0,d.index+a)+p+o.substring(d.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&er.contains(p)&&e.include(er.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=i8.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(xw);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},r8=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,O2=class extends At{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||O2.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=r8.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},wt=O2;wt.PI="PI",wt.PI2="PI2",wt.RECIPROCAL_PI="RECIPROCAL_PI",wt.RECIPROCAL_PI2="RECIPROCAL_PI2",wt.LOG2="LOG2",wt.EPSILON="EPSILON";var s8=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3140
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var M2,Lv=new Promise(e=>{M2=e}),dw=!1;async function Gk(){if(dw)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.380/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});M2(s),dw=!0}function bu(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Gt.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new T_().parse(e);else{if(e.type==="SubdivGeometry")return new ki(e,i);if(e.type==="TextGeometry")return new A2(e,t)}let s;try{s=vw(r)}catch(n){console.error(n)}if(!s){let n=Gt.createFromState(lu.defaultData(),100,100);r.shape=n,s=vw(r)}return s}var Vk=new me;function lg(e,t,i,r){let s=e.position.array,n=e.normal.array,a=Vk.makeScale(t,i,r).invert().elements,o,l,h;for(var d=0,c=s.length;d<c;d+=3)s[d]*=t,s[d+1]*=i,s[d+2]*=r,o=n[d],l=n[d+1],h=n[d+2],n[d]=a[0]*o+a[4]*l+a[8]*h,n[d+1]=a[1]*o+a[5]*l+a[9]*h,n[d+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var dd=new si,wo=new M,Ne;Lv.then(e=>{Ne=e});var uw=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),pw=new Uint32Array([0,1,2,3]),fw=new Uint8Array([4]),ki=class extends He{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=za.div(t,i);this.subdividedGeometry&&lg(this.subdividedGeometry.attributes,...r),this.originalGeometry&&lg(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(wo.fromArray(r));let n=wo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=ki.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Is(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ki.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Nr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;dd.setFromBufferAttribute(t),dd.getCenter(i),e.boundingSphere.radius=i.distanceTo(dd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),dd.getSize(wo);let r={width:wo.x,height:wo.y,depth:wo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Ne.free_bvh(t),Ne.free_subdivision_surface(t));try{s=ki.allocate(e,r)}catch(l){console.error(l,e),s=ki.allocate({positionWASM:uw,indexWASM:pw,verticesPerFaceWASM:fw},r)}if(Ne.set_destination_refinement_level(s,0),n=ki.buildLevel(s,!0,o),e.subdivisions>0)try{Ne.set_destination_refinement_level(s,e.subdivisions),a=ki.buildLevel(s,!1,o)}catch{try{Ne.set_destination_refinement_level(s,e.subdivisions-1),a=ki.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0?t.geometry:bu(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let n,a,o,l;({positions:n,triIndices:l}=Ku(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,c=d+e.radialSegments*3;h=[d,c]}return{indices:a,verticesPerFace:o}=E2(n,l,r,h),{positions:n,indices:a,verticesPerFace:o}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=uw,r=pw,s=fw);let o=i.length,l=r.length,h=s.length,d=i.length+n.length+a.length,c=r.length+s.length,u=d*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,g=c*Uint32Array.BYTES_PER_ELEMENT,f=Ne._malloc(u),m=new Float32Array(Ne.HEAPF32.buffer,f,d),v=new Uint32Array(Ne.HEAPU32.buffer,f+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(w=>w!==1)&&(y=new me().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Ne.alloc_subdivision_surface2(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ne.alloc_subdivision_surface(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ne._free(f),x}static buildLevel(e,t,i,r,s){let n=s?Ne.get_mesh_data2(e,t?Ne.Level.CONTROL:Ne.Level.REFINED,i,s.elements):Ne.get_mesh_data(e,t?Ne.Level.CONTROL:Ne.Level.REFINED,i),a=8,o=Ne.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,d=Ne.HEAPU32[o[h]>>2],c=Ne.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=Ne.HEAPU32[o[h]>>2],p=Ne.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let g=Ne.HEAPU32[o[h]>>2],f=Ne.HEAPU32.subarray(g>>2,(g>>2)+l[h]);h++;let m=Ne.HEAPU32[o[h]>>2],v=Ne.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new He;if(y.setIndex(new Ho(v,1)),y.setAttribute("position",new De(c,3)),y.setAttribute("normal",new De(p,3)),t){y.setAttribute("faceMap",new Ho(f,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new qe(x,4))}return Ne.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Ne.free_mesh_data(n)}static freeSubdivPointer(e){Ne.free_bvh(e),Ne.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ne.get_wireframe_data_for_base_level(e),s=4,n=Ne.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Ne.HEAPU32[n[o]>>2],h=Ne.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let d=Ne.HEAPU32[n[o]>>2],c=Ne.HEAPU32.subarray(d>>2,(d>>2)+a[o]);if(t===void 0){let u=new He;u.setAttribute("position",new De(h,3));let p=new Float32Array(h.length);for(let g=0,f=h.length;g<f;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return u.setAttribute("color",new qe(p,3)),u.setIndex(new Ho(c,1)),Ne.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ne.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ne.set_destination_refinement_level(e,t);let s=i?Ne.get_topological_data2(e,r?Ne.Level.CONTROL:Ne.Level.REFINED,i.elements):Ne.get_topological_data(e,r?Ne.Level.CONTROL:Ne.Level.REFINED),n=6,a=Ne.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Ne.HEAPU32[a[l]>>2],d=new Float32Array(Ne.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ne.HEAPU32[a[l]>>2],u=new Uint32Array(Ne.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ne.HEAPU32[a[l]>>2],g=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ne.free_topological_data(s),{positions:d,indices:u,verticesPerFace:g}}},mw=["getX","getY","getZ"];function Ku(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let d=t?t.getX(h):h,c="";for(let u=0;u<3;u++)c+=`${~~(e[mw[u]](d)*o)},`;if(c in i)n.push(i[c]);else{for(let u=0;u<3;u++)a.push(e[mw[u]](d));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var ud=new M,Cf=new M,Tf=new M,Pf=new M;function E2(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let d=a.length/2/o;a=a.filter((c,u)=>Math.floor(u/2)%d===0)}let l=0;for(let d=0;d<a.length;d+=2)l+=(a[d]-a[(d===0?a.length:d)-2])*(a[d+1]+a[(d===0?a.length:d)-1]);e.length=0;let h=0;if(l<0)for(let d=0;d<a.length;d+=2)e.push(a[d],a[d+1],0),s.push(h++);else for(let d=a.length-2;d>=0;d-=2)e.push(a[d],a[d+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){ud.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),Cf.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),Tf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),Pf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),Cf.sub(ud).normalize(),Tf.sub(ud).normalize(),Pf.sub(ud).normalize();let l=Cf.cross(Tf).dot(Pf);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:a>=r[d]&&a<r[d+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let d=0,c=0;d<e.length;d+=3,c++)e[d+2]===0&&(a.push(c),l++),e[d+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let d=o[0];o[0]=o[1],o[1]=d}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var Nn={};WM(Nn,{calcBoolean:()=>Yk,calcBooleanTopological:()=>Xk,freeMeshSet:()=>Kk,getMeshSet:()=>Qk,transformMeshSet:()=>Zk});var C2,Hk=new Promise(e=>{C2=e}),gw=!1;async function Wk(){if(gw)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.380/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});C2(s),gw=!0}var ot,Jo;Hk.then(e=>ot=e);function qk(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:n,triIndices:a}=Ku(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=E2(n,a,e);o=h.length,r=[];for(let d=0,c=0;d<o;d++){r.push(h[d]);for(let u=0;u<h[d];u++)r.push(l[c++])}}else{let l=a.length;r=Array(l+l/3),o=0;for(let h=0,d=0;d<r.length;)r[d++]=3,o++,r[d++]=a[h++],r[d++]=a[h++],r[d++]=a[h++]}return{positions:n,faceIndices:r,nFaces:o}}function T2(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=ot._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(ot.HEAPU32.buffer,n,t):new Float32Array(ot.HEAPF32.buffer,n,t)).set(e,0),n}function P2(e){switch(e){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function Xk(e,t){Jo===void 0&&(Jo=ot.init_csg());let i=T2(e),r=ot.csg_calc_topological(Jo,i,e.length,P2(t));ot._free(i);let s=6,n=ot.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=ot.HEAPU32[n[o]>>2],h=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let d=ot.HEAPU32[n[o]>>2],c=new Uint32Array(ot.HEAPU32.subarray(d>>2,(d>>2)+a[o]));o++;let u=ot.HEAPU32[n[o]>>2],p=new Uint8Array(ot.HEAPU32.subarray(u>>2,(u>>2)+a[o]));return ot.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function Yk(e,t,i,r){Jo===void 0&&(Jo=ot.init_csg());let s=T2(e),n=ot.csg_calc(Jo,s,e.length,r,P2(t));ot._free(s);let a=5,o=ot.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,d=ot.HEAPU32[o[h]>>2],c=ot.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=ot.HEAPU32[o[h]>>2],p=ot.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let g=l[h];i.setAttribute("position",new De(c,3)),i.setAttribute("normal",new De(p,3));let f=ot.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Nr),i.boundingSphere.center.set(f[0],f[1],f[2]),i.boundingSphere.radius=(f[3]**2+f[4]**2+f[5]**2)**.5,i.userData.parameters={width:f[3]*2,height:f[4]*2,depth:f[5]*2},ot.free_mesh_data(n),g}function Qk(e,t,i){if(ot===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let w=0;w<m.verticesPerFace[v];w++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=qk(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,d=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=ot._malloc(d),g=new Float32Array(ot.HEAPF32.buffer,p,l),f=new Uint32Array(ot.HEAPU32.buffer,p+c,h);return g.set(r,0),f.set(s,0),ot.get_csg_mesh(p,a,p+c,o,n)}function Zk(e,t){ot.transform_csg_mesh(e,t.elements)}function Kk(e){ot.free_csg_mesh(e)}var Jk={ConeGeometry:L6,CubeGeometry:R6,CylinderGeometry:i2,DodecahedronGeometry:B6,EllipseGeometry:Ov,HelixGeometry:uk,IcosahedronGeometry:pk,LatheGeometry:fk,NonParametricGeometry:bk,PolygonGeometry:w2,PyramidGeometry:_k,RectangleGeometry:b2,SphereGeometry:Mk,PlaneGeometry:Ek,BackdropGeometry:Ck,StarGeometry:_2,TextFrameGeometry:Pk,TorusGeometry:Dk,TorusKnotGeometry:Lk,TriangleGeometry:Rk,PathGeometry:zk,VectorGeometry:Qa},vw=e=>Jk[e.type].create(e);function th(e){return e!==null&&"booleanOp"in e}var D2=class extends t2(tr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new me}updateVisible(){super.updateVisible(),this.visible=!th(this.parent)&&this.visible,th(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Nn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),th(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof D2&&(e.freeBooleanPointer(),th(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&th(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},pd=new si;function Rv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0;for(let c=t;c<i;c++){let u=e.getX(c),p=e.getY(c),g=e.getZ(c);u<n&&(n=u),p<a&&(a=p),g<o&&(o=g),u>l&&(l=u),p>h&&(h=p),g>d&&(d=g)}pd.min.set(n,a,o),pd.max.set(l,h,d),pd.getCenter(r),pd.getSize(s).multiplyScalar(.5)}var $k=new He,e8=new gl,ar=class extends D2{constructor(e,t){super($k,e8),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?Rv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},yw=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},ia=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=st.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof ia&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},t8=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},er=new t8,At=class extends ia{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=st.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},or=class extends At{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},Di=class extends or{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof k?e:new k(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Er=class extends or{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof M?e:new M(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},nr=class extends Fe{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},sn=class extends or{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof nr?e:new nr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},i8=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,xw=/[a-z_0-9]+/gi,we=class extends At{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=xw.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let d=l[h],c=d[0],u=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&u&&er.containsKeyword(c)){let g=this.keywords[c];if(!g){let f=er.getKeywordData(c);f.cache&&(g=e.keywords[c]),g=g||er.getKeyword(c,e),f.cache&&(e.keywords[c]=g)}p=g.build(e)}c!==p&&o[d.index+a-1]!=="."&&(o=o.substring(0,d.index+a)+p+o.substring(d.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&er.contains(p)&&e.include(er.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=i8.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(xw);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},r8=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,O2=class extends At{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||O2.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=r8.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},wt=O2;wt.PI="PI",wt.PI2="PI2",wt.RECIPROCAL_PI="RECIPROCAL_PI",wt.RECIPROCAL_PI2="RECIPROCAL_PI2",wt.LOG2="LOG2",wt.EPSILON="EPSILON";var s8=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
3141
  )*?)}`,"gim"),n8=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),L2=class extends At{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=s8.exec(e);if(t){let i=t[2],r;for(;r=n8.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},Iv=class extends At{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};er.addKeyword("uv",function(){return new Iv});er.addKeyword("uv2",function(){return new Iv(1)});var Lo=class extends At{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Lo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Rs:return["Linear"];case Ke:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=Lo.Nodes[this.method],n=e.include(s);if(n===Lo.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let a=this.factor.build(e,"f");return e.format(n+"( "+i+", "+a+" )",r,t)}else return e.format(n+"( "+i+" )",r,t)}fromEncoding(e){let t=Lo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Lo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Ts=Lo;Ts.Nodes={LinearToLinear:new we(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3142
3142
  `)),sRGBToLinear:new we(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
3143
3143
  `)),LinearTosRGB:new we(["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(`
@@ -5191,7 +5191,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5191
5191
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result} * ${d}, ${a.result} );
5192
5192
  }
5193
5193
  `),o&&h.push(o.code,`outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),l?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=h.join(`
5194
- `)}return t}},A8=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;)this.dispose(t.src,t.data),this.cache.delete(t.src),t=t.next,t.prev=this.head,this.head.next=t;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}},M8=class extends A8{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},Df;function E8(e){return typeof e=="string"?e:(Df||(Df=new M8),Df.load(e))}var C8=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},T8=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},rA=class extends C8{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isVideo=e.type==="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let s of r){let n=this[s];n&&(n.image=this.img,n.needsUpdate=!0)}this.shared.requestRender()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=n=>{r=n.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=E8(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let i;return this.isVideo?i=new iO(this.img,void 0,e,e):i=new ci(this.img,void 0,e,e),this.loaded&&(i.needsUpdate=!0),this[e]=i,i}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}},Pa=class extends rA{};function Ri(e,t){return t.color(e)}function P8(e,t){switch(e.type){case"fresnel":return L8(e,t);case"gradient":return R8(e);case"depth":return I8(e);case"normal":return B8(e);case"noise":return z8(e,t);case"rainbow":return N8(e);case"toon":return U8(e,t);case"outline":return F8(e,t);case"transmission":return k8(e,t);case"color":return O8(e,t);case"pattern":return j8(e,t)}}function D8(e){return{type:e.type}}function os(e){let{alpha:t,mode:i,isMask:r}=e;return{...D8(e),alpha:t,mode:i,isMask:r}}function O8(e,t){return{...os(e),color:Ri(e.color,t)}}function L8(e,t){let{bias:i,scale:r,intensity:s,factor:n,color:a,isMask:o}=e;return{...os(e),color:Ri(a,t),bias:i,scale:r,intensity:s,factor:n}}function R8(e){let{gradientType:t,smooth:i,colors:r,steps:s,angle:n,offset:a,morph:o}=e;return{...os(e),gradientType:t,smooth:i,colors:r.map(l=>new tt(l[0],l[1],l[2],l[3])),num:r.length,steps:s,offset:new k(...a),morph:new k(...o),angle:n}}function I8(e){let{gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:a,direction:o,colors:l,steps:h,smooth:d}=e;return{...os(e),gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:new M(...a),direction:o?new M(...o):new M(1,0,0),colors:l.map(c=>c!==void 0?new tt(c[0],c[1],c[2],c[3]):new tt(0,0,0,0)),steps:h.slice(0,l.length),smooth:d}}function B8(e){let{cnormal:t}=e;return{...os(e),cnormal:new M(t[0],t[1],t[2])}}function z8(e,t){return{...os(e),scale:e.scale,move:e.move,fA:new k(...e.fA),fB:new k(...e.fB),size:new M(...e.size),distortion:new k(...e.distortion),colorA:Ri(e.colorA,t),colorB:Ri(e.colorB,t),colorC:Ri(e.colorC,t),colorD:Ri(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function N8(e){return{...os(e),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new M(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new M(...e.offset)}}function U8(e,t){return{...os(e),positioning:e.positioning,colors:e.colors.map(i=>new tt(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new M(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:Ri(e.shadowColor,t),offset:new M(...e.offset)}}function F8(e,t){return{...os(e),outlineColor:Ri(e.outlineColor,t),contourColor:Ri(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new M(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function k8(e,t){return{...os(e),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function j8(e,t){return{...os(e),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new k(...e.offset),colorA:Ri(e.colorA,t),colorB:Ri(e.colorB,t),frequency:new k(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new k(...e.vertical),horizontal:new k(...e.horizontal),sides:e.sides}}var _u=class extends nr{},sA={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},nA={depth:["colors"]};function G8(e,t,i){if(t==="isMask")return!0;let r=sA[e.type],s=nA[e.type];if(s!==void 0){let n=e.color;if(s.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function aA(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,n=e;if("image"in n){let a=n.image,o=t.image(a),l=r;l.image instanceof Pa||l.image.deref(),l.image=o}if("video"in n){let a=n.video,o=t.video(a),l=r;l.image instanceof Pa||l.image.deref(),l.image=o}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("repeat"in n||"offset"in n){let a="mat",o=i.uniforms[`f${i.id}_${a}`];"repeat"in n&&(o.repeat=n.repeat),"offset"in n&&(o.offset=n.offset),o.updateMatrix()}return s}function V8(e,t,i,r){let s=!1;for(let[n,a]of Object.entries(e)){if(!n||a===void 0)continue;if(lA(n,i,r)){n==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${n}`];if(!!o&&!(o instanceof Bv))switch(s=s||G8(i,n,a),o.constructor){case Vt:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof _u?o.value=new nr(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case sn:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof _u?o.value=new nr(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Di:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]);break}case Er:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case on:{aA(a,t,i);break}case ba:{o.value=a.map(l=>new tt(...l));break}default:{o.value=a;break}}}return s}var Ua=class{constructor(e,t,i,r){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let s in r)this.uniforms[`f${this.id}_${s}`]=r[s];for(let s in i)lA(s,this,i)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return Un.createLigherLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.image(i.texture.image):r.video(i.texture.video),n=new cg(s,i.texture.wrapping),a=new g8(s),o=new v8(i.texture.repeat,i.texture.offset),l=new Ce(i.crop?1:0),h=new Mt(i.projection??0),d=new Mt(["x","y","z"].indexOf(i.axis)??0),c=new Mt(i.side??0),u=new Di(i.size?new k(i.size[0],i.size[1]):new k(100,100)),p=new Ce(i.blending??0),g=new Ce(i.alpha??1),f=new Mt(i.mode??0),m=new ji(i.isMask??!1),v=new U2(n,a,l,h,d,c,u,p,o,g,f,m),y=new Rt(v.calpha,"f");return new Xt(e,t,i,{texture:n,textureSize:a,crop:l,projection:h,axis:d,side:c,size:u,blending:p,mat:o,alpha:g,mode:f,isMask:m},v,f,y,m)}else if(i.type==="matcap"){let s=r.image(i.texture.image),n=new cg(s,i.texture.wrapping),a=new Ce(i.alpha??1),o=new Mt(i.mode??0),l=new ji(i.isMask??!1),h=new V2(n,a,o,l),d=new Rt(h.calpha,"f");return new Xt(e,t,i,{texture:n,alpha:a,mode:o,isMask:l},h,o,d,l)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new Er(new M(...i.offset)),n=new Ce(i.scale??10),a=new Ce(i.intensity??8),o=new Ce(i.movement??1),l=new Mt(i.noiseType??0),h=new Mt(i.voronoiStyle??0),d=new Ce(i.smoothness??.5),c=new Ce(i.seed??0),u=new Ce(i.highCut??1),p=new Ce(i.lowCut??0),g=new Mt(i.quality??1),f=new tA(a,o,s,h,d,c,u,p,g,n,l);return new oA(e,t,i,{offset:s,scale:n,intensity:a,movement:o,noiseType:l,voronoiStyle:h,smoothness:d,seed:c,highCut:u,lowCut:p,quality:g},f)}else throw new Error;else return q8(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(i.scene?.markNeedsUpdateRendererDirty(),!0):V8(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?aA(r.props,i.shared,this):!0;return!1}dispose(){if(H8(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Pa||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},Xt=class extends Ua{constructor(e,t,i,r,s,n,a,o){super(e,t,i,r),this.params=r,this.color=s,this.mode=n,this.alpha=a,this.isMask=o}},oA=class extends Ua{constructor(e,t,i,r,s){super(e,t,i,r),this.position=s}},Un=class extends Ua{constructor(e,t,i,r,s){super(e,t,i,s),this.node=r}static createLigherLayer(e,t,i,r){let s,n=new Ce(i.alpha),a=new Mt(i.mode),o;if(!i.visible)s=new iA,o={};else if(i.category==="lambert"){s=new w8;let l=new Vt(r.color(i.emissive)??0),h=new ji(i.occlusion??!0);o={emissive:l,occlusion:h},s.emissive=l,s.occlusion=h}else if(i.category==="toon"){s=new S8;let l=new Ce(i.shininess??30),h=new Vt(r.color(i.specular)??1118481);o={shininess:l,specular:h},s.shininess=l,s.specular=h}else if(i.category==="physical"){s=new _8;let l=new Ce(i.roughness??.3),h=new Ce(i.metalness??0),d=new Ce(i.reflectivity??.5),c=new ji(i.occlusion??!0);o={roughness:l,metalness:h,reflectivity:d,occlusion:c},s.roughness=l,s.metalness=h,s.reflectivity=d,s.occlusion=c}else{s=new b8;let l=new Ce(i.shininess??30),h=new Vt(i.specular!==void 0?r.color(i.specular)??1118481:1118481),d=new ji(i.occlusion??!0);o={shininess:l,specular:h,occlusion:d},s.shininess=l,s.specular=h,s.occlusion=d}return s.alpha=new Ce(1),s.shadingAlpha=n,s.shadingBlend=a,o.alpha=s.shadingAlpha,o.mode=s.shadingBlend,new Un(e,t,i,s,o)}get category(){return this.node.category}};function H8(e){let t=e instanceof Ua?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function _r(e){return{alpha:new Ce(e.alpha??1),mode:new Mt(e.mode??0),isMask:new ji(e.isMask??!1)}}function W8(e,t,i,r){switch(e.type){case"color":{let s=new Vt(r.color??5526619),n=_r(r),a=new dg(s,n.alpha),o=new Rt(a.calpha,"f");return new Xt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}case"fresnel":{let s=new Vt(r.color??16777215),n=new Ce(r.bias??.1),a=new Ce(r.scale??1),o=new Ce(r.intensity??2),l=new Ce(r.factor??1),h=_r(r),d=new y8(s,n,a,o,l,h.alpha,h.mode,h.isMask),c=new Rt(d.calpha,"f");return new Xt(t,i,e,{color:s,bias:n,scale:a,intensity:o,factor:l,...h},d,h.mode,c,h.isMask)}case"rainbow":{let s=new Ce(r.filmThickness??30),n=new Ce(r.movement??0),a=new Er(r.wavelengths??new M(0,0,0)),o=new Ce(r.noiseStrength??0),l=new Ce(r.noiseScale??1),h=new Er(r.offset??new M(0,0,0)),d=_r(r),c=new Q2(s,n,a,o,l,h,d.alpha,d.isMask),u=new Rt(c.calpha,"f");return new Xt(t,i,e,{filmThickness:s,movement:n,wavelengths:a,noiseStrength:o,noiseScale:l,offset:h,...d},c,d.mode,u,d.isMask)}case"transmission":{let s=new Ce(r.thickness??10),n=new Ce(r.ior??1.5),a=new Ce(r.roughness??.5),o=Ue.transmissionSize,l=Ue.transmissionRenderTarget,h=Ue.transmissionRenderTargetDepth,d=window.innerWidth,c=window.innerHeight,u=d>=c?new Di(c/d,1):new Di(1,d/c),p=_r(r),g=new $2(s,n,a,o,l,h,u,p.alpha),f=new Rt(g.calpha,"f");return new Xt(t,i,e,{thickness:s,ior:n,roughness:a,aspectRatio:u,...p},g,p.mode,f,p.isMask)}case"toon":{let s=new Mt(r.positioning??0),n;r.colors?n=new ba(r.colors.length,r.colors):(n=new ba(10,new tt(0,0,0,1)),n.value[1]=new tt(1,1,1,1));let a;r.steps?a=new wa(r.steps.length,r.steps):(a=new wa(10,1),a.value[0]=0);let o=new Er(r.source??new M(0,0,0)),l=new ji(r.isWorldSpace??!0),h=new Ce(r.noiseStrength??0),d=new Ce(r.noiseScale??1),c=new sn(r.shadowColor),u=new Er(r.offset??new M(0,0,0)),p=_r(r),g=new K2(s,n,a,o,l,h,d,c,u,p.alpha),f=new Rt(g.calpha,"f");return new Xt(t,i,e,{positioning:s,colors:n,steps:a,source:o,isWorldSpace:l,noiseStrength:h,noiseScale:d,shadowColor:c,offset:u,...p},g,p.mode,f,p.isMask)}case"outline":{let s=new Vt(r.outlineColor??16777215),n=new Vt(r.contourColor??16777215),a=new Ce(r.outlineWidth??.1),o=new Ce(r.contourWidth??.1),l=new Ce(r.outlineThreshold??.1),h=new Ce(r.contourThreshold??.1),d=new Ce(r.outlineSmoothing??.1),c=new Ce(r.contourFrequency??.1),u=new Er(r.contourDirection??new M(0,1,0)),p=new ji(r.positionalLines??!1),g=new ji(r.compensation??!0),f=Ue.normalRenderTarget,m=Ue.normalRenderTargetDepth,v=Ue.pixelRatioNode,y=Ue.resolution,x=_r(r),w=new q2(s,n,a,o,l,h,d,c,u,p,g,y,f,m,v,x.alpha),_=new Rt(w.calpha,"f");return new Xt(t,i,e,{outlineColor:s,contourColor:n,outlineWidth:a,contourWidth:o,outlineThreshold:l,contourThreshold:h,outlineSmoothing:d,contourFrequency:c,contourDirection:u,positionalLines:p,compensation:g,...x},w,x.mode,_,x.isMask)}case"depth":{let s=new Mt(r.gradientType??0),n=new ji(r.smooth??!1),a=new Ce(r.near??50),o=new Ce(r.far??200),l=new Ce(r.isVector??1),h=new Ce(r.isWorldSpace??0),d=new Er(r.origin??new M),c=new Er(r.direction??new M),u;r.colors?u=new ba(r.colors.length,r.colors):(u=new ba(2,new tt(0,0,0,1)),u.value[1]=new tt(1,1,1,1));let p;r.steps?p=new wa(r.steps.length,r.steps):(p=new wa(2,1),p.value[0]=0);let g=_r(r),f=new F2(s,n,a,o,l,h,d,c,u,p,g.alpha,g.isMask),m=new Rt(f.calpha,"f");return new Xt(t,i,e,{gradientType:s,smooth:n,near:a,far:o,isVector:l,isWorldSpace:h,origin:d,direction:c,colors:u,steps:p,...g},f,g.mode,m,g.isMask)}case"noise":{let s=new Ce(r.scale??1),n=new Er(r.size??new M(100,100,100)),a=new Ce(r.move??1),o=new Di(r.fA??new k(1.7,9.2)),l=new Di(r.fB??new k(8.3,2.8)),h=new Di(r.distortion??new k(1,1)),d=new sn(r.colorA),c=new sn(r.colorB),u=new sn(r.colorC),p=new sn(r.colorD),g=new Mt(r.noiseType??0),f=new Mt(r.voronoiStyle??0),m=new Ce(r.highCut??1),v=new Ce(r.lowCut??0),y=new Ce(r.smoothness??.5),x=new Ce(r.seed??.5),w=new Mt(r.quality??1),_=_r(r),S=new H2(s,n,a,o,l,h,d,c,u,p,_.alpha,g,_.isMask,f,m,v,y,x,w),A=new Rt(S.calpha,"f");return new Xt(t,i,e,{scale:s,size:n,move:a,fA:o,fB:l,distortion:h,colorA:d,colorB:c,colorC:u,colorD:p,noiseType:g,..._,voronoiStyle:f,highCut:m,lowCut:v,smoothness:y,seed:x,quality:w},S,_.mode,A,_.isMask)}case"normal":{let s=new Er(r.cnormal??new M(1,1,1)),n=_r(r),a=new N2(s,n.alpha),o=new Rt(a.calpha,"f");return new Xt(t,i,e,{cnormal:s,...n},a,n.mode,o,n.isMask)}case"gradient":{let s=new Mt(r.gradientType??0),n=new ji(r.smooth??!1),a;r.colors?a=new ba(r.colors.length,r.colors):(a=new ba(10,new tt(0,0,0,1)),a.value[1]=new tt(1,1,1,1));let o;r.steps?o=new wa(r.steps.length,r.steps):(o=new wa(10,1),o.value[0]=0);let l=new Di(r.offset??new k(0,0)),h=new Di(r.morph??new k(0,0)),d=new Ce(r.angle??0),c=_r(r),u=new j2(s,n,a,o,l,h,d,c.alpha,c.isMask),p=new Rt(u.calpha,"f");return new Xt(t,i,e,{gradientType:s,smooth:n,colors:a,steps:o,offset:l,morph:h,angle:d,...c},u,c.mode,p,c.isMask)}case"pattern":{let s=new Mt(r.style??0),n=new Mt(r.projection??0),a=new Mt(["x","y","z"].indexOf(r.axis)??0),o=new Ce(r.blending??0),l=new Di(r.offset??new k(0,0)),h=new sn(r.colorA),d=new sn(r.colorB),c=new Di(r.frequency??new k(10,10)),u=new Ce(r.size??.5),p=new Ce(r.variation??0),g=new Ce(r.smoothness??.5),f=new Ce(r.zigzag??0),m=new Ce(r.rotation??0),v=new Di(r.vertical??new k(0,1)),y=new Di(r.horizontal??new k(0,1)),x=new Mt(r.sides??6),w=_r(r),_=new X2(s,n,a,o,l,h,d,c,u,p,g,f,m,v,y,x,w.alpha,w.isMask),S=new Rt(_.calpha,"f");return new Xt(t,i,e,{style:s,projection:n,axis:a,blending:o,offset:l,colorA:h,colorB:d,frequency:c,size:u,variation:p,smoothness:g,zigzag:f,rotation:m,vertical:v,horizontal:y,sides:x,...w},_,w.mode,S,w.isMask)}default:{let s=new Vt(1,0,0,1),n=_r(r),a=new dg(s,n.alpha),o=new Rt(a.calpha,"f");return new Xt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}}}function q8(e,t,i,r){let s=P8(i,r);return W8(i,e,t,s)}function lA(e,t,i){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=i.intensity*(i.visible?1:0),r):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=i.alpha*(i.visible?1:0),i.type==="outline"&&e==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=i.compensation&&i.visible)}return r}}function Su(e,t){let i=0;for(let r of e.layers){if(r.data.type!=="displace"&&r.data.isMask)return!0;if(r.data.type!=="displace"&&"alpha"in r.data&&r.data.type!=="light"&&r.data.type!=="fresnel"&&r.data.type!=="texture"&&r.data.type!=="matcap"&&r.data.type!=="rainbow"&&r.data.type!=="outline"&&r.data.type!=="pattern"){let s=r.data.visible?r.data.alpha:0;if(s===1&&r.data.type==="depth"||r.data.type==="gradient"){for(let n of r.data.colors)if(n[3]<1){s=n[3];break}}else if(s===1&&r.data.type==="noise"){let n=t.color(r.data.colorA).a,a=t.color(r.data.colorB).a,o=t.color(r.data.colorC).a,l=t.color(r.data.colorD).a,h=Math.min(n,Math.min(a,Math.min(o,l)));h<1&&(s=h)}i+=(1-i)*s}}return i<1}var ea=class extends It{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.cacheKey="",this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},X8=class extends ea{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i){return this.root.getFlavor(e,t,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},hA=class extends ea{constructor(e,t){super(),this.data=e,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,i){let r=i?6:(e?3:0)+t;if(r===0)return this;this.flavors===void 0&&(this.flavors=[]),r-=1;let s=this.flavors[r];return s===void 0&&(s=new X8(e,t,i,this),this.flavors[r]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let i=e.layers??yr.defaultTwoLayerData("phong").layers;this.layers=i.map(r=>Ua.create(this.layerIdGen++,r.id,r.data,t.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Su(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof Un),this.lightLayer===void 0&&(this.lightLayer=new Un(0,"",{...Pr.defaultData("light","phong"),visible:!1},new iA,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,t,i){if(t!==void 0?this.data=t:t=this.data,this.transparent=Su(t,i.shared),e.path[0]==="layers"){this.data=t;let r=i.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let n=Ua.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,n),i.scene?.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene?.markNeedsUpdateRendererDirty();else if(e.type===6){let n=this.layers.findIndex(o=>o.uuid===e.id),a=this.layers[n];this.layers.splice(n,1),this.layers.splice(e.localIndex,0,a),i.scene?.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{e.type===0&&e.props.occlusion!==void 0&&i.scene?.markNeedsUpdateRendererDirty();let n=this.layers.find(a=>a.uuid===s);if(n){let a=t.layers.data(s);if(n.updateByOp({...e,path:e.path.slice(2)},a,i)){let o=Ua.create(this.layerIdGen++,s,a,r);this.layers.splice(this.layers.findIndex(l=>l.uuid===s),1,o),this.onUpdate()}}}}else this.reset(t,i)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof Xt?t.color.mask=void 0:t instanceof Un&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof Xt&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof Un?r.node.mask=new Zi(t.color,t.alpha,Zi.MUL):r instanceof Xt&&(r.isMask.value||(r.color.mask=new Zi(t.color,t.alpha,Zi.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof Xt),t=this.layers.findIndex(i=>i instanceof Un);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let s=this.layers[r];if(s instanceof Xt){if(s.isMask.value)continue;i=new Sw(i,s.color,s.alpha,s.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Rt("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof Un);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof Xt){if(r.isMask.value)continue;e=new Sw(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof oA);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Zi(t,e[i].position,Zi.ADD),t=new Zi(t,new Ce(.5).setReadonly(!0),Zi.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,s,n)=>Math.min(Math.max(r,s),n);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let i=(sA[t.type]??[]).map(n=>t[n]),r=(nA[t.type]??[]).map(n=>t[n]?.length??0),s=[...i,...r];t.visible&&(s.length?e+=`["${t.type}", "${s.join('","')}"],`:e+=`"${t.type}",`)}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new m8;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof Xt){let t=e.params.texture;if(t instanceof cg&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(ea.prototype,{properties:{get:function(){return this.fragment.properties}}});var pg=class extends hA{},Y8=$h(YM()),Aw=new Map;function Q8(e){if(typeof e=="string")return e;let t=Aw.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},Aw.set(e,t)),t.url}var wh=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:Q8(e),format:"wav"},this.sound=new Y8.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},Z8=class{constructor(){this.type="ShapePath",this.color=new Fe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Vd,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,n){return this.currentPath?.bezierCurveTo(e,t,i,r,s,n),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,g,f,m){let v=p.x,y=g.x,x=f.x,w=m.x,_=p.y,S=g.y,A=f.y,b=m.y,E=(w-x)*(_-A)-(b-A)*(v-x),C=(y-v)*(_-A)-(S-_)*(v-x),T=(b-A)*(y-v)-(w-x)*(S-_),P=E/T,L=C/T;if(T===0&&E!==0||P<=0||P>=1||L<0||L>1)return null;if(E===0&&T===0){for(let D=0;D<2;D++)if(r(D===0?f:m,p,g),t.loc===e.ORIGIN){let j=D===0?f:m;return{x:j.x,y:j.y,t:t.t}}else if(t.loc===e.BETWEEN){let j=+(v+t.t*(y-v)).toPrecision(10),W=+(_+t.t*(S-_)).toPrecision(10);return{x:j,y:W,t:t.t}}return null}else{for(let W=0;W<2;W++)if(r(W===0?f:m,p,g),t.loc===e.ORIGIN){let q=W===0?f:m;return{x:q.x,y:q.y,t:t.t}}let D=+(v+P*(y-v)).toPrecision(10),j=+(_+P*(S-_)).toPrecision(10);return{x:D,y:j,t:P}}}function r(p,g,f){let m=f.x-g.x,v=f.y-g.y,y=p.x-g.x,x=p.y-g.y,w=m*x-y*v;if(p.x===g.x&&p.y===g.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===f.x&&p.y===f.y){t.loc=e.DESTINATION,t.t=1;return}if(w<-Number.EPSILON){t.loc=e.LEFT;return}if(w>Number.EPSILON){t.loc=e.RIGHT;return}if(m*y<0||v*x<0){t.loc=e.BEHIND;return}if(Math.sqrt(m*m+v*v)<Math.sqrt(y*y+x*x)){t.loc=e.BEYOND;return}let _;m!==0?_=y/m:_=x/v,t.loc=e.BETWEEN,t.t=_}function s(p,g){let f=[],m=[];for(let v=1;v<p.length;v++){let y=p[v-1],x=p[v];for(let w=1;w<g.length;w++){let _=g[w-1],S=g[w],A=i(y,x,_,S);A!==null&&f.find(b=>b.t<=A.t+Number.EPSILON&&b.t>=A.t-Number.EPSILON)===void 0&&(f.push(A),m.push(new k(A.x,A.y)))}}return m}function n(p,g,f){let m=new k;g.getCenter(m);let v=[];return f.forEach(y=>{y.boundingBox.containsPoint(m)&&s(p,y.points).forEach(x=>{v.push({identifier:y.identifier,isCW:y.isCW,point:x})})}),v.sort((y,x)=>y.point.x-x.point.x),v}function a(p,g,f,m,v){(v==null||v==="")&&(v="nonzero");let y=new k;p.boundingBox.getCenter(y);let x=[new k(f,y.y),new k(m,y.y)],w=n(x,p.boundingBox,g);w.sort((C,T)=>C.point.x-T.point.x);let _=[],S=[];w.forEach(C=>{C.identifier===p.identifier?_.push(C):S.push(C)});let A=_[0].point.x,b=[],E=0;for(;E<S.length&&S[E].point.x<A;)b.length>0&&b[b.length-1]===S[E].identifier?b.pop():b.push(S[E].identifier),E++;if(b.push(p.identifier),v==="evenodd"){let C=b.length%2===0,T=b[b.length-2];return{identifier:p.identifier,isHole:C,for:T}}else if(v==="nonzero"){let C=!0,T=null,P=null;for(let L=0;L<b.length;L++){let D=b[L];g[D]&&(C?(P=g[D].isCW,C=!1,T=D):P!==g[D].isCW&&(P=g[D].isCW,C=!0))}return{identifier:p.identifier,isHole:C,for:T}}else console.warn('fill-rule: "'+v+'" is currently not implemented.')}let o=0,l=999999999,h=-999999999,d=[];this.subPaths.forEach(p=>{let g=p.getPoints(),f=-999999999,m=999999999,v=-999999999,y=999999999;for(let x=0;x<g.length;x++){let w=g[x];w.y>f&&(f=w.y),w.y<m&&(m=w.y),w.x>v&&(v=w.x),w.x<y&&(y=w.x)}h<=v&&(h=v+1),l>=y&&(l=y-1),g.length&&d.push({curves:p.curves,points:g,isCW:S_.isClockWise(g),identifier:o++,boundingBox:new sL(new k(y,m),new k(v,f))})});let c=d.map(p=>a(p,d,l,h,this.userData?.style.fillRule)),u=[];return d.forEach(p=>{let g=c[p.identifier];if(g&&!g.isHole){let f=new Hd;f.curves=p.curves,c.filter(m=>m?.isHole&&m.for===p.identifier).forEach(m=>{if(m){let v=d[m.identifier],y=new Vd;y.curves=v.curves,f.holes.push(y)}}),u.push(f)}}),u}},cA,Mw=new Promise(e=>{cA=e}),Ew=!1;async function K8(){if(Ew)return;let e=await import("./opentype.js");cA(e),Ew=!0}var J8=class{async load(e,t,i=()=>{}){let{load:r}=await Mw;r(e,(s,n)=>{s||!n?i(s??"Something went wrong"):t(n)})}async parse(e){let{parse:t,Bidi:i}=await Mw;try{let r=t(e),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function $8(e){return await(await fetch(e)).arrayBuffer()}var ej=new J8;async function Cw(e){let t,i,r=!1;if(e.url?(t=await $8(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer),t){let s=await ej.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}}function tj(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var ij=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,d=String.fromCharCode(i[l].unicode),c=s[a];if(tj(h,c)||o)n.push({char:d,index:h,replacements:[c.state.glyphIndex],replacementChars:[c.char]}),a++;else{let u=c.char,p="",g=[c.state.glyphIndex],f=[],m=!1;for(;!m;)a++,p=t.charAt(a),u+=p,g.push(e.charToGlyphIndex(p)),f=e.stringToGlyphs(u),f.length===1&&f[0].index===h&&(m=!0),a>t.length&&(m=!0);n.push({char:d,index:h,replacements:g,replacementChars:Array.from(u)}),a++}}return n}generateShapes(e,t){if(!this._isLoaded)return;let i=this.font,r=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,n=e.map(v=>this.getTextWidth(v,t)),a=t.width,o=this.getCharWidth(`
5194
+ `)}return t}},A8=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;)this.dispose(t.src,t.data),this.cache.delete(t.src),t=t.next,t.prev=this.head,this.head.next=t;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}},M8=class extends A8{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},Df;function E8(e){return typeof e=="string"?e:(Df||(Df=new M8),Df.load(e))}var C8=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},T8=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},rA=class extends C8{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isVideo=e.type==="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let s of r){let n=this[s];n&&(n.image=this.img,n.needsUpdate=!0)}this.shared.requestRender()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=n=>{r=n.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=E8(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let i;return this.isVideo?i=new iO(this.img,void 0,e,e):i=new ci(this.img,void 0,e,e),this.loaded&&(i.needsUpdate=!0),this[e]=i,i}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}},Pa=class extends rA{};function Ri(e,t){return t.color(e)}function P8(e,t){switch(e.type){case"fresnel":return L8(e,t);case"gradient":return R8(e);case"depth":return I8(e);case"normal":return B8(e);case"noise":return z8(e,t);case"rainbow":return N8(e);case"toon":return U8(e,t);case"outline":return F8(e,t);case"transmission":return k8(e,t);case"color":return O8(e,t);case"pattern":return j8(e,t)}}function D8(e){return{type:e.type}}function os(e){let{alpha:t,mode:i,isMask:r}=e;return{...D8(e),alpha:t,mode:i,isMask:r}}function O8(e,t){return{...os(e),color:Ri(e.color,t)}}function L8(e,t){let{bias:i,scale:r,intensity:s,factor:n,color:a,isMask:o}=e;return{...os(e),color:Ri(a,t),bias:i,scale:r,intensity:s,factor:n}}function R8(e){let{gradientType:t,smooth:i,colors:r,steps:s,angle:n,offset:a,morph:o}=e;return{...os(e),gradientType:t,smooth:i,colors:r.map(l=>new tt(l[0],l[1],l[2],l[3])),num:r.length,steps:s,offset:new k(...a),morph:new k(...o),angle:n}}function I8(e){let{gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:a,direction:o,colors:l,steps:h,smooth:d}=e;return{...os(e),gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:new M(...a),direction:o?new M(...o):new M(1,0,0),colors:l.map(c=>c!==void 0?new tt(c[0],c[1],c[2],c[3]):new tt(0,0,0,0)),steps:h.slice(0,l.length),smooth:d}}function B8(e){let{cnormal:t}=e;return{...os(e),cnormal:new M(t[0],t[1],t[2])}}function z8(e,t){return{...os(e),scale:e.scale,move:e.move,fA:new k(...e.fA),fB:new k(...e.fB),size:new M(...e.size),distortion:new k(...e.distortion),colorA:Ri(e.colorA,t),colorB:Ri(e.colorB,t),colorC:Ri(e.colorC,t),colorD:Ri(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function N8(e){return{...os(e),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new M(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new M(...e.offset)}}function U8(e,t){return{...os(e),positioning:e.positioning,colors:e.colors.map(i=>new tt(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new M(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:Ri(e.shadowColor,t),offset:new M(...e.offset)}}function F8(e,t){return{...os(e),outlineColor:Ri(e.outlineColor,t),contourColor:Ri(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new M(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function k8(e,t){return{...os(e),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function j8(e,t){return{...os(e),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new k(...e.offset),colorA:Ri(e.colorA,t),colorB:Ri(e.colorB,t),frequency:new k(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new k(...e.vertical),horizontal:new k(...e.horizontal),sides:e.sides}}var _u=class extends nr{},sA={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},nA={depth:["colors"]};function G8(e,t,i){if(t==="isMask")return!0;let r=sA[e.type],s=nA[e.type];if(s!==void 0){let n=e.color;if(s.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function aA(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,n=e;if("image"in n){let a=n.image,o=t.image(a),l=r;l.image instanceof Pa||l.image.deref(),l.image=o}if("video"in n){let a=n.video,o=t.video(a),l=r;l.image instanceof Pa||l.image.deref(),l.image=o}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("repeat"in n||"offset"in n){let a="mat",o=i.uniforms[`f${i.id}_${a}`];"repeat"in n&&(o.repeat=n.repeat),"offset"in n&&(o.offset=n.offset),o.updateMatrix()}return s}function V8(e,t,i,r){let s=!1;for(let[n,a]of Object.entries(e)){if(!n||a===void 0)continue;if(lA(n,i,r)){n==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${n}`];if(!!o&&!(o instanceof Bv))switch(s=s||G8(i,n,a),o.constructor){case Vt:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof _u?o.value=new nr(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case sn:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof _u?o.value=new nr(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Di:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]);break}case Er:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case on:{aA(a,t,i);break}case ba:{o.value=a.map(l=>new tt(...l));break}default:{o.value=a;break}}}return s}var Ua=class{constructor(e,t,i,r){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let s in r)this.uniforms[`f${this.id}_${s}`]=r[s];for(let s in i)lA(s,this,i)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return Un.createLigherLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.image(i.texture.image):r.video(i.texture.video),n=new cg(s,i.texture.wrapping),a=new g8(s),o=new v8(i.texture.repeat,i.texture.offset),l=new Ce(i.crop?1:0),h=new Mt(i.projection??0),d=new Mt(["x","y","z"].indexOf(i.axis)??0),c=new Mt(i.side??0),u=new Di(i.size?new k(i.size[0],i.size[1]):new k(100,100)),p=new Ce(i.blending??0),g=new Ce(i.alpha??1),f=new Mt(i.mode??0),m=new ji(i.isMask??!1),v=new U2(n,a,l,h,d,c,u,p,o,g,f,m),y=new Rt(v.calpha,"f");return new Xt(e,t,i,{texture:n,textureSize:a,crop:l,projection:h,axis:d,side:c,size:u,blending:p,mat:o,alpha:g,mode:f,isMask:m},v,f,y,m)}else if(i.type==="matcap"){let s=r.image(i.texture.image),n=new cg(s,i.texture.wrapping),a=new Ce(i.alpha??1),o=new Mt(i.mode??0),l=new ji(i.isMask??!1),h=new V2(n,a,o,l),d=new Rt(h.calpha,"f");return new Xt(e,t,i,{texture:n,alpha:a,mode:o,isMask:l},h,o,d,l)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new Er(new M(...i.offset)),n=new Ce(i.scale??10),a=new Ce(i.intensity??8),o=new Ce(i.movement??1),l=new Mt(i.noiseType??0),h=new Mt(i.voronoiStyle??0),d=new Ce(i.smoothness??.5),c=new Ce(i.seed??0),u=new Ce(i.highCut??1),p=new Ce(i.lowCut??0),g=new Mt(i.quality??1),f=new tA(a,o,s,h,d,c,u,p,g,n,l);return new oA(e,t,i,{offset:s,scale:n,intensity:a,movement:o,noiseType:l,voronoiStyle:h,smoothness:d,seed:c,highCut:u,lowCut:p,quality:g},f)}else throw new Error;else return q8(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(i.scene?.markNeedsUpdateRendererDirty(),!0):V8(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?aA(r.props,i.shared,this):!0;return!1}dispose(){if(H8(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Pa||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},Xt=class extends Ua{constructor(e,t,i,r,s,n,a,o){super(e,t,i,r),this.params=r,this.color=s,this.mode=n,this.alpha=a,this.isMask=o}},oA=class extends Ua{constructor(e,t,i,r,s){super(e,t,i,r),this.position=s}},Un=class extends Ua{constructor(e,t,i,r,s){super(e,t,i,s),this.node=r}static createLigherLayer(e,t,i,r){let s,n=new Ce(i.alpha),a=new Mt(i.mode),o;if(!i.visible)s=new iA,o={};else if(i.category==="lambert"){s=new w8;let l=new Vt(r.color(i.emissive)??0),h=new ji(i.occlusion??!0);o={emissive:l,occlusion:h},s.emissive=l,s.occlusion=h}else if(i.category==="toon"){s=new S8;let l=new Ce(i.shininess??30),h=new Vt(r.color(i.specular)??1118481);o={shininess:l,specular:h},s.shininess=l,s.specular=h}else if(i.category==="physical"){s=new _8;let l=new Ce(i.roughness??.3),h=new Ce(i.metalness??0),d=new Ce(i.reflectivity??.5),c=new ji(i.occlusion??!0);o={roughness:l,metalness:h,reflectivity:d,occlusion:c},s.roughness=l,s.metalness=h,s.reflectivity=d,s.occlusion=c}else{s=new b8;let l=new Ce(i.shininess??30),h=new Vt(i.specular!==void 0?r.color(i.specular)??1118481:1118481),d=new ji(i.occlusion??!0);o={shininess:l,specular:h,occlusion:d},s.shininess=l,s.specular=h,s.occlusion=d}return s.alpha=new Ce(1),s.shadingAlpha=n,s.shadingBlend=a,o.alpha=s.shadingAlpha,o.mode=s.shadingBlend,new Un(e,t,i,s,o)}get category(){return this.node.category}};function H8(e){let t=e instanceof Ua?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function _r(e){return{alpha:new Ce(e.alpha??1),mode:new Mt(e.mode??0),isMask:new ji(e.isMask??!1)}}function W8(e,t,i,r){switch(e.type){case"color":{let s=new Vt(r.color??5526619),n=_r(r),a=new dg(s,n.alpha),o=new Rt(a.calpha,"f");return new Xt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}case"fresnel":{let s=new Vt(r.color??16777215),n=new Ce(r.bias??.1),a=new Ce(r.scale??1),o=new Ce(r.intensity??2),l=new Ce(r.factor??1),h=_r(r),d=new y8(s,n,a,o,l,h.alpha,h.mode,h.isMask),c=new Rt(d.calpha,"f");return new Xt(t,i,e,{color:s,bias:n,scale:a,intensity:o,factor:l,...h},d,h.mode,c,h.isMask)}case"rainbow":{let s=new Ce(r.filmThickness??30),n=new Ce(r.movement??0),a=new Er(r.wavelengths??new M(0,0,0)),o=new Ce(r.noiseStrength??0),l=new Ce(r.noiseScale??1),h=new Er(r.offset??new M(0,0,0)),d=_r(r),c=new Q2(s,n,a,o,l,h,d.alpha,d.isMask),u=new Rt(c.calpha,"f");return new Xt(t,i,e,{filmThickness:s,movement:n,wavelengths:a,noiseStrength:o,noiseScale:l,offset:h,...d},c,d.mode,u,d.isMask)}case"transmission":{let s=new Ce(r.thickness??10),n=new Ce(r.ior??1.5),a=new Ce(r.roughness??.5),o=Ue.transmissionSize,l=Ue.transmissionRenderTarget,h=Ue.transmissionRenderTargetDepth,d=window.innerWidth,c=window.innerHeight,u=d>=c?new Di(c/d,1):new Di(1,d/c),p=_r(r),g=new $2(s,n,a,o,l,h,u,p.alpha),f=new Rt(g.calpha,"f");return new Xt(t,i,e,{thickness:s,ior:n,roughness:a,aspectRatio:u,...p},g,p.mode,f,p.isMask)}case"toon":{let s=new Mt(r.positioning??0),n;r.colors?n=new ba(r.colors.length,r.colors):(n=new ba(10,new tt(0,0,0,1)),n.value[1]=new tt(1,1,1,1));let a;r.steps?a=new wa(r.steps.length,r.steps):(a=new wa(10,1),a.value[0]=0);let o=new Er(r.source??new M(0,0,0)),l=new ji(r.isWorldSpace??!0),h=new Ce(r.noiseStrength??0),d=new Ce(r.noiseScale??1),c=new sn(r.shadowColor),u=new Er(r.offset??new M(0,0,0)),p=_r(r),g=new K2(s,n,a,o,l,h,d,c,u,p.alpha),f=new Rt(g.calpha,"f");return new Xt(t,i,e,{positioning:s,colors:n,steps:a,source:o,isWorldSpace:l,noiseStrength:h,noiseScale:d,shadowColor:c,offset:u,...p},g,p.mode,f,p.isMask)}case"outline":{let s=new Vt(r.outlineColor??16777215),n=new Vt(r.contourColor??16777215),a=new Ce(r.outlineWidth??.1),o=new Ce(r.contourWidth??.1),l=new Ce(r.outlineThreshold??.1),h=new Ce(r.contourThreshold??.1),d=new Ce(r.outlineSmoothing??.1),c=new Ce(r.contourFrequency??.1),u=new Er(r.contourDirection??new M(0,1,0)),p=new ji(r.positionalLines??!1),g=new ji(r.compensation??!0),f=Ue.normalRenderTarget,m=Ue.normalRenderTargetDepth,v=Ue.pixelRatioNode,y=Ue.resolution,x=_r(r),w=new q2(s,n,a,o,l,h,d,c,u,p,g,y,f,m,v,x.alpha),_=new Rt(w.calpha,"f");return new Xt(t,i,e,{outlineColor:s,contourColor:n,outlineWidth:a,contourWidth:o,outlineThreshold:l,contourThreshold:h,outlineSmoothing:d,contourFrequency:c,contourDirection:u,positionalLines:p,compensation:g,...x},w,x.mode,_,x.isMask)}case"depth":{let s=new Mt(r.gradientType??0),n=new ji(r.smooth??!1),a=new Ce(r.near??50),o=new Ce(r.far??200),l=new Ce(r.isVector??1),h=new Ce(r.isWorldSpace??0),d=new Er(r.origin??new M),c=new Er(r.direction??new M),u;r.colors?u=new ba(r.colors.length,r.colors):(u=new ba(2,new tt(0,0,0,1)),u.value[1]=new tt(1,1,1,1));let p;r.steps?p=new wa(r.steps.length,r.steps):(p=new wa(2,1),p.value[0]=0);let g=_r(r),f=new F2(s,n,a,o,l,h,d,c,u,p,g.alpha,g.isMask),m=new Rt(f.calpha,"f");return new Xt(t,i,e,{gradientType:s,smooth:n,near:a,far:o,isVector:l,isWorldSpace:h,origin:d,direction:c,colors:u,steps:p,...g},f,g.mode,m,g.isMask)}case"noise":{let s=new Ce(r.scale??1),n=new Er(r.size??new M(100,100,100)),a=new Ce(r.move??1),o=new Di(r.fA??new k(1.7,9.2)),l=new Di(r.fB??new k(8.3,2.8)),h=new Di(r.distortion??new k(1,1)),d=new sn(r.colorA),c=new sn(r.colorB),u=new sn(r.colorC),p=new sn(r.colorD),g=new Mt(r.noiseType??0),f=new Mt(r.voronoiStyle??0),m=new Ce(r.highCut??1),v=new Ce(r.lowCut??0),y=new Ce(r.smoothness??.5),x=new Ce(r.seed??.5),w=new Mt(r.quality??1),_=_r(r),S=new H2(s,n,a,o,l,h,d,c,u,p,_.alpha,g,_.isMask,f,m,v,y,x,w),A=new Rt(S.calpha,"f");return new Xt(t,i,e,{scale:s,size:n,move:a,fA:o,fB:l,distortion:h,colorA:d,colorB:c,colorC:u,colorD:p,noiseType:g,..._,voronoiStyle:f,highCut:m,lowCut:v,smoothness:y,seed:x,quality:w},S,_.mode,A,_.isMask)}case"normal":{let s=new Er(r.cnormal??new M(1,1,1)),n=_r(r),a=new N2(s,n.alpha),o=new Rt(a.calpha,"f");return new Xt(t,i,e,{cnormal:s,...n},a,n.mode,o,n.isMask)}case"gradient":{let s=new Mt(r.gradientType??0),n=new ji(r.smooth??!1),a;r.colors?a=new ba(r.colors.length,r.colors):(a=new ba(10,new tt(0,0,0,1)),a.value[1]=new tt(1,1,1,1));let o;r.steps?o=new wa(r.steps.length,r.steps):(o=new wa(10,1),o.value[0]=0);let l=new Di(r.offset??new k(0,0)),h=new Di(r.morph??new k(0,0)),d=new Ce(r.angle??0),c=_r(r),u=new j2(s,n,a,o,l,h,d,c.alpha,c.isMask),p=new Rt(u.calpha,"f");return new Xt(t,i,e,{gradientType:s,smooth:n,colors:a,steps:o,offset:l,morph:h,angle:d,...c},u,c.mode,p,c.isMask)}case"pattern":{let s=new Mt(r.style??0),n=new Mt(r.projection??0),a=new Mt(["x","y","z"].indexOf(r.axis)??0),o=new Ce(r.blending??0),l=new Di(r.offset??new k(0,0)),h=new sn(r.colorA),d=new sn(r.colorB),c=new Di(r.frequency??new k(10,10)),u=new Ce(r.size??.5),p=new Ce(r.variation??0),g=new Ce(r.smoothness??.5),f=new Ce(r.zigzag??0),m=new Ce(r.rotation??0),v=new Di(r.vertical??new k(0,1)),y=new Di(r.horizontal??new k(0,1)),x=new Mt(r.sides??6),w=_r(r),_=new X2(s,n,a,o,l,h,d,c,u,p,g,f,m,v,y,x,w.alpha,w.isMask),S=new Rt(_.calpha,"f");return new Xt(t,i,e,{style:s,projection:n,axis:a,blending:o,offset:l,colorA:h,colorB:d,frequency:c,size:u,variation:p,smoothness:g,zigzag:f,rotation:m,vertical:v,horizontal:y,sides:x,...w},_,w.mode,S,w.isMask)}default:{let s=new Vt(1,0,0,1),n=_r(r),a=new dg(s,n.alpha),o=new Rt(a.calpha,"f");return new Xt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}}}function q8(e,t,i,r){let s=P8(i,r);return W8(i,e,t,s)}function lA(e,t,i){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=i.intensity*(i.visible?1:0),r):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=i.alpha*(i.visible?1:0),i.type==="outline"&&e==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=i.compensation&&i.visible)}return r}}function Su(e,t){let i=0;for(let r of e.layers){if(r.data.type!=="displace"&&r.data.isMask)return!0;if(r.data.type!=="displace"&&"alpha"in r.data&&r.data.type!=="light"&&r.data.type!=="fresnel"&&r.data.type!=="texture"&&r.data.type!=="matcap"&&r.data.type!=="rainbow"&&r.data.type!=="outline"&&r.data.type!=="pattern"){let s=r.data.visible?r.data.alpha:0;if(s===1&&r.data.type==="depth"||r.data.type==="gradient"){for(let n of r.data.colors)if(n[3]<1){s=n[3];break}}else if(s===1&&r.data.type==="noise"){let n=t.color(r.data.colorA).a,a=t.color(r.data.colorB).a,o=t.color(r.data.colorC).a,l=t.color(r.data.colorD).a,h=Math.min(n,Math.min(a,Math.min(o,l)));h<1&&(s=h)}i+=(1-i)*s}}return i<1}var ea=class extends It{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.cacheKey="",this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},X8=class extends ea{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i){return this.root.getFlavor(e,t,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},hA=class extends ea{constructor(e,t){super(),this.data=e,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,i){let r=i?6:(e?3:0)+t;if(r===0)return this;this.flavors===void 0&&(this.flavors=[]),r-=1;let s=this.flavors[r];return s===void 0&&(s=new X8(e,t,i,this),this.flavors[r]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let i=e.layers??yr.defaultTwoLayerData("phong").layers;this.layers=i.map(r=>Ua.create(this.layerIdGen++,r.id,r.data,t.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Su(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof Un),this.lightLayer===void 0&&(this.lightLayer=new Un(0,"",{...Pr.defaultData("light","phong"),visible:!1},new iA,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,t,i){if(t!==void 0?this.data=t:t=this.data,this.transparent=Su(t,i.shared),e.path[0]==="layers"){this.data=t;let r=i.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let n=Ua.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,n),i.scene?.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene?.markNeedsUpdateRendererDirty();else if(e.type===6){let n=this.layers.findIndex(o=>o.uuid===e.id),a=this.layers[n];this.layers.splice(n,1),this.layers.splice(e.localIndex,0,a),i.scene?.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{e.type===0&&e.props.occlusion!==void 0&&i.scene?.markNeedsUpdateRendererDirty();let n=this.layers.find(a=>a.uuid===s);if(n){let a=t.layers.data(s);if(n.updateByOp({...e,path:e.path.slice(2)},a,i)){let o=Ua.create(this.layerIdGen++,s,a,r);this.layers.splice(this.layers.findIndex(l=>l.uuid===s),1,o),this.onUpdate()}}}}else this.reset(t,i)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof Xt?t.color.mask=void 0:t instanceof Un&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof Xt&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof Un?r.node.mask=new Zi(t.color,t.alpha,Zi.MUL):r instanceof Xt&&(r.isMask.value||(r.color.mask=new Zi(t.color,t.alpha,Zi.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof Xt),t=this.layers.findIndex(i=>i instanceof Un);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let s=this.layers[r];if(s instanceof Xt){if(s.isMask.value)continue;i=new Sw(i,s.color,s.alpha,s.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Rt("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof Un);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof Xt){if(r.isMask.value)continue;e=new Sw(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof oA);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Zi(t,e[i].position,Zi.ADD),t=new Zi(t,new Ce(.5).setReadonly(!0),Zi.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,s,n)=>Math.min(Math.max(r,s),n);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let i=(sA[t.type]??[]).map(o=>t[o]),r=(nA[t.type]??[]).map(o=>t[o]?.length??0),s=[...i,...r],n="isMask"in t&&t.isMask,a=`"${t.type}-${t.visible}-${n}"`;s.length?e+=`[${a}, "${s.join('","')}"],`:e+=a}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new m8;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof Xt){let t=e.params.texture;if(t instanceof cg&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(ea.prototype,{properties:{get:function(){return this.fragment.properties}}});var pg=class extends hA{},Y8=$h(YM()),Aw=new Map;function Q8(e){if(typeof e=="string")return e;let t=Aw.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},Aw.set(e,t)),t.url}var wh=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:Q8(e),format:"wav"},this.sound=new Y8.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},Z8=class{constructor(){this.type="ShapePath",this.color=new Fe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Vd,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,n){return this.currentPath?.bezierCurveTo(e,t,i,r,s,n),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,g,f,m){let v=p.x,y=g.x,x=f.x,w=m.x,_=p.y,S=g.y,A=f.y,b=m.y,E=(w-x)*(_-A)-(b-A)*(v-x),C=(y-v)*(_-A)-(S-_)*(v-x),T=(b-A)*(y-v)-(w-x)*(S-_),P=E/T,L=C/T;if(T===0&&E!==0||P<=0||P>=1||L<0||L>1)return null;if(E===0&&T===0){for(let D=0;D<2;D++)if(r(D===0?f:m,p,g),t.loc===e.ORIGIN){let j=D===0?f:m;return{x:j.x,y:j.y,t:t.t}}else if(t.loc===e.BETWEEN){let j=+(v+t.t*(y-v)).toPrecision(10),W=+(_+t.t*(S-_)).toPrecision(10);return{x:j,y:W,t:t.t}}return null}else{for(let W=0;W<2;W++)if(r(W===0?f:m,p,g),t.loc===e.ORIGIN){let q=W===0?f:m;return{x:q.x,y:q.y,t:t.t}}let D=+(v+P*(y-v)).toPrecision(10),j=+(_+P*(S-_)).toPrecision(10);return{x:D,y:j,t:P}}}function r(p,g,f){let m=f.x-g.x,v=f.y-g.y,y=p.x-g.x,x=p.y-g.y,w=m*x-y*v;if(p.x===g.x&&p.y===g.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===f.x&&p.y===f.y){t.loc=e.DESTINATION,t.t=1;return}if(w<-Number.EPSILON){t.loc=e.LEFT;return}if(w>Number.EPSILON){t.loc=e.RIGHT;return}if(m*y<0||v*x<0){t.loc=e.BEHIND;return}if(Math.sqrt(m*m+v*v)<Math.sqrt(y*y+x*x)){t.loc=e.BEYOND;return}let _;m!==0?_=y/m:_=x/v,t.loc=e.BETWEEN,t.t=_}function s(p,g){let f=[],m=[];for(let v=1;v<p.length;v++){let y=p[v-1],x=p[v];for(let w=1;w<g.length;w++){let _=g[w-1],S=g[w],A=i(y,x,_,S);A!==null&&f.find(b=>b.t<=A.t+Number.EPSILON&&b.t>=A.t-Number.EPSILON)===void 0&&(f.push(A),m.push(new k(A.x,A.y)))}}return m}function n(p,g,f){let m=new k;g.getCenter(m);let v=[];return f.forEach(y=>{y.boundingBox.containsPoint(m)&&s(p,y.points).forEach(x=>{v.push({identifier:y.identifier,isCW:y.isCW,point:x})})}),v.sort((y,x)=>y.point.x-x.point.x),v}function a(p,g,f,m,v){(v==null||v==="")&&(v="nonzero");let y=new k;p.boundingBox.getCenter(y);let x=[new k(f,y.y),new k(m,y.y)],w=n(x,p.boundingBox,g);w.sort((C,T)=>C.point.x-T.point.x);let _=[],S=[];w.forEach(C=>{C.identifier===p.identifier?_.push(C):S.push(C)});let A=_[0].point.x,b=[],E=0;for(;E<S.length&&S[E].point.x<A;)b.length>0&&b[b.length-1]===S[E].identifier?b.pop():b.push(S[E].identifier),E++;if(b.push(p.identifier),v==="evenodd"){let C=b.length%2===0,T=b[b.length-2];return{identifier:p.identifier,isHole:C,for:T}}else if(v==="nonzero"){let C=!0,T=null,P=null;for(let L=0;L<b.length;L++){let D=b[L];g[D]&&(C?(P=g[D].isCW,C=!1,T=D):P!==g[D].isCW&&(P=g[D].isCW,C=!0))}return{identifier:p.identifier,isHole:C,for:T}}else console.warn('fill-rule: "'+v+'" is currently not implemented.')}let o=0,l=999999999,h=-999999999,d=[];this.subPaths.forEach(p=>{let g=p.getPoints(),f=-999999999,m=999999999,v=-999999999,y=999999999;for(let x=0;x<g.length;x++){let w=g[x];w.y>f&&(f=w.y),w.y<m&&(m=w.y),w.x>v&&(v=w.x),w.x<y&&(y=w.x)}h<=v&&(h=v+1),l>=y&&(l=y-1),g.length&&d.push({curves:p.curves,points:g,isCW:S_.isClockWise(g),identifier:o++,boundingBox:new sL(new k(y,m),new k(v,f))})});let c=d.map(p=>a(p,d,l,h,this.userData?.style.fillRule)),u=[];return d.forEach(p=>{let g=c[p.identifier];if(g&&!g.isHole){let f=new Hd;f.curves=p.curves,c.filter(m=>m?.isHole&&m.for===p.identifier).forEach(m=>{if(m){let v=d[m.identifier],y=new Vd;y.curves=v.curves,f.holes.push(y)}}),u.push(f)}}),u}},cA,Mw=new Promise(e=>{cA=e}),Ew=!1;async function K8(){if(Ew)return;let e=await import("./opentype.js");cA(e),Ew=!0}var J8=class{async load(e,t,i=()=>{}){let{load:r}=await Mw;r(e,(s,n)=>{s||!n?i(s??"Something went wrong"):t(n)})}async parse(e){let{parse:t,Bidi:i}=await Mw;try{let r=t(e),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function $8(e){return await(await fetch(e)).arrayBuffer()}var ej=new J8;async function Cw(e){let t,i,r=!1;if(e.url?(t=await $8(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer),t){let s=await ej.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}}function tj(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var ij=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,d=String.fromCharCode(i[l].unicode),c=s[a];if(tj(h,c)||o)n.push({char:d,index:h,replacements:[c.state.glyphIndex],replacementChars:[c.char]}),a++;else{let u=c.char,p="",g=[c.state.glyphIndex],f=[],m=!1;for(;!m;)a++,p=t.charAt(a),u+=p,g.push(e.charToGlyphIndex(p)),f=e.stringToGlyphs(u),f.length===1&&f[0].index===h&&(m=!0),a>t.length&&(m=!0);n.push({char:d,index:h,replacements:g,replacementChars:Array.from(u)}),a++}}return n}generateShapes(e,t){if(!this._isLoaded)return;let i=this.font,r=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,n=e.map(v=>this.getTextWidth(v,t)),a=t.width,o=this.getCharWidth(`
5195
5195
  `,t),l=t.horizontalAlign===1?o:0,h=this.computeSpaceWidthForLine(e,0,t),d=this.getLineInitialOffsetX(n[0],a,t.horizontalAlign,e[0],o),c=this.getLineInitialOffsetY(s,e.length,t.height,r,t.verticalAlign),u=[],p=e.map(v=>[]),g=e.map(v=>[]),f;for(let v=0;v<e.length;v++){let y=e[v],x={features:{liga:!0}},w=[];try{w=i.stringToGlyphs(y,x)}catch(S){console.warn(S)}d=this.getLineInitialOffsetX(n[v],a,t.horizontalAlign,y,o);let _=[];try{_=this.reverseLigaturesTable(i,y,w)}catch(S){console.warn(S)}h=this.computeSpaceWidthForLine(e,v,t);for(let S=0;S<w.length;S++){let A=w[S],b=A.index===0?`
5196
5196
  `:A.unicode?String.fromCharCode(A.unicode):void 0,E=_[S],C=0,T=0;S===0&&t.horizontalAlign===2&&A.leftSideBearing!==void 0&&(T=-A.leftSideBearing*r),f&&(C=i.getKerningValue(A,f)*r),d+=T+C;let P=0;if(b===`
5197
5197
  `)P=l;else if(b===" ")P=h;else{let L=this.createPath(A,r,d,c,t);L&&(P=L.offsetX-(C+T),u.push(L.path))}if(E.replacements.length===1)g[v].push([d,c]),p[v].push(P);else{let L=E.replacements.map(q=>(i.glyphs.get(q).advanceWidth??0)*r),D=L.reduce((q,z)=>q+=z,0),j=L.map(q=>q/D),W=d;for(let q=0;q<j.length;q++){let z=P*j[q];g[v].push([W,c]),p[v].push(z),W+=z}}d+=P,f=A}c-=s}let m=[];for(let v=0,y=u.length;v<y;v++)m.push(...u[v].toShapes());return{shapes:m,charWidths:p,lineWidths:n,charCoords:g}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(e,t,i,r,s){return(i===3||i===2)&&r.indexOf(`
@@ -5595,7 +5595,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
5595
5595
  }
5596
5596
  `,Ff=new It({vertexShader:Kj,fragmentShader:Jj,uniforms:{depthContrast:{value:1}}}),$j=class{constructor(){this._constraints=new Map}setConstraint(e,t){t===null?this._constraints.delete(e):this._constraints.set(e,t)}removeDependencies(e){this._constraints.delete(e)}applyConstraints(e){let t=new Set;this._constraints.forEach((i,r)=>{let s=[r,i],n=i;for(;this._constraints.has(n);)n=this._constraints.get(n),t.has(n)||s.push(n);for(let a=s.length-2;a>=0;a--)if(!t.has(s[a])){let o=e.find(s[a]);o?o.applyPathSnapping(e):console.warn(`missing entity ${s[a]}`),t.add(s[a])}})}findDependency(e,t){let i=e;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===t)return!0;return!1}},vg=new gl;vg.wireframe=!0;var Xw=new M,xA=class extends Ia{constructor(e,t){super(),this.data=e,this.backupFog=new f_(16777215,.1,2e3),this.fogUseBGColor=!1,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.occlusion=!1,this.aoFullRes=!1,this.radius=128,this.bias=.5,this.aoColor={r:0,g:0,b:0},this.geometryCacheChanged=!1,this.bgColor=new nr(1,1,1,1),this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new $j,this.needsRecomputeInstances=!1,this.ambientLight=new kO(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Gj(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=jj(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let n=r.children.indexOf(s);i.splice(0,0,n)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>OU(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(),r.resetBBoxNeedsUpdate(),Cs(r)&&cn(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r)}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),i.parent.remove(i),cn(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Cs(i)&&(i.freeBooleanPointer(),r instanceof pl&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof Gv&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid)}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate();let n=e.localIndex;s.children.splice(n,0,s.children.pop()),Cs(i)&&(i.invalidateUpstreamBooleanData(),cn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof pl&&r.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props){let{rest:n}=t.props;t={...t,props:n},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{kj(s,t,i,{scene:this,shared:r}),s instanceof Fr&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ri(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Vi&&this.switchActiveCamera(i)}this.expandInstances(t,!0),this.traverseEntity(i=>{cn(i)&&i.recomputeBoolean(),i instanceof Vi&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){bt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{bt.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,n,a){e&&e!==r.uuid&&r.find(e)&&s.forInstancesRec(o=>{o.isInstanceRoot||(o.data=iu(o.data,l=>{let h=l.events.data(a.id),d=o.goUp(n);if(d){let c=[...uS(d.identity),e].join("-"),u=this.entityIdentityToEntity[c];if(u){let p=u.uuid;Os.zoom(h,t)[i]=p}else console.warn("cannot find instance")}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof tl&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{r.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=iu(s.data,n=>{n.events.delete(r.id)}).data)}):r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),r.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,i,r)}),r.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,i,r)})):"actions"in r.data&&r.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,i,r)})})}),!0})}expandInstances(e,t){let i=new Set;this.traverseEntity(r=>{if(r instanceof tl&&r.isInstanceRoot)return r.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||r.resetBBoxNeedsUpdate(),!0});for(let r of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),Vv(r)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof tl&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)bt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new Vi(xA.PERSONAL_CAMERA_ID,{...du.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;bt.is(s)&&!s.raycastLock&&(s.visible||n?.object.data.visible)&&((Cs(s)||Uw(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Ww(s,e,t)),i(s))}};return i(this),t}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;bt.is(s)&&(s.visible||n?.object.data.visible)&&((Cs(s)||Uw(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Ww(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)bt.is(t)&&e(t)}traverseEntity(e){for(let t of this.children)bt.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)xu.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)bt.is(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ri(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Ri(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ri(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled),e.occlusion!==void 0&&(this.occlusion=e.occlusion),e.aoFullRes!==void 0&&(this.aoFullRes=e.aoFullRes),e.radius!==void 0&&(this.radius=e.radius),e.bias!==void 0&&(this.bias=e.bias),e.aoColor!==void 0&&(this.aoColor=Ri(e.aoColor,t))}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,n){let a={scene:this,shared:n},o=Hv(e,t,a);return o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,n)),o.updateState(t,a),o instanceof Fr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:n,recursive:a}=e[r],o=this.find(n),l=a?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new si;return i.setFromPoints(t),i.getCenter(Xw),Xw}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof ar)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof ea&&e(t.material[i]);else t.material instanceof ea&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let i,r;e>=t?(i=t/e,r=1):(i=1,r=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(n=>{n.uniforms[`f${n.id}_aspectRatio`].value.x=i,n.uniforms[`f${n.id}_aspectRatio`].value.y=r})})}},Br=xA;Br.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera",Br.PERSONAL_CAMERA_EXPORT_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCameraExport";var Rd=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},eG=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return iG(Math.atan2(r,i))},tG=(e,t,i)=>{let r={x:0,y:0};return i=yg(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},yg=e=>e*(Math.PI/180),iG=e=>e*(180/Math.PI),rG=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,kf=new Map,Yw=e=>{kf.has(e)&&clearTimeout(kf.get(e)),kf.set(e,setTimeout(e,100))},Eu=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},Qw=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},wA=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),Zw=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},xg=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},Wv=(e,t,i)=>{let r=bA(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let n="";for(let a=0,o=t.length;a<o;a+=1)n+=t[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},sG=(e,t)=>{let i=bA(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},bA=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},jf=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},nG=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},wg=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},aG=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(_A="ontouchstart"in window,SA=!!window.PointerEvent,AA=!!window.MSPointerEvent);var _A,SA,AA,nh={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"}},jo,Jh={};SA?jo=nh.pointer:AA?jo=nh.MSPointer:_A?(jo=nh.touch,Jh=nh.mouse):jo=nh.mouse;function Za(){}Za.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};Za.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};Za.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(a){a.call(i,{type:s,target:i},t)})};Za.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=nG(t.options,e))};Za.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Eu(e,jo[t],i._domHandlers_[t]),Jh[t]&&Eu(e,Jh[t],i._domHandlers_[t]),i};Za.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},Qw(e,jo[t],i._domHandlers_[t]),Jh[t]&&Qw(e,Jh[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var qv=Za;function pi(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=pi.id,pi.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}pi.prototype=new qv;pi.constructor=pi;pi.id=0;pi.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};pi.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=sG("borderRadius","50%"),i=Wv("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},jf(r.el,i),this.options.shape==="circle"&&jf(r.back,t),jf(r.front,t),this.applyStyles(r),this};pi.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};pi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};pi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};pi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};pi.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};pi.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};pi.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=Wv("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};pi.prototype.restCallback=function(){var e=this,t={};t.front=Wv("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};pi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};pi.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,n,a;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?n="left":n="right"),e.lockX||(t>0?a="up":a="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:n,y:a,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+n,e),h.y||this.trigger("plain:"+a,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var oG=pi;function Zt(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=Zt.id,Zt.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Zt.prototype=new qv;Zt.constructor=Zt;Zt.id=0;Zt.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};Zt.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};Zt.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};Zt.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},n=i.options,a={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-a.x,y:e.y-a.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",n.zone.appendChild(o);var l=o.getBoundingClientRect();n.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new oG(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:t,position:e,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(xg(h.ui.el,s),xg(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};Zt.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};Zt.prototype.bindNipple=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};Zt.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=e.force||e.pressure||e.webkitForce||0;n!==s&&(t.trigger("pressure",n),r.trigger("pressure "+t.identifier+":pressure",n),s=n)}.bind(r),100)};Zt.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=wA(e),t.updateBox();var s=function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var o=[e[0]];o.identifier=a,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))};return wg(e,s),t.manager.bindDocument(),!1};Zt.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),n=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,a);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),n>0&&t.pressureFn(e,d,d.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=Rd(a,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};Zt.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};Zt.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.scroll;if(!rG(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=Rd(l,s.position),d=eG(l,s.position),c=yg(d),u=h/o,p={distance:h,position:l},g,f;if(s.options.shape==="circle"?(g=Math.min(h,o),f=tG(s.position,g,d)):(f=aG(l,s.position,o),g=Rd(f,s.position)),i.follow){if(h>o){let x=l.x-f.x,w=l.y-f.y;s.position.x+=x,s.position.y+=w,s.el.style.top=s.position.y-(t.box.top+n.y)+"px",s.el.style.left=s.position.x-(t.box.left+n.x)+"px",h=Rd(l,s.position)}}else l=f,h=g;var m=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:m,y:v},i.dataOnly||xg(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:u,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:c,degree:d},vector:{x:m/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:yg(180-d),degree:180-d},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};Zt.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[n.id]=n.identifier))};Zt.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};Zt.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var lG=Zt;function vi(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=Zw(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(n){n.forEach(function(a){s=a.el.getBoundingClientRect(),a.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;Eu(window,"resize",function(){Yw(i)});var r=function(){t.scroll=Zw()};return Eu(window,"scroll",function(){Yw(r)}),t.collections}vi.prototype=new qv;vi.constructor=vi;vi.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};vi.prototype.create=function(e){return this.createCollection(e)};vi.prototype.createCollection=function(e){var t=this,i=new lG(t,e);return t.bindCollection(i),t.collections.push(i),i};vi.prototype.bindCollection=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};vi.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};vi.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};vi.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};vi.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};vi.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};vi.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};vi.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};vi.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=wA(t);var n=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},a=function(o){r=i.getIdentifier(o),wg(i.collections,n.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return wg(t,a),!1};vi.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};vi.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var hG=vi,Kw=new hG,cG={create:function(e){return Kw.create(e)},factory:Kw},dG=$h(Wb());function nn(e,t){let i=new He;if(!e.getAttribute("position"))return i.setAttribute("position",new De([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=Ku(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new De(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var uG=new me,pG=new me,gs=[[0,0,0],[0,0,0],[0,0,0]];function MA(e){let t=e.elements;gs[0][0]=t[0],gs[0][1]=t[4],gs[0][2]=t[8],gs[1][0]=t[1],gs[1][1]=t[5],gs[1][2]=t[9],gs[2][0]=t[2],gs[2][1]=t[6],gs[2][2]=t[10];let{u:i,v:r}=(0,dG.SVD)(gs),s=uG.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),n=pG.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(n.transpose())}var fG=class extends P_{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new ta({color:65280,linewidth:10}),t=new M(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new M(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new M().addVectors(t,i.multiplyScalar(r)),n=new He;return n.setFromPoints([t,s]),new Gd(n,e)}},EA=e=>e instanceof Mu||e instanceof tl;function mG(e,t){return e.distance-t.distance}function CA(e,t,i){if(!(!jn(t)||!t.visible)){Cs(t)&&t.raycast(e,i);for(let r of t.children)CA(e,r,i)}}function bg(e,t,i){if(!i.some(s=>Cu(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>CA(e,s,r)),r.sort(mG),r}function _g(e){let t=[];if(e.length){let i=e[0].object;jn(i)&&t.push(i);let r=i.parent;for(;r;)EA(r)&&t.push(r),r=r.parent}return t}function Cu(e,t){if(Cs(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(EA(t))return TA(e,t)}function TA(e,t){if(!(!jn(t)||!t.visible)){if(Cs(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=TA(e,i);if(r)return r}}}function gG(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}var vG=class{constructor(e,t,i,r,s,n,a){this.scene=t,this.camera=i,this.sharedAssets=r,this.stopRaycast=s,this.requestRender=n,this.isExport=a,this.raycaster=new fG,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this.renderer=e,this._useWindowEvents=t.data.publish.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(gG(t,i,r),this.camera)}},PA=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e[e.scroll=6]="scroll",e))(PA||{}),yn=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},DA=new Map,Ch=new Map,Go=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:n,delay:a,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new wh({src:l,volume:n,delay:a,loop:o}),Ch.has(i.uuid)?Ch.get(i.uuid).push(this):Ch.set(i.uuid,[this]),DA.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Sg=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=DA.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Ch.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Ch.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Th=class{constructor(e,t,i,r){if(this.data=t,t.interaction==="play")this.interaction=new Go(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Sg(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Go?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Go?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof Go&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function yG(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var OA=new Map,Ph=new Map,Dh=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=yG(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n)),a!==void 0&&(this.delay=a),Ph.has(i.uuid)?Ph.get(i.uuid).push(this):Ph.set(i.uuid,[this]),OA.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Ag=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=OA.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Ph.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Ph.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Xv=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new Dh(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Ag(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Dh?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Dh?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},xG="text/plain",wG="us-ascii",Jw=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),bG=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:n}=i.groups,a=r.split(";");n=t?"":n;let o=!1;a[a.length-1]==="base64"&&(a.pop(),o=!0);let l=(a.shift()||"").toLowerCase(),h=[...a.map(d=>{let[c,u=""]=d.split("=").map(p=>p.trim());return c==="charset"&&(u=u.toLowerCase(),u===wG)?"":`${c}${u?`=${u}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==xG)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${n?`#${n}`:""}`};function _G(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return bG(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let n=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,o="";for(;;){let h=n.exec(r.pathname);if(!h)break;let d=h[0],c=h.index,u=r.pathname.slice(a,c);o+=u.replace(/\/{2,}/g,"/"),o+=d,a=c+d.length}let l=r.pathname.slice(a,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let n=r.pathname.split("/"),a=n[n.length-1];Jw(a,t.removeDirectoryIndex)&&(n=n.slice(0,-1),r.pathname=n.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let n of[...r.searchParams.keys()])Jw(n,t.removeQueryParameters)&&r.searchParams.delete(n);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var SG=class{constructor({url:e,context:t},i){if(this.managers=i,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:_G(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){dS?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.managers.controlsManager.orbitControls?.onPointerUp(je[0]),LU())}},LA=class{constructor(e,t,i){this.data=e,this.managers=i,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=r=>{this.timeoutIdQueue.shift();let s=this.scene.find(r);if(s===void 0)return;let n=this.controlsManager.sharedGameControlGlobals.rapierWorld,a=n?s.dataPatched.physics?.fusedBody:!0;if(s.cloner){for(let o of s.cloner.children)a?(o.playModeVisible=!1,o.rigidBody&&s.dataPatched.physics?.rigidBody==="positioned"&&(n.removeRigidBody(o.rigidBody),o.rigidBody=void 0),o.boundsTree&&(o.boundsTree=void 0)):this.clone===void 0||this.clone===o?(o.playModeVisible=!1,o.rigidBody&&(n.removeRigidBody(o.rigidBody),o.rigidBody=void 0)):o.playModeVisible===void 0&&(o.playModeVisible=!0);(a||this.clone===void 0||this.clone===!1)&&(s.visible=!1,s.rigidBody&&(n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.boundsTree&&(s.boundsTree=void 0))}else s.rigidBody&&(n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.boundsTree&&(s.boundsTree=void 0),s.visible=!1;n===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.boundsTree!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.rigidBody!==void 0),this.managers.eventManager.requestRender()},this.objects=[...e.objects],this.scene=t,this.controlsManager=i.controlsManager}dispatch(e){this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},$w=(()=>{let e,t,i,r;function s(o){!e&&!eb()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(n)),o&&(t=o,r=o.requestRender)}function n(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,d=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,u=0;for(;u<c;){let p=h[u];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&d[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),u++):(d[p.userData.actionId]>p.userData.quantity&&d[p.userData.actionId]--,h.splice(u,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody):(p.boundsTree=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(g=>g.boundsTree!==void 0)),c--,r())}e=u>0?requestAnimationFrame(n):void 0,i=u>0?o:void 0}function a(){eb()?e&&(cancelAnimationFrame(e),i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",a),s})();function eb(){return!!document&&document.hidden}var tb=new rt,AG=new M,MG=new M,Oh=class{constructor(e,t,i){this.data=e,this.scene=t,this.controlsManager=i,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=st.generateUUID(),this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=bU(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=()=>{if(this.timeoutIdQueue.shift(),this.object===void 0)return;let r=new Gi(this.object);if(r.playModeVisible=!0,r.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem;n===Br.PERSONAL_CAMERA_ID&&this.scene.find(Br.PERSONAL_CAMERA_EXPORT_ID)&&(n=Br.PERSONAL_CAMERA_EXPORT_ID);let a=this.scene.find(n);a&&(a.updateMatrixWorldSVD(),r.hiddenMatrix.setPosition(0,0,0),r.hiddenMatrix.premultiply(a.matrixWorldRigid),r.updateMatrixWorld())}r.position.fromArray(this.data.position),r.rotation.fromArray(this.data.rotation),r.updateMatrix(),this.scene.add(r);let s=this.controlsManager.sharedGameControlGlobals;s.createdObjects.push(r),s.nCreatedPerAction[this.uniqueId]===void 0?s.nCreatedPerAction[this.uniqueId]=1:s.nCreatedPerAction[this.uniqueId]++,r.updateWorldMatrix(!0,!0),r.traverseObject(this.traverseObjectCB),$w(),this.controlsManager.requestRender()},this.traverseObjectCB=r=>{r.hasNonUniformScale&&r.updateMatrixWorldSVD();let s;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(r instanceof es)if(r.objectForSample){if(r.objectForSample.dataPatched.physics.fusedBody)return;s=r.object}else return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(r instanceof Gi)s=r.object;else if(s=r,s.dataPatched.cloner?.hideBase)return!0}else{if(r instanceof es)return;r instanceof Gi?s=r.object:s=r}this.data.destroy==="Time"?r.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(r.userData.quantity=this.data.destroyAfterQuantity,r.userData.actionId=this.uniqueId),r.matrixWorld.decompose(AG,tb,MG);let n=new M().fromArray(this.data.velocity).applyQuaternion(tb),a=s.dataPatched;if(!(a.collision==="visibility"?!a.visible:!a.collision)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(r,s,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(r.rigidBody?.collider(0).setActiveEvents(1),r.userData.hasCollisionDestroy=!0),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&r.rigidBody?.setLinvel(n.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in r.object&&this.controlsManager.addBoundsTree(r),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&(r.userData.velocity=n)),s.dataPatched.physics?.fusedBody===!0))return!0},this.scene=t,this.object=this.scene.find(this.data.object),$w(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.scene.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},EG=class{constructor(e,t,i,r){this.scene=t,this.sharedAssets=i,this.sceneData=e,this.managers=r}dispatch(){KA(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager?.gameControls.forEach(t=>t.reset(!0));let e;this.sceneData.publish.playCamera?e=this.scene.find(this.sceneData.publish.playCamera):(e=this.scene.find(Br.PERSONAL_CAMERA_ID),e||(e=this.scene.find(Br.PERSONAL_CAMERA_EXPORT_ID))),this.scene.switchActiveCamera(e),this.managers.controlsManager.requestRender()}},RA={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},Yv={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},CG=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Tu={CSS:{},springs:{}};function ts(e,t,i){return Math.min(Math.max(e,t),i)}function Lh(e,t){return e.indexOf(t)>-1}function Gf(e,t){return e.apply(null,t)}var Ve={arr:function(e){return Array.isArray(e)},obj:function(e){return Lh(Object.prototype.toString.call(e),"Object")},pth:function(e){return Ve.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||Ve.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return Ve.hex(e)||Ve.rgb(e)||Ve.hsl(e)},key:function(e){return!RA.hasOwnProperty(e)&&!Yv.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function IA(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function BA(e,t){var i=IA(e),r=ts(Ve.und(i[0])?1:i[0],.1,100),s=ts(Ve.und(i[1])?100:i[1],.1,100),n=ts(Ve.und(i[2])?10:i[2],.1,100),a=ts(Ve.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=n/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,d=1,c=l<1?(l*o+-a)/h:-a+o;function u(g){var f=t?t*g/1e3:g;return l<1?f=Math.exp(-f*l*o)*(d*Math.cos(h*f)+c*Math.sin(h*f)):f=(d+c*f)*Math.exp(-f*o),g===0||g===1?g:1-f}function p(){var g=Tu.springs[e];if(g)return g;for(var f=1/6,m=0,v=0;;)if(m+=f,u(m)===1){if(v++,v>=16)break}else v=0;var y=m*f*1e3;return Tu.springs[e]=y,y}return t?u:p}function TG(e){return e===void 0&&(e=10),function(t){return Math.ceil(ts(t,1e-6,1)*e)*(1/e)}}var PG=function(){var e=11,t=1/(e-1);function i(d,c){return 1-3*c+3*d}function r(d,c){return 3*c-6*d}function s(d){return 3*d}function n(d,c,u){return((i(c,u)*d+r(c,u))*d+s(c))*d}function a(d,c,u){return 3*i(c,u)*d*d+2*r(c,u)*d+s(c)}function o(d,c,u,p,g){var f,m,v=0;do m=c+(u-c)/2,f=n(m,p,g)-d,f>0?u=m:c=m;while(Math.abs(f)>1e-7&&++v<10);return m}function l(d,c,u,p){for(var g=0;g<4;++g){var f=a(c,u,p);if(f===0)return c;var m=n(c,u,p)-d;c-=m/f}return c}function h(d,c,u,p){if(!(0<=d&&d<=1&&0<=u&&u<=1))return;var g=new Float32Array(e);if(d!==c||u!==p)for(var f=0;f<e;++f)g[f]=n(f*t,d,u);function m(v){for(var y=0,x=1,w=e-1;x!==w&&g[x]<=v;++x)y+=t;--x;var _=(v-g[x])/(g[x+1]-g[x]),S=y+_*t,A=a(S,d,u);return A>=.001?l(v,S,d,u):A===0?S:o(v,y,y+t,d,u)}return function(v){return d===c&&u===p||v===0||v===1?v:n(m(v),c,p)}}return h}(),zA=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,n=4;r<((s=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var n=ts(r,1,10),a=ts(s,.1,2);return function(o){return o===0||o===1?o:-n*Math.pow(2,10*(o-1))*Math.sin((o-1-a/(Math.PI*2)*Math.asin(1/n))*(Math.PI*2)/a)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(n){return Math.pow(n,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(n,a){return function(o){return 1-s(n,a)(1-o)}},e["easeInOut"+r]=function(n,a){return function(o){return o<.5?s(n,a)(o*2)/2:1-s(n,a)(o*-2+2)/2}}}),e}();function Qv(e,t){if(Ve.fnc(e))return e;var i=e.split("(")[0],r=zA[i],s=IA(e);switch(i){case"spring":return BA(e,t);case"cubicBezier":return Gf(PG,s);case"steps":return Gf(TG,s);default:return Gf(r,s)}}function NA(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function $u(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],n=0;n<i;n++)if(n in e){var a=e[n];t.call(r,a,n,e)&&s.push(a)}return s}function ep(e){return e.reduce(function(t,i){return t.concat(Ve.arr(i)?ep(i):i)},[])}function ib(e){return Ve.arr(e)?e:(Ve.str(e)&&(e=NA(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Zv(e,t){return e.some(function(i){return i===t})}function Kv(e){var t={};for(var i in e)t[i]=e[i];return t}function Mg(e,t){var i=Kv(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function tp(e,t){var i=Kv(e);for(var r in t)i[r]=Ve.und(e[r])?t[r]:e[r];return i}function DG(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function OG(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,d){return l+l+h+h+d+d}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),n=parseInt(r[2],16),a=parseInt(r[3],16);return"rgba("+s+","+n+","+a+",1)"}function LG(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,n=t[4]||1;function a(u,p,g){return g<0&&(g+=1),g>1&&(g-=1),g<1/6?u+(p-u)*6*g:g<1/2?p:g<2/3?u+(p-u)*(2/3-g)*6:u}var o,l,h;if(r==0)o=l=h=s;else{var d=s<.5?s*(1+r):s+r-s*r,c=2*s-d;o=a(c,d,i+1/3),l=a(c,d,i),h=a(c,d,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+n+")"}function RG(e){if(Ve.rgb(e))return DG(e);if(Ve.hex(e))return OG(e);if(Ve.hsl(e))return LG(e)}function pn(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function IG(e){if(Lh(e,"translate")||e==="perspective")return"px";if(Lh(e,"rotate")||Lh(e,"skew"))return"deg"}function Eg(e,t){return Ve.fnc(e)?e(t.target,t.id,t.total):e}function Ps(e,t){return e.getAttribute(t)}function Jv(e,t,i){var r=pn(t);if(Zv([i,"deg","rad","turn"],r))return t;var s=Tu.CSS[t+i];if(!Ve.und(s))return s;var n=100,a=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(a),a.style.position="absolute",a.style.width=n+i;var l=n/a.offsetWidth;o.removeChild(a);var h=l*parseFloat(t);return Tu.CSS[t+i]=h,h}function UA(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?Jv(e,s,i):s}}function $v(e,t){if(Ve.dom(e)&&!Ve.inp(e)&&(Ps(e,t)||Ve.svg(e)&&e[t]))return"attribute";if(Ve.dom(e)&&Zv(CG,t))return"transform";if(Ve.dom(e)&&t!=="transform"&&UA(e,t))return"css";if(e[t]!=null)return"object"}function FA(e){if(Ve.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function BG(e,t,i,r){var s=Lh(t,"scale")?1:0+IG(t),n=FA(e).get(t)||s;return i&&(i.transforms.list.set(t,n),i.transforms.last=t),r?Jv(e,n,r):n}function e0(e,t,i,r){switch($v(e,t)){case"transform":return BG(e,t,r,i);case"css":return UA(e,t,i);case"attribute":return Ps(e,t);default:return e[t]||0}}function t0(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=pn(e)||0,s=parseFloat(t),n=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+n+r;case"-":return s-n+r;case"*":return s*n+r}}function kA(e,t){if(Ve.col(e))return RG(e);if(/\s/g.test(e))return e;var i=pn(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function i0(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function zG(e){return Math.PI*2*Ps(e,"r")}function NG(e){return Ps(e,"width")*2+Ps(e,"height")*2}function UG(e){return i0({x:Ps(e,"x1"),y:Ps(e,"y1")},{x:Ps(e,"x2"),y:Ps(e,"y2")})}function jA(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var n=t.getItem(s);s>0&&(i+=i0(r,n)),r=n}return i}function FG(e){var t=e.points;return jA(e)+i0(t.getItem(t.numberOfItems-1),t.getItem(0))}function GA(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return zG(e);case"rect":return NG(e);case"line":return UG(e);case"polyline":return jA(e);case"polygon":return FG(e)}}function kG(e){var t=GA(e);return e.setAttribute("stroke-dasharray",t),t}function jG(e){for(var t=e.parentNode;Ve.svg(t)&&Ve.svg(t.parentNode);)t=t.parentNode;return t}function VA(e,t){var i=t||{},r=i.el||jG(e),s=r.getBoundingClientRect(),n=Ps(r,"viewBox"),a=s.width,o=s.height,l=i.viewBox||(n?n.split(" "):[0,0,a,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a/l[2],h:o/l[3]}}function GG(e,t){var i=Ve.str(e)?NA(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:VA(i),totalLength:GA(i)*(r/100)}}}function VG(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=VA(e.el,e.svg),s=i(),n=i(-1),a=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(a.y-n.y,a.x-n.x)*180/Math.PI}}function rb(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=kA(Ve.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Ve.str(e)||t?r.split(i):[]}}function HA(e){var t=e?ep(Ve.arr(e)?e.map(ib):ib(e)):[];return $u(t,function(i,r,s){return s.indexOf(i)===r})}function WA(e){var t=HA(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:FA(i)}}})}function HG(e,t){var i=Kv(t);if(/^spring/.test(i.easing)&&(i.duration=BA(i.easing)),Ve.arr(e)){var r=e.length,s=r===2&&!Ve.obj(e[0]);s?e={value:e}:Ve.fnc(t.duration)||(i.duration=t.duration/r)}var n=Ve.arr(e)?e:[e];return n.map(function(a,o){var l=Ve.obj(a)&&!Ve.pth(a)?a:{value:a};return Ve.und(l.delay)&&(l.delay=o?0:t.delay),Ve.und(l.endDelay)&&(l.endDelay=o===n.length-1?t.endDelay:0),l}).map(function(a){return tp(a,i)})}function WG(e){for(var t=$u(ep(e.map(function(n){return Object.keys(n)})),function(n){return Ve.key(n)}).reduce(function(n,a){return n.indexOf(a)<0&&n.push(a),n},[]),i={},r=function(n){var a=t[n];i[a]=e.map(function(o){var l={};for(var h in o)Ve.key(h)?h==a&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function qG(e,t){var i=[],r=t.keyframes;r&&(t=tp(WG(r),t));for(var s in t)Ve.key(s)&&i.push({name:s,tweens:HG(t[s],e)});return i}function XG(e,t){var i={};for(var r in e){var s=Eg(e[r],t);Ve.arr(s)&&(s=s.map(function(n){return Eg(n,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function YG(e,t){var i;return e.tweens.map(function(r){var s=XG(r,t),n=s.value,a=Ve.arr(n)?n[1]:n,o=pn(a),l=e0(t.target,e.name,o,t),h=i?i.to.original:l,d=Ve.arr(n)?n[0]:h,c=pn(d)||pn(l),u=o||c;return Ve.und(a)&&(a=h),s.from=rb(d,u),s.to=rb(t0(a,d),u),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=Qv(s.easing,s.duration),s.isPath=Ve.pth(n),s.isColor=Ve.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var qA={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var n="";r.list.forEach(function(a,o){n+=o+"("+a+") "}),e.style.transform=n}}};function XA(e,t){var i=WA(e);i.forEach(function(r){for(var s in t){var n=Eg(t[s],r),a=r.target,o=pn(n),l=e0(a,s,o,r),h=o||pn(l),d=t0(kA(n,h),l),c=$v(a,s);qA[c](a,s,d,r.transforms,!0)}})}function QG(e,t){var i=$v(e.target,t.name);if(i){var r=YG(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function ZG(e,t){return $u(ep(e.map(function(i){return t.map(function(r){return QG(i,r)})})),function(i){return!Ve.und(i)})}function YA(e,t){var i=e.length,r=function(n){return n.timelineOffset?n.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0,l=n.pingPongEndDelayCorrection??0;return r(n)+a+o+l+n.duration*(n.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0;return r(n)+a+o+n.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0,l=n.pingPongEndDelayCorrection??0;return r(n)+a+o+n.duration*(n.loop??1)-n.endDelay-l})):t.endDelay,s}var sb=0;function KG(e){var t=Mg(RA,e),i=Mg(Yv,e),r=qG(i,e),s=WA(e.targets),n=ZG(s,r),a=YA(n,i),o=sb;return sb++,tp(t,{id:o,children:[],animatables:s,animations:n,duration:a.duration,delay:a.delay,endDelay:a.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var zr=[],nb=[],Id,JG=function(){function e(){Id=requestAnimationFrame(t)}function t(i){var r=zr.length;if(r){for(var s=0;s<r;){var n=zr[s];n.paused?(zr.splice(s,1),r-=1):(n.tick(i),s++)}e()}else Id=cancelAnimationFrame(Id)}return e}();function $G(e){document.hidden?(zr.forEach(function(t){return t.pause(e.timeStamp)}),nb=zr.slice(0),Qt.running=zr=[]):nb.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",$G);function Qt(e){e===void 0&&(e={});var t=0,i=0,r=0,s,n,a=0,o=null;function l(A){var b=window.Promise&&new Promise(function(E){return o=E});return A.finished=b,b}var h=KG(e),d=l(h);function c(){var A=h.direction;A!=="alternate"&&(h.direction=A!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,n.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=h.reversed)})}function u(){h.direction="normal",h.reversed=!1,n.forEach(function(A){return A.reversed=!1})}function p(A){return h.reversed?h.duration-A:A}function g(){t=0,i=p(h.currentTime)*(1/Qt.speed)}function f(A,b){b&&(h.reversed?b.seek(b.duration*b.loop-(A-b.timelineOffset-b.pingPongDelayCorrection)):b.seek(A-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection))}function m(A){if(h.reversed)for(var b=a;b--;)f(A,n[b]);else for(var E=0;E<a;E++)f(A,n[E])}function v(A){var b=0,E=h.animations,C=E.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?A=h.duration-h.delay+h.endDelay-A:A=h.duration+h.delay-h.endDelay-A):_(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?A=h.duration-h.delay+h.endDelay-A:A=h.duration+h.delay-h.endDelay-A);b<C;){var T=E[b],P=T.animatable,L=T.tweens,D=L.length-1,j=L[D];D&&(j=$u(L,function(Z){return A<Z.end})[0]||j);let $;h.parent?.reversed&&h.direction==="alternate"?$=ts(A-j.start-j.endDelay,0,j.duration)/j.duration:$=ts(A-j.start-j.delay,0,j.duration)/j.duration;for(var W=isNaN($)?1:j.easing($),q=j.to.strings,z=j.round,V=[],F=j.to.numbers.length,N=void 0,B=0;B<F;B++){var H=void 0;let Z,ve;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(Z=j.to.numbers[B],ve=j.from.numbers[B]||0):(ve=j.to.numbers[B],Z=j.from.numbers[B]||0):_(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(Z=j.to.numbers[B],ve=j.from.numbers[B]||0):(ve=j.to.numbers[B],Z=j.from.numbers[B]||0),j.isPath?H=VG(j.value,W*ve):H=Z+W*(ve-Z),z&&(j.isColor&&B>2||(H=Math.round(H*z)/z)),V.push(H)}var X=q.length;if(!X)N=V[0];else{N=q[0];for(var Q=0;Q<X;Q++){var U=q[Q],ne=q[Q+1],G=V[Q];isNaN(G)||(ne?N+=G+ne:N+=G+" ")}}qA[T.type](P.target,T.property,N,P.transforms),T.currentValue=N,b++}}function y(A){h[A]&&!h.passThrough&&h[A](h)}function x(){h.remaining&&h.remaining!==!0&&h.remaining--}let w={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function _(A,b,E,C,T){return w[A<<4|b<<3|E<<2|C<<1|T]}function S(A){var b=h.duration;let E=h.delay,C=b-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(E=h.endDelay,C=b-h.delay);var T=p(A);if(h.progress=ts(T/b*100,0,100),h.reversePlayback=T<h.currentTime,a&&m(T),!h.began&&h.currentTime>=0&&(h.began=!0,y("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,y("loopBegin")),(h.reversed||T>=0)&&T<=E&&h.currentTime!==0&&(v(0),y("change")),(T>=C&&h.currentTime!==b+h.pingPongDelayCorrection||!b)&&(v(b),y("change")),T>E&&T<C?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,y("changeBegin")),v(T),y("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,y("change"),a&&y("timelineChangeComplete")):h.began&&T>C&&y("changeComplete"),h.currentTime=ts(T,0,b+h.pingPongDelayCorrection),h.began&&y("update"),A>=b)if(x(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,y("loopComplete"),y("complete"),!h.passThrough&&"Promise"in window&&(o(),d=l(h)));else{a?t+=h.duration/Qt.speed:t+=h.duration;for(let P of n)P.setStartTime(0),P.remaining=P.loop;y("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():a&&u()}}return h.reset=function(){var A=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=A==="reverse",h.remaining=h.loop,n=h.children,a=n.length;for(var b=a;b--;)h.children[b].reset();(h.reversed&&h.loop!==!0||A==="alternate"&&h.loop===1)&&h.remaining++,v(h.reversed?h.duration:0)},h.setStartTime=function(A){t=A},h.set=function(A,b){return XA(A,b),h},h.tick=function(A){r=A,t||(t=r),S((r+(i-t))*Qt.speed)},h.seek=function(A){S(A-t)},h.pause=function(A){h.paused=!0,a&&(s=A??performance.now())},h.play=function(A){!h.paused||(h.completed&&h.reset(),h.paused=!1,zr.push(h),a&&s!==void 0&&(t+=(A??performance.now())-s),Id||JG())},h.reverse=function(){c(),h.completed=!h.reversed,g()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function ab(e,t){for(var i=t.length;i--;)Zv(e,t[i].animatable.target)&&t.splice(i,1)}function eV(e){for(var t=HA(e),i=zr.length;i--;){var r=zr[i],s=r.animations,n=r.children;ab(t,s);for(var a=n.length;a--;){var o=n[a],l=o.animations;ab(t,l),!l.length&&!o.children.length&&n.splice(a,1)}!s.length&&!n.length&&r.pause()}}function tV(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?Qv(t.easing):null,s=t.grid,n=t.axis,a=t.from||0,o=a==="first",l=a==="center",h=a==="last",d=Ve.arr(e),c=parseFloat(d?e[0]:e),u=d?parseFloat(e[1]):0,p=pn(d?e[1]:e)||0,g=t.start||0+(d?c:0),f=[],m=0;return function(v,y,x){if(o&&(a=0),l&&(a=(x-1)/2),h&&(a=x-1),!f.length){for(var w=0;w<x;w++){if(!s)f.push(Math.abs(a-w));else{var _=l?(s[0]-1)/2:a%s[0],S=l?(s[1]-1)/2:Math.floor(a/s[0]),A=w%s[0],b=Math.floor(w/s[0]),E=_-A,C=S-b,T=Math.sqrt(E*E+C*C);n==="x"&&(T=-E),n==="y"&&(T=-C),f.push(T)}m=Math.max.apply(Math,f)}r&&(f=f.map(function(L){return r(L/m)*m})),i==="reverse"&&(f=f.map(function(L){return n?L<0?L*-1:-L:Math.abs(m-L)}))}var P=d?(u-c)/m:c;return g+P*(Math.round(f[y]*100)/100)+p}}function iV(e){e===void 0&&(e={});var t=Qt(e);return t.duration=0,t.add=function(i,r){var s=zr.indexOf(t),n=t.children;s>-1&&zr.splice(s,1);function a(u){u.passThrough=!0}for(var o=0;o<n.length;o++)a(n[o]);var l=tp(i,Mg(Yv,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=Ve.und(r)?h:t0(r,h),a(t);var d=Qt(l);a(d),n.push(d),d.parent=t;var c=YA(n,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,d.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}Qt.version="3.2.0";Qt.speed=1;Qt.running=zr;Qt.remove=eV;Qt.get=e0;Qt.set=XA;Qt.convertPx=Jv;Qt.path=GG;Qt.setDashoffset=kG;Qt.stagger=tV;Qt.timeline=iV;Qt.easing=Qv;Qt.penner=zA;Qt.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var QA=Qt,ob=new M,lb=new M,hb=new rt;function rV(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let n=1-s*s;if(n<=Number.EPSILON){let d=1-r;return i.w=d*e.w+r*t.w,i.x=d*e.x+r*t.x,i.y=d*e.y+r*t.y,i.z=d*e.z+r*t.z,i.normalize(),i}let a=Math.sqrt(n),o=Math.atan2(a,s),l=Math.sin((1-r)*o)/a,h=Math.sin(r*o)/a;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function Wa(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(a==null)return;let o=n??t[e],l=a;if(o!==l)return{update:h=>{let d=st.lerp(o,l,h);s?t[e]=Math.trunc(d):t[e]=d},start:()=>{t[e]=o},end:()=>{t[e]=l}}}function ZA(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=[...n??o],h=[...a];if(!(l.length!==h.length||fv(l,h)))return{update:d=>{l.forEach((c,u)=>{let p=st.lerp(c,h[u],d);t[e][u]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[e],l)},end:()=>{Object.assign(t[e],h)}}}function cb(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new M().fromArray(s):a.clone(),l=new M().fromArray(n);if(!o.equals(l))return{update:h=>{a.lerpVectors(o,l,h)},start:()=>{a.copy(o)},end:()=>{a.copy(l)}}}function sV(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new me().fromArray(s):a.clone(),l=new M,h=new rt,d=new M;o.decompose(l,h,d);let c=new me().fromArray(n),u=new M,p=new rt,g=new M;if(c.decompose(u,p,g),!o.equals(c))return{update:f=>{hb.slerpQuaternions(h,p,f),ob.lerpVectors(l,u,f),lb.lerpVectors(d,g,f),a.compose(ob,hb,lb)},start:()=>{a.compose(l,h,d)},end:()=>{a.compose(u,p,g)}}}function nV(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=n?typeof n=="string"?s.getColor(n).clone():new Fe().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Fe().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let d=o.clone();return t[e]=d,{update:c=>{d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function ra(e,t,i,r){if(typeof t[e]=="number")return Wa(e,t,i??{},r);if(Array.isArray(t[e]))return ZA(e,t,i??{},r)}function aV(e,t,i){let r=[],s=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let a=s??e.zoom,o=n;a!==o&&r.push({update:l=>{e.zoom=st.lerp(a,o,l),e.updateProjectionMatrix()},start:()=>{e.zoom=a,e.updateProjectionMatrix()},end:()=>{e.zoom=o,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let a=Wa("targetOffset",e,t,i);a&&r.push(a)}return r}function oV(e,t,i,r){if(i.scaleBaked===void 0)return;let s=t.scaleBaked??e.data.geometry.scaleBaked,n=i.scaleBaked;if(za.isEqual(s,n))return;let a=[];return a.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[st.lerp(s[0],n[0],o),st.lerp(s[1],n[1],o),st.lerp(s[2],n[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:n},r),e.invalidateDownstreamBooleanData()}}),a}function lV(e,t,i){if(!i.extrusion)return;let r=e.extrusion,s=t.extrusion??{},n=i.extrusion,a=[];return YS.forEach(o=>{let l=ra(o,r,s,n);l&&a.push(l)}),a}function hV(e,t,i,r){let s=[];if(!("geometry"in i))return s;let n=e.geometry.userData.parameters,a="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof Kh){let l=oV(e,a,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,Gh(n,yx)),yx.forEach(h=>{let d=ra(h,l,a,o);d&&s.push(d)}),e instanceof Gv){Object.assign(l,{extrusion:{...n.extrusion}});let h=lV(l,a,o);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()}})}return s}function cV(e,t,i,r){let s=[];if(i.intensity!==void 0){let n=Wa("intensity",e,t,i);n&&s.push(n)}if(i.color!==void 0){let n=nV("color",e,t,i,r);n&&s.push(n)}return s}function dV(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let n="materials"in t&&t.materials?t.materials:[],a=i.materials;e.material.forEach((o,l)=>{if(!a[l])return;let h=n[l]??{},d=a[l];typeof h=="string"||typeof d=="string"||s.push(...db(o,h,d,r))})}else{if(!("material"in i&&i.material))return s;let n="material"in t&&t.material?t.material:{},a=i.material;if(typeof n=="string"||typeof a=="string")return s;s.push(...db(e.material,n,a,r))}return s}function db(e,t,i,r){let s=[],n=Su(i,r)||!!t.layers&&Su(t,r);s.push(wV(e,n));for(let a of e.layers){let o=t.layers?.data(a.uuid),l=i.layers.data(a.uuid);if(!l||!(a.visible??!0)||!(l.visible??!0))continue;let h=a.getNames().filter(d=>!WS.some(c=>d.includes(c)));for(let d of h)try{let c=a.getValue(d),u;if(d==="colors")u=yV(a,o,l,d);else if(Array.isArray(c))d==="steps"&&(u=vV(a,o,l,d));else if(typeof c=="number")u=uV(a,o,l,d);else{if(typeof c=="boolean")continue;c instanceof k?u=pV(a,o,l,d):c instanceof M?u=fV(a,o,l,d):c instanceof nr?u=gV(a,o,l,d,r):c instanceof Fe?u=mV(a,o,l,d,r):"isTexture"in c&&(u=xV(a,o,l,d))}u&&(Array.isArray(u)?s.push(...u):s.push(u))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${d}`,c)}}return s}function uV(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:e.getValue(r),n=i[r];if(s!==n)return{update:a=>{e.setValue(r,st.lerp(s,n,a))},start:()=>{e.setValue(r,s)},end:()=>{e.setValue(r,n)}}}function pV(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new k().fromArray(t[r]):s.clone(),a=new k().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function fV(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new M().fromArray(t[r]):s.clone(),a=new M().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function mV(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new Fe().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Fe().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let d=o.clone();return{update:c=>{e.getValue(r)!==d&&e.setValue(r,d),d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function gV(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new Fe().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new nr(a.r,a.g,a.b,a.a);if(l.equals(h))return;let d=o.clone();return{update:c=>{e.getValue(r)!==d&&e.setValue(r,d),d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function vV(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n,o=i[r];for(let l=0;l<n.length;++l){let h=a[l],d=o[l];h!==d&&s.push({update:c=>{n[l]=st.lerp(h,d,c)},start:()=>{n[l]=h},end:()=>{n[l]=d}})}return s.length?s:void 0}function yV(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n.map(l=>l.toArray()),o=i[r];for(let l=0;l<n.length;++l){let h=[...a[l]],d=[...o[l]];au.isEqual(h,d)||s.push({update:c=>{n[l].fromArray(au.lerp(h,d,c))},start:()=>{n[l].fromArray(h)},end:()=>{n[l].fromArray(d)}})}return s.length?s:void 0}function xV(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let n=t?t[r]:s,a=i[r],o=[...n.repeat],l=[...n.offset],h=[...a.repeat],d=[...a.offset];if(!No.isEqual(o,h)||!No.isEqual(l,d))return{update:c=>{s.repeat=No.lerp(o,h,c),s.offset=No.lerp(l,d,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...d],s.updateMatrix()}}}function wV(e,t){return{update:()=>{e.transparent=t}}}var Vf=new M,ub=new bi;function bV(e,t,i,r){let s=[],n,a,o,l,h,d,c={slide:(t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping).offset};if(h=Wa("slide",c,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping),h&&s.push(h),d=Wa("offset",c,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping),d&&s.push(d),!h&&!d&&(n=cb("position",e,t,i),n&&s.push(n),a=cb("scale",e,t,i),a&&s.push(a),o=_V(e,t,i,r),o&&s.push(o),l=sV("hiddenMatrix",e,t,i),l&&s.push(l)),n||a||o||l||h||d){let u=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Cs(e)&&cn(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,c))};s.push({update:u,start:u,end:u})}return s}function _V(e,t,i,r){let s=t?.rotation?t.rotation:void 0,n=i.rotation;if(!n)return;let a=s?new M().fromArray(s):new M().setFromEuler(e.rotation),o=new M().fromArray(n);if(a.equals(o))return;let l=Vf.subVectors(o,a);if(r&&l.toArray().every(h=>Math.abs(h)<2*Math.PI)){let h=new rt().setFromEuler(ub.setFromVector3(a)),d=new rt().setFromEuler(ub.setFromVector3(o));return{update:c=>{rV(h,d,e.quaternion,c)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}else return{update:h=>{Vf.lerpVectors(a,o,h),e.rotation.setFromVector3(Vf)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}function SV(e,t,i){let r=[];if(!("cloner"in i)||!e.cloner)return r;let s=e.cloner,n="cloner"in t?t.cloner:{},a=i.cloner;FS.forEach(u=>{let p;u==="count"?p=Wa("count",s.parameters,n,a,!0):p=ra(u,s.parameters,n??{},a),p&&r.push(p)});let o=AV(s,n,a);o?.length&&r.push(...o);let l=MV(s,n,a);l?.length&&r.push(...l);let h=EV(s,n,a);h?.length&&r.push(...h);let d=CV(s,n,a);d?.length&&r.push(...d);let c=TV(s,n,a);return c?.length&&r.push(...c),r.length&&r.push({update:()=>{s.update()}}),r}function AV(e,t,i){if(e.parameters.type!=="radial")return;let r=t.radial,s=i.radial;if(!s)return;let n=e.parameters.radial,a=[];return kS.forEach(o=>{let l=ra(o,n,r??{},s);l&&a.push(l)}),a}function MV(e,t,i){if(e.parameters.type!=="linear")return;let r=t.linear,s=i.linear;if(!s)return;let n=[],a=e.parameters.linear;return jS.forEach(o=>{let l=ra(o,a,r??{},s);l&&n.push(l)}),n}function EV(e,t,i){if(e.parameters.type!=="grid")return;let r=t.grid,s=i.grid;if(!s)return;let n=[],a=e.parameters.grid;return GS.forEach(o=>{let l;o==="count"?l=ZA(o,a,r??{},s,!0):l=ra(o,a,r??{},s),l&&n.push(l)}),n}function CV(e,t,i){if(e.parameters.type!=="toObject")return;let r=t.toObject,s=i.toObject;if(!s)return;let n=[],a=e.parameters.toObject;return VS.forEach(o=>{let l;o==="count"?l=Wa(o,a,r??{},s,!0):l=ra(o,a,r??{},s),l&&n.push(l)}),n}function TV(e,t,i){if(!e.parameters.randomness)return;let r=t.randomnessObject,s=i.randomnessObject;if(!s)return;let n=[],a=e.parameters.randomnessObject;return HS.forEach(o=>{let l=ra(o,a,r??{},s);l&&n.push(l)}),n}function pb(e,t,i,r,s){let n=[];return e.data.visible&&n.push(...bV(e,t,i,s)),e.data.visible&&n.push(...SV(e,t,i)),Cs(e)?(e instanceof Fr&&e.data.visible&&n.push(...hV(e,t,i,r)),e.data.visible&&n.push(...dV(e,t,i,r))):Lj(e)?e.data.visible&&n.push(...cV(e,t,i,r)):Oj(e)&&n.push(...aV(e,t,i)),n.length?{update:a=>{n.forEach(o=>o.update(a))},start:a=>{n.forEach(o=>o.start?.(a))},end:a=>{n.forEach(o=>o.end?.(a))}}:void 0}var fb=new M;function KA(e,t,i,r=!1){let s=[];t.traverseObject(n=>{if(r&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(fb,!0),n.rigidBody?.setAngvel(fb,!0)),!bt.is(n))return;let a=n.uuid,o=n.data;if(delete n.states,!o.states)return;let l=!1;s.some(h=>e.objects.isDescendantOf(a,h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&s.push(a),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let h of o.states){let d={...h.data};e.environment.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0&&delete d.position,h.data.rotation!==void 0&&delete d.rotation,h.data.hiddenMatrix!==void 0&&delete d.hiddenMatrix),n.states||(n.states={}),n.states[h.id]=Ca.patch(o,d)}DV(t,n,null,i,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0),PV(t)})}function PV(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)s.data.type==="Create"&&s.data.hideBase==="Yes"&&(e.find(s.data.object).visible=!1)}})}function DV(e,t,i,r,s=!1){if(t instanceof Fr&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof Fr&&t.updateGeometryGroupsIfNeeded(),t instanceof Vi&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),t.cloner)for(let n of t.cloner.children)n.playModeVisible=void 0;t.updateVisible()}function JA(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
5597
5597
  ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
5598
- )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:n}=e;t=`spring( ${i}, ${r}, ${s}, ${n} )`}else{let i;switch(e.easing){case 0:i=zn.linear;break;case 1:i=zn.ease;break;case 2:i=zn.easeIn;break;case 3:i=zn.easeOut;break;case 4:i=zn.easeInOut;break;default:i=zn.linear}let[r,s,n,a]=i;t=`cubicBezier( ${r}, ${s}, ${n}, ${a} )`}return{duration:e.duration,easing:t}}function $A(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var OV={type:"beginState"},LV={type:"completeState",isfromEntity:!1},mb=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let a=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"beginState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(OV)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let a=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"completeState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(LV)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=pb(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let a=Bd(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=Bd(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=Bd(this.object,i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...$A(r),...JA(r),change:this.onChange},this.callback=pb(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Rh=class extends Wi{constructor(e,t,i){if(super(),this.data=e,this.scene=t,this.sharedAssets=i,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let r=t.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=Bd(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:t=!1}={}){try{let i=$A(this.data.tweens[0].data),r=i.loop;t&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=QA.timeline({autoplay:!1,...i,...r===!0||r>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(n=>n?.changeBegan);if(this.timelineNeedsRebuild=s!==-1&&(r===!0||r>1),i.pingPongDelayCorrection&&t===!1&&(this.timelineNeedsRebuild=!0),e){let n=s===-1?0:s;for(let a=n;a<this.data.tweens.length-1;a++){let o=this.data.tweens[a],l=this.data.tweens[a+1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new mb(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.delay:0)+(a===n&&!t?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let n=s===-1?this.data.tweens.length-1:s+1;for(let a=n;a>0;a--){let o=this.data.tweens[a],l=this.data.tweens[a-1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new mb(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a-1]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.endDelay:0))}this.timeline.duration+=i.delay+(t?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Bd(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var RV={type:"beginState"},gb={type:"completeState",isfromEntity:!1},vb={type:"requestRender"},eM=class extends Wi{constructor(e,t){super(),this.data=e,this.scene=t,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new M,this.posEnd=new M,this.qStart=new rt,this.qEnd=new rt,this.zoomStart=1,this.zoomEnd=1,this.toCamera=t.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t={t:0};this.posStart.copy(this.scene.activeCamera.position),this.qStart.copy(this.scene.activeCamera.quaternion),this.zoomStart=this.scene.activeCamera.zoom,this.animation=QA({targets:t,t:1,...JA(this.data),update:()=>{t.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)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.scene.activeCamera,this.switchCamera(this.toCamera)),this.scene.activeCamera.dispatchEvent(RV));let i=this.scene.activeCamera;i.position.lerpVectors(this.posStart,this.posEnd,t.t),i.quaternion.slerpQuaternions(this.qStart,this.qEnd,t.t),i.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*t.t,i.wasMovedBySwitchCameraAction=!0,i.updateMatrix(),i.updateMatrixWorld(),i.updateProjectionMatrix(),i.dispatchEvent(vb),t.t===1&&i.dispatchEvent(gb)}})}switchCamera(e){this.scene.activeCamera.dispatchEvent({type:"cameraChange",camera:e}),this.scene.switchActiveCamera(e)}play(){this.playing||this.scene.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,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.scene.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.scene.activeCamera.dispatchEvent(gb),this.scene.activeCamera.dispatchEvent(vb))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function ns(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?En[e.type].includes("Audio")&&a.Audio.push(new Th(o,l,n,r)):l.type==="Video"?En[e.type].includes("Video")&&a.Video.push(new Xv(o,l,n)):l.type==="Link"?En[e.type].includes("Link")&&a.Link.push(new SG(l,s)):l.type==="Create"?En[e.type].includes("Create")&&a.Create.push(new Oh(l,i,s.controlsManager)):l.type==="Destroy"?En[e.type].includes("Destroy")&&a.Destroy.push(new LA(l,i,s)):l.type==="Reset"?En[e.type].includes("Reset")&&a.Reset.push(new EG(i.data,i,r,s)):l.type==="Transition"?En[e.type].includes("Transition")&&a.Transition.push(new Rh(l,i,r)):l.type==="SwitchCamera"&&En[e.type].includes("SwitchCamera")&&a.SwitchCamera.push(new eM(l,i))}catch{}}),a}function kr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof Th||i instanceof Xv||i instanceof Rh||i instanceof Oh||i instanceof LA||i instanceof eM)&&i.dispose()})})}var r0=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],tM=e=>r0.find(([t,i])=>i===e)?.[0],dc=e=>r0.find(([t])=>t===e)?.[1],IV=(e,t)=>{let i=tM(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},BV=class extends yn{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[tM(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of r0)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=IV(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},zV=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=ns(t,t.actions,r,s,n,i)}disconnect(){kr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){let t=new Set;this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this?(i.object.currentTransitionEvent=this,i.init()):this.useToggle===!1&&t.add(i)}),this.useToggle?(this.actions.Transition.forEach(i=>{i.toggle()}),this.actions.SwitchCamera.forEach(i=>{i.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(i=>i.playFromCurrent()),this.actions.SwitchCamera.forEach(i=>i.playFromCurrent()),this.actions.Create.forEach(i=>i.dispatchStart())):(this.actions.Transition.some(i=>i.playing)||this.actions.Transition.forEach(i=>{t.has(i)===!1&&i.play()}),this.actions.SwitchCamera.some(i=>i.playing)||this.actions.SwitchCamera.forEach(i=>{i.play()})),this.actions.Link.forEach(i=>{i.dispatch()}),e===!1&&this.actions.Create.forEach(i=>{i.dispatch()}),this.actions.Destroy.forEach(i=>{i.dispatch()}),this.actions.Reset.forEach(i=>{i.dispatch()}),this.actions.Audio.forEach(i=>{i.dispatchBasic()}),this.actions.Video.forEach(i=>{i.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},NV=class extends yn{constructor(e,t){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.windowMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.onWindowMouseDown=s=>{s.target===this.eventContext.domElement&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})},this.onWindowMouseUp=s=>{s.target===this.eventContext.domElement&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseDown"))},this.onMouseUp=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent())},this.onMousePressRelease=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent(!0))},this.onKeyDown=s=>{this.heldKeys[s.key]||(this.handleKeyEvent(s,"KeyDown"),this.handleKeyEventHeld(s,"KeyDown",!0)),this.heldKeys[s.key]=!0},this.onKeyUp=s=>{this.handleKeyEvent(s,"KeyUp"),this.handleKeyEventHeld(s,"KeyUp",!0)},this.onKeyPressDown=s=>{this.heldKeysPress[s.key]?this.handleKeyEventHeld(s,"KeyPress"):(this.handleKeyEvent(s,"KeyPress"),this.handleKeyEventHeld(s,"KeyPress",!0)),this.heldKeysPress[s.key]=!0},this.onKeyPressUp=s=>{this.handleKeyEvent(s,"KeyPress",!0)},this.releaseHeldKey=s=>{delete this.heldKeys[s.key]},this.releaseHeldKeyPress=s=>{delete this.heldKeysPress[s.key]},this._onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=dc(s);o&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent(a)})):(o==="KeyDown"||o==="KeyUp"||o==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent()})))};let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let a of n){let o=this.eventsPerObjects[a];s.data.events.filter(({data:l})=>l.type===a&&l.disabled!==!0).forEach(({id:l,data:h})=>{try{let d=new zV(l,h,s,i,r,t);d.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.mode==="Window")?h.mode==="Canvas"&&this.canvasMouseEvents.push(d):o[s.uuid]?o[s.uuid].push(d):o[s.uuid]=[d]}catch{}}),o[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,scene:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=bg(i,r,s);_g(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{Cu(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,scene:a}=this.eventContext;if(s){let o=bg(n,a,i);r=_g(o)}else i.forEach(o=>{Cu(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},UV=new M,FV=new M,iM=class{constructor(e,t,i,r,s){this.actionsIn=ns(e,e.inActions,i,r,s,t),this.actionsOut=ns(e,e.outActions,i,r,s,t)}disconnect(){kr(this.actionsIn),kr(this.actionsOut)}},kV=class extends iM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{let h=UV.setFromMatrixPosition(this.objects[0].matrixWorld),d=FV.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(d)<=this.distance?"in":"out";if(this.stage!==c){let u=c==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),this.stage=c}};let{distance:a,fromObject:o,toObject:l}=t.condition;this.distance=a;for(let h of[o,l]){if(!h)throw new Error("Missing property");let d=r.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},jV=class extends iM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(d=>d.dispatchConditional()),this.actionsOut.Video.forEach(d=>d.dispatchConditional()),this.actionsOut.Create.forEach(d=>d.dispatch()),this.actionsOut.Destroy.forEach(d=>d.dispatch()),this.actionsOut.Reset.forEach(d=>d.dispatch()),this.actionsIn.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(d=>d.play()),this.actionsIn.SwitchCamera.forEach(d=>d.pause()),this.actionsOut.SwitchCamera.forEach(d=>d.play()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(d=>d.dispatchConditional()),this.actionsIn.Video.forEach(d=>d.dispatchConditional()),this.actionsIn.Create.forEach(d=>d.dispatch()),this.actionsIn.Destroy.forEach(d=>d.dispatch()),this.actionsIn.Reset.forEach(d=>d.dispatch()),this.actionsOut.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(d=>d.play()),this.actionsOut.SwitchCamera.forEach(d=>d.pause()),this.actionsIn.SwitchCamera.forEach(d=>d.play()))};let{condition:a}=t;if(!a.object)throw new Error("Missing property");let o=r.find(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.SwitchCamera.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.SwitchCamera.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.SwitchCamera.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.SwitchCamera.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},GV=class extends yn{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let o;a.condition.type==="Comparison"||(a.condition.type==="Distance"?o=new kV(n,a,s,i,r,t):a.condition.type==="State"&&(o=new jV(n,a,s,i,r,t))),o&&(this.eventsPerConditions[a.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},ah=new M,Dn=new M,ga=new M,yb=new pr,VV=.01,vt=new M,li=new M,xb=new M,Da=new rt,Hf=new bi,HV=new me,Wf=new _i,So=new M,vs=new M,Ao=.2;function qf(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var WV=function(){let e=new me;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&qf(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?qf(s.position,t.limits):t.reference==="local"&&(Da.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Da),qf(s.position,t.limits),Da.invert(),s.position.applyQuaternion(Da),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(vt,s.quaternion,li),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof ar&&cn(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),qV=class{constructor(e,t,i,r,s,n){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=ns(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=ns(t,t.dragDropActions.drop,i,r,s,this.object);let a=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.dataPatched.visible!==!1&&(a.push(l),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.dataPatched.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.dataPatched.visible!==!1&&(this.dropDestIds.push(l.uuid),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.dataPatched.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new M().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new M().setFromMatrixPosition(o.matrixWorld),pointStart:new M,pointEnd:new M,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new M().copy(o.position),quat0:new rt().copy(o.quaternion),snapped:!1,orientationMatrix:new me,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){kr(this.actionsDrag),kr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},XV=class extends yn{constructor(e,t){super(e),this.managers=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(je.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,scene:n}=this.eventContext,a=n.raycastWithClones(s);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:d,pointStart:c}of o.dragItems){if(h===a[0].object||h===a[0].object.object||bt.is(h)&&h.isAncestorOf(a[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.managers.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(vt,Da,li),Hf.setFromQuaternion(Da),u.prevR===void 0?(u.prevR=Hf.clone(),u.prevT=vt.clone()):(u.prevR.copy(Hf),u.prevT.copy(vt)),this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),d.copy(c),(this.managers.controlsManager.usePhysics&&h.dataPatched.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(je.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,scene:n}=this.eventContext,a=n.raycastWithClones(s);if(je.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===a[0]?.object||h===a[0]?.object?.object||bt.is(h)&&h.isAncestorOf(a[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=a.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Mu)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(d=>d===h.object.uuid||n.find(d).isAncestorOf(h.object.uuid))))[0]),l){let h=xb.copy(l.face.normal).applyMatrix3(Wf.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){vt.copy(h).applyMatrix3(Wf.setFromMatrix4(o.obj.matrixWorld).transpose());let d=o.obj;vt.x>Ao?li.x=-d.recursiveBBox.min.x:vt.x<-Ao&&(li.x=-d.recursiveBBox.max.x),vt.y>Ao?li.y=-d.recursiveBBox.min.y:vt.y<-Ao&&(li.y=-d.recursiveBBox.max.y),vt.z>Ao?li.z=-d.recursiveBBox.min.z:vt.z<-Ao&&(li.z=-d.recursiveBBox.max.z),li.applyMatrix3(Wf.invert())}else li.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(li)}this.activeEvent.data.autoOrient&&(vt.set(0,1,0).cross(h),vt.length()<1e-4&&vt.set(-1,0,0).cross(h),li.crossVectors(xb,vt),o.orientationMatrix.makeBasis(vt,li,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Audio.forEach(d=>{d.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(d=>{d.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.dataPatched.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.managers.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.managers.controlsManager.usePhysics&&s&&(this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")})),this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!0)}};let i={};e.scene.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.scene.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new qV(r,s.data,e.scene,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{camera:s,raycaster:n}=this.eventContext;s.getWorldDirection(Dn),Dn.negate();let a=Da.identity();switch(r==="parent"?HV.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(vt,a,li):r==="local"&&e.matrixWorld.decompose(vt,a,li),i){case"x":vt.set(1,0,0).applyQuaternion(a),So.copy(Dn).cross(vt),vs.copy(vt).cross(So);break;case"y":vt.set(0,1,0).applyQuaternion(a),So.copy(Dn).cross(vt),vs.copy(vt).cross(So);break;case"z":vt.set(0,0,1).applyQuaternion(a),So.copy(Dn).cross(vt),vs.copy(vt).cross(So);break;case"xy":vs.set(0,0,1).applyQuaternion(a);break;case"yz":vs.set(1,0,0).applyQuaternion(a);break;case"xz":vs.set(0,1,0).applyQuaternion(a);break;case"adaptive":Dn.angleTo(li.set(0,1,0))>Math.PI/6?(vt.crossVectors(li.set(0,1,0),Dn),vs.crossVectors(vt,li)):vs.set(0,1,0);break;default:vs.copy(Dn);break}ga.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:ga;if(yb.setFromNormalAndCoplanarPoint(vs,o),!!n.ray.intersectPlane(yb,t)&&(i==="x"||i==="y"||i==="z")){let l=li.subVectors(t,o).dot(vt);t.copy(o).addScaledVector(vt,l)}}updateDragItem(e,t=!1){ga.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?ah.subVectors(e.fromPosition,ga).divideScalar(e.currentDampingFactor):e.reset==="original"?(ah.subVectors(e.obj.userData.worldPosition0,ga).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):ah.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(ga).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?ah.length()<VV:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&WV(e,ah.add(ga),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.managers.eventManager.requestRender()}},Mo=new M,Xf=new M,Zs=new M,Ks=new M,wb=new pr,YV=.01,QV={type:"requestRender"},ZV=function(){let e=new M,t=new M;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),bb=function(){let e=new me;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof ar&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),KV=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new M,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...zm.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(e.target==="personal camera"?this.target=i.find(Br.PERSONAL_CAMERA_ID):this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=ns(e,e.actions,i,r,s,t)}},JV=class extends yn{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(je.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{scene:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(n=>n.data.type==="Follow"&&!n.data.disabled);s&&(!i.data.environment.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new KV(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,kr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(Zs),e.isReset)Ks.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Ks);else{let{camera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a.getWorldDirection(Xf),Xf.negate(),Mo.copy(Xf)):i==="xy"?Mo.set(0,0,1):i==="xz"?Mo.set(0,1,0):i==="yz"&&Mo.set(1,0,0),wb.setFromNormalAndCoplanarPoint(Mo,Zs),!o.ray.intersectPlane(wb,Ks))return}if(!e.isReset){if(Ks.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Ks.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&&(Ks.x=Zs.x),e.data.enabledTranslation[1]===!1&&(Ks.y=Zs.y),e.data.enabledTranslation[2]===!1&&(Ks.z=Zs.z);let n=ZV(Zs,Ks,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let a=Mo.subVectors(n,Zs).divideScalar(e.currentDampingFactor);Zs.add(a),t&&bb(e.object,Zs),e.paused=a.length()<YV}else bb(e.object,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(QV)}},oh=new M,xd=new M,lh=new me,Eo=new rt,On=new rt,hh=new M,ch=new M,va=new M,Js=new M,Yf=new pr,$V=1e-6,eH={type:"requestRender"},tH={type:"changeRotation"},_b=function(){let e=new me;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(MA(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof ar&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),iH=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new rt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Nm.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(e.target==="personal camera"?this.target=i.find(Br.PERSONAL_CAMERA_ID):this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},rH=class extends yn{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(je.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let n=dc(r);n&&n==="LookAt"&&this.updateSingleEvent(i)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new iH(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let n=this.onTargetChange(i),a=i.target;this.pairOfEventListeners.push([a,n]),a.addEventListener("requestRender",n)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:n,enabledRotation:a,limitDistanceEnabled:o}=e.data,{camera:l,raycaster:h}=this.eventContext,{object:d,target:c}=e;if(d.getWorldPosition(hh),!e.isReset)if(e.target)e.target.getWorldPosition(ch);else{if(s==="custom"?(l.getWorldDirection(xd),xd.negate(),Yf.setFromNormalAndCoplanarPoint(xd,hh)):(s==="xy"?oh.set(0,0,1):s==="xz"?oh.set(0,1,0):s==="yz"&&oh.set(1,0,0),Yf.setFromNormalAndCoplanarPoint(oh,hh)),!h.ray.intersectPlane(Yf,ch))return;r>0&&(s==="custom"||s===void 0)&&ch.addScaledVector(xd,r)}if(e.isReset||(c?t==="target"?va.copy(c.up).applyMatrix4(lh.extractRotation(c.matrixWorld)).normalize():a.some(u=>u===!1)?(i==="x"?(Js.set(0,0,1),a[2]===!1&&Js.set(0,1,0)):i==="y"?(Js.set(1,0,0),a[0]===!1&&Js.set(0,0,1)):(Js.set(0,1,0),a[1]===!1&&Js.set(1,0,0)),va.copy(Js).applyQuaternion(e.worldQuaternion0).normalize()):va.set(0,1,0):s==="custom"?va.set(0,1,0):va.copy(oh)),e.isReset)On.copy(e.worldQuaternion0);else if(hh.distanceTo(ch)>n&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)On.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;sH(lh,ch,hh,va,i,Js),On.setFromRotationMatrix(lh),Eo.setFromUnitVectors(Js.applyQuaternion(On),va),a.some(u=>u===!1)&&t!=="target"&&On.premultiply(Eo).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Eo.setFromRotationMatrix(MA(d.matrixWorld)),Eo.slerp(On,1/e.currentDampingFactor),_b(d,lh.makeRotationFromQuaternion(Eo)),e.paused=8*(1-Eo.dot(On))<$V):(_b(d,lh.makeRotationFromQuaternion(On)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(eH),d.dispatchEvent(tH)}},Ar=new M,oi=new M,qt=new M;function sH(e,t,i,r,s,n){let a=e.elements;qt.subVectors(t,i),qt.lengthSq()===0&&(qt.z=1),qt.normalize(),oi.crossVectors(r,qt),oi.lengthSq()===0&&(Math.abs(r.z)===1?qt.x+=1e-4:qt.z+=1e-4,qt.normalize(),oi.crossVectors(r,qt)),oi.normalize(),Ar.crossVectors(qt,oi),s==="x"?n.z===1?[oi,Ar,qt]=[qt,oi,Ar]:(oi.negate(),[oi,qt]=[qt,oi]):s==="y"?n.x===1?[oi,Ar,qt]=[Ar,qt,oi]:(oi.negate(),[Ar,qt]=[qt,Ar]):n.x===1&&(oi.negate(),[oi,Ar]=[Ar,oi]),a[0]=oi.x,a[4]=Ar.x,a[8]=qt.x,a[1]=oi.y,a[5]=Ar.y,a[9]=qt.y,a[2]=oi.z,a[6]=Ar.z,a[10]=qt.z}var nH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=ns(t,t.actions,r,s,n,i)}disconnect(){kr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()))}},aH=class extends yn{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{je.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=dc(s);o&&o==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(l=>l.dispatchUserEvent(a)))};let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let o=new nH(n,a,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),gr&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),gr&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,scene:s}=this.eventContext;if(i){let n=bg(r,s,this.objects);t=_g(n)}else this.objects.forEach(n=>{Cu(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},oH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=ns(t,t.actions,r,s,n,i)}connect(){this.scrollCounter=0}disconnect(){kr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Create.forEach(t=>t.dispatchThrottled())}},lH=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.object=i,this.domElement=n,this.managers=a,this.scrollStart=0,this.scrollEnd=0,this.actions=ns(t,t.actions,r,s,a,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,n=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?a:l==="bottom"?a-o:a-o*.5;this.scrollStart=n-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){kr(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Create.forEach(t=>t.dispatchThrottled())}},hH=class extends yn{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([a,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=a=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(d=>d.dispatch(o))})},this.onWheel=a=>{!this.isInview||a.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:a.deltaY}),l.forEach(h=>h.dispatch(a.deltaY))})},this.onUserEvent=({eventName:a,target:o,reverse:l})=>{if(!a||!o)return;let h=dc(a);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(d=>{d.dispatchUserEvent(l)}))};let{scene:i,sharedAssets:r,domElement:s,isExport:n}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!n){let h=new oH(o,l,a,i,r,t);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(h):this.wheelEventsPerObject.set(a,[h])}else{let h=new lH(o,l,a,i,r,s,t);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(h):this.scrollEventsPerObject.set(a,[h])}}}),this.intersectionObserver=new IntersectionObserver(a=>{let o=a[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},cH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.actions=ns(t,t.actions,r,s,n,i)}disconnect(){kr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Go?t.interaction.audioPlayer.play():t.interaction instanceof Sg&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Dh?t.interaction.play(i==="autoplay"):t.interaction instanceof Ag&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Go?t.interaction.audioPlayer.play():t.interaction instanceof Sg&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Dh?t.interaction.play():t.interaction instanceof Ag&&t.interaction.dispatch()})}},dH=class extends yn{constructor(e,t){super(e),this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:s,isExport:n}=this.eventContext;(n?document:s).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,o])=>{a.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(l=>{l.dispatchAfter("any")})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=dc(s);o&&o==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(l=>{l.dispatchUserEvent(a)}),this.eventsAfterPerObject.get(n)?.forEach(l=>{l.dispatchUserEvent(a)}))};let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length)for(let{id:n,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let o=new cH(n,a,s,i,r,t);(o.actions.Transition.length||o.actions.SwitchCamera.length||o.actions.Create.length||o.actions.Destroy.length)&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(o):this.eventsPerObject.set(s,[o])),o.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(o):this.eventsAfterPerObject.set(s,[o])),o.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(o):this.eventsAfterPerObject.set(s,[o]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(i=>i.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())})}},uH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.disabled=!0,this.actions=ns(t,t.actions,r,s,n,i),this.target=t.target,this.useToggle=t.toggle}disconnect(){kr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(t=>{t.toggle()}):this.actions.Transition.forEach(t=>{t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},pH="https://unpkg.com/@splinetool/runtime@0.9.378/build/",fH="https://unpkg.com/@splinetool/navmesh-wasm@0.9.378/build/",mH=`
5598
+ )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:n}=e;t=`spring( ${i}, ${r}, ${s}, ${n} )`}else{let i;switch(e.easing){case 0:i=zn.linear;break;case 1:i=zn.ease;break;case 2:i=zn.easeIn;break;case 3:i=zn.easeOut;break;case 4:i=zn.easeInOut;break;default:i=zn.linear}let[r,s,n,a]=i;t=`cubicBezier( ${r}, ${s}, ${n}, ${a} )`}return{duration:e.duration,easing:t}}function $A(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var OV={type:"beginState"},LV={type:"completeState",isfromEntity:!1},mb=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let a=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"beginState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(OV)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let a=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"completeState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(LV)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=pb(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let a=Bd(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=Bd(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=Bd(this.object,i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...$A(r),...JA(r),change:this.onChange},this.callback=pb(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Rh=class extends Wi{constructor(e,t,i){if(super(),this.data=e,this.scene=t,this.sharedAssets=i,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let r=t.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=Bd(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:t=!1}={}){try{let i=$A(this.data.tweens[0].data),r=i.loop;t&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=QA.timeline({autoplay:!1,...i,...r===!0||r>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(n=>n?.changeBegan);if(this.timelineNeedsRebuild=s!==-1&&(r===!0||r>1),i.pingPongDelayCorrection&&t===!1&&(this.timelineNeedsRebuild=!0),e){let n=s===-1?0:s;for(let a=n;a<this.data.tweens.length-1;a++){let o=this.data.tweens[a],l=this.data.tweens[a+1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new mb(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.delay:0)+(a===n&&!t?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let n=s===-1?this.data.tweens.length-1:s+1;for(let a=n;a>0;a--){let o=this.data.tweens[a],l=this.data.tweens[a-1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new mb(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a-1]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.endDelay:0))}this.timeline.duration+=i.delay+(t?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Bd(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var RV={type:"beginState"},gb={type:"completeState",isfromEntity:!1},vb={type:"requestRender"},eM=class extends Wi{constructor(e,t){super(),this.data=e,this.scene=t,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new M,this.posEnd=new M,this.qStart=new rt,this.qEnd=new rt,this.zoomStart=1,this.zoomEnd=1,this.toCamera=t.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t={t:0};this.posStart.copy(this.scene.activeCamera.position),this.qStart.copy(this.scene.activeCamera.quaternion),this.zoomStart=this.scene.activeCamera.zoom,this.animation=QA({targets:t,t:1,...JA(this.data),update:()=>{t.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)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.scene.activeCamera,this.switchCamera(this.toCamera)),this.scene.activeCamera.dispatchEvent(RV));let i=this.scene.activeCamera;i.position.lerpVectors(this.posStart,this.posEnd,t.t),i.quaternion.slerpQuaternions(this.qStart,this.qEnd,t.t),i.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*t.t,i.wasMovedBySwitchCameraAction=!0,i.updateMatrix(),i.updateMatrixWorld(),i.updateProjectionMatrix(),i.dispatchEvent(vb),t.t===1&&i.dispatchEvent(gb)}})}switchCamera(e){this.scene.activeCamera.dispatchEvent({type:"cameraChange",camera:e}),this.scene.switchActiveCamera(e)}play(){this.playing||this.scene.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,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.scene.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.scene.activeCamera.dispatchEvent(gb),this.scene.activeCamera.dispatchEvent(vb))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function ns(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?En[e.type].includes("Audio")&&a.Audio.push(new Th(o,l,n,r)):l.type==="Video"?En[e.type].includes("Video")&&a.Video.push(new Xv(o,l,n)):l.type==="Link"?En[e.type].includes("Link")&&a.Link.push(new SG(l,s)):l.type==="Create"?En[e.type].includes("Create")&&a.Create.push(new Oh(l,i,s.controlsManager)):l.type==="Destroy"?En[e.type].includes("Destroy")&&a.Destroy.push(new LA(l,i,s)):l.type==="Reset"?En[e.type].includes("Reset")&&a.Reset.push(new EG(i.data,i,r,s)):l.type==="Transition"?En[e.type].includes("Transition")&&a.Transition.push(new Rh(l,i,r)):l.type==="SwitchCamera"&&En[e.type].includes("SwitchCamera")&&a.SwitchCamera.push(new eM(l,i))}catch{}}),a}function kr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof Th||i instanceof Xv||i instanceof Rh||i instanceof Oh||i instanceof LA||i instanceof eM)&&i.dispose()})})}var r0=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],tM=e=>r0.find(([t,i])=>i===e)?.[0],dc=e=>r0.find(([t])=>t===e)?.[1],IV=(e,t)=>{let i=tM(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},BV=class extends yn{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[tM(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of r0)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=IV(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},zV=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=ns(t,t.actions,r,s,n,i)}disconnect(){kr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){let t=new Set;this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this?(i.object.currentTransitionEvent=this,i.init()):this.useToggle===!1&&t.add(i)}),this.useToggle?(this.actions.Transition.forEach(i=>{i.toggle()}),this.actions.SwitchCamera.forEach(i=>{i.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(i=>i.playFromCurrent()),this.actions.SwitchCamera.forEach(i=>i.playFromCurrent()),this.actions.Create.forEach(i=>i.dispatchStart())):(this.actions.Transition.some(i=>i.playing)||this.actions.Transition.forEach(i=>{t.has(i)===!1&&i.play()}),this.actions.SwitchCamera.some(i=>i.playing)||this.actions.SwitchCamera.forEach(i=>{i.play()})),this.actions.Link.forEach(i=>{i.dispatch()}),e===!1&&this.actions.Create.forEach(i=>{i.dispatch()}),this.actions.Destroy.forEach(i=>{i.dispatch()}),this.actions.Reset.forEach(i=>{i.dispatch()}),this.actions.Audio.forEach(i=>{i.dispatchBasic()}),this.actions.Video.forEach(i=>{i.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},NV=class extends yn{constructor(e,t){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.windowMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.onWindowMouseDown=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})},this.onWindowMouseUp=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseDown"))},this.onMouseUp=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent())},this.onMousePressRelease=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent(!0))},this.onKeyDown=s=>{this.heldKeys[s.key]||(this.handleKeyEvent(s,"KeyDown"),this.handleKeyEventHeld(s,"KeyDown",!0)),this.heldKeys[s.key]=!0},this.onKeyUp=s=>{this.handleKeyEvent(s,"KeyUp"),this.handleKeyEventHeld(s,"KeyUp",!0)},this.onKeyPressDown=s=>{this.heldKeysPress[s.key]?this.handleKeyEventHeld(s,"KeyPress"):(this.handleKeyEvent(s,"KeyPress"),this.handleKeyEventHeld(s,"KeyPress",!0)),this.heldKeysPress[s.key]=!0},this.onKeyPressUp=s=>{this.handleKeyEvent(s,"KeyPress",!0)},this.releaseHeldKey=s=>{delete this.heldKeys[s.key]},this.releaseHeldKeyPress=s=>{delete this.heldKeysPress[s.key]},this._onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=dc(s);o&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent(a)})):(o==="KeyDown"||o==="KeyUp"||o==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent()})))};let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let a of n){let o=this.eventsPerObjects[a];s.data.events.filter(({data:l})=>l.type===a&&l.disabled!==!0).forEach(({id:l,data:h})=>{try{let d=new zV(l,h,s,i,r,t);d.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.mode==="Window")?h.mode==="Canvas"&&this.canvasMouseEvents.push(d):o[s.uuid]?o[s.uuid].push(d):o[s.uuid]=[d]}catch{}}),o[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,scene:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=bg(i,r,s);_g(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{Cu(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,scene:a}=this.eventContext;if(s){let o=bg(n,a,i);r=_g(o)}else i.forEach(o=>{Cu(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},UV=new M,FV=new M,iM=class{constructor(e,t,i,r,s){this.actionsIn=ns(e,e.inActions,i,r,s,t),this.actionsOut=ns(e,e.outActions,i,r,s,t)}disconnect(){kr(this.actionsIn),kr(this.actionsOut)}},kV=class extends iM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{let h=UV.setFromMatrixPosition(this.objects[0].matrixWorld),d=FV.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(d)<=this.distance?"in":"out";if(this.stage!==c){let u=c==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),this.stage=c}};let{distance:a,fromObject:o,toObject:l}=t.condition;this.distance=a;for(let h of[o,l]){if(!h)throw new Error("Missing property");let d=r.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},jV=class extends iM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(d=>d.dispatchConditional()),this.actionsOut.Video.forEach(d=>d.dispatchConditional()),this.actionsOut.Create.forEach(d=>d.dispatch()),this.actionsOut.Destroy.forEach(d=>d.dispatch()),this.actionsOut.Reset.forEach(d=>d.dispatch()),this.actionsIn.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(d=>d.play()),this.actionsIn.SwitchCamera.forEach(d=>d.pause()),this.actionsOut.SwitchCamera.forEach(d=>d.play()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(d=>d.dispatchConditional()),this.actionsIn.Video.forEach(d=>d.dispatchConditional()),this.actionsIn.Create.forEach(d=>d.dispatch()),this.actionsIn.Destroy.forEach(d=>d.dispatch()),this.actionsIn.Reset.forEach(d=>d.dispatch()),this.actionsOut.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(d=>d.play()),this.actionsOut.SwitchCamera.forEach(d=>d.pause()),this.actionsIn.SwitchCamera.forEach(d=>d.play()))};let{condition:a}=t;if(!a.object)throw new Error("Missing property");let o=r.find(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.SwitchCamera.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.SwitchCamera.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.SwitchCamera.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.SwitchCamera.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},GV=class extends yn{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let o;a.condition.type==="Comparison"||(a.condition.type==="Distance"?o=new kV(n,a,s,i,r,t):a.condition.type==="State"&&(o=new jV(n,a,s,i,r,t))),o&&(this.eventsPerConditions[a.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},ah=new M,Dn=new M,ga=new M,yb=new pr,VV=.01,vt=new M,li=new M,xb=new M,Da=new rt,Hf=new bi,HV=new me,Wf=new _i,So=new M,vs=new M,Ao=.2;function qf(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var WV=function(){let e=new me;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&qf(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?qf(s.position,t.limits):t.reference==="local"&&(Da.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Da),qf(s.position,t.limits),Da.invert(),s.position.applyQuaternion(Da),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(vt,s.quaternion,li),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof ar&&cn(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),qV=class{constructor(e,t,i,r,s,n){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=ns(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=ns(t,t.dragDropActions.drop,i,r,s,this.object);let a=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.dataPatched.visible!==!1&&(a.push(l),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.dataPatched.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.dataPatched.visible!==!1&&(this.dropDestIds.push(l.uuid),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.dataPatched.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new M().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new M().setFromMatrixPosition(o.matrixWorld),pointStart:new M,pointEnd:new M,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new M().copy(o.position),quat0:new rt().copy(o.quaternion),snapped:!1,orientationMatrix:new me,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){kr(this.actionsDrag),kr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},XV=class extends yn{constructor(e,t){super(e),this.managers=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(je.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,scene:n}=this.eventContext,a=n.raycastWithClones(s);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:d,pointStart:c}of o.dragItems){if(h===a[0].object||h===a[0].object.object||bt.is(h)&&h.isAncestorOf(a[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.managers.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(vt,Da,li),Hf.setFromQuaternion(Da),u.prevR===void 0?(u.prevR=Hf.clone(),u.prevT=vt.clone()):(u.prevR.copy(Hf),u.prevT.copy(vt)),this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),d.copy(c),(this.managers.controlsManager.usePhysics&&h.dataPatched.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(je.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,scene:n}=this.eventContext,a=n.raycastWithClones(s);if(je.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===a[0]?.object||h===a[0]?.object?.object||bt.is(h)&&h.isAncestorOf(a[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=a.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Mu)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(d=>d===h.object.uuid||n.find(d).isAncestorOf(h.object.uuid))))[0]),l){let h=xb.copy(l.face.normal).applyMatrix3(Wf.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){vt.copy(h).applyMatrix3(Wf.setFromMatrix4(o.obj.matrixWorld).transpose());let d=o.obj;vt.x>Ao?li.x=-d.recursiveBBox.min.x:vt.x<-Ao&&(li.x=-d.recursiveBBox.max.x),vt.y>Ao?li.y=-d.recursiveBBox.min.y:vt.y<-Ao&&(li.y=-d.recursiveBBox.max.y),vt.z>Ao?li.z=-d.recursiveBBox.min.z:vt.z<-Ao&&(li.z=-d.recursiveBBox.max.z),li.applyMatrix3(Wf.invert())}else li.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(li)}this.activeEvent.data.autoOrient&&(vt.set(0,1,0).cross(h),vt.length()<1e-4&&vt.set(-1,0,0).cross(h),li.crossVectors(xb,vt),o.orientationMatrix.makeBasis(vt,li,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Audio.forEach(d=>{d.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(d=>{d.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.dataPatched.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.managers.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.managers.controlsManager.usePhysics&&s&&(this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")})),this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!0)}};let i={};e.scene.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.scene.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new qV(r,s.data,e.scene,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{camera:s,raycaster:n}=this.eventContext;s.getWorldDirection(Dn),Dn.negate();let a=Da.identity();switch(r==="parent"?HV.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(vt,a,li):r==="local"&&e.matrixWorld.decompose(vt,a,li),i){case"x":vt.set(1,0,0).applyQuaternion(a),So.copy(Dn).cross(vt),vs.copy(vt).cross(So);break;case"y":vt.set(0,1,0).applyQuaternion(a),So.copy(Dn).cross(vt),vs.copy(vt).cross(So);break;case"z":vt.set(0,0,1).applyQuaternion(a),So.copy(Dn).cross(vt),vs.copy(vt).cross(So);break;case"xy":vs.set(0,0,1).applyQuaternion(a);break;case"yz":vs.set(1,0,0).applyQuaternion(a);break;case"xz":vs.set(0,1,0).applyQuaternion(a);break;case"adaptive":Dn.angleTo(li.set(0,1,0))>Math.PI/6?(vt.crossVectors(li.set(0,1,0),Dn),vs.crossVectors(vt,li)):vs.set(0,1,0);break;default:vs.copy(Dn);break}ga.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:ga;if(yb.setFromNormalAndCoplanarPoint(vs,o),!!n.ray.intersectPlane(yb,t)&&(i==="x"||i==="y"||i==="z")){let l=li.subVectors(t,o).dot(vt);t.copy(o).addScaledVector(vt,l)}}updateDragItem(e,t=!1){ga.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?ah.subVectors(e.fromPosition,ga).divideScalar(e.currentDampingFactor):e.reset==="original"?(ah.subVectors(e.obj.userData.worldPosition0,ga).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):ah.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(ga).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?ah.length()<VV:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&WV(e,ah.add(ga),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.managers.eventManager.requestRender()}},Mo=new M,Xf=new M,Zs=new M,Ks=new M,wb=new pr,YV=.01,QV={type:"requestRender"},ZV=function(){let e=new M,t=new M;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),bb=function(){let e=new me;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof ar&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),KV=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new M,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...zm.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(e.target==="personal camera"?this.target=i.find(Br.PERSONAL_CAMERA_ID):this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=ns(e,e.actions,i,r,s,t)}},JV=class extends yn{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(je.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{scene:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(n=>n.data.type==="Follow"&&!n.data.disabled);s&&(!i.data.environment.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new KV(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,kr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(Zs),e.isReset)Ks.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Ks);else{let{camera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a.getWorldDirection(Xf),Xf.negate(),Mo.copy(Xf)):i==="xy"?Mo.set(0,0,1):i==="xz"?Mo.set(0,1,0):i==="yz"&&Mo.set(1,0,0),wb.setFromNormalAndCoplanarPoint(Mo,Zs),!o.ray.intersectPlane(wb,Ks))return}if(!e.isReset){if(Ks.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Ks.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&&(Ks.x=Zs.x),e.data.enabledTranslation[1]===!1&&(Ks.y=Zs.y),e.data.enabledTranslation[2]===!1&&(Ks.z=Zs.z);let n=ZV(Zs,Ks,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let a=Mo.subVectors(n,Zs).divideScalar(e.currentDampingFactor);Zs.add(a),t&&bb(e.object,Zs),e.paused=a.length()<YV}else bb(e.object,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(QV)}},oh=new M,xd=new M,lh=new me,Eo=new rt,On=new rt,hh=new M,ch=new M,va=new M,Js=new M,Yf=new pr,$V=1e-6,eH={type:"requestRender"},tH={type:"changeRotation"},_b=function(){let e=new me;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(MA(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof ar&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),iH=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new rt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Nm.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(e.target==="personal camera"?this.target=i.find(Br.PERSONAL_CAMERA_ID):this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},rH=class extends yn{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(je.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let n=dc(r);n&&n==="LookAt"&&this.updateSingleEvent(i)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new iH(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let n=this.onTargetChange(i),a=i.target;this.pairOfEventListeners.push([a,n]),a.addEventListener("requestRender",n)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),gr&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:n,enabledRotation:a,limitDistanceEnabled:o}=e.data,{camera:l,raycaster:h}=this.eventContext,{object:d,target:c}=e;if(d.getWorldPosition(hh),!e.isReset)if(e.target)e.target.getWorldPosition(ch);else{if(s==="custom"?(l.getWorldDirection(xd),xd.negate(),Yf.setFromNormalAndCoplanarPoint(xd,hh)):(s==="xy"?oh.set(0,0,1):s==="xz"?oh.set(0,1,0):s==="yz"&&oh.set(1,0,0),Yf.setFromNormalAndCoplanarPoint(oh,hh)),!h.ray.intersectPlane(Yf,ch))return;r>0&&(s==="custom"||s===void 0)&&ch.addScaledVector(xd,r)}if(e.isReset||(c?t==="target"?va.copy(c.up).applyMatrix4(lh.extractRotation(c.matrixWorld)).normalize():a.some(u=>u===!1)?(i==="x"?(Js.set(0,0,1),a[2]===!1&&Js.set(0,1,0)):i==="y"?(Js.set(1,0,0),a[0]===!1&&Js.set(0,0,1)):(Js.set(0,1,0),a[1]===!1&&Js.set(1,0,0)),va.copy(Js).applyQuaternion(e.worldQuaternion0).normalize()):va.set(0,1,0):s==="custom"?va.set(0,1,0):va.copy(oh)),e.isReset)On.copy(e.worldQuaternion0);else if(hh.distanceTo(ch)>n&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)On.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;sH(lh,ch,hh,va,i,Js),On.setFromRotationMatrix(lh),Eo.setFromUnitVectors(Js.applyQuaternion(On),va),a.some(u=>u===!1)&&t!=="target"&&On.premultiply(Eo).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Eo.setFromRotationMatrix(MA(d.matrixWorld)),Eo.slerp(On,1/e.currentDampingFactor),_b(d,lh.makeRotationFromQuaternion(Eo)),e.paused=8*(1-Eo.dot(On))<$V):(_b(d,lh.makeRotationFromQuaternion(On)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(eH),d.dispatchEvent(tH)}},Ar=new M,oi=new M,qt=new M;function sH(e,t,i,r,s,n){let a=e.elements;qt.subVectors(t,i),qt.lengthSq()===0&&(qt.z=1),qt.normalize(),oi.crossVectors(r,qt),oi.lengthSq()===0&&(Math.abs(r.z)===1?qt.x+=1e-4:qt.z+=1e-4,qt.normalize(),oi.crossVectors(r,qt)),oi.normalize(),Ar.crossVectors(qt,oi),s==="x"?n.z===1?[oi,Ar,qt]=[qt,oi,Ar]:(oi.negate(),[oi,qt]=[qt,oi]):s==="y"?n.x===1?[oi,Ar,qt]=[Ar,qt,oi]:(oi.negate(),[Ar,qt]=[qt,Ar]):n.x===1&&(oi.negate(),[oi,Ar]=[Ar,oi]),a[0]=oi.x,a[4]=Ar.x,a[8]=qt.x,a[1]=oi.y,a[5]=Ar.y,a[9]=qt.y,a[2]=oi.z,a[6]=Ar.z,a[10]=qt.z}var nH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=ns(t,t.actions,r,s,n,i)}disconnect(){kr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()))}},aH=class extends yn{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{je.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{je.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=dc(s);o&&o==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(l=>l.dispatchUserEvent(a)))};let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let o=new nH(n,a,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),gr&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),gr&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,scene:s}=this.eventContext;if(i){let n=bg(r,s,this.objects);t=_g(n)}else this.objects.forEach(n=>{Cu(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},oH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=ns(t,t.actions,r,s,n,i)}connect(){this.scrollCounter=0}disconnect(){kr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Create.forEach(t=>t.dispatchThrottled())}},lH=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.object=i,this.domElement=n,this.managers=a,this.scrollStart=0,this.scrollEnd=0,this.actions=ns(t,t.actions,r,s,a,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,n=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?a:l==="bottom"?a-o:a-o*.5;this.scrollStart=n-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){kr(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Create.forEach(t=>t.dispatchThrottled())}},hH=class extends yn{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([a,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=a=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(d=>d.dispatch(o))})},this.onWheel=a=>{!this.isInview||a.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:a.deltaY}),l.forEach(h=>h.dispatch(a.deltaY))})},this.onUserEvent=({eventName:a,target:o,reverse:l})=>{if(!a||!o)return;let h=dc(a);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(d=>{d.dispatchUserEvent(l)}))};let{scene:i,sharedAssets:r,domElement:s,isExport:n}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!n){let h=new oH(o,l,a,i,r,t);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(h):this.wheelEventsPerObject.set(a,[h])}else{let h=new lH(o,l,a,i,r,s,t);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(h):this.scrollEventsPerObject.set(a,[h])}}}),this.intersectionObserver=new IntersectionObserver(a=>{let o=a[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},cH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.actions=ns(t,t.actions,r,s,n,i)}disconnect(){kr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Go?t.interaction.audioPlayer.play():t.interaction instanceof Sg&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Dh?t.interaction.play(i==="autoplay"):t.interaction instanceof Ag&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Go?t.interaction.audioPlayer.play():t.interaction instanceof Sg&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Dh?t.interaction.play():t.interaction instanceof Ag&&t.interaction.dispatch()})}},dH=class extends yn{constructor(e,t){super(e),this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:s,isExport:n}=this.eventContext;(n?document:s).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,o])=>{a.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(l=>{l.dispatchAfter("any")})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=dc(s);o&&o==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(l=>{l.dispatchUserEvent(a)}),this.eventsAfterPerObject.get(n)?.forEach(l=>{l.dispatchUserEvent(a)}))};let{scene:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length)for(let{id:n,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let o=new cH(n,a,s,i,r,t);(o.actions.Transition.length||o.actions.SwitchCamera.length||o.actions.Create.length||o.actions.Destroy.length)&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(o):this.eventsPerObject.set(s,[o])),o.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(o):this.eventsAfterPerObject.set(s,[o])),o.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(o):this.eventsAfterPerObject.set(s,[o]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(i=>i.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())})}},uH=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.disabled=!0,this.actions=ns(t,t.actions,r,s,n,i),this.target=t.target,this.useToggle=t.toggle}disconnect(){kr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(t=>{t.toggle()}):this.actions.Transition.forEach(t=>{t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},pH="https://unpkg.com/@splinetool/runtime@0.9.380/build/",fH="https://unpkg.com/@splinetool/navmesh-wasm@0.9.380/build/",mH=`
5599
5599
  (async function() {
5600
5600
  const [wasmImport, wasmBinary] = await Promise.all([
5601
5601
  import('${pH}' + 'navmesh.js'),
@@ -6099,7 +6099,7 @@ void main() {
6099
6099
  vec4 image = texture2D(tMap, insideUv);
6100
6100
  gl_FragColor = mix(image, background, isOutside);
6101
6101
  }
6102
- `,V7=class extends an{constructor(){super(new It({vertexShader:j7,fragmentShader:G7,uniforms:{tInput:new de(null),tMap:new de(null),uResolution:new de(new k),uSize:new de(new k),uCoords:new de(new k),uScale:new de(1),uSceneColor:new de(new Fe(16711680)),uDPR:new de(1),uCurrent:new de(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(e){this.uniforms.tMap.value=e}};function Vb(e,t){return t&&t.enabled&&e.push(t.effect),e}var H7=e=>Object.values(ht).includes(e)?e:ht.NORMAL,W7=class extends Wi{constructor(e){super(),this.postprocessingState=qh.defaultData,this._scene=new Ia,this._camera=new Vi,this.effects=new Map,this.blueNoiseTexture=new fm,this._renderToScreen=!0,this.clock=new YO,this.renderer=e,this.debug=!1,this.effects.set("bloom",new f7),this.effects.set("chromaticAberration",new g7),this.effects.set("vignette",new w7),this.effects.set("noise",new x7),this.effects.set("colorAverage",new v7),this.effects.set("hueSaturation",new y7),this.effects.set("brightnessContrast",new m7),this.effects.set("depthOfField",new b7),this.effects.set("pixelation",new _7),this.effectComposer=new D7(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Lg(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new T7(this.scene,this.camera,this.renderer),this.aoPass=new k7(this.scene,this.camera),this.taaPass=new C7,this.taaPass.renderToScreen=!1,this.helperPass=new L7(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new V7,this.overlayPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let t=this.effectComposer.passes.length-1;t>=0;t--){let i=this.effectComposer.passes[t];if(i.enabled===!0&&!e&&this._renderToScreen){i.renderToScreen=!0,e=!0;continue}i.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new fm(e,128,128),this.blueNoiseTexture.wrapS=ln,this.blueNoiseTexture.wrapT=ln,this.blueNoiseTexture.minFilter=Dt,this.blueNoiseTexture.magFilter=Dt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,t,i,r,s,n,a,o){this.aoPass.enabled=e,this.aoPass.radius=t,this.aoPass.bias=i,this.aoPass.aoColor=r,this.aoPass.fogEnabled=s,this.aoPass.fogNear=n,this.aoPass.fogFar=a,this.aoPass.runHalfRes!==!o&&(this.aoPass.runHalfRes=!o)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(Vb,[]);e.length>0&&(this.uvEffectPass=new Du(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Vb,[]);t.length>0&&(this.effectPass=new Du(this.camera,...t),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new k;this.renderer.getDrawingBufferSize(e),this._rt=new St(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ln,wrapT:ln}),this._rt.samples=0,this._savePass=new Dg(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new Dg(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?t.removePass(this._savePass):t.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=H7(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof tt?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof tt?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Hb=new ci,q7=class extends p_{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new k,this.pipeline=new W7(this),this.isXRCopyPassSet=!1,this.clear=(s=!0,n=!0,a=!0)=>{let o=this.getContext(),l=0;s&&(l|=o.COLOR_BUFFER_BIT),n&&(l|=o.DEPTH_BUFFER_BIT),a&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this._resizeTransmission(s,n),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new St(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:et,magFilter:et,wrapS:Yt,wrapT:Yt,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return Ue.transmissionLod.value===1}set hdTransmission(e){Ue.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new St(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:il,magFilter:et,wrapS:Yt,wrapT:Yt,depthBuffer:!1}),this.transmissionDepthTarget=new St(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Dt,magFilter:Dt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new St(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Dt,magFilter:Dt,type:Or,depthTexture:new nl(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Vi?Ff.uniforms.depthContrast.value=(t.far-t.near)/1e4:Ff.uniforms.depthContrast.value=1,e.overrideMaterial=Ff,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?vg:null,t.layers.enable(0),t.layers.enable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!0)}))}renderSplineScene(e,t,i,r,s){this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{Ue.penumbraSize.value[o]=a}),Ue.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ue.resolution.value.set(this.resolution.x,this.resolution.y):Ue.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Ue.normalRenderTarget.value=this.overrideNormal,Ue.normalRenderTargetDepth.value=Hb):e.needsNormal()&&(this.createNormalRenderTarget(),Ue.normalRenderTarget.value=this.normalRenderTarget.texture,Ue.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t)),e.occlusion&&(this.createAORenderTarget(),Ue.aoRenderTarget.value=this.aoRenderTarget.texture),Ue.aoEnabled.value=e.occlusion,this.pipeline.setAmbientOcclusionParams(e.occlusion,e.radius,e.bias,e.aoColor,e.enableFog,e.backupFog.near,e.backupFog.far,e.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let n=!1;if(this.overrideTransmission!==void 0)Ue.transmissionRenderTarget.value=this.overrideTransmission,Ue.transmissionRenderTargetDepth.value=Hb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),Ue.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ue.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&(this.pipeline.updatePostprocessing(e.postprocessing),!r&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?vg:null,this.pipeline.render(),Ue.frameIndex.value=(Ue.frameIndex.value+1)%16,t instanceof Vi&&t.copyHistory()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},X7=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Nv(e.shared,t),this.scene=new Br(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Fr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},Y7=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Q7(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function Ih(e){return e instanceof Kh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Z7(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof ar)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof ar&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!yr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!yr.isMergable(l.material))return;n=yr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][Ih(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][Ih(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][Ih(r)].push(l)}),i}function K7(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function J7(e,t){let i=Z7(t,e),r=K7(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,d=new Array(r),c=0;for(let[u,p]of Object.entries(i))for(let g of Object.values(p)){if(o=0,h=0,g.forEach(m=>{m instanceof ar&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&Q7(a[m]);let f=Ta(a.slice(0,o),!1);if(f){let m;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new tr(f,l[0].material);break}default:{m=new tr(f,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof ar&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][Ih(x)]&&i[x.material.uuid][Ih(x)].length>1||(d[c++]=x));for(let x=0;x<c;x++)t.attach(d[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let u=0;u<n;u++)s[u].removeFromParent()}var $7=$h(QM(),1),eW=new k;function tW(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var a0=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this.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}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._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&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping()),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=eW.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderAutoMode())},this._debouncedResize=pv(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Y7({x:10,y:10})),RU(e)}async load(e,t){tW(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await XH(e);this._data=i,i.version&&(0,$7.default)(i.version,"0.9.378")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Nw(i)&&Wk(),cj(i)&&Gk(),i.scene.environment.usePhysics&&UU(),Rw(i)&&K8(),_H(i)&&zU()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new X7(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();J7(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}Nw(i)&&this._scene.traverse(n=>{cn(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(n=>{n instanceof es&&n.pendingMediaLoad&&n.update()})});let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),Rw(i)&&AH(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),KA(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new q7({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?Ig:qb,Zj(i.scene.environment.ambientLight.softShadowQuality)),i.scene.environment.ambientLight.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.environment.ambientLight.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new QH(this._renderer,this._camera,new k(this._viewportWidth,this._viewportHeight),new k(window.innerWidth,window.innerHeight))}if(t){let n=new vG(this._renderer,this._scene,this._camera,this._sharedAssetsManager,i.scene.publish.stopRaycast,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new MH(i,n),this._eventManager=new YH(i.scene.publish,this._controls,n),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Br.PERSONAL_CAMERA_ID){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof aM&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new nr(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{d1.unsubscribe(e)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),IU(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=d1(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var rp=window,sp=rp.ShadowRoot&&(rp.ShadyCSS===void 0||rp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o0=Symbol(),dM=new WeakMap,pc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==o0)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(sp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=dM.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&dM.set(i,t))}return t}toString(){return this.cssText}},uM=e=>new pc(typeof e=="string"?e:e+"",void 0,o0),l0=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new pc(i,e,o0)},h0=(e,t)=>{sp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=rp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},np=sp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return uM(i)})(e):e;var c0,ap=window,pM=ap.trustedTypes,iW=pM?pM.emptyScript:"",fM=ap.reactiveElementPolyfillSupport,u0={toAttribute(e,t){switch(t){case Boolean:e=e?iW:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},mM=(e,t)=>t!==e&&(t==t||e==e),d0={attribute:!0,type:String,converter:u0,reflect:!1,hasChanged:mM},wn=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=d0){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||d0}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(np(s))}else t!==void 0&&i.push(np(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return h0(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=d0){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:u0).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:u0;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||mM)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};wn.finalized=!0,wn.elementProperties=new Map,wn.elementStyles=[],wn.shadowRootOptions={mode:"open"},fM?.({ReactiveElement:wn}),((c0=ap.reactiveElementVersions)!==null&&c0!==void 0?c0:ap.reactiveElementVersions=[]).push("1.6.0");var p0,op=window,Pl=op.trustedTypes,gM=Pl?Pl.createPolicy("lit-html",{createHTML:e=>e}):void 0,sa=`lit$${(Math.random()+"").slice(9)}$`,SM="?"+sa,rW=`<${SM}>`,Dl=document,mc=(e="")=>Dl.createComment(e),gc=e=>e===null||typeof e!="object"&&typeof e!="function",AM=Array.isArray,sW=e=>AM(e)||typeof e?.[Symbol.iterator]=="function",fc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vM=/-->/g,yM=/>/g,Ka=RegExp(`>|[
6102
+ `,V7=class extends an{constructor(){super(new It({vertexShader:j7,fragmentShader:G7,uniforms:{tInput:new de(null),tMap:new de(null),uResolution:new de(new k),uSize:new de(new k),uCoords:new de(new k),uScale:new de(1),uSceneColor:new de(new Fe(16711680)),uDPR:new de(1),uCurrent:new de(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(e){this.uniforms.tMap.value=e}};function Vb(e,t){return t&&t.enabled&&e.push(t.effect),e}var H7=e=>Object.values(ht).includes(e)?e:ht.NORMAL,W7=class extends Wi{constructor(e){super(),this.postprocessingState=qh.defaultData,this._scene=new Ia,this._camera=new Vi,this.effects=new Map,this.blueNoiseTexture=new fm,this._renderToScreen=!0,this.clock=new YO,this.renderer=e,this.debug=!1,this.effects.set("bloom",new f7),this.effects.set("chromaticAberration",new g7),this.effects.set("vignette",new w7),this.effects.set("noise",new x7),this.effects.set("colorAverage",new v7),this.effects.set("hueSaturation",new y7),this.effects.set("brightnessContrast",new m7),this.effects.set("depthOfField",new b7),this.effects.set("pixelation",new _7),this.effectComposer=new D7(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Lg(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new T7(this.scene,this.camera,this.renderer),this.aoPass=new k7(this.scene,this.camera),this.taaPass=new C7,this.taaPass.renderToScreen=!1,this.helperPass=new L7(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new V7,this.overlayPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let t=this.effectComposer.passes.length-1;t>=0;t--){let i=this.effectComposer.passes[t];if(i.enabled===!0&&!e&&this._renderToScreen){i.renderToScreen=!0,e=!0;continue}i.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new fm(e,128,128),this.blueNoiseTexture.wrapS=ln,this.blueNoiseTexture.wrapT=ln,this.blueNoiseTexture.minFilter=Dt,this.blueNoiseTexture.magFilter=Dt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,t,i,r,s,n,a,o){this.aoPass.enabled=e,this.aoPass.radius=t,this.aoPass.bias=i,this.aoPass.aoColor=r,this.aoPass.fogEnabled=s,this.aoPass.fogNear=n,this.aoPass.fogFar=a,this.aoPass.runHalfRes!==!o&&(this.aoPass.runHalfRes=!o)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(Vb,[]);e.length>0&&(this.uvEffectPass=new Du(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Vb,[]);t.length>0&&(this.effectPass=new Du(this.camera,...t),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new k;this.renderer.getDrawingBufferSize(e),this._rt=new St(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ln,wrapT:ln}),this._rt.samples=0,this._savePass=new Dg(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new Dg(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?t.removePass(this._savePass):t.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=H7(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof tt?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof tt?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Hb=new ci,q7=class extends p_{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new k,this.pipeline=new W7(this),this.isXRCopyPassSet=!1,this.clear=(s=!0,n=!0,a=!0)=>{let o=this.getContext(),l=0;s&&(l|=o.COLOR_BUFFER_BIT),n&&(l|=o.DEPTH_BUFFER_BIT),a&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this._resizeTransmission(s,n),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new St(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:et,magFilter:et,wrapS:Yt,wrapT:Yt,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return Ue.transmissionLod.value===1}set hdTransmission(e){Ue.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new St(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:il,magFilter:et,wrapS:Yt,wrapT:Yt,depthBuffer:!1}),this.transmissionDepthTarget=new St(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Dt,magFilter:Dt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new St(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Dt,magFilter:Dt,type:Or,depthTexture:new nl(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Vi?Ff.uniforms.depthContrast.value=(t.far-t.near)/1e4:Ff.uniforms.depthContrast.value=1,e.overrideMaterial=Ff,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?vg:null,t.layers.enable(0),t.layers.enable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!0)}))}renderSplineScene(e,t,i,r,s){this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{Ue.penumbraSize.value[o]=a}),Ue.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ue.resolution.value.set(this.resolution.x,this.resolution.y):Ue.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Ue.normalRenderTarget.value=this.overrideNormal,Ue.normalRenderTargetDepth.value=Hb):e.needsNormal()&&(this.createNormalRenderTarget(),Ue.normalRenderTarget.value=this.normalRenderTarget.texture,Ue.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t)),e.occlusion&&(this.createAORenderTarget(),Ue.aoRenderTarget.value=this.aoRenderTarget.texture),Ue.aoEnabled.value=e.occlusion,this.pipeline.setAmbientOcclusionParams(e.occlusion,e.radius,e.bias,e.aoColor,e.enableFog,e.backupFog.near,e.backupFog.far,e.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let n=!1;if(this.overrideTransmission!==void 0)Ue.transmissionRenderTarget.value=this.overrideTransmission,Ue.transmissionRenderTargetDepth.value=Hb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),Ue.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ue.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&(this.pipeline.updatePostprocessing(e.postprocessing),!r&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?vg:null,this.pipeline.render(),Ue.frameIndex.value=(Ue.frameIndex.value+1)%16,t instanceof Vi&&t.copyHistory()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},X7=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Nv(e.shared,t),this.scene=new Br(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Fr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},Y7=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Q7(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function Ih(e){return e instanceof Kh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Z7(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof ar)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof ar&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!yr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!yr.isMergable(l.material))return;n=yr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][Ih(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][Ih(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][Ih(r)].push(l)}),i}function K7(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function J7(e,t){let i=Z7(t,e),r=K7(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,d=new Array(r),c=0;for(let[u,p]of Object.entries(i))for(let g of Object.values(p)){if(o=0,h=0,g.forEach(m=>{m instanceof ar&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&Q7(a[m]);let f=Ta(a.slice(0,o),!1);if(f){let m;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new tr(f,l[0].material);break}default:{m=new tr(f,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof ar&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][Ih(x)]&&i[x.material.uuid][Ih(x)].length>1||(d[c++]=x));for(let x=0;x<c;x++)t.attach(d[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let u=0;u<n;u++)s[u].removeFromParent()}var $7=$h(QM(),1),eW=new k;function tW(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var a0=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this.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}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._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&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping()),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=eW.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderAutoMode())},this._debouncedResize=pv(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Y7({x:10,y:10})),RU(e)}async load(e,t){tW(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await XH(e);this._data=i,i.version&&(0,$7.default)(i.version,"0.9.380")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Nw(i)&&Wk(),cj(i)&&Gk(),i.scene.environment.usePhysics&&UU(),Rw(i)&&K8(),_H(i)&&zU()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new X7(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();J7(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}Nw(i)&&this._scene.traverse(n=>{cn(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(n=>{n instanceof es&&n.pendingMediaLoad&&n.update()})});let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),Rw(i)&&AH(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),KA(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new q7({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?Ig:qb,Zj(i.scene.environment.ambientLight.softShadowQuality)),i.scene.environment.ambientLight.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.environment.ambientLight.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new QH(this._renderer,this._camera,new k(this._viewportWidth,this._viewportHeight),new k(window.innerWidth,window.innerHeight))}if(t){let n=new vG(this._renderer,this._scene,this._camera,this._sharedAssetsManager,i.scene.publish.stopRaycast,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new MH(i,n),this._eventManager=new YH(i.scene.publish,this._controls,n),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Br.PERSONAL_CAMERA_ID){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof aM&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new nr(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{d1.unsubscribe(e)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),IU(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=d1(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var rp=window,sp=rp.ShadowRoot&&(rp.ShadyCSS===void 0||rp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o0=Symbol(),dM=new WeakMap,pc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==o0)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(sp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=dM.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&dM.set(i,t))}return t}toString(){return this.cssText}},uM=e=>new pc(typeof e=="string"?e:e+"",void 0,o0),l0=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new pc(i,e,o0)},h0=(e,t)=>{sp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=rp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},np=sp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return uM(i)})(e):e;var c0,ap=window,pM=ap.trustedTypes,iW=pM?pM.emptyScript:"",fM=ap.reactiveElementPolyfillSupport,u0={toAttribute(e,t){switch(t){case Boolean:e=e?iW:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},mM=(e,t)=>t!==e&&(t==t||e==e),d0={attribute:!0,type:String,converter:u0,reflect:!1,hasChanged:mM},wn=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=d0){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||d0}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(np(s))}else t!==void 0&&i.push(np(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return h0(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=d0){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:u0).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:u0;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||mM)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};wn.finalized=!0,wn.elementProperties=new Map,wn.elementStyles=[],wn.shadowRootOptions={mode:"open"},fM?.({ReactiveElement:wn}),((c0=ap.reactiveElementVersions)!==null&&c0!==void 0?c0:ap.reactiveElementVersions=[]).push("1.6.0");var p0,op=window,Pl=op.trustedTypes,gM=Pl?Pl.createPolicy("lit-html",{createHTML:e=>e}):void 0,sa=`lit$${(Math.random()+"").slice(9)}$`,SM="?"+sa,rW=`<${SM}>`,Dl=document,mc=(e="")=>Dl.createComment(e),gc=e=>e===null||typeof e!="object"&&typeof e!="function",AM=Array.isArray,sW=e=>AM(e)||typeof e?.[Symbol.iterator]=="function",fc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vM=/-->/g,yM=/>/g,Ka=RegExp(`>|[
6103
6103
  \f\r](?:([^\\s"'>=/]+)([
6104
6104
  \f\r]*=[
6105
6105
  \f\r]*(?:[^