@splinetool/runtime 0.9.68 → 0.9.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/runtime.cjs +2 -2
- package/build/runtime.js +2 -2
- package/package.json +1 -1
package/build/runtime.cjs
CHANGED
|
@@ -3134,7 +3134,7 @@ void main() {
|
|
|
3134
3134
|
squared_mean = squared_mean / samples;
|
|
3135
3135
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3136
3136
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3137
|
-
}`;function lD(n,e,t){let r=new fc,i=new O,s=new O,o=new Ke,a=new vu({depthPacking:m_}),l=new xu,c={},h=t.maxTextureSize,u={0:gr,1:zn,2:Wt},f=new vt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new O},radius:{value:4}},vertexShader:oD,fragmentShader:aD}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let m=new Le;m.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new ir(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ou,this.render=function(b,S,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=n.getRenderTarget(),y=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),E=n.state;E.setBlending(Dt),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,I=b.length;C<I;C++){let B=b[C],N=B.shadow;if(N===void 0){console.warn("THREE.WebGLShadowMap:",B,"has no shadow.");continue}if(N.autoUpdate===!1&&N.needsUpdate===!1)continue;i.copy(N.mapSize);let H=N.getFrameExtents();if(i.multiply(H),s.copy(N.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/H.x),i.x=s.x*H.x,N.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/H.y),i.y=s.y*H.y,N.mapSize.y=s.y)),N.map===null&&!N.isPointLightShadow&&this.type===rc&&(N.map=new ut(i.x,i.y),N.map.texture.name=B.name+".shadowMap",N.mapPass=new ut(i.x,i.y),N.camera.updateProjectionMatrix()),N.map===null){let Q={minFilter:_r,magFilter:_r,format:bn};N.map=new ut(i.x,i.y,Q),N.map.texture.name=B.name+".shadowMap",N.camera.updateProjectionMatrix()}n.setRenderTarget(N.map),n.clear();let j=N.getViewportCount();for(let Q=0;Q<j;Q++){let X=N.getViewport(Q);o.set(s.x*X.x,s.y*X.y,s.x*X.z,s.y*X.w),E.viewport(o),N.updateMatrices(B,Q),r=N.getFrustum(),w(S,M,N.camera,B,this.type)}!N.isPointLightShadow&&this.type===rc&&x(N,M),N.needsUpdate=!1}g.needsUpdate=!1,n.setRenderTarget(_,y,T)};function x(b,S){let M=e.update(p);f.defines.VSM_SAMPLES!==b.blurSamples&&(f.defines.VSM_SAMPLES=b.blurSamples,d.defines.VSM_SAMPLES=b.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),f.uniforms.shadow_pass.value=b.map.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(S,null,M,f,p,null),d.uniforms.shadow_pass.value=b.mapPass.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(S,null,M,d,p,null)}function v(b,S,M,_,y,T){let E=null,C=M.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0?E=C:E=M.isPointLight===!0?l:a,n.localClippingEnabled&&S.clipShadows===!0&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0){let I=E.uuid,B=S.uuid,N=c[I];N===void 0&&(N={},c[I]=N);let H=N[B];H===void 0&&(H=E.clone(),N[B]=H),E=H}return E.visible=S.visible,E.wireframe=S.wireframe,T===rc?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:u[S.side],E.alphaMap=S.alphaMap,E.alphaTest=S.alphaTest,E.clipShadows=S.clipShadows,E.clippingPlanes=S.clippingPlanes,E.clipIntersection=S.clipIntersection,E.displacementMap=S.displacementMap,E.displacementScale=S.displacementScale,E.displacementBias=S.displacementBias,E.wireframeLinewidth=S.wireframeLinewidth,E.linewidth=S.linewidth,M.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(M.matrixWorld),E.nearDistance=_,E.farDistance=y),E}function w(b,S,M,_,y){if(b.visible===!1)return;if(b.layers.test(S.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&y===rc)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,b.matrixWorld);let C=e.update(b),I=b.material;if(Array.isArray(I)){let B=C.groups;for(let N=0,H=B.length;N<H;N++){let j=B[N],Q=I[j.materialIndex];if(Q&&Q.visible){let X=v(b,Q,_,M.near,M.far,y);n.renderBufferDirect(M,null,C,X,b,j)}}}else if(I.visible){let B=v(b,I,_,M.near,M.far,y);n.renderBufferDirect(M,null,C,B,b,null)}}let E=b.children;for(let C=0,I=E.length;C<I;C++)w(E[C],S,M,_,y)}}function cD(n,e,t){let r=t.isWebGL2;function i(){let z=!1,xe=new Ke,Me=null,Ye=new Ke(0,0,0,0);return{setMask:function(Ne){Me!==Ne&&!z&&(n.colorMask(Ne,Ne,Ne,Ne),Me=Ne)},setLocked:function(Ne){z=Ne},setClear:function(Ne,Je,be,Qe,nt){nt===!0&&(Ne*=Qe,Je*=Qe,be*=Qe),xe.set(Ne,Je,be,Qe),Ye.equals(xe)===!1&&(n.clearColor(Ne,Je,be,Qe),Ye.copy(xe))},reset:function(){z=!1,Me=null,Ye.set(-1,0,0,0)}}}function s(){let z=!1,xe=null,Me=null,Ye=null;return{setTest:function(Ne){Ne?Y(2929):q(2929)},setMask:function(Ne){xe!==Ne&&!z&&(n.depthMask(Ne),xe=Ne)},setFunc:function(Ne){if(Me!==Ne){if(Ne)switch(Ne){case zM:n.depthFunc(512);break;case UM:n.depthFunc(519);break;case GM:n.depthFunc(513);break;case Wp:n.depthFunc(515);break;case kM:n.depthFunc(514);break;case VM:n.depthFunc(518);break;case HM:n.depthFunc(516);break;case WM:n.depthFunc(517);break;default:n.depthFunc(515)}else n.depthFunc(515);Me=Ne}},setLocked:function(Ne){z=Ne},setClear:function(Ne){Ye!==Ne&&(n.clearDepth(Ne),Ye=Ne)},reset:function(){z=!1,xe=null,Me=null,Ye=null}}}function o(){let z=!1,xe=null,Me=null,Ye=null,Ne=null,Je=null,be=null,Qe=null,nt=null;return{setTest:function(mt){z||(mt?Y(2960):q(2960))},setMask:function(mt){xe!==mt&&!z&&(n.stencilMask(mt),xe=mt)},setFunc:function(mt,bt,Jr){(Me!==mt||Ye!==bt||Ne!==Jr)&&(n.stencilFunc(mt,bt,Jr),Me=mt,Ye=bt,Ne=Jr)},setOp:function(mt,bt,Jr){(Je!==mt||be!==bt||Qe!==Jr)&&(n.stencilOp(mt,bt,Jr),Je=mt,be=bt,Qe=Jr)},setLocked:function(mt){z=mt},setClear:function(mt){nt!==mt&&(n.clearStencil(mt),nt=mt)},reset:function(){z=!1,xe=null,Me=null,Ye=null,Ne=null,Je=null,be=null,Qe=null,nt=null}}}let a=new i,l=new s,c=new o,h={},u={},f=new WeakMap,d=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,I=null,B=n.getParameter(35661),N=!1,H=0,j=n.getParameter(7938);j.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(j)[1]),N=H>=1):j.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),N=H>=2);let Q=null,X={},U=n.getParameter(3088),F=n.getParameter(2978),V=new Ke().fromArray(U),R=new Ke().fromArray(F);function G(z,xe,Me){let Ye=new Uint8Array(4),Ne=n.createTexture();n.bindTexture(z,Ne),n.texParameteri(z,10241,9728),n.texParameteri(z,10240,9728);for(let Je=0;Je<Me;Je++)n.texImage2D(xe+Je,0,6408,1,1,0,6408,5121,Ye);return Ne}let W={};W[3553]=G(3553,3553,1),W[34067]=G(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),Y(2929),l.setFunc(Wp),fe(!1),ge(vv),Y(2884),ce(Dt);function Y(z){h[z]!==!0&&(n.enable(z),h[z]=!0)}function q(z){h[z]!==!1&&(n.disable(z),h[z]=!1)}function se(z,xe){return u[z]!==xe?(n.bindFramebuffer(z,xe),u[z]=xe,r&&(z===36009&&(u[36160]=xe),z===36160&&(u[36009]=xe)),!0):!1}function K(z,xe){let Me=d,Ye=!1;if(z)if(Me=f.get(xe),Me===void 0&&(Me=[],f.set(xe,Me)),z.isWebGLMultipleRenderTargets){let Ne=z.texture;if(Me.length!==Ne.length||Me[0]!==36064){for(let Je=0,be=Ne.length;Je<be;Je++)Me[Je]=36064+Je;Me.length=Ne.length,Ye=!0}}else Me[0]!==36064&&(Me[0]=36064,Ye=!0);else Me[0]!==1029&&(Me[0]=1029,Ye=!0);Ye&&(t.isWebGL2?n.drawBuffers(Me):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function te(z){return m!==z?(n.useProgram(z),m=z,!0):!1}let k={[$o]:32774,[EM]:32778,[CM]:32779};if(r)k[Sv]=32775,k[Av]=32776;else{let z=e.get("EXT_blend_minmax");z!==null&&(k[Sv]=z.MIN_EXT,k[Av]=z.MAX_EXT)}let le={[DM]:0,[PM]:1,[LM]:768,[Q0]:770,[FM]:776,[OM]:774,[NM]:772,[IM]:769,[K0]:771,[RM]:775,[BM]:773};function ce(z,xe,Me,Ye,Ne,Je,be,Qe){if(z===Dt){p===!0&&(q(3042),p=!1);return}if(p===!1&&(Y(3042),p=!0),z!==TM){if(z!==g||Qe!==_){if((x!==$o||b!==$o)&&(n.blendEquation(32774),x=$o,b=$o),Qe)switch(z){case hs:n.blendFuncSeparate(1,771,1,771);break;case xv:n.blendFunc(1,1);break;case bv:n.blendFuncSeparate(0,769,0,1);break;case wv:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case hs:n.blendFuncSeparate(770,771,1,771);break;case xv:n.blendFunc(770,1);break;case bv:n.blendFuncSeparate(0,769,0,1);break;case wv:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}v=null,w=null,S=null,M=null,g=z,_=Qe}return}Ne=Ne||xe,Je=Je||Me,be=be||Ye,(xe!==x||Ne!==b)&&(n.blendEquationSeparate(k[xe],k[Ne]),x=xe,b=Ne),(Me!==v||Ye!==w||Je!==S||be!==M)&&(n.blendFuncSeparate(le[Me],le[Ye],le[Je],le[be]),v=Me,w=Ye,S=Je,M=be),g=z,_=null}function ae(z,xe){z.side===Wt?q(2884):Y(2884);let Me=z.side===gr;xe&&(Me=!Me),fe(Me),z.blending===hs&&z.transparent===!1?ce(Dt):ce(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.premultipliedAlpha),l.setFunc(z.depthFunc),l.setTest(z.depthTest),l.setMask(z.depthWrite),a.setMask(z.colorWrite);let Ye=z.stencilWrite;c.setTest(Ye),Ye&&(c.setMask(z.stencilWriteMask),c.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),c.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),_e(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?Y(32926):q(32926)}function fe(z){y!==z&&(z?n.frontFace(2304):n.frontFace(2305),y=z)}function ge(z){z!==AM?(Y(2884),z!==T&&(z===vv?n.cullFace(1029):z===MM?n.cullFace(1028):n.cullFace(1032))):q(2884),T=z}function de(z){z!==E&&(N&&n.lineWidth(z),E=z)}function _e(z,xe,Me){z?(Y(32823),(C!==xe||I!==Me)&&(n.polygonOffset(xe,Me),C=xe,I=Me)):q(32823)}function Ee(z){z?Y(3089):q(3089)}function ye(z){z===void 0&&(z=33984+B-1),Q!==z&&(n.activeTexture(z),Q=z)}function Oe(z,xe){Q===null&&ye();let Me=X[Q];Me===void 0&&(Me={type:void 0,texture:void 0},X[Q]=Me),(Me.type!==z||Me.texture!==xe)&&(n.bindTexture(z,xe||W[z]),Me.type=z,Me.texture=xe)}function pt(){let z=X[Q];z!==void 0&&z.type!==void 0&&(n.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function P(){try{n.compressedTexImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function D(){try{n.texSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Z(){try{n.texSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ue(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Te(){try{n.texStorage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Fe(){try{n.texImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ne(){try{n.texImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Re(z){V.equals(z)===!1&&(n.scissor(z.x,z.y,z.z,z.w),V.copy(z))}function Ie(z){R.equals(z)===!1&&(n.viewport(z.x,z.y,z.z,z.w),R.copy(z))}function ve(){n.disable(3042),n.disable(2884),n.disable(2929),n.disable(32823),n.disable(3089),n.disable(2960),n.disable(32926),n.blendEquation(32774),n.blendFunc(1,0),n.blendFuncSeparate(1,0,1,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(513),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(519,0,4294967295),n.stencilOp(7680,7680,7680),n.clearStencil(0),n.cullFace(1029),n.frontFace(2305),n.polygonOffset(0,0),n.activeTexture(33984),n.bindFramebuffer(36160,null),r===!0&&(n.bindFramebuffer(36009,null),n.bindFramebuffer(36008,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),h={},Q=null,X={},u={},f=new WeakMap,d=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,I=null,V.set(0,0,n.canvas.width,n.canvas.height),R.set(0,0,n.canvas.width,n.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:Y,disable:q,bindFramebuffer:se,drawBuffers:K,useProgram:te,setBlending:ce,setMaterial:ae,setFlipSided:fe,setCullFace:ge,setLineWidth:de,setPolygonOffset:_e,setScissorTest:Ee,activeTexture:ye,bindTexture:Oe,unbindTexture:pt,compressedTexImage2D:P,texImage2D:Fe,texImage3D:ne,texStorage2D:pe,texStorage3D:Te,texSubImage2D:D,texSubImage3D:Z,compressedTexSubImage2D:ue,scissor:Re,viewport:Ie,reset:ve}}function hD(n,e,t,r,i,s,o){let a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,d=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(P,D){return x?new OffscreenCanvas(P,D):fu("canvas")}function w(P,D,Z,ue){let pe=1;if((P.width>ue||P.height>ue)&&(pe=ue/Math.max(P.width,P.height)),pe<1||D===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){let Te=D?uu:Math.floor,Fe=Te(pe*P.width),ne=Te(pe*P.height);p===void 0&&(p=v(Fe,ne));let Re=Z?v(Fe,ne):p;return Re.width=Fe,Re.height=ne,Re.getContext("2d").drawImage(P,0,0,Fe,ne),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Fe+"x"+ne+")."),Re}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function b(P){return Qp(P.width)&&Qp(P.height)}function S(P){return a?!1:P.wrapS!==mr||P.wrapT!==mr||P.minFilter!==_r&&P.minFilter!==et}function M(P,D){return P.generateMipmaps&&D&&P.minFilter!==_r&&P.minFilter!==et}function _(P){n.generateMipmap(P)}function y(P,D,Z,ue,pe=!1){if(a===!1)return D;if(P!==null){if(n[P]!==void 0)return n[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let Te=D;return D===6403&&(Z===5126&&(Te=33326),Z===5131&&(Te=33325),Z===5121&&(Te=33321)),D===33319&&(Z===5126&&(Te=33328),Z===5131&&(Te=33327),Z===5121&&(Te=33323)),D===6408&&(Z===5126&&(Te=34836),Z===5131&&(Te=34842),Z===5121&&(Te=ue===He&&pe===!1?35907:32856),Z===32819&&(Te=32854),Z===32820&&(Te=32855)),(Te===33325||Te===33326||Te===33327||Te===33328||Te===34842||Te===34836)&&e.get("EXT_color_buffer_float"),Te}function T(P,D,Z){return M(P,Z)===!0||P.isFramebufferTexture&&P.minFilter!==_r&&P.minFilter!==et?Math.log2(Math.max(D.width,D.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?D.mipmaps.length:1}function E(P){return P===_r||P===Mv||P===_v?9728:9729}function C(P){let D=P.target;D.removeEventListener("dispose",C),B(D),D.isVideoTexture&&m.delete(D)}function I(P){let D=P.target;D.removeEventListener("dispose",I),H(D)}function B(P){let D=r.get(P);if(D.__webglInit===void 0)return;let Z=P.source,ue=g.get(Z);if(ue){let pe=ue[D.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&N(P),Object.keys(ue).length===0&&g.delete(Z)}r.remove(P)}function N(P){let D=r.get(P);n.deleteTexture(D.__webglTexture);let Z=P.source,ue=g.get(Z);delete ue[D.__cacheKey],o.memory.textures--}function H(P){let D=P.texture,Z=r.get(P),ue=r.get(D);if(ue.__webglTexture!==void 0&&(n.deleteTexture(ue.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++)n.deleteFramebuffer(Z.__webglFramebuffer[pe]),Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer[pe]);else{if(n.deleteFramebuffer(Z.__webglFramebuffer),Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer),Z.__webglMultisampledFramebuffer&&n.deleteFramebuffer(Z.__webglMultisampledFramebuffer),Z.__webglColorRenderbuffer)for(let pe=0;pe<Z.__webglColorRenderbuffer.length;pe++)Z.__webglColorRenderbuffer[pe]&&n.deleteRenderbuffer(Z.__webglColorRenderbuffer[pe]);Z.__webglDepthRenderbuffer&&n.deleteRenderbuffer(Z.__webglDepthRenderbuffer)}if(P.isWebGLMultipleRenderTargets)for(let pe=0,Te=D.length;pe<Te;pe++){let Fe=r.get(D[pe]);Fe.__webglTexture&&(n.deleteTexture(Fe.__webglTexture),o.memory.textures--),r.remove(D[pe])}r.remove(D),r.remove(P)}let j=0;function Q(){j=0}function X(){let P=j;return P>=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),j+=1,P}function U(P){let D=[];return D.push(P.wrapS),D.push(P.wrapT),D.push(P.magFilter),D.push(P.minFilter),D.push(P.anisotropy),D.push(P.internalFormat),D.push(P.format),D.push(P.type),D.push(P.generateMipmaps),D.push(P.premultiplyAlpha),D.push(P.flipY),D.push(P.unpackAlignment),D.push(P.encoding),D.join()}function F(P,D){let Z=r.get(P);if(P.isVideoTexture&&Oe(P),P.isRenderTargetTexture===!1&&P.version>0&&Z.__version!==P.version){let ue=P.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(Z,P,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,Z.__webglTexture)}function V(P,D){let Z=r.get(P);if(P.version>0&&Z.__version!==P.version){K(Z,P,D);return}t.activeTexture(33984+D),t.bindTexture(35866,Z.__webglTexture)}function R(P,D){let Z=r.get(P);if(P.version>0&&Z.__version!==P.version){K(Z,P,D);return}t.activeTexture(33984+D),t.bindTexture(32879,Z.__webglTexture)}function G(P,D){let Z=r.get(P);if(P.version>0&&Z.__version!==P.version){te(Z,P,D);return}t.activeTexture(33984+D),t.bindTexture(34067,Z.__webglTexture)}let W={[na]:10497,[mr]:33071,[Yp]:33648},Y={[_r]:9728,[Mv]:9984,[_v]:9986,[et]:9729,[ZM]:9985,[As]:9987};function q(P,D,Z){if(Z?(n.texParameteri(P,10242,W[D.wrapS]),n.texParameteri(P,10243,W[D.wrapT]),(P===32879||P===35866)&&n.texParameteri(P,32882,W[D.wrapR]),n.texParameteri(P,10240,Y[D.magFilter]),n.texParameteri(P,10241,Y[D.minFilter])):(n.texParameteri(P,10242,33071),n.texParameteri(P,10243,33071),(P===32879||P===35866)&&n.texParameteri(P,32882,33071),(D.wrapS!==mr||D.wrapT!==mr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(P,10240,E(D.magFilter)),n.texParameteri(P,10241,E(D.minFilter)),D.minFilter!==_r&&D.minFilter!==et&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let ue=e.get("EXT_texture_filter_anisotropic");if(D.type===ls&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===cc&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||r.get(D).__currentAnisotropy)&&(n.texParameterf(P,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),r.get(D).__currentAnisotropy=D.anisotropy)}}function se(P,D){let Z=!1;P.__webglInit===void 0&&(P.__webglInit=!0,D.addEventListener("dispose",C));let ue=D.source,pe=g.get(ue);pe===void 0&&(pe={},g.set(ue,pe));let Te=U(D);if(Te!==P.__cacheKey){pe[Te]===void 0&&(pe[Te]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),pe[Te].usedTimes++;let Fe=pe[P.__cacheKey];Fe!==void 0&&(pe[P.__cacheKey].usedTimes--,Fe.usedTimes===0&&N(D)),P.__cacheKey=Te,P.__webglTexture=pe[Te].texture}return Z}function K(P,D,Z){let ue=3553;D.isDataArrayTexture&&(ue=35866),D.isData3DTexture&&(ue=32879);let pe=se(P,D),Te=D.source;if(t.activeTexture(33984+Z),t.bindTexture(ue,P.__webglTexture),Te.version!==Te.__currentVersion||pe===!0){n.pixelStorei(37440,D.flipY),n.pixelStorei(37441,D.premultiplyAlpha),n.pixelStorei(3317,D.unpackAlignment),n.pixelStorei(37443,0);let Fe=S(D)&&b(D.image)===!1,ne=w(D.image,Fe,!1,h);ne=pt(D,ne);let Re=b(ne)||a,Ie=s.convert(D.format,D.encoding),ve=s.convert(D.type),z=y(D.internalFormat,Ie,ve,D.encoding,D.isVideoTexture);q(ue,D,Re);let xe,Me=D.mipmaps,Ye=a&&D.isVideoTexture!==!0,Ne=Te.__currentVersion===void 0||pe===!0,Je=T(D,ne,Re);if(D.isDepthTexture)z=6402,a?D.type===ls?z=36012:D.type===Fi?z=33190:D.type===us?z=35056:z=33189:D.type===ls&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===no&&z===6402&&D.type!==$0&&D.type!==Fi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Fi,ve=s.convert(D.type)),D.format===ms&&z===6402&&(z=34041,D.type!==us&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=us,ve=s.convert(D.type))),Ne&&(Ye?t.texStorage2D(3553,1,z,ne.width,ne.height):t.texImage2D(3553,0,z,ne.width,ne.height,0,Ie,ve,null));else if(D.isDataTexture)if(Me.length>0&&Re){Ye&&Ne&&t.texStorage2D(3553,Je,z,Me[0].width,Me[0].height);for(let be=0,Qe=Me.length;be<Qe;be++)xe=Me[be],Ye?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,ve,xe.data):t.texImage2D(3553,be,z,xe.width,xe.height,0,Ie,ve,xe.data);D.generateMipmaps=!1}else Ye?(Ne&&t.texStorage2D(3553,Je,z,ne.width,ne.height),t.texSubImage2D(3553,0,0,0,ne.width,ne.height,Ie,ve,ne.data)):t.texImage2D(3553,0,z,ne.width,ne.height,0,Ie,ve,ne.data);else if(D.isCompressedTexture){Ye&&Ne&&t.texStorage2D(3553,Je,z,Me[0].width,Me[0].height);for(let be=0,Qe=Me.length;be<Qe;be++)xe=Me[be],D.format!==bn?Ie!==null?Ye?t.compressedTexSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,xe.data):t.compressedTexImage2D(3553,be,z,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ye?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,ve,xe.data):t.texImage2D(3553,be,z,xe.width,xe.height,0,Ie,ve,xe.data)}else if(D.isDataArrayTexture)Ye?(Ne&&t.texStorage3D(35866,Je,z,ne.width,ne.height,ne.depth),t.texSubImage3D(35866,0,0,0,0,ne.width,ne.height,ne.depth,Ie,ve,ne.data)):t.texImage3D(35866,0,z,ne.width,ne.height,ne.depth,0,Ie,ve,ne.data);else if(D.isData3DTexture)Ye?(Ne&&t.texStorage3D(32879,Je,z,ne.width,ne.height,ne.depth),t.texSubImage3D(32879,0,0,0,0,ne.width,ne.height,ne.depth,Ie,ve,ne.data)):t.texImage3D(32879,0,z,ne.width,ne.height,ne.depth,0,Ie,ve,ne.data);else if(D.isFramebufferTexture){if(Ne)if(Ye)t.texStorage2D(3553,Je,z,ne.width,ne.height);else{let be=ne.width,Qe=ne.height;for(let nt=0;nt<Je;nt++)t.texImage2D(3553,nt,z,be,Qe,0,Ie,ve,null),be>>=1,Qe>>=1}}else if(Me.length>0&&Re){Ye&&Ne&&t.texStorage2D(3553,Je,z,Me[0].width,Me[0].height);for(let be=0,Qe=Me.length;be<Qe;be++)xe=Me[be],Ye?t.texSubImage2D(3553,be,0,0,Ie,ve,xe):t.texImage2D(3553,be,z,Ie,ve,xe);D.generateMipmaps=!1}else Ye?(Ne&&t.texStorage2D(3553,Je,z,ne.width,ne.height),t.texSubImage2D(3553,0,0,0,Ie,ve,ne)):t.texImage2D(3553,0,z,Ie,ve,ne);M(D,Re)&&_(ue),Te.__currentVersion=Te.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function te(P,D,Z){if(D.image.length!==6)return;let ue=se(P,D),pe=D.source;if(t.activeTexture(33984+Z),t.bindTexture(34067,P.__webglTexture),pe.version!==pe.__currentVersion||ue===!0){n.pixelStorei(37440,D.flipY),n.pixelStorei(37441,D.premultiplyAlpha),n.pixelStorei(3317,D.unpackAlignment),n.pixelStorei(37443,0);let Te=D.isCompressedTexture||D.image[0].isCompressedTexture,Fe=D.image[0]&&D.image[0].isDataTexture,ne=[];for(let be=0;be<6;be++)!Te&&!Fe?ne[be]=w(D.image[be],!1,!0,c):ne[be]=Fe?D.image[be].image:D.image[be],ne[be]=pt(D,ne[be]);let Re=ne[0],Ie=b(Re)||a,ve=s.convert(D.format,D.encoding),z=s.convert(D.type),xe=y(D.internalFormat,ve,z,D.encoding),Me=a&&D.isVideoTexture!==!0,Ye=pe.__currentVersion===void 0||ue===!0,Ne=T(D,Re,Ie);q(34067,D,Ie);let Je;if(Te){Me&&Ye&&t.texStorage2D(34067,Ne,xe,Re.width,Re.height);for(let be=0;be<6;be++){Je=ne[be].mipmaps;for(let Qe=0;Qe<Je.length;Qe++){let nt=Je[Qe];D.format!==bn?ve!==null?Me?t.compressedTexSubImage2D(34069+be,Qe,0,0,nt.width,nt.height,ve,nt.data):t.compressedTexImage2D(34069+be,Qe,xe,nt.width,nt.height,0,nt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Me?t.texSubImage2D(34069+be,Qe,0,0,nt.width,nt.height,ve,z,nt.data):t.texImage2D(34069+be,Qe,xe,nt.width,nt.height,0,ve,z,nt.data)}}}else{Je=D.mipmaps,Me&&Ye&&(Je.length>0&&Ne++,t.texStorage2D(34067,Ne,xe,ne[0].width,ne[0].height));for(let be=0;be<6;be++)if(Fe){Me?t.texSubImage2D(34069+be,0,0,0,ne[be].width,ne[be].height,ve,z,ne[be].data):t.texImage2D(34069+be,0,xe,ne[be].width,ne[be].height,0,ve,z,ne[be].data);for(let Qe=0;Qe<Je.length;Qe++){let mt=Je[Qe].image[be].image;Me?t.texSubImage2D(34069+be,Qe+1,0,0,mt.width,mt.height,ve,z,mt.data):t.texImage2D(34069+be,Qe+1,xe,mt.width,mt.height,0,ve,z,mt.data)}}else{Me?t.texSubImage2D(34069+be,0,0,0,ve,z,ne[be]):t.texImage2D(34069+be,0,xe,ve,z,ne[be]);for(let Qe=0;Qe<Je.length;Qe++){let nt=Je[Qe];Me?t.texSubImage2D(34069+be,Qe+1,0,0,ve,z,nt.image[be]):t.texImage2D(34069+be,Qe+1,xe,ve,z,nt.image[be])}}}M(D,Ie)&&_(34067),pe.__currentVersion=pe.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function k(P,D,Z,ue,pe){let Te=s.convert(Z.format,Z.encoding),Fe=s.convert(Z.type),ne=y(Z.internalFormat,Te,Fe,Z.encoding);r.get(D).__hasExternalTextures||(pe===32879||pe===35866?t.texImage3D(pe,0,ne,D.width,D.height,D.depth,0,Te,Fe,null):t.texImage2D(pe,0,ne,D.width,D.height,0,Te,Fe,null)),t.bindFramebuffer(36160,P),ye(D)?f.framebufferTexture2DMultisampleEXT(36160,ue,pe,r.get(Z).__webglTexture,0,Ee(D)):n.framebufferTexture2D(36160,ue,pe,r.get(Z).__webglTexture,0),t.bindFramebuffer(36160,null)}function le(P,D,Z){if(n.bindRenderbuffer(36161,P),D.depthBuffer&&!D.stencilBuffer){let ue=33189;if(Z||ye(D)){let pe=D.depthTexture;pe&&pe.isDepthTexture&&(pe.type===ls?ue=36012:pe.type===Fi&&(ue=33190));let Te=Ee(D);ye(D)?f.renderbufferStorageMultisampleEXT(36161,Te,ue,D.width,D.height):n.renderbufferStorageMultisample(36161,Te,ue,D.width,D.height)}else n.renderbufferStorage(36161,ue,D.width,D.height);n.framebufferRenderbuffer(36160,36096,36161,P)}else if(D.depthBuffer&&D.stencilBuffer){let ue=Ee(D);Z&&ye(D)===!1?n.renderbufferStorageMultisample(36161,ue,35056,D.width,D.height):ye(D)?f.renderbufferStorageMultisampleEXT(36161,ue,35056,D.width,D.height):n.renderbufferStorage(36161,34041,D.width,D.height),n.framebufferRenderbuffer(36160,33306,36161,P)}else{let ue=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let pe=0;pe<ue.length;pe++){let Te=ue[pe],Fe=s.convert(Te.format,Te.encoding),ne=s.convert(Te.type),Re=y(Te.internalFormat,Fe,ne,Te.encoding),Ie=Ee(D);Z&&ye(D)===!1?n.renderbufferStorageMultisample(36161,Ie,Re,D.width,D.height):ye(D)?f.renderbufferStorageMultisampleEXT(36161,Ie,Re,D.width,D.height):n.renderbufferStorage(36161,Re,D.width,D.height)}}n.bindRenderbuffer(36161,null)}function ce(P,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,P),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),F(D.depthTexture,0);let ue=r.get(D.depthTexture).__webglTexture,pe=Ee(D);if(D.depthTexture.format===no)ye(D)?f.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,pe):n.framebufferTexture2D(36160,36096,3553,ue,0);else if(D.depthTexture.format===ms)ye(D)?f.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,pe):n.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ae(P){let D=r.get(P),Z=P.isWebGLCubeRenderTarget===!0;if(P.depthTexture&&!D.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");ce(D.__webglFramebuffer,P)}else if(Z){D.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)t.bindFramebuffer(36160,D.__webglFramebuffer[ue]),D.__webglDepthbuffer[ue]=n.createRenderbuffer(),le(D.__webglDepthbuffer[ue],P,!1)}else t.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=n.createRenderbuffer(),le(D.__webglDepthbuffer,P,!1);t.bindFramebuffer(36160,null)}function fe(P,D,Z){let ue=r.get(P);D!==void 0&&k(ue.__webglFramebuffer,P,P.texture,36064,3553),Z!==void 0&&ae(P)}function ge(P){let D=P.texture,Z=r.get(P),ue=r.get(D);P.addEventListener("dispose",I),P.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=n.createTexture()),ue.__version=D.version,o.memory.textures++);let pe=P.isWebGLCubeRenderTarget===!0,Te=P.isWebGLMultipleRenderTargets===!0,Fe=b(P)||a;if(pe){Z.__webglFramebuffer=[];for(let ne=0;ne<6;ne++)Z.__webglFramebuffer[ne]=n.createFramebuffer()}else{if(Z.__webglFramebuffer=n.createFramebuffer(),Te)if(i.drawBuffers){let ne=P.texture;for(let Re=0,Ie=ne.length;Re<Ie;Re++){let ve=r.get(ne[Re]);ve.__webglTexture===void 0&&(ve.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&P.samples>0&&ye(P)===!1){let ne=Te?D:[D];Z.__webglMultisampledFramebuffer=n.createFramebuffer(),Z.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,Z.__webglMultisampledFramebuffer);for(let Re=0;Re<ne.length;Re++){let Ie=ne[Re];Z.__webglColorRenderbuffer[Re]=n.createRenderbuffer(),n.bindRenderbuffer(36161,Z.__webglColorRenderbuffer[Re]);let ve=s.convert(Ie.format,Ie.encoding),z=s.convert(Ie.type),xe=y(Ie.internalFormat,ve,z,Ie.encoding),Me=Ee(P);n.renderbufferStorageMultisample(36161,Me,xe,P.width,P.height),n.framebufferRenderbuffer(36160,36064+Re,36161,Z.__webglColorRenderbuffer[Re])}n.bindRenderbuffer(36161,null),P.depthBuffer&&(Z.__webglDepthRenderbuffer=n.createRenderbuffer(),le(Z.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(36160,null)}}if(pe){t.bindTexture(34067,ue.__webglTexture),q(34067,D,Fe);for(let ne=0;ne<6;ne++)k(Z.__webglFramebuffer[ne],P,D,36064,34069+ne);M(D,Fe)&&_(34067),t.unbindTexture()}else if(Te){let ne=P.texture;for(let Re=0,Ie=ne.length;Re<Ie;Re++){let ve=ne[Re],z=r.get(ve);t.bindTexture(3553,z.__webglTexture),q(3553,ve,Fe),k(Z.__webglFramebuffer,P,ve,36064+Re,3553),M(ve,Fe)&&_(3553)}t.unbindTexture()}else{let ne=3553;(P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(a?ne=P.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(ne,ue.__webglTexture),q(ne,D,Fe),k(Z.__webglFramebuffer,P,D,36064,ne),M(D,Fe)&&_(ne),t.unbindTexture()}P.depthBuffer&&ae(P)}function de(P){let D=b(P)||a,Z=P.isWebGLMultipleRenderTargets===!0?P.texture:[P.texture];for(let ue=0,pe=Z.length;ue<pe;ue++){let Te=Z[ue];if(M(Te,D)){let Fe=P.isWebGLCubeRenderTarget?34067:3553,ne=r.get(Te).__webglTexture;t.bindTexture(Fe,ne),_(Fe),t.unbindTexture()}}}function _e(P){if(a&&P.samples>0&&ye(P)===!1){let D=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],Z=P.width,ue=P.height,pe=16384,Te=[],Fe=P.stencilBuffer?33306:36096,ne=r.get(P),Re=P.isWebGLMultipleRenderTargets===!0;if(Re)for(let Ie=0;Ie<D.length;Ie++)t.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+Ie,36161,null),t.bindFramebuffer(36160,ne.__webglFramebuffer),n.framebufferTexture2D(36009,36064+Ie,3553,null,0);t.bindFramebuffer(36008,ne.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,ne.__webglFramebuffer);for(let Ie=0;Ie<D.length;Ie++){Te.push(36064+Ie),P.depthBuffer&&Te.push(Fe);let ve=ne.__ignoreDepthValues!==void 0?ne.__ignoreDepthValues:!1;if(ve===!1&&(P.depthBuffer&&(pe|=256),P.stencilBuffer&&(pe|=1024)),Re&&n.framebufferRenderbuffer(36008,36064,36161,ne.__webglColorRenderbuffer[Ie]),ve===!0&&(n.invalidateFramebuffer(36008,[Fe]),n.invalidateFramebuffer(36009,[Fe])),Re){let z=r.get(D[Ie]).__webglTexture;n.framebufferTexture2D(36009,36064,3553,z,0)}n.blitFramebuffer(0,0,Z,ue,0,0,Z,ue,pe,9728),d&&n.invalidateFramebuffer(36008,Te)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Re)for(let Ie=0;Ie<D.length;Ie++){t.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+Ie,36161,ne.__webglColorRenderbuffer[Ie]);let ve=r.get(D[Ie]).__webglTexture;t.bindFramebuffer(36160,ne.__webglFramebuffer),n.framebufferTexture2D(36009,36064+Ie,3553,ve,0)}t.bindFramebuffer(36009,ne.__webglMultisampledFramebuffer)}}function Ee(P){return Math.min(u,P.samples)}function ye(P){let D=r.get(P);return a&&P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function Oe(P){let D=o.render.frame;m.get(P)!==D&&(m.set(P,D),P.update())}function pt(P,D){let Z=P.encoding,ue=P.format,pe=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Jp||Z!==hn&&(Z===He?a===!1?e.has("EXT_sRGB")===!0&&ue===bn?(P.format=Jp,P.minFilter=et,P.generateMipmaps=!1):D=du.sRGBToLinear(D):(ue!==bn||pe!==It)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",Z)),D}this.allocateTextureUnit=X,this.resetTextureUnits=Q,this.setTexture2D=F,this.setTexture2DArray=V,this.setTexture3D=R,this.setTextureCube=G,this.rebindTextures=fe,this.setupRenderTarget=ge,this.updateRenderTargetMipmap=de,this.updateMultisampleRenderTarget=_e,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=k,this.useMultisampledRTT=ye}function uD(n,e,t){let r=t.isWebGL2;function i(s,o=null){let a;if(s===It)return 5121;if(s===r_)return 32819;if(s===n_)return 32820;if(s===$M)return 5120;if(s===e_)return 5122;if(s===$0)return 5123;if(s===t_)return 5124;if(s===Fi)return 5125;if(s===ls)return 5126;if(s===cc)return r?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===i_)return 6406;if(s===bn)return 6408;if(s===o_)return 6409;if(s===a_)return 6410;if(s===no)return 6402;if(s===ms)return 34041;if(s===l_)return 6403;if(s===s_)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===Jp)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===c_)return 36244;if(s===h_)return 33319;if(s===u_)return 33320;if(s===f_)return 36249;if(s===lp||s===cp||s===hp||s===up)if(o===He)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===lp)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===lp)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Tv||s===Ev||s===Cv||s===Dv)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Tv)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Ev)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Cv)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Dv)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===d_)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Pv||s===Lv)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Pv)return o===He?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Lv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Iv||s===Nv||s===Bv||s===Ov||s===Rv||s===Fv||s===zv||s===Uv||s===Gv||s===kv||s===Vv||s===Hv||s===Wv||s===jv)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Iv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Nv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Bv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Ov)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Rv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Fv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===zv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Uv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Gv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===kv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Vv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Hv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Wv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===jv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===qv)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===qv)return o===He?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===us?r?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}var om=class extends Jt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},cs=class extends lt{constructor(){super(),this.isGroup=!0,this.type="Group"}},fD={type:"move"},oc=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new cs,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 cs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new cs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(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,r){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(a!==null&&(i=t.getPose(e.targetRaySpace,r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(fD))),c&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,r);if(c.joints[p.jointName]===void 0){let v=new cs;v.matrixAutoUpdate=!1,v.visible=!1,c.joints[p.jointName]=v,c.add(v)}let x=c.joints[p.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,m=.005;c.inputState.pinching&&f>d+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},ci=class extends Nt{constructor(e,t,r,i,s,o,a,l,c,h){if(h=h!==void 0?h:no,h!==no&&h!==ms)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&h===no&&(r=Fi),r===void 0&&h===ms&&(r=us),super(null,i,s,o,a,l,h,r,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:_r,this.minFilter=l!==void 0?l:_r,this.flipY=!1,this.generateMipmaps=!1}},am=class extends Ot{constructor(e,t){super();let r=this,i=null,s=1,o=null,a="local-floor",l=null,c=null,h=null,u=null,f=null,d=null,m=t.getContextAttributes(),p=null,g=null,x=[],v=new Map,w=new Jt;w.layers.enable(1),w.viewport=new Ke;let b=new Jt;b.layers.enable(2),b.viewport=new Ke;let S=[w,b],M=new om;M.layers.enable(1),M.layers.enable(2);let _=null,y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let F=x[U];return F===void 0&&(F=new oc,x[U]=F),F.getTargetRaySpace()},this.getControllerGrip=function(U){let F=x[U];return F===void 0&&(F=new oc,x[U]=F),F.getGripSpace()},this.getHand=function(U){let F=x[U];return F===void 0&&(F=new oc,x[U]=F),F.getHandSpace()};function T(U){let F=v.get(U.inputSource);F!==void 0&&F.dispatchEvent({type:U.type,data:U.inputSource})}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C),v.forEach(function(U,F){U!==void 0&&U.disconnect(F)}),v.clear(),_=null,y=null,e.setRenderTarget(p),f=null,u=null,h=null,i=null,g=null,X.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(U){l=U},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return h},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(U){if(i=U,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let F={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,t,F),i.updateRenderState({baseLayer:f}),g=new ut(f.framebufferWidth,f.framebufferHeight,{format:bn,type:It,encoding:e.outputEncoding})}else{let F=null,V=null,R=null;m.depth&&(R=m.stencil?35056:33190,F=m.stencil?ms:no,V=m.stencil?us:Fi);let G={colorFormat:e.outputEncoding===He?35907:32856,depthFormat:R,scaleFactor:s};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(G),i.updateRenderState({layers:[u]}),g=new ut(u.textureWidth,u.textureHeight,{format:bn,type:It,depthTexture:new ci(u.textureWidth,u.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,F),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let W=e.properties.get(g);W.__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),X.setContext(i),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function C(U){let F=i.inputSources;for(let V=0;V<F.length;V++){let R=F[V].handedness==="right"?1:0;v.set(F[V],x[R])}for(let V=0;V<U.removed.length;V++){let R=U.removed[V],G=v.get(R);G&&(G.dispatchEvent({type:"disconnected",data:R}),v.delete(R))}for(let V=0;V<U.added.length;V++){let R=U.added[V],G=v.get(R);G&&G.dispatchEvent({type:"connected",data:R})}}let I=new A,B=new A;function N(U,F,V){I.setFromMatrixPosition(F.matrixWorld),B.setFromMatrixPosition(V.matrixWorld);let R=I.distanceTo(B),G=F.projectionMatrix.elements,W=V.projectionMatrix.elements,Y=G[14]/(G[10]-1),q=G[14]/(G[10]+1),se=(G[9]+1)/G[5],K=(G[9]-1)/G[5],te=(G[8]-1)/G[0],k=(W[8]+1)/W[0],le=Y*te,ce=Y*k,ae=R/(-te+k),fe=ae*-te;F.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(fe),U.translateZ(ae),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();let ge=Y+ae,de=q+ae,_e=le-fe,Ee=ce+(R-fe),ye=se*q/de*ge,Oe=K*q/de*ge;U.projectionMatrix.makePerspective(_e,Ee,ye,Oe,ge,de)}function H(U,F){F===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(F.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(i===null)return;M.near=b.near=w.near=U.near,M.far=b.far=w.far=U.far,(_!==M.near||y!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),_=M.near,y=M.far);let F=U.parent,V=M.cameras;H(M,F);for(let G=0;G<V.length;G++)H(V[G],F);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),U.position.copy(M.position),U.quaternion.copy(M.quaternion),U.scale.copy(M.scale),U.matrix.copy(M.matrix),U.matrixWorld.copy(M.matrixWorld);let R=U.children;for(let G=0,W=R.length;G<W;G++)R[G].updateMatrixWorld(!0);V.length===2?N(M,w,b):M.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(u!==null)return u.fixedFoveation;if(f!==null)return f.fixedFoveation},this.setFoveation=function(U){u!==null&&(u.fixedFoveation=U),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=U)};let j=null;function Q(U,F){if(c=F.getViewerPose(l||o),d=F,c!==null){let R=c.views;f!==null&&(e.setRenderTargetFramebuffer(g,f.framebuffer),e.setRenderTarget(g));let G=!1;R.length!==M.cameras.length&&(M.cameras.length=0,G=!0);for(let W=0;W<R.length;W++){let Y=R[W],q=null;if(f!==null)q=f.getViewport(Y);else{let K=h.getViewSubImage(u,Y);q=K.viewport,W===0&&(e.setRenderTargetTextures(g,K.colorTexture,u.ignoreDepthValues?void 0:K.depthStencilTexture),e.setRenderTarget(g))}let se=S[W];se===void 0&&(se=new Jt,se.layers.enable(W),se.viewport=new Ke,S[W]=se),se.matrix.fromArray(Y.transform.matrix),se.projectionMatrix.fromArray(Y.projectionMatrix),se.viewport.set(q.x,q.y,q.width,q.height),W===0&&M.matrix.copy(se.matrix),G===!0&&M.cameras.push(se)}}let V=i.inputSources;for(let R=0;R<x.length;R++){let G=V[R],W=v.get(G);W!==void 0&&W.update(G,F,l||o)}j&&j(U,F),d=null}let X=new rx;X.setAnimationLoop(Q),this.setAnimationLoop=function(U){j=U},this.dispose=function(){}}};function dD(n,e){function t(p,g){p.fogColor.value.copy(g.color),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function r(p,g,x,v,w){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),h(p,g)):g.isMeshPhongMaterial?(i(p,g),c(p,g)):g.isMeshStandardMaterial?(i(p,g),u(p,g),g.isMeshPhysicalMaterial&&f(p,g,w)):g.isMeshMatcapMaterial?(i(p,g),d(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,x,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===gr&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===gr&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x=e.get(g).envMap;if(x&&(p.envMap.value=x,p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let b=n.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let w;g.aoMap?w=g.aoMap:g.lightMap&&(w=g.lightMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uv2Transform.value.copy(w.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,x,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*x,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let w;g.map?w=g.map:g.alphaMap&&(w=g.alphaMap),w!==void 0&&(w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function c(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function h(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function u(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function f(p,g,x){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===gr&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=x.texture,p.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function d(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:r}}function pD(){let n=fu("canvas");return n.style.display="block",n}function zu(n={}){this.isWebGLRenderer=!0;let e=n.canvas!==void 0?n.canvas:pD(),t=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",c=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,h;t!==null?h=t.getContextAttributes().alpha:h=n.alpha!==void 0?n.alpha:!1;let u=null,f=null,d=[],m=[];this.domElement=e,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=hn,this.physicallyCorrectLights=!1,this.toneMapping=zi,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,x=0,v=0,w=null,b=-1,S=null,M=new Ke,_=new Ke,y=null,T=e.width,E=e.height,C=1,I=null,B=null,N=new Ke(0,0,T,E),H=new Ke(0,0,T,E),j=!1,Q=new fc,X=!1,U=!1,F=null,V=new Be,R=new O,G=new A,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return w===null?C:1}let q=t;function se(L,$){for(let ie=0;ie<L.length;ie++){let re=L[ie],he=e.getContext(re,$);if(he!==null)return he}return null}try{let L={alpha:!0,depth:r,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${yo}`),e.addEventListener("webglcontextlost",z,!1),e.addEventListener("webglcontextrestored",xe,!1),e.addEventListener("webglcontextcreationerror",Me,!1),q===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),q=se($,L),q===null)throw se($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}q.getShaderPrecisionFormat===void 0&&(q.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let K,te,k,le,ce,ae,fe,ge,de,_e,Ee,ye,Oe,pt,P,D,Z,ue,pe,Te,Fe,ne,Re;function Ie(){K=new OC(q),te=new DC(q,K,n),K.init(te),ne=new uD(q,K,te),k=new cD(q,K,te),le=new zC(q),ce=new K2,ae=new hD(q,K,k,ce,te,ne,le),fe=new LC(p),ge=new BC(p),de=new Q_(q,te),Re=new EC(q,K,de,te),_e=new RC(q,de,le,Re),Ee=new VC(q,_e,de,le),pe=new kC(q,te,ae),D=new PC(ce),ye=new Q2(p,fe,ge,K,te,Re,D),Oe=new dD(p,ce),pt=new $2,P=new sD(K,te),ue=new TC(p,fe,k,Ee,h,o),Z=new lD(p,Ee,te),Te=new CC(q,K,le,te),Fe=new FC(q,K,le,te),le.programs=ye.programs,p.capabilities=te,p.extensions=K,p.properties=ce,p.renderLists=pt,p.shadowMap=Z,p.state=k,p.info=le}Ie();let ve=new am(p,q);this.xr=ve,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){let L=K.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=K.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(L){L!==void 0&&(C=L,this.setSize(T,E,!1))},this.getSize=function(L){return L.set(T,E)},this.setSize=function(L,$,ie){if(ve.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=L,E=$,e.width=Math.floor(L*C),e.height=Math.floor($*C),ie!==!1&&(e.style.width=L+"px",e.style.height=$+"px"),this.setViewport(0,0,L,$)},this.getDrawingBufferSize=function(L){return L.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(L,$,ie){T=L,E=$,C=ie,e.width=Math.floor(L*ie),e.height=Math.floor($*ie),this.setViewport(0,0,L,$)},this.getCurrentViewport=function(L){return L.copy(M)},this.getViewport=function(L){return L.copy(N)},this.setViewport=function(L,$,ie,re){L.isVector4?N.set(L.x,L.y,L.z,L.w):N.set(L,$,ie,re),k.viewport(M.copy(N).multiplyScalar(C).floor())},this.getScissor=function(L){return L.copy(H)},this.setScissor=function(L,$,ie,re){L.isVector4?H.set(L.x,L.y,L.z,L.w):H.set(L,$,ie,re),k.scissor(_.copy(H).multiplyScalar(C).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(L){k.setScissorTest(j=L)},this.setOpaqueSort=function(L){I=L},this.setTransparentSort=function(L){B=L},this.getClearColor=function(L){return L.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(L=!0,$=!0,ie=!0){let re=0;L&&(re|=16384),$&&(re|=256),ie&&(re|=1024),q.clear(re)},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(){e.removeEventListener("webglcontextlost",z,!1),e.removeEventListener("webglcontextrestored",xe,!1),e.removeEventListener("webglcontextcreationerror",Me,!1),pt.dispose(),P.dispose(),ce.dispose(),fe.dispose(),ge.dispose(),Ee.dispose(),Re.dispose(),ye.dispose(),ve.dispose(),ve.removeEventListener("sessionstart",nt),ve.removeEventListener("sessionend",mt),F&&(F.dispose(),F=null),bt.stop()};function z(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=le.autoReset,$=Z.enabled,ie=Z.autoUpdate,re=Z.needsUpdate,he=Z.type;Ie(),le.autoReset=L,Z.enabled=$,Z.autoUpdate=ie,Z.needsUpdate=re,Z.type=he}function Me(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function Ye(L){let $=L.target;$.removeEventListener("dispose",Ye),Ne($)}function Ne(L){Je(L),ce.remove(L)}function Je(L){let $=ce.get(L).programs;$!==void 0&&($.forEach(function(ie){ye.releaseProgram(ie)}),L.isShaderMaterial&&ye.releaseShaderCache(L))}this.renderBufferDirect=function(L,$,ie,re,he,Ze){$===null&&($=W);let rt=he.isMesh&&he.matrixWorld.determinant()<0,st=dM(L,$,ie,re,he);k.setMaterial(re,rt);let it=ie.index,Tt=ie.attributes.position;if(it===null){if(Tt===void 0||Tt.count===0)return}else if(it.count===0)return;let ht=1;re.wireframe===!0&&(it=_e.getWireframeAttribute(ie),ht=2),Re.setup(he,re,st,ie,it);let gt,kt=Te;it!==null&&(gt=de.get(it),kt=Fe,kt.setIndex(gt));let Qs=it!==null?it.count:Tt.count,Ro=ie.drawRange.start*ht,Fo=ie.drawRange.count*ht,ri=Ze!==null?Ze.start*ht:0,wt=Ze!==null?Ze.count*ht:1/0,zo=Math.max(Ro,ri),tr=Math.min(Qs,Ro+Fo,ri+wt)-1,ni=Math.max(0,tr-zo+1);if(ni!==0){if(he.isMesh)re.wireframe===!0?(k.setLineWidth(re.wireframeLinewidth*Y()),kt.setMode(1)):kt.setMode(4);else if(he.isLine){let es=re.linewidth;es===void 0&&(es=1),k.setLineWidth(es*Y()),he.isLineSegments?kt.setMode(1):he.isLineLoop?kt.setMode(2):kt.setMode(3)}else he.isPoints?kt.setMode(0):he.isSprite&&kt.setMode(4);if(he.isInstancedMesh)kt.renderInstances(zo,ni,he.count);else if(ie.isInstancedBufferGeometry){let es=Math.min(ie.instanceCount,ie._maxInstanceCount);kt.renderInstances(zo,ni,es)}else kt.render(zo,ni)}},this.compile=function(L,$){f=P.get(L),f.init(),m.push(f),L.traverseVisible(function(ie){ie.isLight&&ie.layers.test($.layers)&&(f.pushLight(ie),ie.castShadow&&f.pushShadow(ie))}),f.setupLights(p.physicallyCorrectLights),L.traverse(function(ie){let re=ie.material;if(re)if(Array.isArray(re))for(let he=0;he<re.length;he++){let Ze=re[he];ip(Ze,L,ie)}else ip(re,L,ie)}),m.pop(),f=null};let be=null;function Qe(L){be&&be(L)}function nt(){bt.stop()}function mt(){bt.start()}let bt=new rx;bt.setAnimationLoop(Qe),typeof self<"u"&&bt.setContext(self),this.setAnimationLoop=function(L){be=L,ve.setAnimationLoop(L),L===null?bt.stop():bt.start()},ve.addEventListener("sessionstart",nt),ve.addEventListener("sessionend",mt),this.render=function(L,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.autoUpdate===!0&&L.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),ve.enabled===!0&&ve.isPresenting===!0&&(ve.cameraAutoUpdate===!0&&ve.updateCamera($),$=ve.getCamera()),L.isScene===!0&&L.onBeforeRender(p,L,$,w),f=P.get(L,m.length),f.init(),m.push(f),V.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),Q.setFromProjectionMatrix(V),U=this.localClippingEnabled,X=D.init(this.clippingPlanes,U,$),u=pt.get(L,d.length),u.init(),d.push(u),Jr(L,$,0,p.sortObjects),u.finish(),p.sortObjects===!0&&u.sort(I,B),X===!0&&D.beginShadows();let ie=f.state.shadowsArray;if(Z.render(ie,L,$),X===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(u,L),f.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let re=$.cameras;for(let he=0,Ze=re.length;he<Ze;he++){let rt=re[he];Lh(u,L,rt,rt.viewport)}}else Lh(u,L,$);w!==null&&(ae.updateMultisampleRenderTarget(w),ae.updateRenderTargetMipmap(w)),L.isScene===!0&&L.onAfterRender(p,L,$),Re.resetDefaultState(),b=-1,S=null,m.pop(),m.length>0?f=m[m.length-1]:f=null,d.pop(),d.length>0?u=d[d.length-1]:u=null};function Jr(L,$,ie,re){if(L.visible===!1)return;if(L.layers.test($.layers)){if(L.isGroup)ie=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update($);else if(L.isLight)f.pushLight(L),L.castShadow&&f.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||Q.intersectsSprite(L)){re&&G.setFromMatrixPosition(L.matrixWorld).applyMatrix4(V);let rt=Ee.update(L),st=L.material;st.visible&&u.push(L,rt,st,ie,G.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==le.render.frame&&(L.skeleton.update(),L.skeleton.frame=le.render.frame),!L.frustumCulled||Q.intersectsObject(L))){re&&G.setFromMatrixPosition(L.matrixWorld).applyMatrix4(V);let rt=Ee.update(L),st=L.material;if(Array.isArray(st)){let it=rt.groups;for(let Tt=0,ht=it.length;Tt<ht;Tt++){let gt=it[Tt],kt=st[gt.materialIndex];kt&&kt.visible&&u.push(L,rt,kt,ie,G.z,gt)}}else st.visible&&u.push(L,rt,st,ie,G.z,null)}}let Ze=L.children;for(let rt=0,st=Ze.length;rt<st;rt++)Jr(Ze[rt],$,ie,re)}function Lh(L,$,ie,re){let he=L.opaque,Ze=L.transmissive,rt=L.transparent;f.setupLightsView(ie),Ze.length>0&&Oo(he,$,ie),re&&k.viewport(M.copy(re)),he.length>0&&Ih(he,$,ie),Ze.length>0&&Ih(Ze,$,ie),rt.length>0&&Ih(rt,$,ie),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function Oo(L,$,ie){let re=te.isWebGL2;F===null&&(F=new ut(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?cc:It,minFilter:As,samples:re&&s===!0?4:0})),p.getDrawingBufferSize(R),re?F.setSize(R.x,R.y):F.setSize(uu(R.x),uu(R.y));let he=p.getRenderTarget();p.setRenderTarget(F),p.clear();let Ze=p.toneMapping;p.toneMapping=zi,Ih(L,$,ie),p.toneMapping=Ze,ae.updateMultisampleRenderTarget(F),ae.updateRenderTargetMipmap(F),p.setRenderTarget(he)}function Ih(L,$,ie){let re=$.isScene===!0?$.overrideMaterial:null;for(let he=0,Ze=L.length;he<Ze;he++){let rt=L[he],st=rt.object,it=rt.geometry,Tt=re===null?rt.material:re,ht=rt.group;st.layers.test(ie.layers)&&fM(st,$,ie,it,Tt,ht)}}function fM(L,$,ie,re,he,Ze){L.onBeforeRender(p,$,ie,re,he,Ze),L.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),he.onBeforeRender(p,$,ie,re,L,Ze),he.transparent===!0&&he.side===Wt?(he.side=gr,he.needsUpdate=!0,p.renderBufferDirect(ie,$,re,he,L,Ze),he.side=zn,he.needsUpdate=!0,p.renderBufferDirect(ie,$,re,he,L,Ze),he.side=Wt):p.renderBufferDirect(ie,$,re,he,L,Ze),L.onAfterRender(p,$,ie,re,he,Ze)}function ip(L,$,ie){$.isScene!==!0&&($=W);let re=ce.get(L),he=f.state.lights,Ze=f.state.shadowsArray,rt=he.state.version,st=ye.getParameters(L,he.state,Ze,$,ie),it=ye.getProgramCacheKey(st),Tt=re.programs;re.environment=L.isMeshStandardMaterial?$.environment:null,re.fog=$.fog,re.envMap=(L.isMeshStandardMaterial?ge:fe).get(L.envMap||re.environment),Tt===void 0&&(L.addEventListener("dispose",Ye),Tt=new Map,re.programs=Tt);let ht=Tt.get(it);if(ht!==void 0){if(re.currentProgram===ht&&re.lightsStateVersion===rt)return mv(L,st),ht}else st.uniforms=ye.getUniforms(L),L.onBuild(ie,st,p),L.onBeforeCompile(st,p),ht=ye.acquireProgram(st,it),Tt.set(it,ht),re.uniforms=st.uniforms;let gt=re.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(gt.clippingPlanes=D.uniform),mv(L,st),re.needsLights=mM(L),re.lightsStateVersion=rt,re.needsLights&&(gt.ambientLightColor.value=he.state.ambient,gt.lightProbe.value=he.state.probe,gt.directionalLights.value=he.state.directional,gt.directionalLightShadows.value=he.state.directionalShadow,gt.spotLights.value=he.state.spot,gt.spotLightShadows.value=he.state.spotShadow,gt.rectAreaLights.value=he.state.rectArea,gt.ltc_1.value=he.state.rectAreaLTC1,gt.ltc_2.value=he.state.rectAreaLTC2,gt.pointLights.value=he.state.point,gt.pointLightShadows.value=he.state.pointShadow,gt.hemisphereLights.value=he.state.hemi,gt.directionalShadowMap.value=he.state.directionalShadowMap,gt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,gt.spotShadowMap.value=he.state.spotShadowMap,gt.spotShadowMatrix.value=he.state.spotShadowMatrix,gt.pointShadowMap.value=he.state.pointShadowMap,gt.pointShadowMatrix.value=he.state.pointShadowMatrix);let kt=ht.getUniforms(),Qs=ra.seqWithValue(kt.seq,gt);return re.currentProgram=ht,re.uniformsList=Qs,ht}function mv(L,$){let ie=ce.get(L);ie.outputEncoding=$.outputEncoding,ie.instancing=$.instancing,ie.skinning=$.skinning,ie.morphTargets=$.morphTargets,ie.morphNormals=$.morphNormals,ie.morphColors=$.morphColors,ie.morphTargetsCount=$.morphTargetsCount,ie.numClippingPlanes=$.numClippingPlanes,ie.numIntersection=$.numClipIntersection,ie.vertexAlphas=$.vertexAlphas,ie.vertexTangents=$.vertexTangents,ie.toneMapping=$.toneMapping}function dM(L,$,ie,re,he){$.isScene!==!0&&($=W),ae.resetTextureUnits();let Ze=$.fog,rt=re.isMeshStandardMaterial?$.environment:null,st=w===null?p.outputEncoding:w.isXRRenderTarget===!0?w.texture.encoding:hn,it=(re.isMeshStandardMaterial?ge:fe).get(re.envMap||rt),Tt=re.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,ht=!!re.normalMap&&!!ie.attributes.tangent,gt=!!ie.morphAttributes.position,kt=!!ie.morphAttributes.normal,Qs=!!ie.morphAttributes.color,Ro=re.toneMapped?p.toneMapping:zi,Fo=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,ri=Fo!==void 0?Fo.length:0,wt=ce.get(re),zo=f.state.lights;if(X===!0&&(U===!0||L!==S)){let ii=L===S&&re.id===b;D.setState(re,L,ii)}let tr=!1;re.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==zo.state.version||wt.outputEncoding!==st||he.isInstancedMesh&&wt.instancing===!1||!he.isInstancedMesh&&wt.instancing===!0||he.isSkinnedMesh&&wt.skinning===!1||!he.isSkinnedMesh&&wt.skinning===!0||wt.envMap!==it||re.fog===!0&&wt.fog!==Ze||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==D.numPlanes||wt.numIntersection!==D.numIntersection)||wt.vertexAlphas!==Tt||wt.vertexTangents!==ht||wt.morphTargets!==gt||wt.morphNormals!==kt||wt.morphColors!==Qs||wt.toneMapping!==Ro||te.isWebGL2===!0&&wt.morphTargetsCount!==ri)&&(tr=!0):(tr=!0,wt.__version=re.version);let ni=wt.currentProgram;tr===!0&&(ni=ip(re,$,he));let es=!1,Ql=!1,sp=!1,zr=ni.getUniforms(),Kl=wt.uniforms;if(k.useProgram(ni.program)&&(es=!0,Ql=!0,sp=!0),re.id!==b&&(b=re.id,Ql=!0),es||S!==L){if(zr.setValue(q,"projectionMatrix",L.projectionMatrix),te.logarithmicDepthBuffer&&zr.setValue(q,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),S!==L&&(S=L,Ql=!0,sp=!0),re.isShaderMaterial||re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshStandardMaterial||re.envMap){let ii=zr.map.cameraPosition;ii!==void 0&&ii.setValue(q,G.setFromMatrixPosition(L.matrixWorld))}(re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshLambertMaterial||re.isMeshBasicMaterial||re.isMeshStandardMaterial||re.isShaderMaterial)&&zr.setValue(q,"isOrthographic",L.isOrthographicCamera===!0),(re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshLambertMaterial||re.isMeshBasicMaterial||re.isMeshStandardMaterial||re.isShaderMaterial||re.isShadowMaterial||he.isSkinnedMesh)&&zr.setValue(q,"viewMatrix",L.matrixWorldInverse)}if(he.isSkinnedMesh){zr.setOptional(q,he,"bindMatrix"),zr.setOptional(q,he,"bindMatrixInverse");let ii=he.skeleton;ii&&(te.floatVertexTextures?(ii.boneTexture===null&&ii.computeBoneTexture(),zr.setValue(q,"boneTexture",ii.boneTexture,ae),zr.setValue(q,"boneTextureSize",ii.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 op=ie.morphAttributes;return(op.position!==void 0||op.normal!==void 0||op.color!==void 0&&te.isWebGL2===!0)&&pe.update(he,ie,re,ni),(Ql||wt.receiveShadow!==he.receiveShadow)&&(wt.receiveShadow=he.receiveShadow,zr.setValue(q,"receiveShadow",he.receiveShadow)),Ql&&(zr.setValue(q,"toneMappingExposure",p.toneMappingExposure),wt.needsLights&&pM(Kl,sp),Ze&&re.fog===!0&&Oe.refreshFogUniforms(Kl,Ze),Oe.refreshMaterialUniforms(Kl,re,C,E,F),ra.upload(q,wt.uniformsList,Kl,ae)),re.isShaderMaterial&&re.uniformsNeedUpdate===!0&&(ra.upload(q,wt.uniformsList,Kl,ae),re.uniformsNeedUpdate=!1),re.isSpriteMaterial&&zr.setValue(q,"center",he.center),zr.setValue(q,"modelViewMatrix",he.modelViewMatrix),zr.setValue(q,"normalMatrix",he.normalMatrix),zr.setValue(q,"modelMatrix",he.matrixWorld),ni}function pM(L,$){L.ambientLightColor.needsUpdate=$,L.lightProbe.needsUpdate=$,L.directionalLights.needsUpdate=$,L.directionalLightShadows.needsUpdate=$,L.pointLights.needsUpdate=$,L.pointLightShadows.needsUpdate=$,L.spotLights.needsUpdate=$,L.spotLightShadows.needsUpdate=$,L.rectAreaLights.needsUpdate=$,L.hemisphereLights.needsUpdate=$}function mM(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return x},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(L,$,ie){ce.get(L.texture).__webglTexture=$,ce.get(L.depthTexture).__webglTexture=ie;let re=ce.get(L);re.__hasExternalTextures=!0,re.__hasExternalTextures&&(re.__autoAllocateDepthBuffer=ie===void 0,re.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),re.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,$){let ie=ce.get(L);ie.__webglFramebuffer=$,ie.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(L,$=0,ie=0){w=L,x=$,v=ie;let re=!0;if(L){let it=ce.get(L);it.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),re=!1):it.__webglFramebuffer===void 0?ae.setupRenderTarget(L):it.__hasExternalTextures&&ae.rebindTextures(L,ce.get(L.texture).__webglTexture,ce.get(L.depthTexture).__webglTexture)}let he=null,Ze=!1,rt=!1;if(L){let it=L.texture;(it.isData3DTexture||it.isDataArrayTexture)&&(rt=!0);let Tt=ce.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(he=Tt[$],Ze=!0):te.isWebGL2&&L.samples>0&&ae.useMultisampledRTT(L)===!1?he=ce.get(L).__webglMultisampledFramebuffer:he=Tt,M.copy(L.viewport),_.copy(L.scissor),y=L.scissorTest}else M.copy(N).multiplyScalar(C).floor(),_.copy(H).multiplyScalar(C).floor(),y=j;if(k.bindFramebuffer(36160,he)&&te.drawBuffers&&re&&k.drawBuffers(L,he),k.viewport(M),k.scissor(_),k.setScissorTest(y),Ze){let it=ce.get(L.texture);q.framebufferTexture2D(36160,36064,34069+$,it.__webglTexture,ie)}else if(rt){let it=ce.get(L.texture),Tt=$||0;q.framebufferTextureLayer(36160,36064,it.__webglTexture,ie||0,Tt)}b=-1},this.readRenderTargetPixels=function(L,$,ie,re,he,Ze,rt){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let st=ce.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&rt!==void 0&&(st=st[rt]),st){k.bindFramebuffer(36160,st);try{let it=L.texture,Tt=it.format,ht=it.type;if(Tt!==bn&&ne.convert(Tt)!==q.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=ht===cc&&(K.has("EXT_color_buffer_half_float")||te.isWebGL2&&K.has("EXT_color_buffer_float"));if(ht!==It&&ne.convert(ht)!==q.getParameter(35738)&&!(ht===ls&&(te.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=L.width-re&&ie>=0&&ie<=L.height-he&&q.readPixels($,ie,re,he,ne.convert(Tt),ne.convert(ht),Ze)}finally{let it=w!==null?ce.get(w).__webglFramebuffer:null;k.bindFramebuffer(36160,it)}}},this.copyFramebufferToTexture=function(L,$,ie=0){let re=Math.pow(2,-ie),he=Math.floor($.image.width*re),Ze=Math.floor($.image.height*re);ae.setTexture2D($,0),q.copyTexSubImage2D(3553,ie,0,0,L.x,L.y,he,Ze),k.unbindTexture()},this.copyTextureToTexture=function(L,$,ie,re=0){let he=$.image.width,Ze=$.image.height,rt=ne.convert(ie.format),st=ne.convert(ie.type);ae.setTexture2D(ie,0),q.pixelStorei(37440,ie.flipY),q.pixelStorei(37441,ie.premultiplyAlpha),q.pixelStorei(3317,ie.unpackAlignment),$.isDataTexture?q.texSubImage2D(3553,re,L.x,L.y,he,Ze,rt,st,$.image.data):$.isCompressedTexture?q.compressedTexSubImage2D(3553,re,L.x,L.y,$.mipmaps[0].width,$.mipmaps[0].height,rt,$.mipmaps[0].data):q.texSubImage2D(3553,re,L.x,L.y,rt,st,$.image),re===0&&ie.generateMipmaps&&q.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(L,$,ie,re,he=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ze=L.max.x-L.min.x+1,rt=L.max.y-L.min.y+1,st=L.max.z-L.min.z+1,it=ne.convert(re.format),Tt=ne.convert(re.type),ht;if(re.isData3DTexture)ae.setTexture3D(re,0),ht=32879;else if(re.isDataArrayTexture)ae.setTexture2DArray(re,0),ht=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}q.pixelStorei(37440,re.flipY),q.pixelStorei(37441,re.premultiplyAlpha),q.pixelStorei(3317,re.unpackAlignment);let gt=q.getParameter(3314),kt=q.getParameter(32878),Qs=q.getParameter(3316),Ro=q.getParameter(3315),Fo=q.getParameter(32877),ri=ie.isCompressedTexture?ie.mipmaps[0]:ie.image;q.pixelStorei(3314,ri.width),q.pixelStorei(32878,ri.height),q.pixelStorei(3316,L.min.x),q.pixelStorei(3315,L.min.y),q.pixelStorei(32877,L.min.z),ie.isDataTexture||ie.isData3DTexture?q.texSubImage3D(ht,he,$.x,$.y,$.z,Ze,rt,st,it,Tt,ri.data):ie.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),q.compressedTexSubImage3D(ht,he,$.x,$.y,$.z,Ze,rt,st,it,ri.data)):q.texSubImage3D(ht,he,$.x,$.y,$.z,Ze,rt,st,it,Tt,ri),q.pixelStorei(3314,gt),q.pixelStorei(32878,kt),q.pixelStorei(3316,Qs),q.pixelStorei(3315,Ro),q.pixelStorei(32877,Fo),he===0&&re.generateMipmaps&&q.generateMipmap(ht),k.unbindTexture()},this.initTexture=function(L){ae.setTexture2D(L,0),k.unbindTexture()},this.resetState=function(){x=0,v=0,w=null,k.reset(),Re.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var lm=class extends zu{};lm.prototype.isWebGL1Renderer=!0;var aa=class{constructor(e,t=1,r=1e3){this.isFog=!0,this.name="",this.color=new Se(e),this.near=t,this.far=r}clone(){return new aa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},un=class extends lt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,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()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},bu=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Xp,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=li()}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,r){e*=this.stride,r*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[r+i];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=li()),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]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}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=li()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ur=new A,oo=class{constructor(e,t,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=i===!0}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,r=this.data.count;t<r;t++)Ur.fromBufferAttribute(this,t),Ur.applyMatrix4(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)Ur.fromBufferAttribute(this,t),Ur.applyNormalMatrix(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)Ur.fromBufferAttribute(this,t),Ur.transformDirection(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Xe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new oo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+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}}},cm=class extends cr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Se(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var hm=class extends Xe{constructor(e,t,r,i=1){typeof r=="number"&&(i=r,r=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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}};var Zr=class extends cr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Se(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}},P0=new A,L0=new A,I0=new Be,Up=new so,tu=new Br,ao=class extends lt{constructor(e=new Le,t=new Zr){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,r=[0];for(let i=1,s=t.count;i<s;i++)P0.fromBufferAttribute(t,i-1),L0.fromBufferAttribute(t,i),r[i]=r[i-1],r[i]+=P0.distanceTo(L0);e.setAttribute("lineDistance",new Ae(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),tu.copy(r.boundingSphere),tu.applyMatrix4(i),tu.radius+=s,e.ray.intersectsSphere(tu)===!1)return;I0.copy(i).invert(),Up.copy(e.ray).applyMatrix4(I0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new A,h=new A,u=new A,f=new A,d=this.isLineSegments?2:1,m=r.index,g=r.attributes.position;if(m!==null){let x=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=d){let S=m.getX(w),M=m.getX(w+1);if(c.fromBufferAttribute(g,S),h.fromBufferAttribute(g,M),Up.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);let y=e.ray.origin.distanceTo(f);y<e.near||y>e.far||t.push({distance:y,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{let x=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=d){if(c.fromBufferAttribute(g,w),h.fromBufferAttribute(g,w+1),Up.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(f);M<e.near||M>e.far||t.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){let i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},N0=new A,B0=new A,ys=class extends ao{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,r=[];for(let i=0,s=t.count;i<s;i+=2)N0.fromBufferAttribute(t,i),B0.fromBufferAttribute(t,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+N0.distanceTo(B0);e.setAttribute("lineDistance",new Ae(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var um=class extends cr{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Se(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var wu=class extends Nt{constructor(e,t,r,i,s,o,a,l,c){super(e,t,r,i,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:et,this.magFilter=s!==void 0?s:et,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Sn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){let t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){let t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/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=[],r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let r=this.getLengths(),i=0,s=r.length,o;t?o=t:o=e*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);let h=r[i],f=r[i+1]-h,d=(o-h)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new O:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t){let r=new A,i=[],s=[],o=[],a=new A,l=new Be;for(let d=0;d<=e;d++){let m=d/e;i[d]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let c=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),u<=c&&(c=u,r.set(0,1,0)),f<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(nr(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(a,m))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(nr(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],d*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}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}},lo=class extends Sn{constructor(e=0,t=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let r=t||new O,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),f=l-this.aX,d=c-this.aY;l=f*h-d*u+this.aX,c=f*u+d*h+this.aY}return r.set(l,c)}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}},fm=class extends lo{constructor(e,t,r,i,s,o){super(e,t,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Wm(){let n=0,e=0,t=0,r=0;function i(s,o,a,l){n=s,e=a,t=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,u){let f=(o-s)/c-(a-s)/(c+h)+(a-o)/h,d=(a-o)/h-(l-o)/(h+u)+(l-a)/u;f*=h,d*=h,i(o,a,f,d)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+r*a}}}var ru=new A,Gp=new Wm,kp=new Wm,Vp=new Wm,dm=class extends Sn{constructor(e=[],t=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=r,this.tension=i}getPoint(e,t=new A){let r=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(ru.subVectors(i[0],i[1]).add(i[0]),c=ru);let u=i[a%s],f=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(ru.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=ru),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(u),d),p=Math.pow(u.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(h),d);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),Gp.initNonuniformCatmullRom(c.x,u.x,f.x,h.x,m,p,g),kp.initNonuniformCatmullRom(c.y,u.y,f.y,h.y,m,p,g),Vp.initNonuniformCatmullRom(c.z,u.z,f.z,h.z,m,p,g)}else this.curveType==="catmullrom"&&(Gp.initCatmullRom(c.x,u.x,f.x,h.x,this.tension),kp.initCatmullRom(c.y,u.y,f.y,h.y,this.tension),Vp.initCatmullRom(c.z,u.z,f.z,h.z,this.tension));return r.set(Gp.calc(l),kp.calc(l),Vp.calc(l)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(i.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,r=this.points.length;t<r;t++){let i=this.points[t];e.points.push(i.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,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function O0(n,e,t,r,i){let s=(r-e)*.5,o=(i-t)*.5,a=n*n,l=n*a;return(2*t-2*r+s+o)*l+(-3*t+3*r-2*s-o)*a+s*n+t}function mD(n,e){let t=1-n;return t*t*e}function gD(n,e){return 2*(1-n)*n*e}function yD(n,e){return n*n*e}function ac(n,e,t,r){return mD(n,e)+gD(n,t)+yD(n,r)}function vD(n,e){let t=1-n;return t*t*t*e}function xD(n,e){let t=1-n;return 3*t*t*n*e}function bD(n,e){return 3*(1-n)*n*n*e}function wD(n,e){return n*n*n*e}function lc(n,e,t,r,i){return vD(n,e)+xD(n,t)+bD(n,r)+wD(n,i)}var $r=class extends Sn{constructor(e=new O,t=new O,r=new O,i=new O){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new O){let r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(lc(e,i.x,s.x,o.x,a.x),lc(e,i.y,s.y,o.y,a.y)),r}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}},pm=class extends Sn{constructor(e=new A,t=new A,r=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new A){let r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(lc(e,i.x,s.x,o.x,a.x),lc(e,i.y,s.y,o.y,a.y),lc(e,i.z,s.z,o.z,a.z)),r}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}},en=class extends Sn{constructor(e=new O,t=new O){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new O){let r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let r=t||new O;return r.copy(this.v2).sub(this.v1).normalize(),r}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}},dc=class extends Sn{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){let r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}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}},kn=class extends Sn{constructor(e=new O,t=new O,r=new O){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new O){let r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(ac(e,i.x,s.x,o.x),ac(e,i.y,s.y,o.y)),r}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}},mm=class extends Sn{constructor(e=new A,t=new A,r=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new A){let r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(ac(e,i.x,s.x,o.x),ac(e,i.y,s.y,o.y),ac(e,i.z,s.z,o.z)),r}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}},la=class extends Sn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new O){let r=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return r.set(O0(a,l.x,c.x,h.x,u.x),O0(a,l.y,c.y,h.y,u.y)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,r=this.points.length;t<r;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(new O().fromArray(i))}return this}},SD=Object.freeze({__proto__:null,ArcCurve:fm,CatmullRomCurve3:dm,CubicBezierCurve:$r,CubicBezierCurve3:pm,EllipseCurve:lo,LineCurve:en,LineCurve3:dc,QuadraticBezierCurve:kn,QuadraticBezierCurve3:mm,SplineCurve:la}),gm=class extends Sn{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 en(t,e))}getPoint(e,t){let r=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=r){let o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,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 r=0,i=this.curves.length;r<i;r++)t+=this.curves[r].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],r;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let h=l[c];r&&r.equals(h)||(t.push(h),r=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,r=e.curves.length;t<r;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,r=this.curves.length;t<r;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,r=e.curves.length;t<r;t++){let i=e.curves[t];this.curves.push(new SD[i.type]().fromJSON(i))}return this}},pc=class extends gm{constructor(e){super(),this.type="Path",this.currentPoint=new O,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,r=e.length;t<r;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 r=new en(this.currentPoint.clone(),new O(e,t));return this.curves.push(r),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,r,i){let s=new kn(this.currentPoint.clone(),new O(e,t),new O(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(e,t,r,i,s,o){let a=new $r(this.currentPoint.clone(),new O(e,t),new O(r,i),new O(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),r=new la(t);return this.curves.push(r),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,r,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,r,i,s,o),this}absarc(e,t,r,i,s,o){return this.absellipse(e,t,r,r,i,s,o),this}ellipse(e,t,r,i,s,o,a,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,r,i,s,o,a,l),this}absellipse(e,t,r,i,s,o,a,l){let c=new lo(e,t,r,i,s,o,a,l);if(this.curves.length>0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let h=c.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}},ca=class extends Le{constructor(e=[new O(0,.5),new O(.5,0),new O(0,-.5)],t=12,r=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:i},t=Math.floor(t),i=nr(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],h=1/t,u=new A,f=new O,d=new A,m=new A,p=new A,g=0,x=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,d.x=x*1,d.y=-g,d.z=x*0,p.copy(d),d.normalize(),l.push(d.x,d.y,d.z);break;case e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,d.x=x*1,d.y=-g,d.z=x*0,m.copy(d),d.x+=p.x,d.y+=p.y,d.z+=p.z,d.normalize(),l.push(d.x,d.y,d.z),p.copy(m)}for(let v=0;v<=t;v++){let w=r+v*h*i,b=Math.sin(w),S=Math.cos(w);for(let M=0;M<=e.length-1;M++){u.x=e[M].x*b,u.y=e[M].y,u.z=e[M].x*S,o.push(u.x,u.y,u.z),f.x=v/t,f.y=M/(e.length-1),a.push(f.x,f.y);let _=l[3*M+0]*b,y=l[3*M+1],T=l[3*M+0]*S;c.push(_,y,T)}}for(let v=0;v<t;v++)for(let w=0;w<e.length-1;w++){let b=w+v*e.length,S=b,M=b+e.length,_=b+e.length+1,y=b+1;s.push(S,M,y),s.push(_,y,M)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(c,3))}static fromJSON(e){return new ca(e.points,e.segments,e.phiStart,e.phiLength)}};var co=class extends Le{constructor(e=1,t=1,r=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let h=[],u=[],f=[],d=[],m=0,p=[],g=r/2,x=0;v(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(f,3)),this.setAttribute("uv",new Ae(d,2));function v(){let b=new A,S=new A,M=0,_=(t-e)/r;for(let y=0;y<=s;y++){let T=[],E=y/s,C=E*(t-e)+e;for(let I=0;I<=i;I++){let B=I/i,N=B*l+a,H=Math.sin(N),j=Math.cos(N);S.x=C*H,S.y=-E*r+g,S.z=C*j,u.push(S.x,S.y,S.z),b.set(H,_,j).normalize(),f.push(b.x,b.y,b.z),d.push(B,1-E),T.push(m++)}p.push(T)}for(let y=0;y<i;y++)for(let T=0;T<s;T++){let E=p[T][y],C=p[T+1][y],I=p[T+1][y+1],B=p[T][y+1];h.push(E,C,B),h.push(C,I,B),M+=6}c.addGroup(x,M,0),x+=M}function w(b){let S=m,M=new O,_=new A,y=0,T=b===!0?e:t,E=b===!0?1:-1;for(let I=1;I<=i;I++)u.push(0,g*E,0),f.push(0,E,0),d.push(.5,.5),m++;let C=m;for(let I=0;I<=i;I++){let N=I/i*l+a,H=Math.cos(N),j=Math.sin(N);_.x=T*j,_.y=g*E,_.z=T*H,u.push(_.x,_.y,_.z),f.push(0,E,0),M.x=H*.5+.5,M.y=j*.5*E+.5,d.push(M.x,M.y),m++}for(let I=0;I<i;I++){let B=S+I,N=C+I;b===!0?h.push(N,N+1,B):h.push(N+1,N,B),y+=3}c.addGroup(x,y,b===!0?1:2),x+=y}}static fromJSON(e){return new co(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ha=class extends co{constructor(e=1,t=1,r=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,r,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new ha(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ua=class extends Le{constructor(e=[],t=[],r=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:i};let s=[],o=[];a(i),c(r),h(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let w=new A,b=new A,S=new A;for(let M=0;M<t.length;M+=3)d(t[M+0],w),d(t[M+1],b),d(t[M+2],S),l(w,b,S,v)}function l(v,w,b,S){let M=S+1,_=[];for(let y=0;y<=M;y++){_[y]=[];let T=v.clone().lerp(b,y/M),E=w.clone().lerp(b,y/M),C=M-y;for(let I=0;I<=C;I++)I===0&&y===M?_[y][I]=T:_[y][I]=T.clone().lerp(E,I/C)}for(let y=0;y<M;y++)for(let T=0;T<2*(M-y)-1;T++){let E=Math.floor(T/2);T%2===0?(f(_[y][E+1]),f(_[y+1][E]),f(_[y][E])):(f(_[y][E+1]),f(_[y+1][E+1]),f(_[y+1][E]))}}function c(v){let w=new A;for(let b=0;b<s.length;b+=3)w.x=s[b+0],w.y=s[b+1],w.z=s[b+2],w.normalize().multiplyScalar(v),s[b+0]=w.x,s[b+1]=w.y,s[b+2]=w.z}function h(){let v=new A;for(let w=0;w<s.length;w+=3){v.x=s[w+0],v.y=s[w+1],v.z=s[w+2];let b=g(v)/2/Math.PI+.5,S=x(v)/Math.PI+.5;o.push(b,1-S)}m(),u()}function u(){for(let v=0;v<o.length;v+=6){let w=o[v+0],b=o[v+2],S=o[v+4],M=Math.max(w,b,S),_=Math.min(w,b,S);M>.9&&_<.1&&(w<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function f(v){s.push(v.x,v.y,v.z)}function d(v,w){let b=v*3;w.x=e[b+0],w.y=e[b+1],w.z=e[b+2]}function m(){let v=new A,w=new A,b=new A,S=new A,M=new O,_=new O,y=new O;for(let T=0,E=0;T<s.length;T+=9,E+=6){v.set(s[T+0],s[T+1],s[T+2]),w.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),M.set(o[E+0],o[E+1]),_.set(o[E+2],o[E+3]),y.set(o[E+4],o[E+5]),S.copy(v).add(w).add(b).divideScalar(3);let C=g(S);p(M,E+0,v,C),p(_,E+2,w,C),p(y,E+4,b,C)}}function p(v,w,b,S){S<0&&v.x===1&&(o[w]=v.x-1),b.x===0&&b.z===0&&(o[w]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function x(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new ua(e.vertices,e.indices,e.radius,e.details)}},fa=class extends ua{constructor(e=1,t=0){let r=(1+Math.sqrt(5))/2,i=1/r,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fa(e.radius,e.detail)}},tU=new A,rU=new A,nU=new A,iU=new Qr;var Fn=class extends pc{constructor(e){super(e),this.uuid=li(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let r=0,i=this.holes.length;r<i;r++)t[r]=this.holes[r].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,r=e.holes.length;t<r;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,r=this.holes.length;t<r;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,r=e.holes.length;t<r;t++){let i=e.holes[t];this.holes.push(new pc().fromJSON(i))}return this}},AD={triangulate:function(n,e,t=2){let r=e&&e.length,i=r?e[0]*t:n.length,s=lx(n,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,h,u,f,d;if(r&&(s=CD(n,e,s,t)),n.length>80*t){a=c=n[0],l=h=n[1];for(let m=t;m<i;m+=t)u=n[m],f=n[m+1],u<a&&(a=u),f<l&&(l=f),u>c&&(c=u),f>h&&(h=f);d=Math.max(c-a,h-l),d=d!==0?1/d:0}return mc(s,o,t,a,l,d),o}};function lx(n,e,t,r,i){let s,o;if(i===UD(n,e,t,r)>0)for(s=e;s<t;s+=r)o=R0(s,n[s],n[s+1],o);else for(s=t-r;s>=e;s-=r)o=R0(s,n[s],n[s+1],o);return o&&Uu(o,o.next)&&(yc(o),o=o.next),o}function vs(n,e){if(!n)return n;e||(e=n);let t=n,r;do if(r=!1,!t.steiner&&(Uu(t,t.next)||Ut(t.prev,t,t.next)===0)){if(yc(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function mc(n,e,t,r,i,s,o){if(!n)return;!o&&s&&ND(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?_D(n,r,i,s):MD(n)){e.push(l.i/t),e.push(n.i/t),e.push(c.i/t),yc(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=TD(vs(n),e,t),mc(n,e,t,r,i,s,2)):o===2&&ED(n,e,t,r,i,s):mc(vs(n),e,t,r,i,s,1);break}}}function MD(n){let e=n.prev,t=n,r=n.next;if(Ut(e,t,r)>=0)return!1;let i=n.next.next;for(;i!==n.prev;){if(ta(e.x,e.y,t.x,t.y,r.x,r.y,i.x,i.y)&&Ut(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function _D(n,e,t,r){let i=n.prev,s=n,o=n.next;if(Ut(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,c=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,h=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,u=ym(a,l,e,t,r),f=ym(c,h,e,t,r),d=n.prevZ,m=n.nextZ;for(;d&&d.z>=u&&m&&m.z<=f;){if(d!==n.prev&&d!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ut(d.prev,d,d.next)>=0||(d=d.prevZ,m!==n.prev&&m!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Ut(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;d&&d.z>=u;){if(d!==n.prev&&d!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ut(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;m&&m.z<=f;){if(m!==n.prev&&m!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Ut(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function TD(n,e,t){let r=n;do{let i=r.prev,s=r.next.next;!Uu(i,s)&&cx(i,r,r.next,s)&&gc(i,s)&&gc(s,i)&&(e.push(i.i/t),e.push(r.i/t),e.push(s.i/t),yc(r),yc(r.next),r=n=s),r=r.next}while(r!==n);return vs(r)}function ED(n,e,t,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&RD(o,a)){let l=hx(o,a);o=vs(o,o.next),l=vs(l,l.next),mc(o,e,t,r,i,s),mc(l,e,t,r,i,s);return}a=a.next}o=o.next}while(o!==n)}function CD(n,e,t,r){let i=[],s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*r,l=s<o-1?e[s+1]*r:n.length,c=lx(n,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(OD(c));for(i.sort(DD),s=0;s<i.length;s++)PD(i[s],t),t=vs(t,t.next);return t}function DD(n,e){return n.x-e.x}function PD(n,e){if(e=LD(n,e),e){let t=hx(e,n);vs(e,e.next),vs(t,t.next)}}function LD(n,e){let t=e,r=n.x,i=n.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>s){if(s=f,f===r){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(r===s)return o;let a=o,l=o.x,c=o.y,h=1/0,u;t=o;do r>=t.x&&t.x>=l&&r!==t.x&&ta(i<c?r:s,i,l,c,i<c?s:r,i,t.x,t.y)&&(u=Math.abs(i-t.y)/(r-t.x),gc(t,n)&&(u<h||u===h&&(t.x>o.x||t.x===o.x&&ID(o,t)))&&(o=t,h=u)),t=t.next;while(t!==a);return o}function ID(n,e){return Ut(n.prev,n,e.prev)<0&&Ut(e.next,n,n.next)<0}function ND(n,e,t,r){let i=n;do i.z===null&&(i.z=ym(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,BD(i)}function BD(n){let e,t,r,i,s,o,a,l,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,r=t,a=0,e=0;e<c&&(a++,r=r.nextZ,!!r);e++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||t.z<=r.z)?(i=t,t=t.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;t=r}s.nextZ=null,c*=2}while(o>1);return n}function ym(n,e,t,r,i){return n=32767*(n-t)*i,e=32767*(e-r)*i,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function OD(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function ta(n,e,t,r,i,s,o,a){return(i-o)*(e-a)-(n-o)*(s-a)>=0&&(n-o)*(r-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(r-a)>=0}function RD(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!FD(n,e)&&(gc(n,e)&&gc(e,n)&&zD(n,e)&&(Ut(n.prev,n,e.prev)||Ut(n,e.prev,e))||Uu(n,e)&&Ut(n.prev,n,n.next)>0&&Ut(e.prev,e,e.next)>0)}function Ut(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Uu(n,e){return n.x===e.x&&n.y===e.y}function cx(n,e,t,r){let i=iu(Ut(n,e,t)),s=iu(Ut(n,e,r)),o=iu(Ut(t,r,n)),a=iu(Ut(t,r,e));return!!(i!==s&&o!==a||i===0&&nu(n,t,e)||s===0&&nu(n,r,e)||o===0&&nu(t,n,r)||a===0&&nu(t,e,r))}function nu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function iu(n){return n>0?1:n<0?-1:0}function FD(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&cx(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function gc(n,e){return Ut(n.prev,n,n.next)<0?Ut(n,e,n.next)>=0&&Ut(n,n.prev,e)>=0:Ut(n,e,n.prev)<0||Ut(n,n.next,e)<0}function zD(n,e){let t=n,r=!1,i=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==n);return r}function hx(n,e){let t=new vm(n.i,n.x,n.y),r=new vm(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function R0(n,e,t,r){let i=new vm(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function yc(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function vm(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function UD(n,e,t,r){let i=0;for(let s=e,o=t-r;s<t;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}var fs=class{static area(e){let t=e.length,r=0;for(let i=t-1,s=0;s<t;i=s++)r+=e[i].x*e[s].y-e[s].x*e[i].y;return r*.5}static isClockWise(e){return fs.area(e)<0}static triangulateShape(e,t){let r=[],i=[],s=[];F0(e),z0(r,e);let o=e.length;t.forEach(F0);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,z0(r,t[l]);let a=AD.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function F0(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function z0(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var da=class extends ua{constructor(e=1,t=0){let r=(1+Math.sqrt(5))/2,i=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new da(e.radius,e.detail)}};var pa=class extends Le{constructor(e=new Fn([new O(0,.5),new O(-.5,-.5),new O(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let r=[],i=[],s=[],o=[],a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new Ae(i,3)),this.setAttribute("normal",new Ae(s,3)),this.setAttribute("uv",new Ae(o,2));function c(h){let u=i.length/3,f=h.extractPoints(t),d=f.shape,m=f.holes;fs.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,x=m.length;g<x;g++){let v=m[g];fs.isClockWise(v)===!0&&(m[g]=v.reverse())}let p=fs.triangulateShape(d,m);for(let g=0,x=m.length;g<x;g++){let v=m[g];d=d.concat(v)}for(let g=0,x=d.length;g<x;g++){let v=d[g];i.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let g=0,x=p.length;g<x;g++){let v=p[g],w=v[0]+u,b=v[1]+u,S=v[2]+u;r.push(w,b,S),l+=3}}}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return GD(t,e)}static fromJSON(e,t){let r=[];for(let i=0,s=e.shapes.length;i<s;i++){let o=t[e.shapes[i]];r.push(o)}return new pa(r,e.curveSegments)}};function GD(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let i=n[t];e.shapes.push(i.uuid)}else e.shapes.push(n.uuid);return e}var ho=class extends Le{constructor(e=1,t=32,r=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),c=0,h=[],u=new A,f=new A,d=[],m=[],p=[],g=[];for(let x=0;x<=r;x++){let v=[],w=x/r,b=0;x==0&&o==0?b=.5/t:x==r&&l==Math.PI&&(b=-.5/t);for(let S=0;S<=t;S++){let M=S/t;u.x=-e*Math.cos(i+M*s)*Math.sin(o+w*a),u.y=e*Math.cos(o+w*a),u.z=e*Math.sin(i+M*s)*Math.sin(o+w*a),m.push(u.x,u.y,u.z),f.copy(u).normalize(),p.push(f.x,f.y,f.z),g.push(M+b,1-w),v.push(c++)}h.push(v)}for(let x=0;x<r;x++)for(let v=0;v<t;v++){let w=h[x][v+1],b=h[x][v],S=h[x+1][v],M=h[x+1][v+1];(x!==0||o>0)&&d.push(w,b,M),(x!==r-1||l<Math.PI)&&d.push(b,S,M)}this.setIndex(d),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(e){return new ho(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var ma=class extends Le{constructor(e=1,t=.4,r=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:r,radialSegments:i,p:s,q:o},r=Math.floor(r),i=Math.floor(i);let a=[],l=[],c=[],h=[],u=new A,f=new A,d=new A,m=new A,p=new A,g=new A,x=new A;for(let w=0;w<=r;++w){let b=w/r*s*Math.PI*2;v(b,s,o,e,d),v(b+.01,s,o,e,m),g.subVectors(m,d),x.addVectors(m,d),p.crossVectors(g,x),x.crossVectors(p,g),p.normalize(),x.normalize();for(let S=0;S<=i;++S){let M=S/i*Math.PI*2,_=-t*Math.cos(M),y=t*Math.sin(M);u.x=d.x+(_*x.x+y*p.x),u.y=d.y+(_*x.y+y*p.y),u.z=d.z+(_*x.z+y*p.z),l.push(u.x,u.y,u.z),f.subVectors(u,d).normalize(),c.push(f.x,f.y,f.z),h.push(w/r),h.push(S/i)}}for(let w=1;w<=r;w++)for(let b=1;b<=i;b++){let S=(i+1)*(w-1)+(b-1),M=(i+1)*w+(b-1),_=(i+1)*w+b,y=(i+1)*(w-1)+b;a.push(S,M,y),a.push(M,_,y)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(h,2));function v(w,b,S,M,_){let y=Math.cos(w),T=Math.sin(w),E=S/b*w,C=Math.cos(E);_.x=M*(2+C)*.5*y,_.y=M*(2+C)*T*.5,_.z=M*Math.sin(E)*.5}}static fromJSON(e){return new ma(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var xm=class extends cr{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Se(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},bm=class extends vt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Su=class extends cr{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Se(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},wm=class extends Su{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new O(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return nr(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Se(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Se(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Se(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Sm=class extends cr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Se(16777215),this.specular=new Se(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ru,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Am=class extends cr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Se(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Mm=class extends cr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},_m=class extends cr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Se(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ru,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Tm=class extends cr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Se(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Em=class extends Zr{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}},kD={ShadowMaterial:xm,SpriteMaterial:cm,RawShaderMaterial:bm,ShaderMaterial:vt,PointsMaterial:um,MeshPhysicalMaterial:wm,MeshStandardMaterial:Su,MeshPhongMaterial:Sm,MeshToonMaterial:Am,MeshNormalMaterial:Mm,MeshLambertMaterial:_m,MeshDepthMaterial:vu,MeshDistanceMaterial:xu,MeshBasicMaterial:Un,MeshMatcapMaterial:Tm,LineDashedMaterial:Em,LineBasicMaterial:Zr,Material:cr};cr.fromType=function(n){return new kD[n]};var lr={arraySlice:function(n,e,t){return lr.isTypedArray(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)},convertArray:function(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)},isTypedArray:function(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)},getKeyframeOrder:function(n){function e(i,s){return n[i]-n[s]}let t=n.length,r=new Array(t);for(let i=0;i!==t;++i)r[i]=i;return r.sort(e),r},sortedArray:function(n,e,t){let r=n.length,i=new n.constructor(r);for(let s=0,o=0;o!==r;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=n[a+l]}return i},flattenJSON:function(n,e,t,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(e.push(s.time),t.push(o)),s=n[i++];while(s!==void 0)},subclip:function(n,e,t,r,i=30){let s=n.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],h=c.getValueSize(),u=[],f=[];for(let d=0;d<c.times.length;++d){let m=c.times[d]*i;if(!(m<t||m>=r)){u.push(c.times[d]);for(let p=0;p<h;++p)f.push(c.values[d*h+p])}}u.length!==0&&(c.times=lr.convertArray(u,c.times.constructor),c.values=lr.convertArray(f,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(n,e=0,t=n,r=30){r<=0&&(r=30);let i=t.tracks.length,s=e/r;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let c=n.tracks.find(function(x){return x.name===a.name&&x.ValueTypeName===l});if(c===void 0)continue;let h=0,u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let f=0,d=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let m=a.times.length-1,p;if(s<=a.times[0]){let x=h,v=u-h;p=lr.arraySlice(a.values,x,v)}else if(s>=a.times[m]){let x=m*u+h,v=x+u-h;p=lr.arraySlice(a.values,x,v)}else{let x=a.createInterpolant(),v=h,w=u-h;x.evaluate(s),p=lr.arraySlice(x.resultBuffer,v,w)}l==="quaternion"&&new jt().fromArray(p).normalize().conjugate().toArray(p);let g=c.times.length;for(let x=0;x<g;++x){let v=x*d+f;if(l==="quaternion")jt.multiplyQuaternionsFlat(c.values,v,p,0,c.values,v);else{let w=d-f*2;for(let b=0;b<w;++b)c.values[v+b]-=p[b]}}}return n.blendMode=p_,n}},ga=class{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,r=this._cachedIndex,i=t[r],s=t[r-1];r:{e:{let o;t:{n:if(!(e<i)){for(let a=r+2;;){if(i===void 0){if(e<s)break n;return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=i,i=t[++r],e<i)break e}o=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=t[--r-1],e>=s)break e}o=r,r=0;break t}break r}for(;r<o;){let a=r+o>>>1;e<t[a]?o=a:r=a+1}if(i=t[r],s=t[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=r[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Cm=class extends ga{constructor(e,t,r,i){super(e,t,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Yv,endingEnd:Yv}}intervalChanged_(e,t,r){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Xv:s=e,a=2*t-r;break;case Jv:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case Xv:o=e,l=2*r-t;break;case Jv:o=1,l=r+i[1]-i[0];break;default:o=e-1,l=t}let c=(r-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-r),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(e,t,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,m=(r-t)/(i-t),p=m*m,g=p*m,x=-f*g+2*f*p-f*m,v=(1+f)*g+(-1.5-2*f)*p+(-.5+f)*m+1,w=(-1-d)*g+(1.5+d)*p+.5*m,b=d*g-d*p;for(let S=0;S!==a;++S)s[S]=x*o[h+S]+v*o[c+S]+w*o[l+S]+b*o[u+S];return s}},Dm=class extends ga{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(r-t)/(i-t),u=1-h;for(let f=0;f!==a;++f)s[f]=o[c+f]*u+o[l+f]*h;return s}},Pm=class extends ga{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Vn=class{constructor(e,t,r,i){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=lr.convertArray(t,this.TimeBufferType),this.values=lr.convertArray(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:lr.convertArray(e.times,Array),values:lr.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(r.interpolation=i)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new Pm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Cm(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case cu:t=this.InterpolantFactoryMethodDiscrete;break;case hu:t=this.InterpolantFactoryMethodLinear;break;case fp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let r="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(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return cu;case this.InterpolantFactoryMethodLinear:return hu;case this.InterpolantFactoryMethodSmooth:return fp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]*=e}return this}trim(e,t){let r=this.times,i=r.length,s=0,o=i-1;for(;s!==i&&r[s]<e;)++s;for(;o!==-1&&r[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=lr.arraySlice(r,s,o),this.values=lr.arraySlice(this.values,s*a,o*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 r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&lr.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=lr.arraySlice(this.times),t=lr.arraySlice(this.values),r=this.getValueSize(),i=this.getInterpolation()===fp,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(i)l=!0;else{let u=a*r,f=u-r,d=u+r;for(let m=0;m!==r;++m){let p=t[u+m];if(p!==t[f+m]||p!==t[d+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let u=a*r,f=o*r;for(let d=0;d!==r;++d)t[f+d]=t[u+d]}++o}}if(s>0){e[o]=e[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=lr.arraySlice(e,0,o),this.values=lr.arraySlice(t,0,o*r)):(this.times=e,this.values=t),this}clone(){let e=lr.arraySlice(this.times,0),t=lr.arraySlice(this.values,0),r=this.constructor,i=new r(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Vn.prototype.TimeBufferType=Float32Array;Vn.prototype.ValueBufferType=Float32Array;Vn.prototype.DefaultInterpolation=hu;var uo=class extends Vn{};uo.prototype.ValueTypeName="bool";uo.prototype.ValueBufferType=Array;uo.prototype.DefaultInterpolation=cu;uo.prototype.InterpolantFactoryMethodLinear=void 0;uo.prototype.InterpolantFactoryMethodSmooth=void 0;var Lm=class extends Vn{};Lm.prototype.ValueTypeName="color";var Im=class extends Vn{};Im.prototype.ValueTypeName="number";var Nm=class extends ga{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-t)/(i-t),c=e*a;for(let h=c+a;c!==h;c+=4)jt.slerpFlat(s,0,o,c-a,o,c,l);return s}},vc=class extends Vn{InterpolantFactoryMethodLinear(e){return new Nm(this.times,this.values,this.getValueSize(),e)}};vc.prototype.ValueTypeName="quaternion";vc.prototype.DefaultInterpolation=hu;vc.prototype.InterpolantFactoryMethodSmooth=void 0;var fo=class extends Vn{};fo.prototype.ValueTypeName="string";fo.prototype.ValueBufferType=Array;fo.prototype.DefaultInterpolation=cu;fo.prototype.InterpolantFactoryMethodLinear=void 0;fo.prototype.InterpolantFactoryMethodSmooth=void 0;var Bm=class extends Vn{};Bm.prototype.ValueTypeName="vector";var U0={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},po=class{constructor(e,t,r){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u<f;u+=2){let d=c[u],m=c[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return m}return null}}},VD=new po,xs=class{constructor(e){this.manager=e!==void 0?e:VD,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let r=this;return new Promise(function(i,s){r.load(e,i,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}},Oi={},bs=class extends xs{constructor(e){super(e)}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=U0.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Oi[e]!==void 0){Oi[e].push({onLoad:t,onProgress:r,onError:i});return}Oi[e]=[],Oi[e].push({onLoad:t,onProgress:r,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Oi[e],u=c.body.getReader(),f=c.headers.get("Content-Length"),d=f?parseInt(f):0,m=d!==0,p=0,g=new ReadableStream({start(x){v();function v(){u.read().then(({done:w,value:b})=>{if(w)x.close();else{p+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:d});for(let M=0,_=h.length;M<_;M++){let y=h[M];y.onProgress&&y.onProgress(S)}x.enqueue(b),v()}})}}});return new Response(g)}else throw Error(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(m=>d.decode(m))}}}).then(c=>{U0.add(e,c);let h=Oi[e];delete Oi[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onLoad&&d.onLoad(c)}}).catch(c=>{let h=Oi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Oi[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onError&&d.onError(c)}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}};var ws=class extends lt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Se(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}},mo=class extends ws{constructor(e,t,r){super(e,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(lt.DefaultUp),this.updateMatrix(),this.groundColor=new Se(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},G0=new Be,k0=new A,V0=new A,xc=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new O(512,512),this.map=null,this.mapPass=null,this.matrix=new Be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fc,this._frameExtents=new O(1,1),this._viewportCount=1,this._viewports=[new Ke(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,r=this.matrix;k0.setFromMatrixPosition(e.matrixWorld),t.position.copy(k0),V0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(V0),t.updateMatrixWorld(),G0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(G0),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(t.projectionMatrix),r.multiply(t.matrixWorldInverse)}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}},Om=class extends xc{constructor(){super(new Jt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,r=hc*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Au=class extends ws{constructor(e,t,r=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(lt.DefaultUp),this.updateMatrix(),this.target=new lt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Om}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}},H0=new Be,tc=new A,Hp=new A,Rm=class extends xc{constructor(){super(new Jt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new O(4,2),this._viewportCount=6,this._viewports=[new Ke(2,1,1,1),new Ke(0,1,1,1),new Ke(3,1,1,1),new Ke(1,1,1,1),new Ke(3,0,1,1),new Ke(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(e,t=0){let r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),tc.setFromMatrixPosition(e.matrixWorld),r.position.copy(tc),Hp.copy(r.position),Hp.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Hp),r.updateMatrixWorld(),i.makeTranslation(-tc.x,-tc.y,-tc.z),H0.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(H0)}},Mu=class extends ws{constructor(e,t,r=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Rm}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}},Fm=class extends xc{constructor(){super(new oa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},_u=class extends ws{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(lt.DefaultUp),this.updateMatrix(),this.target=new lt,this.shadow=new Fm}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var zm=class extends Le{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Ss=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},r,i)}parse(e){let t={},r={};function i(d,m){if(t[m]!==void 0)return t[m];let g=d.interleavedBuffers[m],x=s(d,g.buffer),v=Bh(g.type,x),w=new bu(v,g.stride);return w.uuid=g.uuid,t[m]=w,w}function s(d,m){if(r[m]!==void 0)return r[m];let g=d.arrayBuffers[m],x=new Uint32Array(g).buffer;return r[m]=x,x}let o=e.isInstancedBufferGeometry?new zm:new Le,a=e.data.index;if(a!==void 0){let d=Bh(a.type,a.array);o.setIndex(new Xe(d,1))}let l=e.data.attributes;for(let d in l){let m=l[d],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new oo(g,m.itemSize,m.offset,m.normalized)}else{let g=Bh(m.type,m.array),x=m.isInstancedBufferAttribute?hm:Xe;p=new x(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(d,p)}let c=e.data.morphAttributes;if(c)for(let d in c){let m=c[d],p=[];for(let g=0,x=m.length;g<x;g++){let v=m[g],w;if(v.isInterleavedBufferAttribute){let b=i(e.data,v.data);w=new oo(b,v.itemSize,v.offset,v.normalized)}else{let b=Bh(v.type,v.array);w=new Xe(b,v.itemSize,v.normalized)}v.name!==void 0&&(w.name=v.name),p.push(w)}o.morphAttributes[d]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,m=u.length;d!==m;++d){let p=u[d];o.addGroup(p.start,p.count,p.materialIndex)}let f=e.data.boundingSphere;if(f!==void 0){let d=new A;f.center!==void 0&&d.fromArray(f.center),o.boundingSphere=new Br(d,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var Tu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=W0(),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=W0();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function W0(){return(typeof performance>"u"?Date:performance).now()}var jm="\\[\\]\\.:\\/",HD=new RegExp("["+jm+"]","g"),qm="[^"+jm+"]",WD="[^"+jm.replace("\\.","")+"]",jD=/((?:WC+[\/:])*)/.source.replace("WC",qm),qD=/(WCOD+)?/.source.replace("WCOD",WD),YD=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",qm),XD=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",qm),JD=new RegExp("^"+jD+qD+YD+XD+"$"),QD=["material","materials","bones"],Um=class{constructor(e,t,r){let i=r||St.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,t)}setValue(e,t){let r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}},St=class{constructor(e,t,r){this.path=t,this.parsedPath=r||St.parseTrackName(t),this.node=St.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new St.Composite(e,t,r):new St(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(HD,"")}static parseTrackName(e){let t=JD.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=r.nodeName.substring(i+1);QD.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=r(a.children);if(l)return l}return null},i=r(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)e[t++]=r[i]}_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 r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=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,r=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=St.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(r){let c=t.objectIndex;switch(r){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===c){c=h;break}break;default:if(e[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[r]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[i];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" 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 l=this.BindingType.Direct;if(s!==void 0){if(i==="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])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};St.Composite=Um;St.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};St.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};St.prototype.GetterByBindingType=[St.prototype._getValue_direct,St.prototype._getValue_array,St.prototype._getValue_arrayElement,St.prototype._getValue_toArray];St.prototype.SetterByBindingTypeAndVersioning=[[St.prototype._setValue_direct,St.prototype._setValue_direct_setNeedsUpdate,St.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[St.prototype._setValue_array,St.prototype._setValue_array_setNeedsUpdate,St.prototype._setValue_array_setMatrixWorldNeedsUpdate],[St.prototype._setValue_arrayElement,St.prototype._setValue_arrayElement_setNeedsUpdate,St.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[St.prototype._setValue_fromArray,St.prototype._setValue_fromArray_setNeedsUpdate,St.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var we=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new we(this.value.clone===void 0?this.value:this.value.clone())}};var Eu=class{constructor(e,t,r=0,i=1/0){this.ray=new so(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new uc,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,r=[]){return Gm(e,this,r,t),r.sort(j0),r}intersectObjects(e,t=!0,r=[]){for(let i=0,s=e.length;i<s;i++)Gm(e[i],this,r,t);return r.sort(j0),r}};function j0(n,e){return n.distance-e.distance}function Gm(n,e,t,r){if(n.layers.test(e.layers)&&n.raycast(e,t),r===!0){let i=n.children;for(let s=0,o=i.length;s<o;s++)Gm(i[s],e,t,!0)}}var bc=class{constructor(e=1,t=0,r=0){return this.radius=e,this.phi=t,this.theta=r,this}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,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,r){return this.radius=Math.sqrt(e*e+t*t+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(nr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var q0=new A,su=new A,Cu=class{constructor(e=new A,t=new A){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){q0.subVectors(e,this.start),su.subVectors(this.end,this.start);let r=su.dot(su),s=su.dot(q0)/r;return t&&(s=nr(s,0,1)),s}closestPointToPoint(e,t,r){let i=this.closestPointToPointParameter(e,t);return this.delta(r).multiplyScalar(i).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)}},Y0=new A,Du=class extends lt{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let r=new Le,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,h=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}r.setAttribute("position",new Ae(i,3));let s=new Zr({fog:!1,toneMapped:!1});this.cone=new ys(r,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Y0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Y0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Pu=class extends ir{constructor(e,t,r){let i=new ho(t,4,2),s=new Un({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var X0=new A,ou=new A,J0=new A,Lu=class extends lt{constructor(e,t,r){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,t===void 0&&(t=1);let i=new Le;i.setAttribute("position",new Ae([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Zr({fog:!1,toneMapped:!1});this.lightPlane=new ao(i,s),this.add(this.lightPlane),i=new Le,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new ao(i,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(){X0.setFromMatrixPosition(this.light.matrixWorld),ou.setFromMatrixPosition(this.light.target.matrixWorld),J0.subVectors(ou,X0),this.lightPlane.lookAt(ou),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(ou),this.targetLine.scale.z=J0.length()}},au=new A,Vt=new Gn,An=class extends ys{constructor(e){let t=new Le,r=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={},a=new Se(16755200),l=new Se(16711680),c=new Se(43775),h=new Se(16777215),u=new Se(3355443);f("n1","n2",a),f("n2","n4",a),f("n4","n3",a),f("n3","n1",a),f("f1","f2",a),f("f2","f4",a),f("f4","f3",a),f("f3","f1",a),f("n1","f1",a),f("n2","f2",a),f("n3","f3",a),f("n4","f4",a),f("p","n1",l),f("p","n2",l),f("p","n3",l),f("p","n4",l),f("u1","u2",c),f("u2","u3",c),f("u3","u1",c),f("c","t",h),f("p","c",u),f("cn1","cn2",u),f("cn3","cn4",u),f("cf1","cf2",u),f("cf3","cf4",u);function f(m,p,g){d(m,g),d(p,g)}function d(m,p){i.push(0,0,0),s.push(p.r,p.g,p.b),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Ae(i,3)),t.setAttribute("color",new Ae(s,3)),super(t,r),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){let e=this.geometry,t=this.pointMap,r=1,i=1;Vt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Xt("c",t,e,Vt,0,0,-1),Xt("t",t,e,Vt,0,0,1),Xt("n1",t,e,Vt,-r,-i,-1),Xt("n2",t,e,Vt,r,-i,-1),Xt("n3",t,e,Vt,-r,i,-1),Xt("n4",t,e,Vt,r,i,-1),Xt("f1",t,e,Vt,-r,-i,1),Xt("f2",t,e,Vt,r,-i,1),Xt("f3",t,e,Vt,-r,i,1),Xt("f4",t,e,Vt,r,i,1),Xt("u1",t,e,Vt,r*.7,i*1.1,-1),Xt("u2",t,e,Vt,-r*.7,i*1.1,-1),Xt("u3",t,e,Vt,0,i*2,-1),Xt("cf1",t,e,Vt,-r,0,1),Xt("cf2",t,e,Vt,r,0,1),Xt("cf3",t,e,Vt,0,-i,1),Xt("cf4",t,e,Vt,0,i,1),Xt("cn1",t,e,Vt,-r,0,-1),Xt("cn2",t,e,Vt,r,0,-1),Xt("cn3",t,e,Vt,0,-i,-1),Xt("cn4",t,e,Vt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Xt(n,e,t,r,i,s,o){au.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],au.x,au.y,au.z)}}var go=class extends ys{constructor(e,t=16776960){let r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[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 Le;s.setIndex(new Xe(r,1)),s.setAttribute("position",new Ae(i,3)),super(s,new Zr({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))}};var Iu=class extends ys{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Le;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(r,3));let s=new Zr({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,r){let i=new Se,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Nu=class{constructor(){this.type="ShapePath",this.color=new Se,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new pc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}bezierCurveTo(e,t,r,i,s,o){return this.currentPath.bezierCurveTo(e,t,r,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function r(v){let w=[];for(let b=0,S=v.length;b<S;b++){let M=v[b],_=new Fn;_.curves=M.curves,w.push(_)}return w}function i(v,w){let b=w.length,S=!1;for(let M=b-1,_=0;_<b;M=_++){let y=w[M],T=w[_],E=T.x-y.x,C=T.y-y.y;if(Math.abs(C)>Number.EPSILON){if(C<0&&(y=w[_],E=-E,T=w[M],C=-C),v.y<y.y||v.y>T.y)continue;if(v.y===y.y){if(v.x===y.x)return!0}else{let I=C*(v.x-y.x)-E*(v.y-y.y);if(I===0)return!0;if(I<0)continue;S=!S}}else{if(v.y!==y.y)continue;if(T.x<=v.x&&v.x<=y.x||y.x<=v.x&&v.x<=T.x)return!0}}return S}let s=fs.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return r(o);let a,l,c,h=[];if(o.length===1)return l=o[0],c=new Fn,c.curves=l.curves,h.push(c),h;let u=!s(o[0].getPoints());u=e?!u:u;let f=[],d=[],m=[],p=0,g;d[p]=void 0,m[p]=[];for(let v=0,w=o.length;v<w;v++)l=o[v],g=l.getPoints(),a=s(g),a=e?!a:a,a?(!u&&d[p]&&p++,d[p]={s:new Fn,p:g},d[p].s.curves=l.curves,u&&p++,m[p]=[]):m[p].push({h:l,p:g[0]});if(!d[0])return r(o);if(d.length>1){let v=!1,w=0;for(let b=0,S=d.length;b<S;b++)f[b]=[];for(let b=0,S=d.length;b<S;b++){let M=m[b];for(let _=0;_<M.length;_++){let y=M[_],T=!0;for(let E=0;E<d.length;E++)i(y.p,d[E].p)&&(b!==E&&w++,T?(T=!1,f[E].push(y)):v=!0);T&&f[b].push(y)}}w>0&&v===!1&&(m=f)}let x;for(let v=0,w=d.length;v<w;v++){c=d[v].s,h.push(c),x=m[v];for(let b=0,S=x.length;b<S;b++)c.holes.push(x[b].h)}return h}};var ux=new ArrayBuffer(4),sU=new Float32Array(ux),oU=new Uint32Array(ux),si=new Uint32Array(512),oi=new Uint32Array(512);for(let n=0;n<256;++n){let e=n-127;e<-27?(si[n]=0,si[n|256]=32768,oi[n]=24,oi[n|256]=24):e<-14?(si[n]=1024>>-e-14,si[n|256]=1024>>-e-14|32768,oi[n]=-e-1,oi[n|256]=-e-1):e<=15?(si[n]=e+15<<10,si[n|256]=e+15<<10|32768,oi[n]=13,oi[n|256]=13):e<128?(si[n]=31744,si[n|256]=64512,oi[n]=24,oi[n|256]=24):(si[n]=31744,si[n|256]=64512,oi[n]=13,oi[n|256]=13)}var fx=new Uint32Array(2048),wc=new Uint32Array(64),KD=new Uint32Array(64);for(let n=1;n<1024;++n){let e=n<<13,t=0;for(;(e&8388608)===0;)e<<=1,t-=8388608;e&=-8388609,t+=947912704,fx[n]=e|t}for(let n=1024;n<2048;++n)fx[n]=939524096+(n-1024<<13);for(let n=1;n<31;++n)wc[n]=n<<23;wc[31]=1199570944;wc[32]=2147483648;for(let n=33;n<63;++n)wc[n]=2147483648+(n-32<<23);wc[63]=3347054592;for(let n=1;n<64;++n)n!==32&&(KD[n]=1024);var Bu=class extends ut{constructor(e,t,r){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,r),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=yo);var ba=".",Sc=Symbol("target"),Ym=Symbol("unsubscribe");function Ac(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function dx(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var dn=Array.isArray;function vo(n){return typeof n=="symbol"}var ZD={after:(n,e)=>dn(n)?n.slice(e.length):e===""?n:n.slice(e.length+1),concat:(n,e)=>dn(n)?(n=[...n],e&&n.push(e),n):e&&e.toString!==void 0?(n!==""&&(n+=ba),vo(e)?n+e.toString():n+e):n,initial:n=>{if(dn(n))return n.slice(0,-1);if(n==="")return n;let e=n.lastIndexOf(ba);return e===-1?"":n.slice(0,e)},last:n=>{if(dn(n))return n[n.length-1]||"";if(n==="")return n;let e=n.lastIndexOf(ba);return e===-1?n:n.slice(e+1)},walk:(n,e)=>{if(dn(n))for(let t of n)e(t);else if(n!==""){let t=0,r=n.indexOf(ba);if(r===-1)e(n);else for(;t<n.length;)r===-1&&(r=n.length),e(n.slice(t,r)),t=r+1,r=n.indexOf(ba,t)}},get(n,e){return this.walk(e,t=>{n&&(n=n[t])}),n}},Hr=ZD;function Xm(n){return typeof n=="object"&&typeof n.next=="function"}function Jm(n,e,t,r,i){let s=n.next;if(e.name==="entries")n.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],r),o.value[1]=i(o.value[1],e,o.value[0],r)),o};else if(e.name==="values"){let o=t[Sc].keys();n.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,r)),a}}else n.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,r)),o};return n}function Gu(n,e,t){return n.isUnsubscribed||e.ignoreSymbols&&vo(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Mc=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(),r=t.get(e);return r===void 0&&(r={},t.set(e,r)),r}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let r=this._getProperties(e),i=r[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),r[t]=i),i}getProxy(e,t,r,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,r):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Hr.get(t,this.getPath(e)))}defineProperty(e,t,r){return Reflect.defineProperty(e,t,r)?(this.isUnsubscribed||(this._getProperties(e)[t]=r),!0):!1}setProperty(e,t,r,i,s){if(!this._equals(s,r)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,r,i):Reflect.set(e,t,r)}return!0}deleteProperty(e,t,r){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(e,t,r){let i=this._getOwnPropertyDescriptor(t,r);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let r=this._getOwnPropertyDescriptor(e,t);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function wa(n){return toString.call(n)==="[object Object]"}function Sa(){return!0}function Ms(n,e){return n.length!==e.length||n.some((t,r)=>e[r]!==t)}var ku=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var $D=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Qm={push:Sa,pop:Sa,shift:Sa,unshift:Sa,copyWithin:Ms,reverse:Ms,sort:Ms,splice:Ms,flat:Ms,fill:Ms},px=new Set([...ku,...$D,...Object.keys(Qm)]);function Aa(n,e){if(n.size!==e.size)return!0;for(let t of n)if(!e.has(t))return!0;return!1}var Km=["keys","values","entries"],Zm=new Set(["has","toString"]),$m={add:Aa,clear:Aa,delete:Aa,forEach:Aa},mx=new Set([...Zm,...Object.keys($m),...Km]);function Ma(n,e){if(n.size!==e.size)return!0;let t;for(let[r,i]of n)if(t=e.get(r),t!==i||t===void 0&&!e.has(r))return!0;return!1}var eP=new Set([...Zm,"get"]),eg={set:Ma,clear:Ma,delete:Ma,forEach:Ma},gx=new Set([...eP,...Object.keys(eg),...Km]);var xr=class{constructor(e,t,r,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return ku.has(e)}_shallowClone(e){let t=e;if(wa(e))t={...e};else if(dn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(r=>this._shallowClone(r)));else if(e instanceof Map){t=new Map;for(let[r,i]of e.entries())t.set(r,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,r,i){return e?(dn(i)?this._onIsChanged=Qm[t]:i instanceof Set?this._onIsChanged=$m[t]:i instanceof Map&&(this._onIsChanged=eg[t]),i):r}update(e,t,r){let i=Hr.after(e,this._path);if(t!=="length"){let s=this.clone;Hr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:r}),s&&s[t]&&(s[t]=r)}this._isChanged=!0}undo(e){let t;for(let r=this._changes.length-1;r!==-1;r--)t=this._changes[r],Hr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var _a=class extends xr{static isHandledMethod(e){return px.has(e)}};var _c=class extends xr{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var Ta=class extends xr{static isHandledMethod(e){return mx.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)}};var Ea=class extends xr{static isHandledMethod(e){return gx.has(e)}undo(e){for(let[t,r]of this.clone.entries())e.set(t,r);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Tc=class extends xr{constructor(e,t,r,i){super(void 0,t,r,i),this._arg1=r[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)}};var Ec=class extends xr{constructor(e,t,r,i){super(void 0,t,r,i),this._weakKey=r[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)}};var Wn=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return wa(e)||dn(e)||Ac(e)}static isHandledMethod(e,t){return wa(e)?xr.isHandledMethod(t):dn(e)?_a.isHandledMethod(t):e instanceof Set?Ta.isHandledMethod(t):e instanceof Map?Ea.isHandledMethod(t):Ac(e)}get isCloning(){return this._stack.length>0}start(e,t,r){let i=xr;dn(e)?i=_a:e instanceof Date?i=_c:e instanceof Set?i=Ta:e instanceof Map?i=Ea:e instanceof WeakSet?i=Tc:e instanceof WeakMap&&(i=Ec),this._stack.push(new i(e,t,r,this._hasOnValidate))}update(e,t,r){this._stack[this._stack.length-1].update(e,t,r)}preferredThisArg(e,t,r){let{name:i}=e,s=Wn.isHandledMethod(r,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,r)}isChanged(e,t,r){return this._stack[this._stack.length-1].isChanged(e,t,r)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var tP={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},tg=(n,e,t={})=>{t={...tP,...t};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new Mc(i),c=typeof t.onValidate=="function",h=new Wn(c),u=(v,w,b,S,M)=>!c||h.isCloning||t.onValidate(Hr.concat(l.getPath(v),w),b,S,M)===!0,f=(v,w,b,S)=>{!Gu(l,t,w)&&!(o&&l.isDetached(v,n))&&d(l.getPath(v),w,b,S)},d=(v,w,b,S,M)=>{h.isCloning?h.update(v,w,S):e(Hr.concat(v,w),b,S,M)},m=v=>v&&(v[r]||v),p=(v,w,b,S)=>dx(v)||b==="constructor"||s&&!Wn.isHandledMethod(w,b)||Gu(l,t,b)||l.isGetInvariant(w,b)||o&&l.isDetached(w,n)?v:(S===void 0&&(S=l.getPath(w)),l.getProxy(v,Hr.concat(S,b),g,r)),g={get(v,w,b){if(vo(w)){if(w===r||w===Sc)return v;if(w===Ym&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Ac(v)?Reflect.get(v,w):Reflect.get(v,w,b);return p(S,v,w)},set(v,w,b,S){b=m(b);let M=v[r]||v,_=M[w];if(i(_,b)&&w in v)return!0;let y=u(v,w,b,_);return y&&l.setProperty(M,w,b,S,_)?(f(v,w,v[w],_),!0):!y},defineProperty(v,w,b){if(!l.isSameDescriptor(b,v,w)){let S=v[w];u(v,w,b.value,S)&&l.defineProperty(v,w,b,S)&&f(v,w,b.value,S)}return!0},deleteProperty(v,w){if(!Reflect.has(v,w))return!0;let b=Reflect.get(v,w),S=u(v,w,void 0,b);return S&&l.deleteProperty(v,w,b)?(f(v,w,void 0,b),!0):!S},apply(v,w,b){let S=w[r]||w;if(l.isUnsubscribed)return Reflect.apply(v,S,b);if((a===!1||a!==!0&&!a.includes(v.name))&&Wn.isHandledType(S)){let M=Hr.initial(l.getPath(v)),_=Wn.isHandledMethod(S,v.name);h.start(S,M,b);let y=Reflect.apply(v,h.preferredThisArg(v,w,S),_?b.map(C=>m(C)):b),T=h.isChanged(S,i),E=h.stop();if(Wn.isHandledType(y)&&_&&(w instanceof Map&&v.name==="get"&&(M=Hr.concat(M,b[0])),y=l.getProxy(y,M,g)),T){let C={name:v.name,args:b,result:y},I=h.isCloning?Hr.initial(M):M,B=h.isCloning?Hr.last(M):"";u(Hr.get(n,I),B,S,E,C)?d(I,B,S,E,C):h.undo(S)}return(w instanceof Map||w instanceof Set)&&Xm(y)?Jm(y,v,w,M,p):y}return Reflect.apply(v,w,b)}},x=l.getProxy(n,t.pathAsArray?[]:"",g);return e=e.bind(x),c&&(t.onValidate=t.onValidate.bind(x)),x};tg.target=n=>n&&n[Sc]||n;tg.unsubscribe=n=>n[Ym]||n;var rg=tg;var rP=typeof global=="object"&&global&&global.Object===Object&&global,Vu=rP;var nP=typeof self=="object"&&self&&self.Object===Object&&self,iP=Vu||nP||Function("return this")(),qt=iP;var sP=qt.Symbol,Wr=sP;var yx=Object.prototype,oP=yx.hasOwnProperty,aP=yx.toString,Cc=Wr?Wr.toStringTag:void 0;function lP(n){var e=oP.call(n,Cc),t=n[Cc];try{n[Cc]=void 0;var r=!0}catch{}var i=aP.call(n);return r&&(e?n[Cc]=t:delete n[Cc]),i}var vx=lP;var cP=Object.prototype,hP=cP.toString;function uP(n){return hP.call(n)}var xx=uP;var fP="[object Null]",dP="[object Undefined]",bx=Wr?Wr.toStringTag:void 0;function pP(n){return n==null?n===void 0?dP:fP:bx&&bx in Object(n)?vx(n):xx(n)}var pn=pP;function mP(n){return n!=null&&typeof n=="object"}var Or=mP;var gP="[object Symbol]";function yP(n){return typeof n=="symbol"||Or(n)&&pn(n)==gP}var _s=yP;function vP(n,e){for(var t=-1,r=n==null?0:n.length,i=Array(r);++t<r;)i[t]=e(n[t],t,n);return i}var Hu=vP;var xP=Array.isArray,Tr=xP;var bP=1/0,wx=Wr?Wr.prototype:void 0,Sx=wx?wx.toString:void 0;function Ax(n){if(typeof n=="string")return n;if(Tr(n))return Hu(n,Ax)+"";if(_s(n))return Sx?Sx.call(n):"";var e=n+"";return e=="0"&&1/n==-bP?"-0":e}var Mx=Ax;var wP=/\s/;function SP(n){for(var e=n.length;e--&&wP.test(n.charAt(e)););return e}var _x=SP;var AP=/^\s+/;function MP(n){return n&&n.slice(0,_x(n)+1).replace(AP,"")}var Tx=MP;function _P(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Qt=_P;var Ex=0/0,TP=/^[-+]0x[0-9a-f]+$/i,EP=/^0b[01]+$/i,CP=/^0o[0-7]+$/i,DP=parseInt;function PP(n){if(typeof n=="number")return n;if(_s(n))return Ex;if(Qt(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Qt(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=Tx(n);var t=EP.test(n);return t||CP.test(n)?DP(n.slice(2),t?2:8):TP.test(n)?Ex:+n}var ng=PP;function LP(n){return n}var Wu=LP;var IP="[object AsyncFunction]",NP="[object Function]",BP="[object GeneratorFunction]",OP="[object Proxy]";function RP(n){if(!Qt(n))return!1;var e=pn(n);return e==NP||e==BP||e==IP||e==OP}var Ca=RP;var FP=qt["__core-js_shared__"],ju=FP;var Cx=function(){var n=/[^.]+$/.exec(ju&&ju.keys&&ju.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function zP(n){return!!Cx&&Cx in n}var Dx=zP;var UP=Function.prototype,GP=UP.toString;function kP(n){if(n!=null){try{return GP.call(n)}catch{}try{return n+""}catch{}}return""}var Gi=kP;var VP=/[\\^$.*+?()[\]{}|]/g,HP=/^\[object .+?Constructor\]$/,WP=Function.prototype,jP=Object.prototype,qP=WP.toString,YP=jP.hasOwnProperty,XP=RegExp("^"+qP.call(YP).replace(VP,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function JP(n){if(!Qt(n)||Dx(n))return!1;var e=Ca(n)?XP:HP;return e.test(Gi(n))}var Px=JP;function QP(n,e){return n?.[e]}var Lx=QP;function KP(n,e){var t=Lx(n,e);return Px(t)?t:void 0}var tn=KP;var ZP=tn(qt,"WeakMap"),qu=ZP;var Ix=Object.create,$P=function(){function n(){}return function(e){if(!Qt(e))return{};if(Ix)return Ix(e);n.prototype=e;var t=new n;return n.prototype=void 0,t}}(),Nx=$P;function eL(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}var Bx=eL;function tL(n,e){var t=-1,r=n.length;for(e||(e=Array(r));++t<r;)e[t]=n[t];return e}var Yu=tL;var rL=800,nL=16,iL=Date.now;function sL(n){var e=0,t=0;return function(){var r=iL(),i=nL-(r-t);if(t=r,i>0){if(++e>=rL)return arguments[0]}else e=0;return n.apply(void 0,arguments)}}var Ox=sL;function oL(n){return function(){return n}}var Rx=oL;var aL=function(){try{var n=tn(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Da=aL;var lL=Da?function(n,e){return Da(n,"toString",{configurable:!0,enumerable:!1,value:Rx(e),writable:!0})}:Wu,Fx=lL;var cL=Ox(Fx),Xu=cL;function hL(n,e){for(var t=-1,r=n==null?0:n.length;++t<r&&e(n[t],t,n)!==!1;);return n}var zx=hL;var uL=9007199254740991,fL=/^(?:0|[1-9]\d*)$/;function dL(n,e){var t=typeof n;return e=e??uL,!!e&&(t=="number"||t!="symbol"&&fL.test(n))&&n>-1&&n%1==0&&n<e}var Ju=dL;function pL(n,e,t){e=="__proto__"&&Da?Da(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):n[e]=t}var Pa=pL;function mL(n,e){return n===e||n!==n&&e!==e}var Ts=mL;var gL=Object.prototype,yL=gL.hasOwnProperty;function vL(n,e,t){var r=n[e];(!(yL.call(n,e)&&Ts(r,t))||t===void 0&&!(e in n))&&Pa(n,e,t)}var Qu=vL;function xL(n,e,t,r){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=r?r(t[a],n[a],a,t,n):void 0;l===void 0&&(l=n[a]),i?Pa(t,a,l):Qu(t,a,l)}return t}var Mn=xL;var Ux=Math.max;function bL(n,e,t){return e=Ux(e===void 0?n.length-1:e,0),function(){for(var r=arguments,i=-1,s=Ux(r.length-e,0),o=Array(s);++i<s;)o[i]=r[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=r[i];return a[e]=t(o),Bx(n,this,a)}}var Ku=bL;function wL(n,e){return Xu(Ku(n,e,Wu),n+"")}var Gx=wL;var SL=9007199254740991;function AL(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=SL}var Zu=AL;function ML(n){return n!=null&&Zu(n.length)&&!Ca(n)}var Es=ML;function _L(n,e,t){if(!Qt(t))return!1;var r=typeof e;return(r=="number"?Es(t)&&Ju(e,t.length):r=="string"&&e in t)?Ts(t[e],n):!1}var kx=_L;function TL(n){return Gx(function(e,t){var r=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=n.length>3&&typeof s=="function"?(i--,s):void 0,o&&kx(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++r<i;){var a=t[r];a&&n(e,a,r,s)}return e})}var Vx=TL;var EL=Object.prototype;function CL(n){var e=n&&n.constructor,t=typeof e=="function"&&e.prototype||EL;return n===t}var La=CL;function DL(n,e){for(var t=-1,r=Array(n);++t<n;)r[t]=e(t);return r}var Hx=DL;var PL="[object Arguments]";function LL(n){return Or(n)&&pn(n)==PL}var ig=LL;var Wx=Object.prototype,IL=Wx.hasOwnProperty,NL=Wx.propertyIsEnumerable,BL=ig(function(){return arguments}())?ig:function(n){return Or(n)&&IL.call(n,"callee")&&!NL.call(n,"callee")},xo=BL;function OL(){return!1}var jx=OL;var Xx=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qx=Xx&&typeof module=="object"&&module&&!module.nodeType&&module,RL=qx&&qx.exports===Xx,Yx=RL?qt.Buffer:void 0,FL=Yx?Yx.isBuffer:void 0,zL=FL||jx,Ia=zL;var UL="[object Arguments]",GL="[object Array]",kL="[object Boolean]",VL="[object Date]",HL="[object Error]",WL="[object Function]",jL="[object Map]",qL="[object Number]",YL="[object Object]",XL="[object RegExp]",JL="[object Set]",QL="[object String]",KL="[object WeakMap]",ZL="[object ArrayBuffer]",$L="[object DataView]",eI="[object Float32Array]",tI="[object Float64Array]",rI="[object Int8Array]",nI="[object Int16Array]",iI="[object Int32Array]",sI="[object Uint8Array]",oI="[object Uint8ClampedArray]",aI="[object Uint16Array]",lI="[object Uint32Array]",Bt={};Bt[eI]=Bt[tI]=Bt[rI]=Bt[nI]=Bt[iI]=Bt[sI]=Bt[oI]=Bt[aI]=Bt[lI]=!0;Bt[UL]=Bt[GL]=Bt[ZL]=Bt[kL]=Bt[$L]=Bt[VL]=Bt[HL]=Bt[WL]=Bt[jL]=Bt[qL]=Bt[YL]=Bt[XL]=Bt[JL]=Bt[QL]=Bt[KL]=!1;function cI(n){return Or(n)&&Zu(n.length)&&!!Bt[pn(n)]}var Jx=cI;function hI(n){return function(e){return n(e)}}var Na=hI;var Qx=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dc=Qx&&typeof module=="object"&&module&&!module.nodeType&&module,uI=Dc&&Dc.exports===Qx,sg=uI&&Vu.process,fI=function(){try{var n=Dc&&Dc.require&&Dc.require("util").types;return n||sg&&sg.binding&&sg.binding("util")}catch{}}(),ki=fI;var Kx=ki&&ki.isTypedArray,dI=Kx?Na(Kx):Jx,$u=dI;var pI=Object.prototype,mI=pI.hasOwnProperty;function gI(n,e){var t=Tr(n),r=!t&&xo(n),i=!t&&!r&&Ia(n),s=!t&&!r&&!i&&$u(n),o=t||r||i||s,a=o?Hx(n.length,String):[],l=a.length;for(var c in n)(e||mI.call(n,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ju(c,l)))&&a.push(c);return a}var ef=gI;function yI(n,e){return function(t){return n(e(t))}}var tf=yI;var vI=tf(Object.keys,Object),Zx=vI;var xI=Object.prototype,bI=xI.hasOwnProperty;function wI(n){if(!La(n))return Zx(n);var e=[];for(var t in Object(n))bI.call(n,t)&&t!="constructor"&&e.push(t);return e}var $x=wI;function SI(n){return Es(n)?ef(n):$x(n)}var Ba=SI;function AI(n){var e=[];if(n!=null)for(var t in Object(n))e.push(t);return e}var eb=AI;var MI=Object.prototype,_I=MI.hasOwnProperty;function TI(n){if(!Qt(n))return eb(n);var e=La(n),t=[];for(var r in n)r=="constructor"&&(e||!_I.call(n,r))||t.push(r);return t}var tb=TI;function EI(n){return Es(n)?ef(n,!0):tb(n)}var hi=EI;var CI=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,DI=/^\w*$/;function PI(n,e){if(Tr(n))return!1;var t=typeof n;return t=="number"||t=="symbol"||t=="boolean"||n==null||_s(n)?!0:DI.test(n)||!CI.test(n)||e!=null&&n in Object(e)}var rb=PI;var LI=tn(Object,"create"),Vi=LI;function II(){this.__data__=Vi?Vi(null):{},this.size=0}var nb=II;function NI(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}var ib=NI;var BI="__lodash_hash_undefined__",OI=Object.prototype,RI=OI.hasOwnProperty;function FI(n){var e=this.__data__;if(Vi){var t=e[n];return t===BI?void 0:t}return RI.call(e,n)?e[n]:void 0}var sb=FI;var zI=Object.prototype,UI=zI.hasOwnProperty;function GI(n){var e=this.__data__;return Vi?e[n]!==void 0:UI.call(e,n)}var ob=GI;var kI="__lodash_hash_undefined__";function VI(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=Vi&&e===void 0?kI:e,this}var ab=VI;function Oa(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}Oa.prototype.clear=nb;Oa.prototype.delete=ib;Oa.prototype.get=sb;Oa.prototype.has=ob;Oa.prototype.set=ab;var og=Oa;function HI(){this.__data__=[],this.size=0}var lb=HI;function WI(n,e){for(var t=n.length;t--;)if(Ts(n[t][0],e))return t;return-1}var Cs=WI;var jI=Array.prototype,qI=jI.splice;function YI(n){var e=this.__data__,t=Cs(e,n);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():qI.call(e,t,1),--this.size,!0}var cb=YI;function XI(n){var e=this.__data__,t=Cs(e,n);return t<0?void 0:e[t][1]}var hb=XI;function JI(n){return Cs(this.__data__,n)>-1}var ub=JI;function QI(n,e){var t=this.__data__,r=Cs(t,n);return r<0?(++this.size,t.push([n,e])):t[r][1]=e,this}var fb=QI;function Ra(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}Ra.prototype.clear=lb;Ra.prototype.delete=cb;Ra.prototype.get=hb;Ra.prototype.has=ub;Ra.prototype.set=fb;var Ds=Ra;var KI=tn(qt,"Map"),Ps=KI;function ZI(){this.size=0,this.__data__={hash:new og,map:new(Ps||Ds),string:new og}}var db=ZI;function $I(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}var pb=$I;function eN(n,e){var t=n.__data__;return pb(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Ls=eN;function tN(n){var e=Ls(this,n).delete(n);return this.size-=e?1:0,e}var mb=tN;function rN(n){return Ls(this,n).get(n)}var gb=rN;function nN(n){return Ls(this,n).has(n)}var yb=nN;function iN(n,e){var t=Ls(this,n),r=t.size;return t.set(n,e),this.size+=t.size==r?0:1,this}var vb=iN;function Fa(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}Fa.prototype.clear=db;Fa.prototype.delete=mb;Fa.prototype.get=gb;Fa.prototype.has=yb;Fa.prototype.set=vb;var Pc=Fa;var sN="Expected a function";function ag(n,e){if(typeof n!="function"||e!=null&&typeof e!="function")throw new TypeError(sN);var t=function(){var r=arguments,i=e?e.apply(this,r):r[0],s=t.cache;if(s.has(i))return s.get(i);var o=n.apply(this,r);return t.cache=s.set(i,o)||s,o};return t.cache=new(ag.Cache||Pc),t}ag.Cache=Pc;var xb=ag;var oN=500;function aN(n){var e=xb(n,function(r){return t.size===oN&&t.clear(),r}),t=e.cache;return e}var bb=aN;var lN=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cN=/\\(\\)?/g,hN=bb(function(n){var e=[];return n.charCodeAt(0)===46&&e.push(""),n.replace(lN,function(t,r,i,s){e.push(i?s.replace(cN,"$1"):r||t)}),e}),wb=hN;function uN(n){return n==null?"":Mx(n)}var Sb=uN;function fN(n,e){return Tr(n)?n:rb(n,e)?[n]:wb(Sb(n))}var za=fN;var dN=1/0;function pN(n){if(typeof n=="string"||_s(n))return n;var e=n+"";return e=="0"&&1/n==-dN?"-0":e}var rf=pN;function mN(n,e){e=za(e,n);for(var t=0,r=e.length;n!=null&&t<r;)n=n[rf(e[t++])];return t&&t==r?n:void 0}var Ab=mN;function gN(n,e){for(var t=-1,r=e.length,i=n.length;++t<r;)n[i+t]=e[t];return n}var Ua=gN;var Mb=Wr?Wr.isConcatSpreadable:void 0;function yN(n){return Tr(n)||xo(n)||!!(Mb&&n&&n[Mb])}var _b=yN;function Tb(n,e,t,r,i){var s=-1,o=n.length;for(t||(t=_b),i||(i=[]);++s<o;){var a=n[s];e>0&&t(a)?e>1?Tb(a,e-1,t,r,i):Ua(i,a):r||(i[i.length]=a)}return i}var Eb=Tb;function vN(n){var e=n==null?0:n.length;return e?Eb(n,1):[]}var Cb=vN;function xN(n){return Xu(Ku(n,void 0,Cb),n+"")}var Db=xN;var bN=tf(Object.getPrototypeOf,Object),Ga=bN;var wN="[object Object]",SN=Function.prototype,AN=Object.prototype,Pb=SN.toString,MN=AN.hasOwnProperty,_N=Pb.call(Object);function TN(n){if(!Or(n)||pn(n)!=wN)return!1;var e=Ga(n);if(e===null)return!0;var t=MN.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Pb.call(t)==_N}var nf=TN;function EN(n,e,t){var r=-1,i=n.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++r<i;)s[r]=n[r+e];return s}var Lb=EN;function CN(){this.__data__=new Ds,this.size=0}var Ib=CN;function DN(n){var e=this.__data__,t=e.delete(n);return this.size=e.size,t}var Nb=DN;function PN(n){return this.__data__.get(n)}var Bb=PN;function LN(n){return this.__data__.has(n)}var Ob=LN;var IN=200;function NN(n,e){var t=this.__data__;if(t instanceof Ds){var r=t.__data__;if(!Ps||r.length<IN-1)return r.push([n,e]),this.size=++t.size,this;t=this.__data__=new Pc(r)}return t.set(n,e),this.size=t.size,this}var Rb=NN;function ka(n){var e=this.__data__=new Ds(n);this.size=e.size}ka.prototype.clear=Ib;ka.prototype.delete=Nb;ka.prototype.get=Bb;ka.prototype.has=Ob;ka.prototype.set=Rb;var sf=ka;function BN(n,e){return n&&Mn(e,Ba(e),n)}var Fb=BN;function ON(n,e){return n&&Mn(e,hi(e),n)}var zb=ON;var Vb=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ub=Vb&&typeof module=="object"&&module&&!module.nodeType&&module,RN=Ub&&Ub.exports===Vb,Gb=RN?qt.Buffer:void 0,kb=Gb?Gb.allocUnsafe:void 0;function FN(n,e){if(e)return n.slice();var t=n.length,r=kb?kb(t):new n.constructor(t);return n.copy(r),r}var of=FN;function zN(n,e){for(var t=-1,r=n==null?0:n.length,i=0,s=[];++t<r;){var o=n[t];e(o,t,n)&&(s[i++]=o)}return s}var Hb=zN;function UN(){return[]}var af=UN;var GN=Object.prototype,kN=GN.propertyIsEnumerable,Wb=Object.getOwnPropertySymbols,VN=Wb?function(n){return n==null?[]:(n=Object(n),Hb(Wb(n),function(e){return kN.call(n,e)}))}:af,Va=VN;function HN(n,e){return Mn(n,Va(n),e)}var jb=HN;var WN=Object.getOwnPropertySymbols,jN=WN?function(n){for(var e=[];n;)Ua(e,Va(n)),n=Ga(n);return e}:af,lf=jN;function qN(n,e){return Mn(n,lf(n),e)}var qb=qN;function YN(n,e,t){var r=e(n);return Tr(n)?r:Ua(r,t(n))}var cf=YN;function XN(n){return cf(n,Ba,Va)}var Yb=XN;function JN(n){return cf(n,hi,lf)}var hf=JN;var QN=tn(qt,"DataView"),uf=QN;var KN=tn(qt,"Promise"),ff=KN;var ZN=tn(qt,"Set"),df=ZN;var Xb="[object Map]",$N="[object Object]",Jb="[object Promise]",Qb="[object Set]",Kb="[object WeakMap]",Zb="[object DataView]",e3=Gi(uf),t3=Gi(Ps),r3=Gi(ff),n3=Gi(df),i3=Gi(qu),bo=pn;(uf&&bo(new uf(new ArrayBuffer(1)))!=Zb||Ps&&bo(new Ps)!=Xb||ff&&bo(ff.resolve())!=Jb||df&&bo(new df)!=Qb||qu&&bo(new qu)!=Kb)&&(bo=function(n){var e=pn(n),t=e==$N?n.constructor:void 0,r=t?Gi(t):"";if(r)switch(r){case e3:return Zb;case t3:return Xb;case r3:return Jb;case n3:return Qb;case i3:return Kb}return e});var Ha=bo;var s3=Object.prototype,o3=s3.hasOwnProperty;function a3(n){var e=n.length,t=new n.constructor(e);return e&&typeof n[0]=="string"&&o3.call(n,"index")&&(t.index=n.index,t.input=n.input),t}var $b=a3;var l3=qt.Uint8Array,lg=l3;function c3(n){var e=new n.constructor(n.byteLength);return new lg(e).set(new lg(n)),e}var Wa=c3;function h3(n,e){var t=e?Wa(n.buffer):n.buffer;return new n.constructor(t,n.byteOffset,n.byteLength)}var ew=h3;var u3=/\w*$/;function f3(n){var e=new n.constructor(n.source,u3.exec(n));return e.lastIndex=n.lastIndex,e}var tw=f3;var rw=Wr?Wr.prototype:void 0,nw=rw?rw.valueOf:void 0;function d3(n){return nw?Object(nw.call(n)):{}}var iw=d3;function p3(n,e){var t=e?Wa(n.buffer):n.buffer;return new n.constructor(t,n.byteOffset,n.length)}var pf=p3;var m3="[object Boolean]",g3="[object Date]",y3="[object Map]",v3="[object Number]",x3="[object RegExp]",b3="[object Set]",w3="[object String]",S3="[object Symbol]",A3="[object ArrayBuffer]",M3="[object DataView]",_3="[object Float32Array]",T3="[object Float64Array]",E3="[object Int8Array]",C3="[object Int16Array]",D3="[object Int32Array]",P3="[object Uint8Array]",L3="[object Uint8ClampedArray]",I3="[object Uint16Array]",N3="[object Uint32Array]";function B3(n,e,t){var r=n.constructor;switch(e){case A3:return Wa(n);case m3:case g3:return new r(+n);case M3:return ew(n,t);case _3:case T3:case E3:case C3:case D3:case P3:case L3:case I3:case N3:return pf(n,t);case y3:return new r;case v3:case w3:return new r(n);case x3:return tw(n);case b3:return new r;case S3:return iw(n)}}var sw=B3;function O3(n){return typeof n.constructor=="function"&&!La(n)?Nx(Ga(n)):{}}var mf=O3;var R3="[object Map]";function F3(n){return Or(n)&&Ha(n)==R3}var ow=F3;var aw=ki&&ki.isMap,z3=aw?Na(aw):ow,lw=z3;var U3="[object Set]";function G3(n){return Or(n)&&Ha(n)==U3}var cw=G3;var hw=ki&&ki.isSet,k3=hw?Na(hw):cw,uw=k3;var V3=1,H3=2,W3=4,fw="[object Arguments]",j3="[object Array]",q3="[object Boolean]",Y3="[object Date]",X3="[object Error]",dw="[object Function]",J3="[object GeneratorFunction]",Q3="[object Map]",K3="[object Number]",pw="[object Object]",Z3="[object RegExp]",$3="[object Set]",eB="[object String]",tB="[object Symbol]",rB="[object WeakMap]",nB="[object ArrayBuffer]",iB="[object DataView]",sB="[object Float32Array]",oB="[object Float64Array]",aB="[object Int8Array]",lB="[object Int16Array]",cB="[object Int32Array]",hB="[object Uint8Array]",uB="[object Uint8ClampedArray]",fB="[object Uint16Array]",dB="[object Uint32Array]",Pt={};Pt[fw]=Pt[j3]=Pt[nB]=Pt[iB]=Pt[q3]=Pt[Y3]=Pt[sB]=Pt[oB]=Pt[aB]=Pt[lB]=Pt[cB]=Pt[Q3]=Pt[K3]=Pt[pw]=Pt[Z3]=Pt[$3]=Pt[eB]=Pt[tB]=Pt[hB]=Pt[uB]=Pt[fB]=Pt[dB]=!0;Pt[X3]=Pt[dw]=Pt[rB]=!1;function gf(n,e,t,r,i,s){var o,a=e&V3,l=e&H3,c=e&W3;if(t&&(o=i?t(n,r,i,s):t(n)),o!==void 0)return o;if(!Qt(n))return n;var h=Tr(n);if(h){if(o=$b(n),!a)return Yu(n,o)}else{var u=Ha(n),f=u==dw||u==J3;if(Ia(n))return of(n,a);if(u==pw||u==fw||f&&!i){if(o=l||f?{}:mf(n),!a)return l?qb(n,zb(o,n)):jb(n,Fb(o,n))}else{if(!Pt[u])return i?n:{};o=sw(n,u,a)}}s||(s=new sf);var d=s.get(n);if(d)return d;s.set(n,o),uw(n)?n.forEach(function(g){o.add(gf(g,e,t,g,n,s))}):lw(n)&&n.forEach(function(g,x){o.set(x,gf(g,e,t,x,n,s))});var m=c?l?hf:Yb:l?hi:Ba,p=h?void 0:m(n);return zx(p||n,function(g,x){p&&(x=g,g=n[x]),Qu(o,x,gf(g,e,t,x,n,s))}),o}var yf=gf;var pB=1,mB=4;function gB(n){return yf(n,pB|mB)}var Lc=gB;function yB(n){return function(e,t,r){for(var i=-1,s=Object(e),o=r(e),a=o.length;a--;){var l=o[n?a:++i];if(t(s[l],l,s)===!1)break}return e}}var mw=yB;var vB=mw(),gw=vB;var xB=function(){return qt.Date.now()},vf=xB;var bB="Expected a function",wB=Math.max,SB=Math.min;function AB(n,e,t){var r,i,s,o,a,l,c=0,h=!1,u=!1,f=!0;if(typeof n!="function")throw new TypeError(bB);e=ng(e)||0,Qt(t)&&(h=!!t.leading,u="maxWait"in t,s=u?wB(ng(t.maxWait)||0,e):s,f="trailing"in t?!!t.trailing:f);function d(M){var _=r,y=i;return r=i=void 0,c=M,o=n.apply(y,_),o}function m(M){return c=M,a=setTimeout(x,e),h?d(M):o}function p(M){var _=M-l,y=M-c,T=e-_;return u?SB(T,s-y):T}function g(M){var _=M-l,y=M-c;return l===void 0||_>=e||_<0||u&&y>=s}function x(){var M=vf();if(g(M))return v(M);a=setTimeout(x,p(M))}function v(M){return a=void 0,f&&r?d(M):(r=i=void 0,o)}function w(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function b(){return a===void 0?o:v(vf())}function S(){var M=vf(),_=g(M);if(r=arguments,i=this,l=M,_){if(a===void 0)return m(l);if(u)return clearTimeout(a),a=setTimeout(x,e),d(l)}return a===void 0&&(a=setTimeout(x,e)),o}return S.cancel=w,S.flush=b,S}var Ic=AB;function MB(n,e,t){(t!==void 0&&!Ts(n[e],t)||t===void 0&&!(e in n))&&Pa(n,e,t)}var Nc=MB;function _B(n){return Or(n)&&Es(n)}var yw=_B;function TB(n,e){if(!(e==="constructor"&&typeof n[e]=="function")&&e!="__proto__")return n[e]}var Bc=TB;function EB(n){return Mn(n,hi(n))}var vw=EB;function CB(n,e,t,r,i,s,o){var a=Bc(n,t),l=Bc(e,t),c=o.get(l);if(c){Nc(n,t,c);return}var h=s?s(a,l,t+"",n,e,o):void 0,u=h===void 0;if(u){var f=Tr(l),d=!f&&Ia(l),m=!f&&!d&&$u(l);h=l,f||d||m?Tr(a)?h=a:yw(a)?h=Yu(a):d?(u=!1,h=of(l,!0)):m?(u=!1,h=pf(l,!0)):h=[]:nf(l)||xo(l)?(h=a,xo(a)?h=vw(a):(!Qt(a)||Ca(a))&&(h=mf(l))):u=!1}u&&(o.set(l,h),i(h,l,r,s,o),o.delete(l)),Nc(n,t,h)}var xw=CB;function bw(n,e,t,r,i){n!==e&&gw(e,function(s,o){if(i||(i=new sf),Qt(s))xw(n,e,o,t,bw,r,i);else{var a=r?r(Bc(n,o),s,o+"",n,e,i):void 0;a===void 0&&(a=s),Nc(n,o,a)}},hi)}var ww=bw;function DB(n){var e=n==null?0:n.length;return e?n[e-1]:void 0}var Sw=DB;function PB(n,e){return e.length<2?n:Ab(n,Lb(e,0,-1))}var Aw=PB;var LB=Vx(function(n,e,t){ww(n,e,t)}),wo=LB;function IB(n,e){return e=za(e,n),n=Aw(n,e),n==null||delete n[rf(Sw(e))]}var Mw=IB;function NB(n){return nf(n)?void 0:n}var _w=NB;var BB=1,OB=2,RB=4,FB=Db(function(n,e){var t={};if(n==null)return t;var r=!1;e=Hu(e,function(s){return s=za(s,n),r||(r=s.length>1),s}),Mn(n,hf(n),t),r&&(t=yf(t,BB|OB|RB,_w));for(var i=e.length;i--;)Mw(t,e[i]);return t}),ja=FB;var zB=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),UB=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),GB=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Oc&&"ontouchend"in document,kB=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,VB=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,HB=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(e)},WB=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},k6=zB(),Oc=UB(),So=GB(),Tw=kB(),xf=VB(),Ew=HB(),Cw=Number(WB());function Dw(n){return Array.isArray(n)?n:[n]}function Rc(n){return Oc?n.metaKey:n.ctrlKey}var Is;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(Is||(Is={}));var Ao;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=r})(Ao||(Ao={}));var Hi;(t=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]}t.isEqual=n;function e(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s]}t.lerp=e})(Hi||(Hi={}));var sr;(i=>{function n(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=n;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function r(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=r})(sr||(sr={}));var Fc;(t=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}t.isEqual=n;function e(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s,r[2]+(i[2]-r[2])*s,r[3]+(i[3]-r[3])*s]}t.lerp=e})(Fc||(Fc={}));var ui;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let h=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/h,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/h,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/h}return a}i.applyMatrix4=r})(ui||(ui={}));var hr;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function i(c){return{r:c.r,g:c.g,b:c.b}}l.clone=i;function s(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=s;function o(c,h){return c.r===h.r&&c.g===h.g&&c.b===h.b}l.equals=o;function a(c,h,u){return{r:c.r+(h.r-c.r)*u,g:c.g+(h.g-c.g)*u,b:c.b+(h.b-c.b)*u}}l.lerp=a})(hr||(hr={}));var mn;(o=>{o.white={...hr.white,a:1};function e(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}o.from0to1=e;function t(a,l){return{...hr.fromHex(a),a:l}}o.fromHexAndA=t;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}}o.toRgb255a1=r;function i(a,l){return hr.equals(a,l)&&a.a===l.a}o.equals=i;function s(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}o.lerp=s})(mn||(mn={}));var bf;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(bf||(bf={}));var wf;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(wf||(wf={}));var Sf;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(Sf||(Sf={}));var Af;(e=>{function n(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+r)),useCenter:!0}}}e.defaultData=n})(Af||(Af={}));var _n=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let s={...r,[e]:t};return Object.setPrototypeOf(s,_n.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let r=t[e.id],i;r===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:r};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,_n.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:r}=e,i=t[r];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,_n.prototype),delete s[r],{data:s,actual:e,reverse:{type:1,id:r,data:i}}}}throw new Error("illegal arg")}};function zc(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let e=Object.getOwnPropertyNames(n);for(let t of e){let r=n[t];r&&typeof r=="object"&&zc(r)}return Object.freeze(n)}function Pw(n,e){let t=0;for(;t<n.length&&t<e.length;){if(n[t]<e[t])return-1;if(n[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==n.length?1:0}var Mf=class extends Error{};function fi(n,e,t){if(n===void 0?e===void 0?(n=0,e=10):n=e-10:e===void 0&&(e=n+10),n>e){let s=n;n=e,e=s}let r=[],i=1/(t+1);for(let s=0;s<t;s++){let o=n+(e-n)*(s+.75+Math.random()*.5)*i;r.push(o)}return r}function _f(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function Lw(){return typeof process<"u"}function Iw(n,e){for(let t of n)e(t.id,t.data),Iw(t.children,e)}function Nw(n,e){e(n.id,n.data);for(let t of n.children)Nw(t,e)}var Tn=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Tn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t,r){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,r);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}isDescendantOf(t,r){for(;t;){let i=this.parent(t);if(i===r)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,r){if(t===null)this.traverse(r);else{let i=this.get(t);i&&Nw(i,r)}}traverse(t){Iw(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,r){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(h=>h.id===t);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(t,r){let i=t,s=r;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(h=>h.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,Tn.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}}checkDuplicatedIdRec({id:t,children:r}){if(this.get(t)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:r,fi:i,id:s,data:o,children:a}=t;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=r,c=this.childrenArray(l),h={fi:i,id:s,data:o,children:a};return c=[...c,h],c.sort((f,d)=>f.fi-d.fi),t.localIndex=c.indexOf(h),{data:this.modifyArrayBy(l,c),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:r}=t;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===r);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:r,fi:i,id:s}=t;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let d=r;for(;d!==null;){if(d===void 0)throw new Error;if(d===s)throw new Mf("cyclic tree");d=this.parent(d)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(d=>d.id===s);l=[...l];let h=l.splice(c,1)[0],u=this.modifyArrayBy(o,l);o=r,l=u.childrenArray(o);let f=h.fi;return h={...h,fi:i},l=[...l,h],l.sort((d,m)=>d.fi-m.fi),t.localIndex=l.indexOf(h),u=u.modifyArrayBy(o,l),{data:u,actual:t,reverse:{type:9,parent:a,fi:f,id:s}}}previous(t,r){if(r===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===r)return i;i=s.id}return null}traverseSortNext(t){let r=this.parent(t);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(r)return this.traverseSortNext(r)}}sortNext(t){let r=this.childrenArray(t);return r.length>0?r[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let r=this.childrenArray(t);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):t}sortPrevious(t){let r=this.parent(t);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):r}}getAllSorted(t){let r=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&r.push({...i,...s})}r.sort((i,s)=>Pw(i.sortKey,s.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(t){var r=t;let i=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)i.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:i}}}insertBeforeHelper(t,r,i){return this.insertAfterHelper(t,this.previous(t,r),i)}insertAfterHelper(t,r,i){let s=this.childrenArray(t);if(r===null){if(s.length===0)return fi(0,i,i);{let o=s[0].fi;return fi(o-i,o,i)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==t)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return fi(l,l+i,i)}else return fi(o.fi,a.fi,i)}}};var Tf;(e=>{function n(t,r){if(Array.isArray(t)){let i=r.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let i=r.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}e.runOp=n})(Tf||(Tf={}));var Gt=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Gt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,r){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,Gt.prototype);let r=t;return Lw()||r.fillCaches(),r}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}}addOp(t){let{fi:r,id:i,data:s}=t,o=this,a={fi:r,id:i,data:s};return o=[...o,a],o.sort((c,h)=>c.fi-h.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:r}=t,i=this,s=i.findIndex(l=>l.id===r);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:r,id:i}=t,s=this;s=[...s];let o=s.findIndex(h=>h.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((h,u)=>h.fi-u.fi),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let i of this){if(i.id===t)return r;r=i.id}return null}insertBeforeHelper(t,r){return this.insertAfterHelper(this.previous(t),r)}insertAfterHelper(t,r){let i=this;if(t===null){if(i.length===0)return fi(0,r,r);{let s=i[0].fi;return fi(s-r,s,r)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return fi(a,a+r,r)}else return fi(s.fi,o.fi,r)}}};var Bw=Symbol(),Cf=Symbol(),qa=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let i=[];for(;!(r instanceof Ef);){let s=r._path,o=r._current;if(s!==""&&i.splice(0,0,s),r=r._parent,r===null)return;r.update(s,o)}r.push(i,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[Cf];r&&r(),delete this._children[e]}}}},hg=class extends qa{constructor(e,t,r){super(),this._parent=e,this._path=t,this._current=r}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,Tf.runOp(this._current,e))}},ug=class extends qa{constructor(e,t,r){super(),this._parent=e,this._path=t,this._current=r}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,_n.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Ow={get(n,e){if(e===Cf)return()=>{n._parent=null};if(e===Bw)return n._current;let{_current:t,_children:r}=n;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[e];if(i!==void 0)return i;let s=t[e],o=Df(n,e,s);return o!==s?(r===void 0&&(r={},n._children=r),r[e]=o,o):s},has(n,e){return e in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,e){let t=n._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},jB={...Ow,set(n,e,t){let r={type:0,props:{[e]:pg(t)??t}};return n.deleteChildren(e),n.runOp(r),!0},deleteProperty(n,e){let t={type:0,props:{[e]:void 0}};return n.deleteChildren(e),n.runOp(t),!0}},qB={...Ow,set(n,e,t){return t===void 0?this.deleteProperty(n,e):(n.deleteChildren(e),n.runOp({type:1,id:e,data:t})),!0},deleteProperty(n,e){return n.runOp({type:2,id:e}),!0}},Ya=class extends qa{constructor(e,t,r){super(),this._children={},this._parent=e,this._path=t,this._current=r,this[Cf]=()=>{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,r)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:r}=this,i=r===void 0?void 0:r[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Df(this,e,s);return o!==s?(r===void 0&&(r={},this._children=r),r[e]=o,o):s}add(e,t,r,i,s){this.runOp({type:7,parent:e,fi:t,id:r,data:i,children:s})}move(e,t,r){this.runOp({type:9,parent:e,fi:t,id:r})}insertAfter(e,t,r){let i=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,r){let i=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,r){let i=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(e,i[s],o)}}moveBefore(e,t,r){let i=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(e,i[s],o)}}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)}},Xa=class extends qa{constructor(e,t,r){super(),this._children={},this._parent=e,this._path=t,this._current=r,this[Cf]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let i=this._current[r].id;e(this.data(this._current[r].id),i)}}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:r}=this,i=r===void 0?void 0:r[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Df(this,e,s);return o!==s?(r===void 0&&(r={},this._children=r),r[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:4,fi:e,id:t,data:r})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r[i],s.id,s.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r[i],s.id,s.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r[i],s)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function cg(n,e,t){if(n.length>0){let r=n[n.length-1];if(r.type===0&&e.type===0&&Pf.equal(r.path,t)){Object.assign(r.props,e.props);return}}n.push({...e,path:t})}var Ef=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,i){cg(this.ts,t,e),cg(this.actual,r,e),cg(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Df(n,e,t){return t instanceof Tn?new Ya(n,e,t):t instanceof Gt?new Xa(n,e,t):t instanceof _n?new Proxy(new ug(n,e,t),qB):t!==null&&typeof t=="object"?_f(t)?t:new Proxy(new hg(n,e,t),jB):t}function fg(n){let e=new Ef(n);return[Df(e,"",n),e]}function dg(n,e){let[t,r]=fg(n);return e(t),r.result()}function pg(n){return n instanceof Ya||n instanceof Xa?n._current:n!==null&&typeof n=="object"?n[Bw]:n}var Pf;(r=>{function n(i,s){if(s.length===i.length)for(var o=0;o<i.length;){if(i[o]!==s[o])return!1;o+=1}else return!1;return!0}r.equal=n;function e(i,s,o){let a=t(o,i);if(a!==void 0&&typeof a=="object"&&a!==null){let l={...s};return Object.keys(a).forEach(c=>{delete l[c]}),l}else return s}r.removeOverridden=e;function t(i,s,o=0){if(s.length<=o)return i;if((i instanceof Tn||i instanceof Ya)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if((i instanceof Gt||i instanceof Xa)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if(typeof s[o]=="number"&&Array.isArray(i))return t(i[s[o]],s,o+1);if(typeof s[o]=="string"&&typeof i=="object")return t(i[s[o]],s,o+1)}r.zoom=t})(Pf||(Pf={}));var Lf=class{},Uc=class extends Lf{constructor(t){super();this.id=t}},Gc=class extends Lf{constructor(t){super();this.data=t}};var gg;try{gg=new TextDecoder}catch{}var Ce,Bs,J=0;var Hw=[],yg=Hw,vg=0,rn={},yt,Ns,En=0,di=0,gn,Wi,jr=[],At,Rw={useRecords:!1,mapsAsObjects:!0},kc=class{},bg=new kc;bg.name="MessagePack 0xC1";var Ja=!1,pi=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(Ce)return Xw(()=>(Nf(),this?this.unpack(e,t):pi.prototype.unpack.call(Rw,e,t)));Bs=t>-1?t:e.length,J=0,vg=0,di=0,Ns=null,yg=Hw,gn=null,Ce=e;try{At=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw Ce=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof pi){if(rn=this,this.structures)return yt=this.structures,If();(!yt||yt.length>0)&&(yt=[])}else rn=Rw,(!yt||yt.length>0)&&(yt=[]);return If()}unpackMultiple(e,t){let r,i=0;try{Ja=!0;let s=e.length,o=this?this.unpack(e,s):Rf.unpack(e,s);if(t){for(t(o);J<s;)if(i=J,t(If())===!1)return}else{for(r=[o];J<s;)i=J,r.push(If());return r}}catch(s){throw s.lastPosition=i,s.values=r,s}finally{Ja=!1,Nf()}}_mergeStructures(e,t){e=e||[];for(let r=0,i=e.length;r<i;r++){let s=e[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let i=e[r],s=t[r];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[r]=i),e[r]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function If(){try{if(!rn.trusted&&!Ja){let e=yt.sharedLength||0;e<yt.length&&(yt.length=e)}let n=Yt();if(J==Bs)yt.restoreStructures&&Fw(),yt=null,Ce=null,Wi&&(Wi=null);else if(J>Bs){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Ja)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw yt.restoreStructures&&Fw(),Nf(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Fw(){for(let n in yt.restoreStructures)yt[n]=yt.restoreStructures[n];yt.restoreStructures=null}function Yt(){let n=Ce[J++];if(n<160)if(n<128){if(n<64)return n;{let e=yt[n&63]||rn.getStructures&&Ww()[n&63];return e?(e.read||(e.read=wg(e,n&63)),e.read()):n}}else if(n<144)if(n-=128,rn.mapsAsObjects){let e={};for(let t=0;t<n;t++)e[qw()]=Yt();return e}else{let e=new Map;for(let t=0;t<n;t++)e.set(Yt(),Yt());return e}else{n-=144;let e=new Array(n);for(let t=0;t<n;t++)e[t]=Yt();return e}else if(n<192){let e=n-160;if(di>=J)return Ns.slice(J-En,(J+=e)-En);if(di==0&&Bs<140){let t=e<16?Sg(e):jw(e);if(t!=null)return t}return xg(e)}else{let e;switch(n){case 192:return null;case 193:return gn?(e=Yt(),e>0?gn[1].slice(gn.position1,gn.position1+=e):gn[0].slice(gn.position0,gn.position0-=e)):bg;case 194:return!1;case 195:return!0;case 196:return mg(Ce[J++]);case 197:return e=At.getUint16(J),J+=2,mg(e);case 198:return e=At.getUint32(J),J+=4,mg(e);case 199:return Mo(Ce[J++]);case 200:return e=At.getUint16(J),J+=2,Mo(e);case 201:return e=At.getUint32(J),J+=4,Mo(e);case 202:if(e=At.getFloat32(J),rn.useFloat32>2){let t=Of[(Ce[J]&127)<<1|Ce[J+1]>>7];return J+=4,(t*e+(e>0?.5:-.5)>>0)/t}return J+=4,e;case 203:return e=At.getFloat64(J),J+=8,e;case 204:return Ce[J++];case 205:return e=At.getUint16(J),J+=2,e;case 206:return e=At.getUint32(J),J+=4,e;case 207:return rn.int64AsNumber?(e=At.getUint32(J)*4294967296,e+=At.getUint32(J+4)):e=At.getBigUint64(J),J+=8,e;case 208:return At.getInt8(J++);case 209:return e=At.getInt16(J),J+=2,e;case 210:return e=At.getInt32(J),J+=4,e;case 211:return rn.int64AsNumber?(e=At.getInt32(J)*4294967296,e+=At.getUint32(J+4)):e=At.getBigInt64(J),J+=8,e;case 212:if(e=Ce[J++],e==114)return Vw(Ce[J++]&63);{let t=jr[e];if(t)return t.read?(J++,t.read(Yt())):t.noBuffer?(J++,t()):t(Ce.subarray(J,++J));throw new Error("Unknown extension "+e)}case 213:return e=Ce[J],e==114?(J++,Vw(Ce[J++]&63,Ce[J++])):Mo(2);case 214:return Mo(4);case 215:return Mo(8);case 216:return Mo(16);case 217:return e=Ce[J++],di>=J?Ns.slice(J-En,(J+=e)-En):XB(e);case 218:return e=At.getUint16(J),J+=2,di>=J?Ns.slice(J-En,(J+=e)-En):JB(e);case 219:return e=At.getUint32(J),J+=4,di>=J?Ns.slice(J-En,(J+=e)-En):QB(e);case 220:return e=At.getUint16(J),J+=2,Uw(e);case 221:return e=At.getUint32(J),J+=4,Uw(e);case 222:return e=At.getUint16(J),J+=2,Gw(e);case 223:return e=At.getUint32(J),J+=4,Gw(e);default:if(n>=224)return n-256;if(n===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+n)}}}var YB=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function wg(n,e){function t(){if(t.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>YB.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Yt);return n.highByte===0&&(n.read=zw(e,n.read)),i()}let r={};for(let i=0,s=n.length;i<s;i++){let o=n[i];r[o]=Yt()}return r}return t.count=0,n.highByte===0?zw(e,t):t}var zw=(n,e)=>function(){let t=Ce[J++];if(t===0)return e();let r=n<32?-(n+(t<<5)):n+(t<<5),i=yt[r]||Ww()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=wg(i,n)),i.read()};function Ww(){let n=Xw(()=>(Ce=null,rn.getStructures()));return yt=rn._mergeStructures(n,yt)}var xg=Bf,XB=Bf,JB=Bf,QB=Bf;function Bf(n){let e;if(n<16&&(e=Sg(n)))return e;if(n>64&&gg)return gg.decode(Ce.subarray(J,J+=n));let t=J+n,r=[];for(e="";J<t;){let i=Ce[J++];if((i&128)===0)r.push(i);else if((i&224)===192){let s=Ce[J++]&63;r.push((i&31)<<6|s)}else if((i&240)===224){let s=Ce[J++]&63,o=Ce[J++]&63;r.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ce[J++]&63,o=Ce[J++]&63,a=Ce[J++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(e+=br.apply(String,r),r.length=0)}return r.length>0&&(e+=br.apply(String,r)),e}function Uw(n){let e=new Array(n);for(let t=0;t<n;t++)e[t]=Yt();return e}function Gw(n){if(rn.mapsAsObjects){let e={};for(let t=0;t<n;t++)e[qw()]=Yt();return e}else{let e=new Map;for(let t=0;t<n;t++)e.set(Yt(),Yt());return e}}var br=String.fromCharCode;function jw(n){let e=J,t=new Array(n);for(let r=0;r<n;r++){let i=Ce[J++];if((i&128)>0){J=e;return}t[r]=i}return br.apply(String,t)}function Sg(n){if(n<4)if(n<2){if(n===0)return"";{let e=Ce[J++];if((e&128)>1){J-=1;return}return br(e)}}else{let e=Ce[J++],t=Ce[J++];if((e&128)>0||(t&128)>0){J-=2;return}if(n<3)return br(e,t);let r=Ce[J++];if((r&128)>0){J-=3;return}return br(e,t,r)}else{let e=Ce[J++],t=Ce[J++],r=Ce[J++],i=Ce[J++];if((e&128)>0||(t&128)>0||(r&128)>0||(i&128)>0){J-=4;return}if(n<6){if(n===4)return br(e,t,r,i);{let s=Ce[J++];if((s&128)>0){J-=5;return}return br(e,t,r,i,s)}}else if(n<8){let s=Ce[J++],o=Ce[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(n<7)return br(e,t,r,i,s,o);let a=Ce[J++];if((a&128)>0){J-=7;return}return br(e,t,r,i,s,o,a)}else{let s=Ce[J++],o=Ce[J++],a=Ce[J++],l=Ce[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(n<10){if(n===8)return br(e,t,r,i,s,o,a,l);{let c=Ce[J++];if((c&128)>0){J-=9;return}return br(e,t,r,i,s,o,a,l,c)}}else if(n<12){let c=Ce[J++],h=Ce[J++];if((c&128)>0||(h&128)>0){J-=10;return}if(n<11)return br(e,t,r,i,s,o,a,l,c,h);let u=Ce[J++];if((u&128)>0){J-=11;return}return br(e,t,r,i,s,o,a,l,c,h,u)}else{let c=Ce[J++],h=Ce[J++],u=Ce[J++],f=Ce[J++];if((c&128)>0||(h&128)>0||(u&128)>0||(f&128)>0){J-=12;return}if(n<14){if(n===12)return br(e,t,r,i,s,o,a,l,c,h,u,f);{let d=Ce[J++];if((d&128)>0){J-=13;return}return br(e,t,r,i,s,o,a,l,c,h,u,f,d)}}else{let d=Ce[J++],m=Ce[J++];if((d&128)>0||(m&128)>0){J-=14;return}if(n<15)return br(e,t,r,i,s,o,a,l,c,h,u,f,d,m);let p=Ce[J++];if((p&128)>0){J-=15;return}return br(e,t,r,i,s,o,a,l,c,h,u,f,d,m,p)}}}}}function mg(n){return rn.copyBuffers?Uint8Array.prototype.slice.call(Ce,J,J+=n):Ce.subarray(J,J+=n)}function Mo(n){let e=Ce[J++];if(jr[e])return jr[e](Ce.subarray(J,J+=n));throw new Error("Unknown extension type "+e)}var kw=new Array(4096);function qw(){let n=Ce[J++];if(n>=160&&n<192){if(n=n-160,di>=J)return Ns.slice(J-En,(J+=n)-En);if(!(di==0&&Bs<180))return xg(n)}else return J--,Yt();let e=(n<<5^(n>1?At.getUint16(J):n>0?Ce[J]:0))&4095,t=kw[e],r=J,i=J+n-3,s,o=0;if(t&&t.bytes==n){for(;r<i;){if(s=At.getUint32(r),s!=t[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(s=Ce[r++],s!=t[o++]){r=1879048192;break}if(r===i)return J=r,t.string;i-=3,r=J}for(t=[],kw[e]=t,t.bytes=n;r<i;)s=At.getUint32(r),t.push(s),r+=4;for(i+=3;r<i;)s=Ce[r++],t.push(s);let a=n<16?Sg(n):jw(n);return a!=null?t.string=a:t.string=xg(n)}var Vw=(n,e)=>{var t=Yt();let r=n;e!==void 0&&(n=n<32?-((e<<5)+n):(e<<5)+n,t.highByte=e);let i=yt[n];return i&&i.isShared&&((yt.restoreStructures||(yt.restoreStructures=[]))[n]=i),yt[n]=t,t.read=wg(t,r),t.read()},Yw=typeof self=="object"?self:global;jr[0]=()=>{};jr[0].noBuffer=!0;jr[101]=()=>{let n=Yt();return(Yw[n[0]]||Error)(n[1])};jr[105]=n=>{let e=At.getUint32(J-4);Wi||(Wi=new Map);let t=Ce[J],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let i={target:r};Wi.set(e,i);let s=Yt();return i.used?Object.assign(r,s):(i.target=s,s)};jr[112]=n=>{let e=At.getUint32(J-4),t=Wi.get(e);return t.used=!0,t.target};jr[115]=()=>new Set(Yt());var Ag=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");jr[116]=n=>{let e=n[0],t=Ag[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Yw[t](Uint8Array.prototype.slice.call(n,1).buffer)};jr[120]=()=>{let n=Yt();return new RegExp(n[0],n[1])};jr[98]=n=>{let e=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],t=J;J+=e-4,gn=[Yt(),Yt()],gn.position0=0,gn.position1=0;let r=J;J=t;try{return Yt()}finally{J=r}};jr[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Xw(n){let e=Bs,t=J,r=vg,i=En,s=di,o=Ns,a=yg,l=Wi,c=gn,h=new Uint8Array(Ce.slice(0,Bs)),u=yt,f=yt.slice(0,yt.length),d=rn,m=Ja,p=n();return Bs=e,J=t,vg=r,En=i,di=s,Ns=o,yg=a,Wi=l,gn=c,Ce=h,Ja=m,yt=u,yt.splice(0,yt.length,...f),rn=d,At=new DataView(Ce.buffer,Ce.byteOffset,Ce.byteLength),p}function Nf(){Ce=null,Wi=null,yt=null}function Jw(n){n.unpack?jr[n.type]=n.unpack:jr[n.type]=n}var Of=new Array(147);for(let n=0;n<256;n++)Of[n]=+("1e"+Math.floor(45.15-n*.30103));var Rf=new pi({useRecords:!1}),KB=Rf.unpack,ZB=Rf.unpackMultiple,$B=Rf.unpack,Ff={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},eO=new Float32Array(1),xj=new Uint8Array(eO.buffer,0,4);var zf;try{zf=new TextEncoder}catch{}var Uf,_g,Gf=typeof Buffer<"u",Mg=Gf?Buffer.allocUnsafeSlow:Uint8Array,$w=Gf?Buffer:Uint8Array,Qw=Gf?4294967296:2144337920,oe,Kt,ee=0,mi,gi=null,tO=/[\u0080-\uFFFF]/,Vc=Symbol("record-id"),_o=class extends pi{constructor(e){super(e),this.offset=0;let t,r,i,s,o,a,l=0,c=$w.prototype.utf8Write?function(y,T,E){return oe.utf8Write(y,T,E)}:zf&&zf.encodeInto?function(y,T){return zf.encodeInto(y,oe.subarray(T)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,f=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=f?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=f?32:64),u&&!e.saveStructures&&(this.structures=[]);let p=d>32||m+d>64,g=d+64,x=d+m+64;if(x>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,b=0;this.pack=this.encode=function(y,T){if(oe||(oe=new Mg(8192),Kt=new DataView(oe.buffer,0,8192),ee=0),mi=oe.length-10,mi-ee<2048?(oe=new Mg(oe.length),Kt=new DataView(oe.buffer,0,oe.length),mi=oe.length-10,ee=0):ee=ee+7&2147483640,r=ee,a=h.structuredClone?new Map:null,h.bundleStrings?(gi=["",""],oe[ee++]=214,oe[ee++]=98,gi.position=ee-r,ee+=4):gi=null,i=h.structures,i){i.uninitialized&&(i=h._mergeStructures(h.getStructures()));let E=i.sharedLength||0;if(E>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let I=i[C];if(!I)continue;let B,N=i.transitions;for(let H=0,j=I.length;H<j;H++){let Q=I[H];B=N[Q],B||(B=N[Q]=Object.create(null)),N=B}N[Vc]=C+64}l=E}u||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(y),gi){Kt.setUint32(gi.position+r,ee-gi.position-r);let E=gi;gi=null,S(E[0]),S(E[1])}if(h.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>mi&&_(ee),h.offset=ee;let E=nO(oe.subarray(r,ee),a.idsToInsert);return a=null,E}return T&tS?(oe.start=r,oe.end=ee,oe):oe.subarray(r,ee)}finally{if(i){if(b<10&&b++,w>1e4)i.transitions=null,b=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let E=0,C=v.length;E<C;E++)v[E][Vc]=0;v=[]}if(s&&h.saveStructures){let E=i.sharedLength||d;i.length>E&&(i=i.slice(0,E));let C=oe.subarray(r,ee);return h.saveStructures(i,l)===!1?(h._mergeStructures(h.getStructures()),h.pack(y)):(l=E,C)}}T&hO&&(ee=r)}};let S=y=>{ee>mi&&(oe=_(ee));var T=typeof y,E;if(T==="string"){let C=y.length;if(gi&&C>=8&&C<4096){let N=tO.test(y);gi[N?0:1]+=y,oe[ee++]=193,S(N?-C:C);return}let I;C<32?I=1:C<256?I=2:C<65536?I=3:I=5;let B=C*3;if(ee+B>mi&&(oe=_(ee+B)),C<64||!c){let N,H,j,Q=ee+I;for(N=0;N<C;N++)H=y.charCodeAt(N),H<128?oe[Q++]=H:H<2048?(oe[Q++]=H>>6|192,oe[Q++]=H&63|128):(H&64512)===55296&&((j=y.charCodeAt(N+1))&64512)===56320?(H=65536+((H&1023)<<10)+(j&1023),N++,oe[Q++]=H>>18|240,oe[Q++]=H>>12&63|128,oe[Q++]=H>>6&63|128,oe[Q++]=H&63|128):(oe[Q++]=H>>12|224,oe[Q++]=H>>6&63|128,oe[Q++]=H&63|128);E=Q-ee-I}else E=c(y,ee+I,B);E<32?oe[ee++]=160|E:E<256?(I<2&&oe.copyWithin(ee+2,ee+1,ee+1+E),oe[ee++]=217,oe[ee++]=E):E<65536?(I<3&&oe.copyWithin(ee+3,ee+2,ee+2+E),oe[ee++]=218,oe[ee++]=E>>8,oe[ee++]=E&255):(I<5&&oe.copyWithin(ee+5,ee+3,ee+3+E),oe[ee++]=219,Kt.setUint32(ee,E),ee+=4),ee+=E}else if(T==="number")if(y>>>0===y)y<64?oe[ee++]=y:y<256?(oe[ee++]=204,oe[ee++]=y):y<65536?(oe[ee++]=205,oe[ee++]=y>>8,oe[ee++]=y&255):(oe[ee++]=206,Kt.setUint32(ee,y),ee+=4);else if(y>>0===y)y>=-32?oe[ee++]=256+y:y>=-128?(oe[ee++]=208,oe[ee++]=y+256):y>=-32768?(oe[ee++]=209,Kt.setInt16(ee,y),ee+=2):(oe[ee++]=210,Kt.setInt32(ee,y),ee+=4);else{let C;if((C=this.useFloat32)>0&&y<4294967296&&y>=-2147483648){oe[ee++]=202,Kt.setFloat32(ee,y);let I;if(C<4||(I=y*Of[(oe[ee]&127)<<1|oe[ee+1]>>7])>>0===I){ee+=4;return}else ee--}oe[ee++]=203,Kt.setFloat64(ee,y),ee+=8}else if(T==="object")if(!y)oe[ee++]=192;else{if(a){let I=a.get(y);if(I){if(!I.id){let B=a.idsToInsert||(a.idsToInsert=[]);I.id=B.push(I)}oe[ee++]=214,oe[ee++]=112,Kt.setUint32(ee,I.id),ee+=4;return}else a.set(y,{offset:ee-r})}let C=y.constructor;if(C===Object)M(y,!0);else if(C===Array){E=y.length,E<16?oe[ee++]=144|E:E<65536?(oe[ee++]=220,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=221,Kt.setUint32(ee,E),ee+=4);for(let I=0;I<E;I++)S(y[I])}else if(C===Map){E=y.size,E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,Kt.setUint32(ee,E),ee+=4);for(let[I,B]of y)S(I),S(B)}else{for(let I=0,B=Uf.length;I<B;I++){let N=_g[I];if(y instanceof N){let H=Uf[I];if(H.write){H.type&&(oe[ee++]=212,oe[ee++]=H.type,oe[ee++]=0),S(H.write.call(this,y));return}let j=oe,Q=Kt,X=ee;oe=null;let U;try{U=H.pack.call(this,y,F=>(oe=j,j=null,ee+=F,ee>mi&&_(ee),{target:oe,targetView:Kt,position:ee-F}),S)}finally{j&&(oe=j,Kt=Q,ee=X,mi=oe.length-10)}U&&(U.length+ee>mi&&_(U.length+ee),ee=rO(U,oe,ee,H.type));return}}M(y,!y.hasOwnProperty)}}else if(T==="boolean")oe[ee++]=y?195:194;else if(T==="bigint"){if(y<BigInt(1)<<BigInt(63)&&y>=-(BigInt(1)<<BigInt(63)))oe[ee++]=211,Kt.setBigInt64(ee,y);else if(y<BigInt(1)<<BigInt(64)&&y>0)oe[ee++]=207,Kt.setBigUint64(ee,y);else if(this.largeBigIntToFloat)oe[ee++]=203,Kt.setFloat64(ee,Number(y));else throw new RangeError(y+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ee+=8}else if(T==="undefined")this.encodeUndefinedAsNil?oe[ee++]=192:(oe[ee++]=212,oe[ee++]=0,oe[ee++]=0);else if(T==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},M=this.useRecords===!1?this.variableMapSize?y=>{let T=Object.keys(y),E=T.length;E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,Kt.setUint32(ee,E),ee+=4);let C;for(let I=0;I<E;I++)S(C=T[I]),S(y[C])}:(y,T)=>{oe[ee++]=222;let E=ee-r;ee+=2;let C=0;for(let I in y)(T||y.hasOwnProperty(I))&&(S(I),S(y[I]),C++);oe[E+++r]=C>>8,oe[E+r]=C&255}:y=>{let T=Object.keys(y),E,C=o.transitions||(o.transitions=Object.create(null)),I=0;for(let N=0,H=T.length;N<H;N++){let j=T[N];E=C[j],E||(E=C[j]=Object.create(null),I++),C=E}let B=C[Vc];if(B)B>=96&&p?(oe[ee++]=((B-=96)&31)+96,oe[ee++]=B>>5):oe[ee++]=B;else{B=o.nextId,B||(B=64),B<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(B=o.nextOwnId,B<x||(B=g),o.nextOwnId=B+1):(B>=x&&(B=g),o.nextId=B+1);let N=T.highByte=B>=96&&p?B-96>>5:-1;C[Vc]=B,o[B-64]=T,B<g?(T.isShared=!0,o.sharedLength=B-63,s=!0,N>=0?(oe[ee++]=(B&31)+96,oe[ee++]=N):oe[ee++]=B):(N>=0?(oe[ee++]=213,oe[ee++]=114,oe[ee++]=(B&31)+96,oe[ee++]=N):(oe[ee++]=212,oe[ee++]=114,oe[ee++]=B),I&&(w+=b*I),v.length>=m&&(v.shift()[Vc]=0),v.push(C),S(T))}for(let N=0,H=T.length;N<H;N++)S(y[T[N]])},_=y=>{let T;if(y>16777216){if(y-r>Qw)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(Qw,Math.round(Math.max((y-r)*(y>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(y-r<<2,oe.length-1)>>12)+1<<12;let E=new Mg(T);return Kt=new DataView(E.buffer,0,T),oe.copy?oe.copy(E,0,r,y):E.set(oe.slice(r,y)),ee-=r,r=0,mi=E.length-10,oe=E}}useBuffer(e){oe=e,Kt=new DataView(oe.buffer,oe.byteOffset,oe.byteLength),ee=0}};_g=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,kc];Uf=[{pack(n,e,t){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,n.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(n,e,t){let r=Array.from(n),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(r)}},{pack(n,e,t){let{target:r,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),t([n.name,n.message])}},{pack(n,e,t){let{target:r,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),t([n.source,n.flags])}},{pack(n,e){this.structuredClone?Kw(n,16,e):Zw(Gf?Buffer.from(n):new Uint8Array(n),e)}},{pack(n,e){let t=n.constructor;t!==$w&&this.structuredClone?Kw(n,Ag.indexOf(t.name),e):Zw(n,e)}},{pack(n,e){let{target:t,position:r}=e(1);t[r]=193}}];function Kw(n,e,t,r){let i=n.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),o)}function Zw(n,e){let t=n.byteLength;var r,i;if(t<256){var{target:r,position:i}=e(t+2);r[i++]=196,r[i++]=t}else if(t<65536){var{target:r,position:i}=e(t+3);r[i++]=197,r[i++]=t>>8,r[i++]=t&255}else{var{target:r,position:i,targetView:s}=e(t+5);r[i++]=198,s.setUint32(i,t),i+=4}r.set(n,i)}function rO(n,e,t,r){let i=n.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=r,e.set(n,t),t+=i,t}function nO(n,e){let t,r=e.length*6,i=n.length-r;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;n.copyWithin(s+r,s,i),r-=6;let a=s+r;n[a++]=214,n[a++]=105,n[a++]=o>>24,n[a++]=o>>16&255,n[a++]=o>>8&255,n[a++]=o&255,i=s}return n}function To(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");_g.unshift(n.Class),Uf.unshift(n)}Jw(n)}var eS=new _o({useRecords:!1}),iO=eS.pack,sO=eS.pack;var{NEVER:oO,ALWAYS:aO,DECIMAL_ROUND:lO,DECIMAL_FIT:cO}=Ff,tS=512,hO=1024;var rS=new _o({structuredClone:!0});To({Class:_n.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,_n.prototype),n}});To({Class:Gt.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Gt.prototype),n}});To({Class:Tn.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Tn.prototype),n}});To({Class:Uc.prototype.constructor,type:4,write(n){return n.id},read(n){return new Uc(n)}});To({Class:Gc.prototype.constructor,type:5,write(n){return n.data},read(n){return new Gc(n)}});function uO(n){var e=0;if(n.length===0)return e;for(let t=0;t<n.length;t++){let r=n[t];e=(e<<5)-e+r,e=e&e}return e}function Tg(n){if(_f(n))return n;if(Array.isArray(n))return n.map(Tg);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=Tg(n[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else return n}var kf;(r=>{function n(i){return rS.pack(i)}r.serialize=n;function e(i){return rS.unpack(i)}r.deserialize=e;function t(i){return uO(n(Tg(i))).toString()}r.checksum=t})(kf||(kf={}));var Vf;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(Vf||(Vf={}));var Hf;(t=>{function n(r){return e(r)}t.defaultData=n;function e(r){if(r==="PointLight")return{type:r,color:mn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5,helper:!0};if(r==="SpotLight")return{type:r,color:mn.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,helper:!0,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:mn.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,helper:!0,shadowRadius:1};throw new Error("not implemented")}})(Hf||(Hf={}));var Eg;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}t.equals=e})(Eg||(Eg={}));var Cg;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}t.equals=e})(Cg||(Cg={}));var Wf;(e=>e.defaultData={...Cg.defaultData,...Eg.defaultData,cloner:null,booleanExclude:null})(Wf||(Wf={}));var Dg=(i=>(i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Center=3]="Center",i[i.Justify=4]="Justify",i))(Dg||{}),Pg=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Pg||{}),Lg=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(Lg||{}),jf;(e=>e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:mn.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(jf||(jf={}));var nS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"];var Qa;(r=>{function n(i,s){return i==="light"&&s?e(s):t(i)}r.defaultData=n;function e(i){switch(i){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:hr.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...hr.fromHex(6710886),a:1},colorB:{...hr.fromHex(6710886),a:1},colorC:{...hr.fromHex(16777215),a:1},colorD:{...hr.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:mn.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Qa||(Qa={}));var jn;(a=>{function n(l){return!l.layers.some(h=>{if(h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")return!0})&&!t(l)}a.isMergable=n;function e(l){let c="";return l.layers.forEach(h=>{Object.entries(h.data).forEach(([u,f])=>{c+=`${u}${f}`,Array.isArray(f)?f.forEach(d=>c+=`${d}`):typeof f=="object"?Object.values(f).forEach(d=>{typeof d=="number"?c+=`${d.toFixed(4)}`:c+=`${d}`}):c+=`${f}`})}),c}a.getHash=e;function t(l){let c=0;for(let h of l.layers)"alpha"in h.data&&h.data.type!=="light"&&h.data.type!=="fresnel"&&(c+=(1-c)*h.data.alpha);return c<1}a.isTransparent=t;function r(){return{layers:new Gt}}a.defaultEmptyData=r;function i(l="layer1",c="layer2"){return s("phong",l,c)}a.defaultData=i;function s(l,c="layer1",h="layer2"){let u=new Gt;return u.push({fi:0,data:Qa.defaultData("light",l),id:c}),u.push({fi:1,data:Qa.defaultData("color"),id:h}),{layers:u}}a.defaultTwoLayerData=s;function o(l,c="basic",h="layer1",u="layer2"){let f=Qa.defaultData("texture");Object.assign(f.texture,{image:l});let d=new Gt;return d.push({fi:0,data:f,id:h}),d.push({fi:1,data:Qa.defaultData("light",c),id:u}),{layers:d}}a.defaultTwoLayerTextureData=o})(jn||(jn={}));var Ka;(e=>{function n(){return{points:new Gt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=n})(Ka||(Ka={}));var qf;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=n})(qf||(qf={}));var Hc;(e=>{function n(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Ka.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};throw new Error("not implemented")}e.defaultData=n})(Hc||(Hc={}));var Wc;(i=>{i.identity={...bf.identity,hiddenMatrix:ui.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function r(s,o){return{position:sr.isEqual(s.position,o.position)?null:o.position,rotation:sr.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:sr.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:ui.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=r})(Wc||(Wc={}));var ji;(e=>e.defaultData={states:new Gt,events:new Gt,visible:!0,raycastLock:!1,...Wc.identity})(ji||(ji={}));var iS;(e=>e.defaultData={type:"Empty",...ji.defaultData})(iS||(iS={}));var Yf;(e=>e.defaultData={type:"Mesh",...ji.defaultData,...Wf.defaultData})(Yf||(Yf={}));var sS;(e=>e.defaultData={type:"TextFrame",...ji.defaultData,...jf.defaultData})(sS||(sS={}));var Xf;(e=>e.defaultData={...ji.defaultData,...Wc.identity,...Ao.defaultData})(Xf||(Xf={}));var oS;(e=>{function n(t){return{...ji.defaultData,...Hf.defaultData(t)}}e.defaultData=n})(oS||(oS={}));var aS;(r=>(r.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:ui.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Gt,events:new Gt,...Ao.defaultData},r.defaultMeshObject={name:"Rectangle",...ji.defaultData,...Yf.defaultData,geometry:Hc.defaultData("RectangleGeometry"),material:jn.defaultTwoLayerData("basic","layer1","layer2")},r.defaultBooleanObject={name:"Boolean",...ji.defaultData,...Yf.defaultData,geometry:Hc.defaultData("BooleanGeometry"),material:jn.defaultTwoLayerData("phong","layer1","layer2")}))(aS||(aS={}));var jc;(t=>{function n(r,i){if(i===void 0)return r;let s={...r};return"material"in s&&"material"in i&&i.material&&(s.material=dg(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let c=o.layers.data(a);c&&wo(c,l)}}).data),s.materials&&i.materials&&(s.materials=dg(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[c,h]of Object.entries(l.layers)){let u=o[a]?.layers?.data(c);u&&wo(u,h)}}}).data),s}t.patchMaterialState=n;function e(r,i){if(i===void 0)return r;let s={...r};if(Object.assign(s,Wc.merge(s,i)),Is.is(r.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(r.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=n(s,i);else if(Vf.is(r.type)){let o=i;s.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=hr.clone(o.color))}return s}t.patch=e})(jc||(jc={}));function cS(n,e=!1){let t=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,l=new Le,c=0;for(let h=0;h<n.length;++h){let u=n[h],f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let d in u.attributes){if(!r.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(u.attributes[d]),f++}if(f!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(u.userData),e){let d;if(t)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,d,h),c+=d}}if(t){let h=0,u=[];for(let f=0;f<n.length;++f){let d=n[f].index;for(let m=0;m<d.count;++m)u.push(d.getX(m)+h);h+=n[f].attributes.position.count}l.setIndex(u)}for(let h in s){let u=lS(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(let h in o){let u=o[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let f=0;f<u;++f){let d=[];for(let p=0;p<o[h].length;++p)d.push(o[h][p][f]);let m=lS(d);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function lS(n){let e,t,r,i=0;for(let a=0;a<n.length;++a){let l=n[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==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;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<n.length;++a)s.set(n[a].array,o),o+=n[a].array.length;return new Xe(s,t,r)}var Ig={type:"change"},hS={type:"changeZoom"},fO={type:"changePan"},Za={type:"start"},qc={type:"end"},Ng=new jt,dO=new O,pO=2*Math.PI,mO=1e-8,gO=.01,uS=2,Bg=.125,fS=2,Og=1,Rg=1,Fg=.1;var Jf=class extends Ot{constructor(t,r){super();this.object=t;this.domElement=r;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.preventScroll=!0;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,fn.DOLLY_ROTATE,fn.PAN];this.offset=new A;this.eye=new A;this.lastPosition=new A;this.lastQuaternion=new jt;this.current=new O;this.overShoot=new O;this.overRatio=new O;this.spherical=new bc;this.sphericalDelta=new bc;this.panOffset=new A;this.panLeftV=new A;this.panUpV=new A;this.panV=new A;this.rotateStart=new O;this.rotateEnd=new O;this.rotateDelta=new O;this.panStart=new O;this.panEnd=new O;this.panDelta=new O;this.dollyStart=new O;this.dollyEnd=new O;this.dollyDelta=new O;this.rotationRangeFactor=new O;this.panRangeFactor=new O;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(Ng.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(Ng),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-Bg),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let r=this.spherical.phi%pO;return this.eye.copy(this.offset).normalize(),this.object.up.copy(lt.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),r>0&&r>Math.PI||r<0&&r>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-Bg,this.sphericalDelta.phi*=1-Bg):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>gO||8*(1-this.lastQuaternion.dot(this.object.quaternion))>mO?(this.dispatchEvent(Ig),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,ft.length===0&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),vO(t),t.pointerType==="touch"?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{pS(t),this.isPointerDown=!1,ft.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(qc),this.state=-1};this.onPointerCancel=t=>{pS(t)};this.onPointerDownMouse=t=>{let r;switch(this.useKeyEvents?r=this.mouseButtons[t.button]:r=this.mouseButtonsPlay[t.button],r){case 0:if(t.altKey===!0&&!t.shiftKey&&!Rc(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(Rc(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(Rc(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Za)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(mS(t),this.touches[ft.length-1]){case fn.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case fn.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case fn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case fn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Za)};this.onPointerMoveTouch=t=>{switch(mS(t),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Ic(()=>this.dispatchEvent(qc),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||((this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth||this.preventScroll)&&t.preventDefault(),this.dispatchEvent(Za),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Za),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(qc)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchMove=t=>{(t.touches.length>1||this.preventScroll)&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp(ft[0]))};this.onPointerHover=t=>{if(!(xf||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let r={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(r):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(r),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,Fg):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,Fg),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.object=t,this.domElement=r,this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ig),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,r,i){this.target.copy(t),this.object.position.copy(r),this.object.zoom=i,this.object.updateProjectionMatrix(),this.dispatchEvent(Ig),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),Fg=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,uS=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(Ng.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Os(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=Os(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=Os(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=Os(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,this.preventScroll=t.preventScroll,t.orbitTouches===1&&(this.touches[0]=fn.ROTATE),t.panTouches===1&&(this.touches[0]=fn.PAN),t.orbitTouches===2&&(this.touches[1]=fn.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=fn.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=fn.ROTATE),t.panTouches===3&&(this.touches[2]=fn.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),So||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchmove",this.onTouchMove),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),So||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchmove",this.onTouchMove),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,r,i,s,o,a,l,c){this.overShoot.set(0,0);let h,u,f;t instanceof A?(h=t.x,u=t.y,this.current.set(this.target.x,this.target.y),f=!0):(h=t.theta,u=t.phi,this.current.set(Os(this.spherical.theta),Os(this.spherical.phi)),f=!1),i===0&&(this.current.x+=h,this.current.y+=u),(r===3||r===2)&&(!f&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(h=0)),(r===3||r===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(u=0)),f||(this.overShoot.x=Os(this.overShoot.x),this.overShoot.y=Os(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(c),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=dS(Math.abs(this.overRatio.x)),this.overRatio.y=dS(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(h*this.overShoot.x<0&&(h*=1-this.overRatio.x),u*this.overShoot.y<0&&(u*=1-this.overRatio.y)):i===2&&(!f&&(this.overRatio.x>.002||this.overRatio.y>.002)||f&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(h=this.overShoot.x*.05,u=this.overShoot.y*.05,f?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):f?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,u+=this.overShoot.y),t instanceof A?(t.x=h,t.y=u):(t.theta=h,t.phi=u)}setEnableDampingSpeed(t){this.enableDamping=t,Og=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*uS}getZoomScale(){return Math.pow(.95,fS)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,r){this.panLeftV.setFromMatrixColumn(r,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,r){this.panUpV.setFromMatrixColumn(r,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,r){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*r*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(r*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(fO)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(hS)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(hS)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Za),this.dollyOut(t),this.dispatchEvent(qc)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Za),this.dollyIn(t),this.dispatchEvent(qc)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,r=1){this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og*r).rotateAround(dO,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,r=1){this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Rg*r),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(t){if(Tw===!1&&Rc(t)===!1&&yO(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(Rg),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),r=.5*(ft[0].pageY+ft[1].pageY);this.rotateStart.set(t,r)}else this.rotateStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartPan(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),r=.5*(ft[0].pageY+ft[1].pageY);this.panStart.set(t,r)}else this.panStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartDolly(){let t=ft[0].pageX-ft[1].pageX,r=ft[0].pageY-ft[1].pageY,i=Math.sqrt(t*t+r*r);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(ft.length===2){let i=zg(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==ft[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og);let r=this.domElement;r&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/r.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/r.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(ft.length===2){let r=zg(t),i=.5*(t.pageX+r.x),s=.5*(t.pageY+r.y);this.panEnd.set(i,s)}else{if(t.pointerId!==ft[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Rg),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let r=zg(t),i=t.pageX-r.x,s=t.pageY-r.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,fS)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function Os(n){let e=Math.PI*2;for(;n<=-Math.PI;)n+=e;for(;n>Math.PI;)n-=e;return n}function dS(n){return 1-Math.pow(1-n,4)}function yO(n){return n.wheelDeltaY===0||n.deltaY===0?Oc&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120?!1:n.wheelDeltaX?n.wheelDeltaX===-3*n.deltaX:n.deltaMode===0:n.wheelDeltaY?n.wheelDeltaY===-3*n.deltaY:n.deltaMode===0}var ft=[],Qf={};function vO(n){ft.push(n)}function pS(n){delete Qf[n.pointerId];for(let e=0;e<ft.length;e++)if(ft[e].pointerId===n.pointerId){ft.splice(e,1);return}}function mS(n){let e=Qf[n.pointerId];e===void 0&&(e=new O,Qf[n.pointerId]=e),e.set(n.pageX,n.pageY)}function zg(n){let e=n.pointerId===ft[0].pointerId?ft[1]:ft[0];return Qf[e.pointerId]}var Rs=class extends Eu{constructor(){super(),this.layers.enable(3)}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,r=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,r)}),r}createRaycastLineHelper(){let e=new Zr({color:65280,linewidth:10}),t=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new A().addVectors(t,r.multiplyScalar(i)),o=new Le;return o.setFromPoints([t,s]),new ao(o,e)}};var yS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},n.parameters),r=t.width/2,i=t.radiusTop??r,s=t.radiusBottom??r;return i===s?(i=r,s=r):i>s?(i=r,s=s*r/i):(i=i*r/s,s=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(n){let{width:e,depth:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:h,cornerRadius:u,cornerSegments:f,hollow:d}=n.parameters,m;return u||d?m=new Yc(c,h,r,i,s,o,a,l*Math.PI/180,u,u,f,d):m=new co(c,h,r,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Fs(n,e,t){t.x=n.x*e.x,t.y=n.y,t.z=n.x*e.y}function gS(n){return new O(n.y,-n.x)}var Yc=class extends Le{constructor(e,t,r,i,s,o,a,l,c,h,u,f,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,h=0);let m=[],p=[],g=[],x=[],v=0,w=r/2,b=new A,S=new A;d&&e==0&&(e=c),d&&t==0&&(t=h);let M=new O(e,w),_=new O(t,-w),y=null,T=null,E=null,C=null,I=M.clone().sub(_),B=0,N=0,H=0;f>0&&(B=Math.min(e,t)*(1-f),N=e-B,H=t-B);let j=M.clone();j.x-=B;let Q=Math.PI-I.angle(),X=I.angle(),U=Math.tan(X/2),F=Math.tan(Q/2),V=U+F,R=f?V:F,G=f?V:U;if(c=Math.min(c,(e-N)/R,I.length()/V),h=Math.min(h,(t-H)/G,I.length()/V),c>0){let te=c/U;y=M.clone().sub(new O(te,c)),f&&(E=y.clone(),E.x-=B-V*c),M.sub(I.clone().setLength(te))}if(h>0){let te=h/F;T=_.clone().sub(new O(te,-h)),_.add(I.clone().setLength(te)),f&&(C=T.clone(),C.x-=B-V*h,j.sub(I.clone().setLength(te)))}I=M.clone().sub(_);let W=I.length()<.5,Y=[];for(let te=0;te<=i;te++){let k=[],le=te/i,ce=le*l+a,ae=new O(Math.sin(ce),Math.cos(ce));C&&T?(q(k,le,ae,Q,h,C,-1,!0),q(k,le,ae,X,h,T,-1,!1)):T?(se(k,ae,T.x,0,-1),q(k,le,ae,X,h,T,-1,!1)):o||se(k,ae,t,H,-1);let fe=gS(I).normalize();if(Fs(fe,ae,b),!W)for(let ge=0;ge<=s;ge++){let de=ge/s,_e=I.clone().multiplyScalar(de).add(_);Fs(_e,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/r),k.push(v++)}if(E&&y?(q(k,le,ae,Q,c,y,1,!1),q(k,le,ae,X,c,E,1,!0)):y?(q(k,le,ae,Q,c,y,1,!1),se(k,ae,y.x,0,1)):o||se(k,ae,e,N,1),f&&!W){let ge=gS(I).multiplyScalar(-1).normalize();Fs(ge,ae,b);for(let de=0;de<=s;de++){let _e=de/s,Ee=I.clone().multiplyScalar(-_e).add(j);Fs(Ee,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/r),k.push(v++)}}f&&!o&&k.push(k[0]),Y.push(k)}for(let te=0;te<Y.length-1;te++)for(let k=0;k<Y[0].length-1;k++){if(o&&f&&k==s)continue;let le=Y[te][k],ce=Y[te+1][k],ae=Y[te+1][k+1],fe=Y[te][k+1],ge=p[ae*3+0],de=p[ae*3+2];m.push(le,ce,fe),(ge!=0||de!=0)&&m.push(ce,ae,fe)}l<Math.PI*2&&(K(-1,Y[0],a),K(1,Y[Y.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(x,2));function q(te,k,le,ce,ae,fe,ge,de){for(let _e=0;_e<u+1;_e++){let Ee=_e/u,ye=ge<0?Ee:1-Ee;de&&(ye-=1),ye*=ce;let Oe=new O(Math.sin(ye),Math.cos(ye)*ge),pt=Oe.clone().multiplyScalar(ae).add(fe);Fs(pt,le,S),p.push(S.x,S.y,S.z),Fs(Oe,le,b),g.push(b.x,b.y,b.z),x.push(k,.5+S.y/r),te.push(v++)}}function se(te,k,le,ce,ae){let fe=new A,ge=new O,de=[le,ce];ae<0&&de.reverse();for(let _e of de)ge.set(_e,w*ae),Fs(ge,k,fe),p.push(fe.x,fe.y,fe.z),g.push(0,ae,0),x.push(.5,.5),te.push(v++)}function K(te,k,le){let ce=new O(Math.sin(le),Math.cos(le)),ae=new O(-Math.cos(le),Math.sin(le)),fe=new A,ge=te<0?(Ee,ye,Oe)=>m.push(Ee,ye,Oe):(Ee,ye,Oe)=>m.push(Ee,Oe,ye),de=new O((e+t+N+H)/4,0);Fs(de,ce,fe),p.push(fe.x,fe.y,fe.z),g.push(ae.x,0,ae.y),x.push(.5,.5);let _e=v++;for(let Ee of k){let ye=p.slice(Ee*3,Ee*3+3);p.push(...ye),g.push(ae.x,0,ae.y);let Oe=x.slice(Ee*2,Ee*2+2);x.push(...Oe),v++}for(let Ee=_e+1;Ee<v-1;Ee++)ge(_e,Ee,Ee+1);ge(_e,v-1,_e+1)}}};var vS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,depth:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:h,cornerSegments:u}=n.parameters,f;return c>0||h>0||l<360?f=new Yc(0,e/2,r,i,s,o,a,l*Math.PI/180,c,h,u,0,!0):f=new ha(e/2,r,i,s,o),f.scale(1,1,t/e),Object.assign(f,{userData:{...n,type:"ConeGeometry"}})}};var xS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a==0?c=new Kr(e,t,r,i,s,o):c=new Gg(e,t,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},Ug=Math.PI/2,Gg=class extends Le{constructor(e=1,t=1,r=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,r/2);let h=[],u=[],f=[],d=[],m=0,p=0;g("z","y","x",-1,-1,r,t,e,o,s,0),g("z","y","x",1,-1,r,t,-e,o,s,1),g("x","z","y",1,1,e,r,t,i,o,2),g("x","z","y",1,-1,e,r,-t,i,o,3),g("x","y","z",1,-1,e,t,r,i,s,4),g("x","y","z",-1,-1,e,t,-r,i,s,5),a>0&&(x("z","y","x",-1,-1,1,r,t,e,o,0),x("z","y","x",1,-1,-1,r,t,e,o,1),x("z","y","x",-1,1,-1,r,t,e,o,1),x("z","y","x",1,1,1,r,t,e,o,0),x("x","y","z",-1,-1,-1,e,t,r,i,0),x("x","y","z",1,-1,1,e,t,r,i,1),x("x","y","z",-1,1,1,e,t,r,i,0),x("x","y","z",1,1,-1,e,t,r,i,1),x("y","x","z",-1,-1,1,t,e,r,s,0),x("y","x","z",1,-1,-1,t,e,r,s,1),x("y","x","z",1,1,1,t,e,r,s,1),x("y","x","z",-1,1,-1,t,e,r,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(f,3)),this.setAttribute("uv",new Ae(d,2));function g(w,b,S,M,_,y,T,E,C,I,B){let N=(y-2*a)/C,H=(T-2*a)/I,j=y/2-a,Q=T/2-a,X=E/2,U=C+1,F=I+1,V=0,R=0,G=new A;for(let W=0;W<F;W++){let Y=W*H-Q;for(let q=0;q<U;q++){let se=q*N-j;G[w]=se*M,G[b]=Y*_,G[S]=X,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[S]=E>0?1:-1,f.push(G.x,G.y,G.z),d.push(q/C),d.push(1-W/I),V+=1}}for(let W=0;W<I;W++)for(let Y=0;Y<C;Y++){let q=m+Y+U*W,se=m+Y+U*(W+1),K=m+(Y+1)+U*(W+1),te=m+(Y+1)+U*W;h.push(q,se,te),h.push(se,K,te),R+=6}c.addGroup(p,R,B),p+=R,m+=V}function x(w,b,S,M,_,y,T,E,C,I,B){let N=(T-2*a)/I,H=T/2-a,j=E/2-a,Q=C/2,X=I+1,U=0,F=0,V=new A,R=new A;for(let G=0;G<l+1;G++){let W=G/l*Ug,Y=Math.sin(W)*a,q=(1-Math.cos(W))*a,se=Math.sin(W),K=Math.cos(W);V[b]=(j+Y)*_,V[S]=(Q-q)*y,R[w]=0,R[b]=se*Math.sign(V[b]),R[S]=K*Math.sign(V[S]);for(let te=0;te<X;te++){let k=te*N-H;V[w]=k*M,u.push(V.x,V.y,V.z),f.push(R.x,R.y,R.z),d.push(te/I),d.push(0),U+=1}}for(let G=0;G<l;G++)for(let W=0;W<I;W++){let Y=m+W+X*G,q=m+W+X*(G+1),se=m+(W+1)+X*(G+1),K=m+(W+1)+X*G;h.push(Y,q,K),h.push(q,se,K),F+=6}c.addGroup(p,F,B),p+=F,m+=U}function v(w,b,S){let M=new A,_=new A(e/2,t/2,r/2);_.subScalar(a);let y=[],T=w*b*S>0?(C,I,B)=>h.push(C,I,B):(C,I,B)=>h.push(C,B,I);for(let C=0;C<=l;C++){let I=[],B=Ug*(1-C/l),N=Math.cos(B),H=Math.sin(B),j=0;for(let Q=0;Q<=C;Q++){let X=Math.cos(j),U=Math.sin(j);M.x=N*X,M.y=H,M.z=N*U;let F=_.clone().addScaledVector(M,a);u.push(w*F.x,b*F.y,S*F.z),f.push(w*M.x,b*M.y,S*M.z),d.push(0,0),I.push(m++),j+=Ug/C}y.push(I)}let E=y.length-1;for(let C=0;C<E;C++){let I=y[C],B=y[C+1],N=I.length-1;T(I[0],B[1],B[0]);for(let H=1;H<=N;H++)T(I[H-1],I[H],B[H]),T(I[H],B[H+1],B[H])}}}};var zs=class extends Le{constructor(e=[],t=[],r="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];h(),u(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(l,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(o=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new A,p=m.clone(),g=new Qr,x=s*i,v=i-x,w=o+1,b=new A,S=(U,F)=>b.subVectors(U,F).normalize(),M=(U,F)=>Array(U).fill(void 0).map(F),_=M(e.length/3,(U,F)=>new A().fromArray(e,F*3).setLength(i)),y=[],T=1e6;for(let U=0;U<_.length;U++){let F=_[U],V=[],R,G,W,Y=1e10,q=-1;for(;(q=t.indexOf(U,q+1))!=-1;){let k=q-q%3;R=t[k+(q+1)%3],G=t[k+(q+2)%3],W=F.distanceToSquared(_[R]),Y=Math.min(Y,W),V.push([R,G,W])}Y+=1e-6;let se=[],K=0,te=V.length;for(let k=0;k<te;k++){[R,G,W]=V[K];let le=y[R]?.includes(U)==!0;W<=Y&&se.push(R+ +le*T),K=V.findIndex(ce=>ce[0]==G)}y.push(se)}let E=[];{let U=0,F=0,V,R,G=d==3;for(let W=0;W<=o;W++){V=W*(W+1)/2,R=(W+1)*(W+2)/2;for(let Y=0;Y<o-W;Y++)[U,F]=[V+Y+W+2,R+Y+W+3],E.push(V,R,...G?[F,V]:[U,R],F,U),[V,R]=[U,F];E.push(V,R,V+o+2)}}let C=m.clone(),I=m.clone(),B=m.clone(),N=m.clone(),H=m.clone(),j=[],Q=M(_.length,()=>M(d,()=>m.clone()));for(let U=0;U<_.length;U++){m.copy(_[U]).normalize(),C.copy(m).multiplyScalar(v);let F=y[U];for(let se=0;se<F.length;se++){let K=F[se],te=F[(se+1)%d];g.setFromPointsAndIndices(_,U,K%T,te%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,Q[U][se])}let V=[],R=[],G=[],W=new A;o==0&&[...Q[U]].reduce((se,K)=>se.add(K),W).multiplyScalar(1/d);for(let se=0;se<d;se++){let K=[],te=(se-1+d)%d,k=Q[U][te],le=Q[U][se];m.copy(k).sub(C),p.copy(le).sub(C);let ce=C.angleTo(m),ae=m.angleTo(p),fe=Math.cos(ce)*x;o==0?I.copy(W):I.copy(C).setLength(v+fe),R.push(fe);let ge=[I,k,le];for(let de=0;de<2;de++){let _e=ge[de],Ee=ge[de+1];N.subVectors(_e,C),H.subVectors(Ee,C),B.crossVectors(N,H).normalize();for(let ye=0;ye<w;ye++){let Oe=[ce,ae][de]*ye/w;m.copy(N).applyAxisAngle(B,Oe).add(C),V.push(m.clone()),de&&(S(m,C),K.push([ye==0?_e:m.clone(),b.clone()]))}de&&(S(Ee,C),K.push([Ee,b.clone()]))}G.push(K)}j.push(G);let Y=2*w,q=2;for(let se=0;se<d;se++){let K=Y*se,te=Y*((se+1)%d),k=[V[K]];for(let ce=1;ce<w;ce++){N=V[K+ce],H=V[te+ce],k.push(N);for(let ae=1,fe=ce-q+1;ae<=fe;ae++)m.lerpVectors(N,H,ae/(fe+1)),m.sub(C).setLength(R[se]).add(C),k.push(m.clone());k.push(H)}for(let ce=0;ce<w;ce++)k.push(V[ce+w+K]);k.push(V[te+w]);let le=E.map(ce=>k[ce]);a.push(...le.map(ce=>[ce.x,ce.y,ce.z]).flat()),c.push(...le.map(ce=>(S(ce,C),[b.x,b.y,b.z])).flat())}}let X=[];for(let U=0;U<y.length;U++)for(let F=0;F<d;F++){let V=y[U][F];if(V<T){let R=y[V].findIndex(Y=>Y%T==U),G=j[U][F],W=j[V][R];for(let Y=0;Y<w;Y++){let q=G[Y],se=W[w-Y],K=G[Y+1],te=W[w-(Y+1)];[q,se,K,K,se,te].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}X.push(G[0][0],W[w][0],G[w][0],W[0][0])}}for(;X.length;){let U,F,V,R;[U,F]=X.splice(0,2);let G=[U];for(;U!=F;)G.push(F),V=X.indexOf(F),R=V%2,F=X.splice(V-R,2)[1-R];b.subVectors(G[0],G[1]).cross(m.subVectors(G[0],G[2])).normalize();let W=b.dot(G[0])<0;W&&b.negate();for(let Y=1;Y<=G.length-2;Y++)[G[Y+ +W],G[Y+1-+W],G[0]].forEach(q=>{a.push(q.x,q.y,q.z),c.push(b.x,b.y,b.z)})}}function u(){let f=new A;for(let _=0;_<a.length;_+=3){f.x=a[_+0],f.y=a[_+1],f.z=a[_+2];let y=S(f)/2/Math.PI+.5,T=M(f)/Math.PI+.5;l.push(y,1-T)}let d=new A,m=new A,p=new A,g=new A,x=new O,v=new O,w=new O,b=(_,y,T,E)=>{E<0&&_.x===1&&(l[y]=_.x-1),T.x===0&&T.z===0&&(l[y]=E/2/Math.PI+.5)};for(let _=0,y=0;_<a.length;_+=9,y+=6){d.set(a[_+0],a[_+1],a[_+2]),m.set(a[_+3],a[_+4],a[_+5]),p.set(a[_+6],a[_+7],a[_+8]),x.set(l[y+0],l[y+1]),v.set(l[y+2],l[y+3]),w.set(l[y+4],l[y+5]),g.copy(d).add(m).add(p).divideScalar(3);let T=S(g);b(x,y+0,d,T),b(v,y+2,m,T),b(w,y+4,p,T)}for(let _=0;_<l.length;_+=6){let y=l[_+0],T=l[_+2],E=l[_+4],C=Math.max(y,T,E),I=Math.min(y,T,E);C>.9&&I<.1&&(y<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),E<.2&&(l[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function M(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(e){return new zs(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var bS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new Xc(e*.5,s,o):new fa(e*.5,i);return a.scale(1,t/e,r/e),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Xc=class extends zs{constructor(e=1,t=.2,r=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,r),this.type=l}static fromJSON(e){return new Xc(e.radius,e.corner,e.cornerSides)}};var Jc=1e-12,$a=class{constructor(e){this.position=new O;this.startPosition=new O;this.uuid=je.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 $a(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},el=class extends $a{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new el(this.parent).copy(this)}},qn=class extends $a{constructor(t,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new el(this),new el(this))}static create(t,r){let i=new qn(t,new O(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(t){let r=this.controls.indexOf(t);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(t,r=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new qn(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[t,r]}computeNormals(t=new O,r=new O){let[i,s]=this.computeTangents();return i&&s&&(wS(i,t),wS(s,r)),[t,r]}computeTangent(t=new O){let[r,i]=this.computeTangents();return r&&i&&t.copy(r).add(i).normalize(),t}computeNormal(t=new O){let[r,i]=this.computeNormals();return t.copy(r).add(i).normalize(),t}};function wS(n,e=new O){let t=n.length();return e.set(-n.y/t,n.x/t)}var Vg=n=>n,tl=new O,Kf=new O,xO=new O,bO=new O,wO=new O,SO=new O,AS=new A,MS=new A;function _S(n){let e=new O;e.addVectors(n.v0,tl.subVectors(n.v1,n.v0).multiplyScalar(2/3));let t=new O;return t.addVectors(n.v2,Kf.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new $r(n.v0,e,t,n.v2)}function Qc(n,e,t=Number.EPSILON){return Math.abs(n-e)<t}function AO(n,e,t=Number.EPSILON){return n.distanceTo(e)<t}function MO(n,e,t=Number.EPSILON){return n.distanceTo(e)<t}function Hg(n,e,t){let r=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2));return Math.acos((i*i+r*r-s*s)/(2*i*r))}function TS(n,e,t){return SS(n,e)&&SS(e,t)&&kg(n.position,e.position,t.position)}function kg(n,e,t){return tl.copy(e).sub(n).cross(Kf.copy(t).sub(n))===0}function ES(n,e,t,r,i){let s=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)),o=(n.y+e.y)/2,a=(n.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(n.y-e.y)/s,c=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-n.x)/s;return r.set(a+l,o+c),i.set(a-l,o-c),[r,i]}function CS(n,e,t){let r=n.distanceTo(t),i=e.distanceTo(t);return r<i?e:n}function DS(n,e,t,r,i,s){let o=e.x-n.x,a=e.y-n.y,l=t.x-n.x,c=t.y-n.y,h=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),u;return Hg(e,n,t)>Math.PI&&(h*=-1),Qc(c,a)?u=(a+c)*(r/h-.5)*8/3/(o-l):u=(o+l)*(r/h-.5)*8/3/(c-a),i.set(e.x-u*a,e.y+u*o),s.set(t.x+u*c,t.y-u*l),[i,s]}function Wg(n,e){return n.position.equals(n.controls[1].position)&&e.position.equals(e.controls[0].position)}function SS(n,e){return kg(n.position,n.controls[1].position,e.position)&&kg(n.position,e.controls[0].position,e.position)}function PS(n,e,t,r,i=.5){let s=tl.subVectors(e,n).multiplyScalar(i).add(n),o=Kf.subVectors(t,e).multiplyScalar(i).add(e),a=xO.subVectors(r,t).multiplyScalar(i).add(t),l=s,c=bO.subVectors(o,s).multiplyScalar(i).add(s),h=wO.subVectors(a,o).multiplyScalar(i).add(o),u=a,f=SO.subVectors(h,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,f.x,f.y,h.x,h.y,u.x,u.y,r.x,r.y]}function LS(n,e,t=12,r=!0){let i=MS.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let c=Vg(e[l]),h=tl,u=Us(c,t);a.push(u);for(let f=0;f<=u;f++)if(c instanceof $r||c instanceof kn||c instanceof en){if(c.getPoint(f/u,h),i.set(h.x,h.y,0),s!==void 0&&MO(s,i))continue;s===void 0&&(s=AS),s.copy(i),n.setXYZ(o,i.x,i.y,i.z),o++}}return r&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),n}function IS(n,e,t,r=12,i=!0){let s=MS.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,h=Vg(e[l]),u=tl,f=Us(h,r);a.push(f);for(let d=0;d<=f;d++)if(h instanceof $r||h instanceof kn||h instanceof en){if(h.getPoint(d/f,u),s.set(u.x,u.y,0),c?.equals(s))continue;c===void 0?c=AS:(n.setXYZ(o,c.x,c.y,c.z),o++,n.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return i&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),a}function jg(n,e=12,t=!1){let r=[];for(let i=0,s=n.length;i<s;i++){let o=n[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=Us(o.roundedCurveCorner,e)*.5;i>0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Us(o.curveAfter,e)),r.push(a)}return n.length>0&&t&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Us(n[0].roundedCurveCorner,e)*.5),r}function Us(n,e=12){return n&&n instanceof lo?e*2:n&&(n instanceof en||n instanceof dc)?1:n&&n instanceof la?e*n.points.length:e}function NS(n,e,t=12,r=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=Vg(e[o]),l=Us(a,t),c=tl;for(let h=0;h<=l;h++)if(a instanceof $r||a instanceof kn||a instanceof en){if(a.getPoint(h/l,c),i!==void 0&&AO(i,c,Jc))continue;i===void 0&&(i=Kf),i.copy(c),n.push(c.x,c.y),s++}}return Qc(n[0],n[n.length-2],Jc)&&Qc(n[1],n[n.length-1],Jc)&&(n.pop(),n.pop()),r&&s>1&&!(Qc(n[s-1],n[1],Jc)&&Qc(n[s-2],n[0],Jc))&&(n.push(n[0],n[1]),s++),n}var qg=new O,_O=new O,TO=new O,EO=new O,CO=new O,DO=new O,dt=class extends Fn{constructor(t=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Ot;this.plane=new Gr(new A(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=je.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=r}static createFromState(t,r,i){let s=new dt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>qn.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>dt.createFromState(o)),r!==void 0&&i!==void 0&&s.applySize(r,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let r=0,i=this.points.length;r<i;r++)this.points[r].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(t){let r=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length-1,h=l.getPointIndexById(t);if(h<0)s+=c;else return h+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0)for(let r=0,i=this.shapeHoles.length;r<i;r++){let s=this.shapeHoles[r],o=t-this.points.length;if(o<=s.points.length-1)return s.points[o]}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let r=this.points.indexOf(t);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...t]}applySize(t,r){t===0&&(t=.001),r===0&&(r=.001),this._width=t,this._height=r}applyScale(t,r){let i=qg.set(t,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,r);this._update(!1)}createPoint(t,r=0,i=je.generateUUID()){let s;t instanceof O?s=t:s=new O(t,r);let o=new qn(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,r){this.points.splice(r,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let r=0,i=this.points.length;r<i;r++){let s=this.points[r];if(s.uuid===t)return s}for(let r=0,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let r=this.points.indexOf(t);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(t){let r=this.points.find(i=>i.uuid===t);r&&this.removePoint(r)}update(t=!0){for(let r=0,i=this.shapeHoles.length;r<i;r++)this.shapeHoles[r].update(!1);this._update(t)}extractShapePointsToBuffer(t,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=i?this.roundedCurveDivisions:this.curveDivisions;return LS(t,i?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=jg(this.points,t,!1),this.roundedCurveDivisions=jg(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,r,i=12){return IS(t,this.curves,r,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),NS(t,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(t,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=Us(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let h=s[l];if(a<i+h)return[l,(a-i+1)/h];i+=h}return[0,1]}getCurveT(t,r,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(Wg(s,o)){let u=s.position.distanceTo(o.position);return s.position.distanceTo(qg.set(i.x,i.y))/u}let c=0;for(let u=0;u<t;u++)c+=a[u];return(r-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,r){Wg(r,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,r.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,r.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let r=this.getLastPoint();if(r?.curveAfter&&(r.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],c=this.points[s+1]??this.points[0],h=a.roundness,u=l&&c&&TS(l,a,c);if(!a.controlsMoved()&&h>0&&!u){let f=a.curveBefore,d=a.curveAfter;if(f===void 0||d===void 0)continue;let m=a.roundedCurveBefore,p=a.roundedCurveAfter,g=f.getLength(),x=d.getLength(),v=Math.min(h,g*.499),w=Math.min(h,x*.499),b=Math.min(v,w),S=1-b/g,M=b/x,_=f.getPointAt(S,qg),y=d.getPointAt(M,_O);this._subSplitCurve(f,m,S,_,void 0),this._subSplitCurve(d,p,M,void 0,y);let T;if(this.useCubicForRoundedCorners){let E=Hg(_,a.position,y)/2,C=Math.tan(E)*_.distanceTo(a.position),[I,B]=ES(_,y,C,TO,EO),N=CS(I,B,a.position),[H,j]=DS(N,_,y,C,CO,DO);T=new $r(_.clone(),H.clone(),j.clone(),y.clone())}else T=new kn(_.clone(),a.position.clone(),y.clone());a.roundedCurveCorner=T,this.roundedCurves.splice(s+i,0,T),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,r,i,s,o){if(t instanceof en)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=t,l=r,c=a.getUtoTmapping(i,0),h=PS(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(h[0],h[1]),l.v1.set(h[2],h[3]),l.v2.set(h[4],h[5]),l.v3.set(h[6],h[7])),o!==void 0&&(l.v0.set(h[6],h[7]),l.v1.set(h[8],h[9]),l.v2.set(h[10],h[11]),l.v3.set(h[12],h[13])),l}return r}clone(){let t=new dt(this._width,this._height);return t.points=this.points.map(r=>r.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(r=>r.clone()),t}toJSON(){return{points:this.points.reduce((t,r)=>t.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let r=t.points.length/7;for(let i=0;i<r;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],c=t.points[s+3],h=t.points[s+4],u=t.points[s+5],f=t.points[s+6],d=new qn(je.generateUUID(),new O(o,a));d.controls[0].position.set(l,c),d.controls[1].position.set(h,u),d.roundness=f,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new dt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let r=(s,o)=>{o instanceof $r&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof kn&&(s[a]=_S(s[a]));for(a=0,l=s.length;a<l;a++){let u=s[a],f=a>0?s[a-1]:null,d;u instanceof $r?(d=this.createPoint(u.v0),d.controls[1].position.copy(u.v1)):u instanceof en&&(d=this.createPoint(u.v1)),d!==void 0&&(f!==null&&r(d,f),o.push(d))}let c=s[s.length-1],h=!1;return c instanceof $r?c.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(c.v2),h=!0):c instanceof en&&c.v2.equals(o[0].position)&&(h=!0),this.isClosed=h,o};return this.points=i(t.curves),t instanceof Fn&&(this.shapeHoles=t.holes.map(s=>{let o=new dt;return o.fromShape(s),o})),this.update(),this}};var Xg=Math.PI*2;function Yg({x:n,y:e},t,r,i,s){return{x:n*t+i,y:e*r+s}}function PO(n,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(n),i=Math.sin(n),s=Math.cos(n+e),o=Math.sin(n+e);return[{x:r-i*t,y:i+r*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function BS(n,e,t,r){let i=n*r-e*t<0?-1:1,s=Math.min(1,Math.max(-1,n*t+e*r));return i*Math.acos(s)}function LO(n,e,t,r,i,s,o,a,l,c){let h=Math.pow(i,2),u=Math.pow(s,2),f=Math.pow(o,2),d=Math.pow(a,2),m=h*u-h*d-u*f;m<0&&(m=0),m/=h*d+u*f,m=Math.sqrt(m)*(l===c?-1:1);let p=m*i/s*a,g=m*-s/i*o,x=p+(n+t)/2,v=g+(e+r)/2,w=(o-p)/i,b=(a-g)/s,S=(-o-p)/i,M=(-a-g)/s,_=BS(1,0,w,b),y=BS(w,b,S,M);return!c&&y>0&&(y-=Xg),c&&y<0&&(y+=Xg),{centerx:x,centery:v,ang1:_,ang2:y}}function OS({px:n,py:e,cx:t,cy:r,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(n-t)/2,h=(e-r)/2;if(c===0&&h===0)return[];i=Math.abs(i),s=Math.abs(s);let u=Math.pow(c,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);u>1&&(i*=Math.sqrt(u),s*=Math.sqrt(u));let f=LO(n,e,t,r,i,s,c,h,o,a),{ang1:d,ang2:m}=f,{centerx:p,centery:g}=f,x=Math.abs(m)/(Xg/4);Math.abs(1-x)<1e-7&&(x=1);let v=Math.max(Math.ceil(x),1);m/=v;for(let w=0;w<v;w++)l.push(PO(d,m)),d+=m;return l.map(w=>{let{x:b,y:S}=Yg(w[0],i,s,p,g),{x:M,y:_}=Yg(w[1],i,s,p,g),{x:y,y:T}=Yg(w[2],i,s,p,g);return{x1:b,y1:S,x2:M,y2:_,x:y,y:T}})}var Rt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Rt||(Rt={}));var ur;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ur||(ur={}));function Ge(n,e){if(!n)throw e||"Assertion Failed!"}var ze=function(){function n(){}return n.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},n.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},n.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},n.edgeGoesLeft=function(e){return n.vertLeq(e.Dst,e.Org)},n.edgeGoesRight=function(e){return n.vertLeq(e.Org,e.Dst)},n.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},n.edgeEval=function(e,t,r){Ge(n.vertLeq(e,t)&&n.vertLeq(t,r));var i=t.s-e.s,s=r.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-r.t)*(i/(i+s)):t.t-r.t+(r.t-e.t)*(s/(i+s)):0},n.edgeSign=function(e,t,r){Ge(n.vertLeq(e,t)&&n.vertLeq(t,r));var i=t.s-e.s,s=r.s-t.s;return i+s>0?(t.t-r.t)*i+(t.t-e.t)*s:0},n.transEval=function(e,t,r){Ge(n.transLeq(e,t)&&n.transLeq(t,r));var i=t.t-e.t,s=r.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-r.s)*(i/(i+s)):t.s-r.s+(r.s-e.s)*(s/(i+s)):0},n.transSign=function(e,t,r){Ge(n.transLeq(e,t)&&n.transLeq(t,r));var i=t.t-e.t,s=r.t-t.t;return i+s>0?(t.s-r.s)*i+(t.s-e.s)*s:0},n.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},n.interpolate=function(e,t,r,i){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+i)/2:t+(i-t)*(e/(e+r)):i+(t-i)*(r/(e+r))},n.intersect=function(e,t,r,i,s){var o,a,l;n.vertLeq(e,t)||(l=e,e=t,t=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(e,r)||(l=e,e=r,r=l,l=t,t=i,i=l),n.vertLeq(r,t)?n.vertLeq(t,i)?(o=n.edgeEval(e,r,t),a=n.edgeEval(r,t,i),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,t.s)):(o=n.edgeSign(e,r,t),a=-n.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,i.s)):s.s=(r.s+t.s)/2,n.transLeq(e,t)||(l=e,e=t,t=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(e,r)||(l=e,e=r,r=l,l=t,t=i,i=l),n.transLeq(r,t)?n.transLeq(t,i)?(o=n.transEval(e,r,t),a=n.transEval(r,t,i),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,t.t)):(o=n.transSign(e,r,t),a=-n.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,i.t)):s.t=(r.t+t.t)/2},n}(),Kc=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Zf=function(){function n(e){this.side=e,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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),n}(),rl=function(){function n(){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 n}(),RS=function(){function n(){var e=new rl,t=new Kc,r=new Zf(0),i=new Zf(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(e){var t=new Zf(0),r=new Zf(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return r.next=i,i.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},n.prototype.splice_=function(e,t){var r=e.Onext,i=t.Onext;r.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=r},n.prototype.makeVertex_=function(e,t,r){var i=e;Ge(i,"Vertex can't be null!");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},n.prototype.makeFace_=function(e,t,r){var i=e;Ge(i,"Face can't be null");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=r.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},n.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},n.prototype.killVertex_=function(e,t){var r=e.anEdge,i=r;do i.Org=t,i=i.Onext;while(i!==r);var s=e.prev,o=e.next;o.prev=s,s.next=o},n.prototype.killFace_=function(e,t){var r=e.anEdge,i=r;do i.Lface=t,i=i.Lnext;while(i!==r);var s=e.prev,o=e.next;o.prev=s,s.next=o},n.prototype.makeEdge=function(){var e=new rl,t=new rl,r=new Kc,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(e,t){var r=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new rl;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!r){var o=new Kc;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},n.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var i=new Kc;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},n.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new rl;return this.makeVertex_(i,r,t.Org),t.Lface=r.Lface=e.Lface,t},n.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},n.prototype.connect=function(e,t){var r=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!r){var o=new Kc;this.makeFace_(o,i,e.Lface)}return i},n.prototype.zapFace=function(e){var t=e.anEdge,r,i,s,o,a;i=t.Lnext;do r=i,i=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},n.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},n.prototype.mergeConvexFaces=function(e){var t,r,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,o=r.Org;i=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&ze.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&ze.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=i;return!0},n.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,i,s,o,a,l,c;for(s=e,s=e;(i=s.next)!==e;s=i){Ge(i.prev===s),l=i.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===i),l=l.Lnext;while(l!==i.anEdge)}for(Ge(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){Ge(o.prev===a),l=o.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===o),l=l.Onext;while(l!==o.anEdge)}for(Ge(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Ge(l.Sym.next===c.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===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),FS=function(){function n(){this.handle=null}return n}(),zS=function(){function n(){this.key=null,this.node=0}return n}(),IO=function(){function n(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new FS,this.handles[r]=new zS;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(r[t[o+1].handle].key,r[t[o].handle].key)&&++o,Ge(o<=this.max),s=t[o].handle,o>this.size||this.leq(r[i].key,r[s].key)){t[e].handle=i,r[i].node=e;break}t[e].handle=s,r[s].node=e,e=o}},n.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(r[s].key,r[i].key)){t[e].handle=i,r[i].node=e;break}t[e].handle=s,r[s].node=e,e=o}},n.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new FS;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new zS}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},n.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,i=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(e){var t=this.nodes,r=this.handles,i;Ge(e>=1&&e<=this.max&&r[e].key!==null),i=r[e].node,t[i].handle=t[this.size].handle,r[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[t[i>>1].handle].key,r[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},n}(),Jg=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),US=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),NO=function(){function n(e,t){this.frame=e,this.leq=t,this.head=new US,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(e){return this.insertBefore(this.head,e)},n.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},n.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new US;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},n.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},n}(),BO=function(){function n(){}return n.regionBelow=function(e){return e.nodeUp.prev.key},n.regionAbove=function(e){return e.nodeUp.next.key},n.debugEvent=function(e){},n.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},n.edgeLeq=function(e,t,r){var i=e.event,s=t.eUp,o=r.eUp;if(s.Dst===i)return o.Dst===i?ze.vertLeq(s.Org,o.Org)?ze.edgeSign(o.Dst,s.Org,o.Org)<=0:ze.edgeSign(s.Dst,o.Org,s.Org)>=0:ze.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ze.edgeSign(s.Dst,i,s.Org)>=0;var a=ze.edgeEval(s.Dst,i,s.Org),l=ze.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(e,t){t.fixUpperEdge&&Ge(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},n.fixUpperEdge=function(e,t,r){Ge(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},n.topLeftRegion=function(e,t){var r=t.eUp.Org,i;do t=n.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(i=e.mesh.connect(n.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;n.fixUpperEdge(e,t,i),t=n.regionAbove(t)}return t},n.topRightRegion=function(e){var t=e.eUp.Dst;do e=n.regionAbove(e);while(e.eUp.Dst===t);return e},n.addRegionBelow=function(e,t,r){var i=new Jg;return i.eUp=r,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(e,t){switch(e.windingRule){case Rt.ODD:return(t&1)!==0;case Rt.NONZERO:return t!==0;case Rt.POSITIVE:return t>0;case Rt.NEGATIVE:return t<0;case Rt.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(e,t){t.windingNumber=n.regionAbove(t).windingNumber+t.eUp.winding,t.inside=n.isWindingInside(e,t.windingNumber)},n.finishRegion=function(e,t){var r=t.eUp,i=r.Lface;i.inside=t.inside,i.anEdge=r,n.deleteRegion(e,t)},n.finishLeftRegions=function(e,t,r){for(var i,s=null,o=t,a=t.eUp;o!==r;){if(o.fixUpperEdge=!1,s=n.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){n.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),n.finishRegion(e,o),a=s.eUp,o=s}return a},n.addRightEdges=function(e,t,r,i,s,o){var a,l,c,h,u=!0;c=r;do Ge(ze.vertLeq(c.Org,c.Dst)),n.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=n.regionBelow(t).eUp.Rprev),l=t,h=s;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===h.Org;)c.Onext!==h&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(h.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(e,a.windingNumber),l.dirty=!0,!u&&n.checkForRightSplice(e,l)&&(n.addWinding(c,h),n.deleteRegion(e,l),e.mesh.delete(h)),u=!1,l=a,h=c;l.dirty=!0,Ge(l.windingNumber-c.winding===a.windingNumber),o&&n.walkDirtyRegions(e,l)},n.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},n.vertexWeights=function(e,t,r){var i=ze.vertL1dist(t,e),s=ze.vertL1dist(r,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*r.coords[0],e.coords[1]+=o*t.coords[1]+a*r.coords[1],e.coords[2]+=o*t.coords[2]+a*r.coords[2]},n.getIntersectData=function(e,t,r,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,n.vertexWeights(t,r,i),n.vertexWeights(t,s,o)},n.checkForRightSplice=function(e,t){var r=n.regionBelow(t),i=t.eUp,s=r.eUp;if(ze.vertLeq(i.Org,s.Org)){if(ze.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ze.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=r.dirty=!0)}else{if(ze.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;n.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},n.checkForLeftSplice=function(e,t){var r=n.regionBelow(t),i=t.eUp,s=r.eUp,o;if(Ge(!ze.vertEq(i.Dst,s.Dst)),ze.vertLeq(i.Dst,s.Dst)){if(ze.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;n.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(ze.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=r.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},n.checkForIntersect=function(e,t){var r=n.regionBelow(t),i=t.eUp,s=r.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,h,u,f=new rl,d,m;if(Ge(!ze.vertEq(c,l)),Ge(ze.edgeSign(l,e.event,o)<=0),Ge(ze.edgeSign(c,e.event,a)>=0),Ge(o!==e.event&&a!==e.event),Ge(!t.fixUpperEdge&&!r.fixUpperEdge),o===a||(h=Math.min(o.t,l.t),u=Math.max(a.t,c.t),h>u))return!1;if(ze.vertLeq(o,a)){if(ze.edgeSign(c,o,a)>0)return!1}else if(ze.edgeSign(l,a,o)<0)return!1;return n.debugEvent(e),ze.intersect(l,o,c,a,f),Ge(Math.min(o.t,l.t)<=f.t),Ge(f.t<=Math.max(a.t,c.t)),Ge(Math.min(c.s,l.s)<=f.s),Ge(f.s<=Math.max(a.s,o.s)),ze.vertLeq(f,e.event)&&(f.s=e.event.s,f.t=e.event.t),d=ze.vertLeq(o,a)?o:a,ze.vertLeq(d,f)&&(f.s=d.s,f.t=d.t),ze.vertEq(f,o)||ze.vertEq(f,a)?(n.checkForRightSplice(e,t),!1):!ze.vertEq(l,e.event)&&ze.edgeSign(l,e.event,f)>=0||!ze.vertEq(c,e.event)&&ze.edgeSign(c,e.event,f)<=0?c===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=n.topLeftRegion(e,t),i=n.regionBelow(t).eUp,n.finishLeftRegions(e,n.regionBelow(t),r),n.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),r=t,t=n.topRightRegion(t),m=n.regionBelow(t).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(e,r,null),n.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(ze.edgeSign(l,e.event,f)>=0&&(n.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),ze.edgeSign(c,e.event,f)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=f.s,i.Org.t=f.t,i.Org.pqHandle=e.pq.insert(i.Org),n.getIntersectData(e,i.Org,o,l,a,c),n.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(e,t){for(var r=n.regionBelow(t),i,s;;){for(;r.dirty;)t=r,r=n.regionBelow(r);if(!t.dirty&&(r=t,t=n.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=r.eUp,i.Dst!==s.Dst&&n.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(n.deleteRegion(e,r),e.mesh.delete(s),r=n.regionBelow(t),s=r.eUp):t.fixUpperEdge&&(n.deleteRegion(e,t),e.mesh.delete(i),t=n.regionAbove(r),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(n.checkForIntersect(e,t))return}else n.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(n.addWinding(s,i),n.deleteRegion(e,t),e.mesh.delete(i),t=n.regionAbove(r))}},n.connectRightVertex=function(e,t,r){var i,s=r.Onext,o=n.regionBelow(t),a=t.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(e,t),ze.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=n.topLeftRegion(e,t),s=n.regionBelow(t).eUp,n.finishLeftRegions(e,n.regionBelow(t),o),c=!0),ze.vertEq(l.Org,e.event)&&(e.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(e,o,null),c=!0),c){n.addRightEdges(e,t,r.Onext,s,s,!0);return}ze.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(r.Lprev,i),n.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(e,t)},n.connectLeftDegenerate=function(e,t,r){var i,s,o,a,l;if(i=t.eUp,ze.vertEq(i.Org,r)){Ge(!1),n.spliceMergeVertices(e,i,r.anEdge);return}if(!ze.vertEq(i.Dst,r)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,i),n.sweepEvent(e,r);return}Ge(!1),t=n.topRightRegion(t),l=n.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ge(s!==o),n.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(r.anEdge,o),ze.edgeGoesLeft(s)||(s=null),n.addRightEdges(e,t,o.Onext,a,s,!0)},n.connectLeftVertex=function(e,t){var r,i,s,o,a,l,c=new Jg;if(c.eUp=t.anEdge.Sym,r=e.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,ze.edgeSign(o.Dst,t,o.Org)===0){n.connectLeftDegenerate(e,r,t);return}if(s=ze.vertLeq(a.Dst,o.Dst)?r:i,r.inside||s.fixUpperEdge){if(s===r)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var h=e.mesh.connect(a.Dnext,t.anEdge);l=h.Sym}s.fixUpperEdge?n.fixUpperEdge(e,s,l):n.computeWinding(e,n.addRegionBelow(e,r,l)),n.sweepEvent(e,t)}else n.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},n.sweepEvent=function(e,t){e.event=t,n.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){n.connectLeftVertex(e,t);return}var i=n.topLeftRegion(e,r.activeRegion);Ge(i!==null);var s=n.regionBelow(i),o=s.eUp,a=n.finishLeftRegions(e,s,null);a.Onext===o?n.connectRightVertex(e,i,a):n.addRightEdges(e,i,a.Onext,o,o,!0)},n.addSentinel=function(e,t,r,i){var s=new Jg,o=e.mesh.makeEdge();o.Org.s=r,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},n.initEdgeDict=function(e){e.dict=new NO(e,n.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-r,a=e.bmax[1]+r;n.addSentinel(e,i,s,o),n.addSentinel(e,i,s,a)},n.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ge(t.fixUpperEdge),Ge(++r===1)),Ge(t.windingNumber===0),n.deleteRegion(e,t)},n.removeDegenerateEdges=function(e){var t,r,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=r)r=t.next,i=t.Lnext,ze.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(n.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===r||i===r.Sym)&&(r=r.next),e.mesh.delete(i)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},n.initPriorityQ=function(e){var t,r,i,s=0;for(i=e.mesh.vHead,r=i.next;r!==i;r=r.next)s++;for(s+=8,t=e.pq=new IO(s,ze.vertLeq),i=e.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=t.insert(r);return r!==i?!1:(t.init(),!0)},n.donePriorityQ=function(e){e.pq=null},n.removeDegenerateFaces=function(e,t){var r,i,s;for(r=t.fHead.next;r!==t.fHead;r=i)i=r.next,s=r.anEdge,Ge(s.Lnext!==s),s.Lnext.Lnext===s&&(n.addWinding(s.Onext,s),e.mesh.delete(s));return!0},n.computeInterior=function(e,t){t===void 0&&(t=!0);var r,i;if(n.removeDegenerateEdges(e),!n.initPriorityQ(e))return!1;for(n.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!ze.vertEq(i,r));)i=e.pq.extractMin(),n.spliceMergeVertices(e,r.anEdge,i.anEdge);n.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,n.debugEvent(e),n.doneEdgeDict(e),n.donePriorityQ(e),n.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},n}(),OO=function(){function n(){this.mesh=new RS,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=Rt.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 n.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},n.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},n.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},n.prototype.computeNormal_=function(e){var t,r,i,s,o,a,l=[0,0,0],c=[0,0,0],h=[0,0,0],u=[0,0,0],f=[0,0,0],d=[null,null,null],m=[null,null,null],p=this.mesh.vHead;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],c[g]=s,m[g]=t,l[g]=s,d[g]=t;for(t=p.next;t!==p;t=t.next)for(var x=0;x<3;++x)s=t.coords[x],s<c[x]&&(c[x]=s,m[x]=t),s>l[x]&&(l[x]=s,d[x]=t);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,r=m[v],i=d[v],h[0]=r.coords[0]-i.coords[0],h[1]=r.coords[1]-i.coords[1],h[2]=r.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)u[0]=t.coords[0]-i.coords[0],u[1]=t.coords[1]-i.coords[1],u[2]=t.coords[2]-i.coords[2],f[0]=h[1]*u[2]-h[2]*u[1],f[1]=h[2]*u[0]-h[0]*u[2],f[2]=h[0]*u[1]-h[1]*u[0],o=f[0]*f[0]+f[1]*f[1]+f[2]*f[2],o>a&&(a=o,e[0]=f[0],e[1]=f[1],e[2]=f[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(h)]=1)},n.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),r=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},n.prototype.tessellateMonoRegion_=function(e,t){var r,i;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ze.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(ze.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ze.edgeGoesLeft(i.Lnext)||ze.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(ze.edgeGoesRight(r.Lprev)||ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=e.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},n.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},n.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},n.prototype.setWindingNumber_=function(e,t,r){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:r?e.delete(s):s.winding=0},n.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},n.prototype.outputPolymesh_=function(e,t,r,i){var s,o=0,a=0,l;r>3&&e.mergeConvexFaces(r);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var h=e.fHead.next;h!==e.fHead;h=h.next)if(h.n=-1,!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==h.anEdge);if(l>r)throw"Face vertex greater that support polygon";h.n=o,++o}this.elementCount=o,t===ur.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var u=c.n*i;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],i>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var f=0,h=e.fHead.next;h!==e.fHead;h=h.next)if(!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;this.elements[f++]=c.n,l++,s=s.Lnext}while(s!==h.anEdge);for(var d=l;d<r;++d)this.elements[f++]=-1;if(t===ur.CONNECTED_POLYGONS){s=h.anEdge;do this.elements[f++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==h.anEdge);for(var m=l;m<r;++m)this.elements[f++]=-1}}},n.prototype.outputContours_=function(e,t){var r,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,h=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],t>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==i);this.elements[h++]=s,this.elements[h++]=o,s+=o}},n.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new RS),e<2&&(e=2),e>3&&(e=3);for(var r=null,i=0;i<t.length;i+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[i+0],r.Org.coords[1]=t[i+1],e>2?r.Org.coords[2]=t[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(e,t,r,i,s,o){if(e===void 0&&(e=Rt.ODD),t===void 0&&(t=ur.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),BO.computeInterior(this,o);var a=this.mesh;return t===ur.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===ur.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,r,i),!0},n}();function Eo(n){var e=n.windingRule,t=e===void 0?Rt.ODD:e,r=n.elementType,i=r===void 0?ur.POLYGONS:r,s=n.polySize,o=s===void 0?3:s,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,h=c===void 0?[0,0,1]:c,u=n.contours,f=u===void 0?[]:u,d=n.strict,m=d===void 0?!0:d,p=n.debug,g=p===void 0?!1:p;if(!f&&m)throw new Error("Contours can't be empty");if(!!f){var x=new OO;n.edgeCreateCallback&&(x.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(x.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<f.length;v++)x.addContour(l||2,f[v]);return x.tesselate(t,i,o,l,h,m),{vertices:x.vertices,vertexIndices:x.vertexIndices,vertexCount:x.vertexCount,elements:x.elements,elementCount:x.elementCount,mesh:g?x.mesh:void 0}}}var Aq=Rt.ODD,Mq=Rt.NONZERO,_q=Rt.POSITIVE,Tq=Rt.NEGATIVE,Eq=Rt.ABS_GEQ_TWO,Cq=ur.POLYGONS,Dq=ur.CONNECTED_POLYGONS,Pq=ur.BOUNDARY_CONTOURS;var nl=class extends Le{constructor(t,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=Rt.ODD;this.elementType=ur.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Rt.ODD,elementType:ur.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,h,u;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,x=s[g+0],v=s[g+1];if(h!==void 0&&x!==h&&(l=!1),u!==void 0&&v!==u&&(c=!1),h=x,u=v,!l&&!c)break}!l&&!c&&(a=Eo({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let f=a?.vertexCount??1,d=a?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(f*3),3),this._normalAttribute=new Xe(new Float32Array(f*3),3),this._uvAttribute=new Xe(new Float32Array(f*2),2),this._indexAttribute=new Xe(new Uint32Array(d*3),1),a){let m=1/0,p=-1/0,g=1/0,x=-1/0;for(let b=0,S=f;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1];_<m&&(m=_),_>p&&(p=_),y<g&&(g=y),y>x&&(x=y)}let v=p-m,w=x-g;for(let b=0,S=f;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1],T=(_-m)/v,E=(y-g)/w;this._positionAttribute.setXYZ(b,_,y,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,E)}for(let b=0,S=d;b<S;b++){let M=b*3,_=a.elements[M+0],y=a.elements[M+1],T=a.elements[M+2];this._indexAttribute.setX(M+0,_),this._indexAttribute.setX(M+1,y),this._indexAttribute.setX(M+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new nl(this._shape,this._curveSegments);return t.userData=Lc(this.userData),t}};var $f=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*$f.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,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 r=e*$f.eSize,i=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let c=new Float32Array(i,o*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=t,r}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)}},Zc=$f;Zc.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Qg=(n,e)=>([t,r])=>(r<t&&(r+=e),(n>=t?n:n+e)<=r),il=class extends Le{constructor(t,r,i=0,s=12,o=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=r,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,r/2-1e-12),this._bevelSegments=Math.floor(o));let a=this._shape.extractShapePointsToFlatArray([],s),l=this._shape.shapeHoles.map(_=>{let y=_.extractShapePointsToFlatArray([],s),T=[];for(let E=y.length-1;E>=1;E-=2){let C=y[E-1],I=y[E-0];T.push(C,I)}return T}),c=Eo({windingRule:Rt.ODD,elementType:ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),h=Eo({windingRule:Rt.ODD,elementType:ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let u=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let y=h.elements[_],T=_%2===0?c.vertexCount:0;c.elements.push(y+T)}for(let _=0;_<h.vertexIndices.length;_++){let y=h.vertexIndices[_],T=c.vertexCount;c.vertexIndices.push(y+T)}for(let _=0;_<h.vertices.length;_++){let y=h.vertices[_];c.vertices.push(y)}}let f=1/0,d=-1/0,m=1/0,p=-1/0;for(let _=0,y=c.vertexCount;_<y;_++){let T=_*2,E=c.vertices[T+0],C=c.vertices[T+1];E<f&&(f=E),E>d&&(d=E),C<m&&(m=C),C>p&&(p=C)}this._minX=f,this._minY=m,this._width=d-f,this._height=p-m;let g=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new Zc(g);let x=[],v=[];for(let _=c.elementCount-1;_>=0;_--){let y=_>=u,T=_*2,E=c.elements[T+0],C=c.elements[T+1],I=E+C,B={start:E,count:C,normals:[],continuous:[],concave:[]},N=E,H=I-1,j=E+1,Q=this._shape.roundedCurves.length;do{let V=N-E,R=c.vertices[H*2+0],G=c.vertices[H*2+1],W=c.vertices[N*2+0],Y=c.vertices[N*2+1],q=c.vertices[j*2+0],se=c.vertices[j*2+1],K=W-R,te=Y-G,k=Math.sqrt(K*K+te*te);K/=k,te/=k;let le=W-q,ce=Y-se,ae=Math.sqrt(le*le+ce*ce);le/=ae,ce/=ae,B.normals[V*2+0]=-ce,B.normals[V*2+1]=le,B.concave[V]=K*ce-te*le>0;let fe=c.vertexIndices[N];if(Array.isArray(fe))B.continuous[V]=!1;else{let[ge,de]=this._shape.getCurveIndexFromVertexId(fe-1,!0);if(de>0&&de<1)B.continuous[V]=!0;else{let _e=de===1?ge+1:ge-1;_e=(_e+Q)%Q;let Ee=de===1?0:1,ye=this._shape.roundedCurves[ge].getTangent(de),Oe=this._shape.roundedCurves[_e].getTangent(Ee);B.continuous[V]=ye.dot(Oe)>.95}}y&&(B.normals[V*2+0]*=-1,B.normals[V*2+1]*=-1),[H,N,j]=[N,j,j+1],j>=I&&(j-=C)}while(j!==E+1);let X=[];X.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(E*2,I*2),vertexCount:C,vertexIndices:new Array(C).fill(!0).map((V,R)=>[R,R]),elements:[0,C],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(E*2,I*2)});for(let V=1;V<=this._bevelSegments;V++){let R=V/this._bevelSegments*Math.PI/2,G=(1-Math.cos(R))*this._bevelSize,W=[],Y=[],q=[],se=[],K=0;for(let k=0;k<C;k++){let le=k*2,ce=(k-1+C)%C*2,ae=c.vertices[B.start*2+le+0],fe=c.vertices[B.start*2+le+1],ge=-B.normals[ce+0]*G,de=-B.normals[ce+1]*G,_e=-B.normals[le+0]*G,Ee=-B.normals[le+1]*G;if(B.concave[k]||!B.concave[k]&&y){let ye=Math.atan2(de,ge),Oe=Math.atan2(Ee,_e);Oe>ye&&(Oe-=Math.PI*2);let pt=Oe-ye;if(B.continuous[k]||y){let P=ye+pt/2,D=Math.cos(P)*G,Z=Math.sin(P)*G;W[2*K+0]=ae+D*(y?-1:1),W[2*K+1]=fe+Z*(y?-1:1),se[K]=k,K++}else{let P=Math.max(1,Math.floor(s/4*Math.abs(pt)/Math.PI));for(let D=0;D<=P;D++){let Z=ye+pt*(D/P),ue=Math.cos(Z)*G,pe=Math.sin(Z)*G;W[2*K+0]=ae+ue,W[2*K+1]=fe+pe,se[K]=k,K++}}}else W[2*K+0]=ae+ge,W[2*K+1]=fe+de,se[K]=k,Y[k]=K,K++,W[2*K+0]=ae,W[2*K+1]=fe,se[K]=k,K++,W[2*K+0]=ae+_e,W[2*K+1]=fe+Ee,se[K]=k,q[k]=K,K++}let te=Eo({windingRule:Rt.POSITIVE,elementType:ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[W],edgeCreateCallback:k=>{let ce=k.Org.idx,ae=se[ce],fe=se[(ce+1)%se.length];k.idx=[ae,fe],k.Sym.idx=[fe,ae]},vertexIdCallback:k=>{let le=k.Lprev.idx;return[le?le[1]:0,k.idx[0]]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!te.vertexCount)break;for(let k=0;k<te.vertexIndices.length;k++){let[le,ce]=te.vertexIndices[k];if(le===ce)continue;let ae=ce;ce<le&&(ae+=C);for(let fe=le;fe<ae;fe++){let ge=fe%C,de=(fe+1)%C;if(!B.continuous[ge]||!B.continuous[de]){te.vertexIndices[k]=[le,ge],te.vertexIndices.splice(k+1,0,[de,ce]),te.vertices.splice((k+1)*2,0,te.vertices[k*2],te.vertices[k*2+1]);break}}}X.push({bevelI:V,angle:R,size:G,boundary:te,reverseMap:se,insetPoints:W})}let U=(V,R,G)=>{let W=0,Y=V.boundary.vertexIndices.length;for(;W<Y&&G(V.boundary.vertexIndices[R]);)R=(R+1)%Y,W++;return W},F=x.length;for(let V=1;V<X.length;V++){let R=X[V-1],G=X[V],W=R.boundary.vertexIndices.length,Y=G.boundary.vertexIndices.length;if(!W||!Y)break;let q=B.concave.length,se=0,K=Qg(se,C);for(;!R.boundary.vertexIndices.filter(K).length||!G.boundary.vertexIndices.filter(K).length;)se++,K=Qg(se,C);let te=R.boundary.vertexIndices.findIndex(K),k=G.boundary.vertexIndices.findIndex(K);do te=(te+1)%W;while(K(R.boundary.vertexIndices[te]));do k=(k+1)%Y;while(K(G.boundary.vertexIndices[k]));se=(se+1)%C;let le=se,ce=this.buildBevelVert(B,R,(te-1+W)%W),ae=this.buildBevelVert(B,G,(k-1+Y)%Y),fe=ce,ge=ae,de,_e,Ee=!1;do{K=Qg(se,C);let ye=U(R,te,K),Oe=U(G,k,K),pt=Ee;if(Ee=!1,ye&&!Oe){for(let P=0;P<ye;P++)de=this.buildBevelVert(B,R,(te+P)%W,P/(ye-1)),x.push(fe.topN,de.topP,ge.topN),x.push(de.bottomP,fe.bottomN,ge.bottomN),fe=de;Ee=!0}else if(!ye&&Oe)for(let P=0;P<Oe;P++)_e=this.buildBevelVert(B,G,(k+P)%Y,P/(Oe-1)),x.push(ge.topN,fe.topP,_e.topP),x.push(fe.bottomP,ge.bottomN,_e.bottomP),ge=_e;else if(ye&&Oe)if(de=this.buildBevelVert(B,R,te,0),_e=this.buildBevelVert(B,G,k,0),pt?(x.push(fe.topN,_e.topP,ge.topN),x.push(fe.topN,de.topP,_e.topP),x.push(_e.bottomP,fe.bottomN,ge.bottomN),x.push(_e.bottomP,de.bottomP,fe.bottomN)):(x.push(ge.topN,fe.topN,de.topP),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,fe.bottomN,ge.bottomN),x.push(de.bottomP,ge.bottomN,_e.bottomP)),fe=de,ge=_e,ye===Oe)for(let P=1;P<ye;P++)de=this.buildBevelVert(B,R,(te+P)%W,P/(ye-1)),_e=this.buildBevelVert(B,G,(k+P)%Y,P/(Oe-1)),x.push(fe.topN,de.topP,ge.topN),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,fe.bottomN,ge.bottomN),x.push(de.bottomP,ge.bottomN,_e.bottomP),fe=de,ge=_e;else if(ye>Oe){let P=ye/Oe,D=0;for(let Z=1;Z<ye;Z++)de=this.buildBevelVert(B,R,(te+Z)%W,Z/(ye-1)),x.push(fe.topN,de.topP,ge.topN),x.push(de.bottomP,fe.bottomN,ge.bottomN),fe=de,Z>(D+1)*P&&(D++,_e=this.buildBevelVert(B,G,(k+D)%Y,D/(Oe-1)),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,ge.bottomN,_e.bottomP),ge=_e)}else{let P=Oe/ye,D=0;for(let Z=1;Z<Oe;Z++)_e=this.buildBevelVert(B,G,(k+Z)%Y,Z/(Oe-1)),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,ge.bottomN,_e.bottomP),ge=_e,Z>(D+1)*P&&(D++,de=this.buildBevelVert(B,R,(te+D)%W,D/(ye-1)),x.push(fe.topN,de.topP,ge.topN),x.push(de.bottomP,fe.bottomN,ge.bottomN),fe=de)}te=(te+ye)%W,k=(k+Oe)%Y,se=(se+1)%q}while(se!==le)}{let V=X[0];for(let R=0,G=V.boundary.vertexCount;R<G;R++){let W=this.buildBevelVert(B,V,R),Y=this.buildBevelVert(B,V,(R+1)%G);x.push(Y.topP,W.topN,W.bottomN),x.push(Y.topP,W.bottomN,Y.bottomP)}}if(y){let V=[];for(let R=x.length-1;R>=F+2;R-=3){let G=x[R-2],W=x[R-1],Y=x[R-0];V.push(Y,W,G)}x.splice(F,x.length-F,...V)}if(y){let V=[];for(let R=X[X.length-1].boundary.vertices.length-1;R>=1;R-=2){let G=X[X.length-1].boundary.vertices[R-1],W=X[X.length-1].boundary.vertices[R-0];V.push(G,W)}v.push(V)}if(!y){let V=X[X.length-1],R=Eo({windingRule:X.length>1?Rt.POSITIVE:Rt.ODD,elementType:ur.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]});if(!R)throw new Error("Error generating geometry for surface");Object.assign(this,{capStartIndex:x.length});for(let G=0;G<R.elementCount*3;G+=3){let W=this.buildSurfaceVert(R,R.elements[G+0]),Y=this.buildSurfaceVert(R,R.elements[G+1]),q=this.buildSurfaceVert(R,R.elements[G+2]);x.push(W.top,Y.top,q.top),x.push(q.bottom,Y.bottom,W.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Xe(Uint32Array.from(x),1),b=new Xe(this._buffer.positions,3),S=new Xe(this._buffer.normals,3),M=new Xe(this._buffer.uvs,2);b.needsUpdate=!0,S.needsUpdate=!0,M.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",S),this.setAttribute("uv",M),this.setIndex(w)}buildSurfaceVert(t,r){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[r*2+0],o=t.vertices[r*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,c=this._buffer.get(2),h=c*3,u=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=o,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=a,this._buffer.uvs[u+1]=l,this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=o,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=a,this._buffer.uvs[u+3]=l,this.vertexCache[i]=f,f}buildBevelVert(t,r,i,s=1){let o=`${r.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=r.boundary.vertexIndices[i],c,h,u,f;a!==l?(h=a,c=l,f=!1,u=t.continuous[h]&&t.continuous[c]):(c=a,h=(c-1+t.count)%t.count,f=t.concave[c]&&r.bevelI>0,u=t.continuous[c]||f);let d=Math.cos(r.angle),m=Math.sin(r.angle),p=i*2,g=c*2,x=h*2,v=r.boundary.vertices[p+0],w=r.boundary.vertices[p+1],b=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,M=(w-this._minY)/this._height,_=t.normals[g+0],y=t.normals[g+1],T=t.normals[x+0],E=t.normals[x+1];if(f){let H=T-_,j=E-y;_=_+H*(1-s),y=y+j*(1-s);let Q=Math.sqrt(_*_+y*y);_/=Q,y/=Q}let C=this._buffer.get(u?2:4),I=C*3,B=C*2,N={i,fi:c,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=w,this._buffer.positions[I+2]=this._depth-b,this._buffer.normals[I+0]=_*d,this._buffer.normals[I+1]=y*d,this._buffer.normals[I+2]=m,this._buffer.uvs[B+0]=S,this._buffer.uvs[B+1]=M,this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=w,this._buffer.positions[I+5]=b,this._buffer.normals[I+3]=_*d,this._buffer.normals[I+4]=y*d,this._buffer.normals[I+5]=-m,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=S,u||(C+=2,I+=6,B+=4,N.topP=C+0,N.bottomP=C+1,this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=w,this._buffer.positions[I+2]=this._depth-b,this._buffer.normals[I+0]=T*d,this._buffer.normals[I+1]=E*d,this._buffer.normals[I+2]=m,this._buffer.uvs[B+0]=S,this._buffer.uvs[B+1]=M,this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=w,this._buffer.positions[I+5]=b,this._buffer.normals[I+3]=T*d,this._buffer.normals[I+4]=E*d,this._buffer.normals[I+5]=-m,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=S),this.vertexCache[o]=N,N}clone(){let t=new il(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=Lc(this.userData),t}};var Er=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=n.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof dt?(o.width!==r||o.height!==i)&&o.applySize(r,i):o=new dt(r,i).fromJSON(o),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&o.update(!1));let l=o??new dt(r,i);return{parameters:Object.assign(t,{width:r,height:i,depth:s,roundness:a}),shape:l}}static build(n){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:i,roundness:s}=n.parameters;n.shape.roundness=s;let o;return e<=0?o=new nl(n.shape,i):o=new il(n.shape,e,t,i,r),Object.assign(o,{userData:{...n,type:"VectorGeometry"}})}};var kS=Math.PI*2,VS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t,spikes:r,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c=n.shape,h=e*.5,u=t*.5,f=RO(c,h,u,i*Math.PI/180,r,s);c.isClosed=!0,c.update();let d=Er.create({shape:c,parameters:{subdivisions:f,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(d,{userData:{...n,type:"EllipseGeometry"}})}};function RO(n,e,t,r,i,s){if(r>=kS)return i>30||i%4===0?(zO(n,e,t,s),Math.round(i/4)):GS(n,r,i,e,t,s);let o={x:0,y:t},a=r+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=OS({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?FO(n,o.x,o.y,c,i,e,t,s):GS(n,r,i,e,t,s)}function FO(n,e,t,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(sl(e,t));for(let c=0,h=r.length;c<h;c++){let u=r[c],f=n.points[c],d=sl(u.x,u.y);f.controls[1].position.set(u.x1,u.y1),d.controls[0].position.set(u.x2,u.y2),n.addPoint(d)}return a>0?HS(n,s,o,a):n.addPoint(sl(0,0)),l}function GS(n,e,t,r,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,c=Math.sin(l)*r,h=Math.cos(l)*i;n.addPoint(sl(c,h))}return e<kS?s>0?HS(n,r,i,s):n.addPoint(sl(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&WS(n,r,i,s)),1}function zO(n,e,t,r=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;n.addPoint(ed(i-e,s,i-e,s-l,i-e,s+l)),n.addPoint(ed(i,s+t,i-a,s+t,i+a,s+t)),n.addPoint(ed(i+e,s,i+e,s+l,i+e,s-l)),n.addPoint(ed(i,s-t,i+a,s-t,i-a,s-t)),r>0&&WS(n,e,t,r)}function sl(n,e){return new qn(je.generateUUID(),new O(n,e))}function ed(n,e,t,r,i,s){let o=sl(n,e);return o.controls[0].position.set(t,r),o.controls[1].position.set(i,s),o}function HS(n,e,t,r){jS(n,e,t,r).forEach(s=>n.addPoint(s))}function WS(n,e,t,r){let i=jS(n,e,t,r),s=new dt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function jS(n,e,t,r){let i=r*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new O(i/e,s/t),a=n.points.map(l=>{let c=l.clone();return c.uuid=je.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),h=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(h),l.controls[1].position.copy(c)}),a}var qS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(t.width),i=Math.abs(t.height??r),s=Math.abs(t.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(t,{width:r,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(n){let{width:e,height:t,depth:r,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:u}=n.parameters,f=new $c(!1,e,t,r,i,s,o,a,l,c,h,u);return Object.assign(f,{userData:{...n,type:"HelixGeometry"}})}},$c=class extends Le{constructor(e=!0,t=1,r=1,i=1,s=1,o=1,a=1,l=1,c=1,h=1,u=1,f=1){super();let d=e&&o===1;d&&(f=0),u>100&&(u=100);let m=()=>new A,p=new A,g=m(),x=m(),v=m(),w,b,S,M,_,y,T,E,C=m(),I=m(),B=m(),N=m(),H=m(),j=m(),Q=m(),X=m(),U=r-2*l+.001,F=U/o,V=Math.ceil(a*o),R=V+1,G=U/V,W=-U/2,Y=h+1,q=2*Math.PI/h,se=Math.PI/2/f,K=.01,te=Math.min((1-u/100)*l,l-K),k=l-te,le=0,ce=2,ae=f*ce+ce,fe=Y*ae/ce,ge=fe+Y*R,de=Y*(R+ae),[_e,Ee,ye]=[3,3,2].map(ve=>Array(de*ve).fill(0)),Oe=[],pt=s-l;function P(ve,z){let xe=Math.PI/2;y=z*G,E=2*Math.PI*(y%F)/F+xe,y+=W,T=Math.sin(E)*pt,_=Math.cos(E)*pt,e?ve.set(_,T,y):ve.set(_,y,T)}P(p,-1e-10),P(g,0),C.copy(p),P(p,1);let D=p.distanceTo(g),Z=k+te,ue=D*V+2*Z,pe=te,Te=ue-Z;for(let ve=0;ve<=V;ve++){P(x,ve),X.subVectors(x,C).normalize(),C.copy(x),j.copy(x).setComponent(+e+1,0).normalize(),Q.crossVectors(X,j).normalize();let z=ve===0,xe=ve===V,Me=z?3*Math.PI/2:se,Ye=z?pe:Te,Ne=z?Y:ge,Je=z?0:de-Y,be=X.clone().multiplyScalar(z?-k:k).add(x),Qe=X.clone().multiplyScalar(z?-1:1).normalize();for(let nt=0;nt<Y;nt++){let mt=nt*q;if(I.addVectors(p.copy(j).multiplyScalar(l*Math.cos(mt)),g.copy(Q).multiplyScalar(l*Math.sin(mt))),B.copy(I).normalize(),z||xe){d||(le=Je+nt,[0,1,2].forEach(bt=>{_e[le*3+bt]=be.getComponent(bt),Ee[le*3+bt]=Qe.getComponent(bt)}),ye[le*2]=+xe,ye[le*2+1]=nt/h),g.copy(B).multiplyScalar(te),v.addVectors(x,g);for(let bt=0;bt<f;bt++){let Jr=bt*se+Me;N.addVectors(p.copy(X).multiplyScalar(k*Math.sin(Jr)),g.copy(B).multiplyScalar(k*Math.cos(Jr))),H.copy(N).normalize(),g.addVectors(v,N),N.normalize(),le=Ne+bt*Y+nt,[0,1,2].forEach(Oo=>{_e[le*3+Oo]=g.getComponent(Oo),Ee[le*3+Oo]=H.getComponent(Oo)});let Lh=+z+Math.sin(Jr);ye[le*2]=(Ye+k*Lh)/ue,ye[le*2+1]=nt/h}}g.addVectors(x,I),le=fe+ve*Y+nt,[0,1,2].forEach(bt=>{_e[le*3+bt]=g.getComponent(bt),Ee[le*3+bt]=B.getComponent(bt)}),ye[le*2]=(Z+ve*D)/ue,ye[le*2+1]=nt/h}}let Fe=R+2*f+ce,ne=1,[Re,Ie]=d?[ne,ne+R-1]:[0,Fe-1];for(let ve=Re;ve<=Ie-1;ve++){let z=d&&ve===Ie-1;for(let xe=0;xe<Y-1;xe++)w=ve*Y+xe,b=w+1,S=(z?xe:w)+Y,M=(z?xe+1:b)+Y,ve===0?Oe.push(b,M,S):ve===Fe-2?Oe.push(w,b,S):Oe.push(w,b,S,b,M,S)}this.setIndex(Oe),this.setAttribute("position",new Ae(_e,3)),this.setAttribute("normal",new Ae(Ee,3)),this.setAttribute("uv",new Ae(ye,2))}};var YS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new eh(e*.5,s,o):new da(e*.5,i);return a.scale(1,t/e,r/e),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},eh=class extends zs{constructor(e=1,t=.2,r=4){let i=(1+Math.sqrt(5))/2,s=[-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],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,r),this.type=a}static fromJSON(e){return new eh(e.radius,e.corner,e.cornerSides)}};var XS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let t=Object.assign({},e?.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}]},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{points:e,segments:t,verticalSegments:r}=n.parameters,i=new Fn;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new ca(i.extractPoints(r).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var yi=new Be,Kg=new lt,td=new A,Gs=class extends Ot{constructor(){super(),this.uuid=je.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 Ht().getNormalMatrix(e);for(let r=0,i=this.vertices.length;r<i;r++)this.vertices[r].applyMatrix4(e);for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return yi.makeRotationX(e),this.applyMatrix4(yi),this}rotateY(e){return yi.makeRotationY(e),this.applyMatrix4(yi),this}rotateZ(e){return yi.makeRotationZ(e),this.applyMatrix4(yi),this}translate(e,t,r){return yi.makeTranslation(e,t,r),this.applyMatrix4(yi),this}scale(e,t,r){return yi.makeScale(e,t,r),this.applyMatrix4(yi),this}lookAt(e){return Kg.lookAt(e),Kg.updateMatrix(),this.applyMatrix4(Kg.matrix),this}fromBufferGeometry(e){let t=this,r=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,c=i.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let f=0;f<s.count;f++)t.vertices.push(new A().fromBufferAttribute(s,f)),a!==void 0&&t.colors.push(new Se().fromBufferAttribute(a,f));function h(f,d,m,p){let g=a===void 0?[]:[t.colors[f].clone(),t.colors[d].clone(),t.colors[m].clone()],x=o===void 0?[]:[new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,m)],v=new ol(f,d,m,x,g,p);t.faces.push(v),l!==void 0&&t.faceVertexUvs[0].push([new O().fromBufferAttribute(l,f),new O().fromBufferAttribute(l,d),new O().fromBufferAttribute(l,m)]),c!==void 0&&t.faceVertexUvs[1].push([new O().fromBufferAttribute(c,f),new O().fromBufferAttribute(c,d),new O().fromBufferAttribute(c,m)])}let u=e.groups;if(u.length>0)for(let f=0;f<u.length;f++){let d=u[f],m=d.start,p=d.count;for(let g=m,x=m+p;g<x;g+=3)r!==void 0?h(r.getX(g),r.getX(g+1),r.getX(g+2),d.materialIndex):h(g,g+1,g+2,d.materialIndex)}else if(r!==void 0)for(let f=0;f<r.count;f+=3)h(r.getX(f),r.getX(f+1),r.getX(f+2));else for(let f=0;f<s.count;f+=3)h(f,f+1,f+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(td).negate(),this.translate(td.x,td.y,td.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,r=t===0?1:1/t,i=new Be;return i.set(r,0,0,-r*e.x,0,r,0,-r*e.y,0,0,r,-r*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new A,t=new A;for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let r=0,i=this.vertices.length;r<i;r++)t[r]=new A;if(e){let r=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],h=this.vertices[a.c];r.subVectors(h,c),i.subVectors(l,c),r.cross(i),t[a.a].add(r),t[a.b].add(r),t[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let r=0,i=this.vertices.length;r<i;r++)t[r].normalize();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[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 r=this.faces[e],i=r.vertexNormals;i.length===3?(i[0].copy(r.normal),i[1].copy(r.normal),i[2].copy(r.normal)):(i[0]=r.normal.clone(),i[1]=r.normal.clone(),i[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,r=this.faces.length;t<r;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new Gs;e.faces=this.faces;for(let t=0,r=this.morphTargets.length;t<r;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new A,h={a:new A,b:new A,c:new A};s.push(c),o.push(h)}}let i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],c=i.vertexNormals[s];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let t=0,r=this.faces.length;t<r;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new yr),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Br),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,r=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,c=e.faces,h=this.colors,u=e.colors;t!==void 0&&(i=new Ht().getNormalMatrix(t));for(let f=0,d=a.length;f<d;f++){let p=a[f].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone());for(let f=0,d=c.length;f<d;f++){let m=c[f],p,g,x=m.vertexNormals,v=m.vertexColors,w=new ol(m.a+s,m.b+s,m.c+s);w.normal.copy(m.normal),i!==void 0&&w.normal.applyMatrix3(i).normalize();for(let b=0,S=x.length;b<S;b++)p=x[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),w.vertexNormals.push(p);w.color.copy(m.color);for(let b=0,S=v.length;b<S;b++)g=v[b],w.vertexColors.push(g.clone());w.materialIndex=m.materialIndex+r,l.push(w)}for(let f=0,d=e.faceVertexUvs.length;f<d;f++){let m=e.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++)v.push(x[w].clone());this.faceVertexUvs[f].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={},r=[],i=[],s=Math.pow(10,e);for(let l=0,c=this.vertices.length;l<c;l++){let h=this.vertices[l],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=l,r.push(this.vertices[l]),i[l]=r.length-1):i[l]=i[t[u]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let h=this.faces[l];h.a=i[h.a],h.b=i[h.b],h.c=i[h.c];let u=[h.a,h.b,h.c];for(let f=0;f<3;f++)if(u[f]===u[(f+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(c,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(e){this.vertices=[];for(let t=0,r=e.length;t<r;t++){let i=e[t];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}e.sort(r);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let c=e[l]._id;o&&o.push(i[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),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 m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let r=[],i=[],s={},o=[],a={},l=[],c={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,x=!1,v=this.faceVertexUvs[0][m]!==void 0,w=p.normal.length()>0,b=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,M=p.vertexColors.length>0,_=0;if(_=h(_,0,0),_=h(_,1,g),_=h(_,2,x),_=h(_,3,v),_=h(_,4,w),_=h(_,5,b),_=h(_,6,S),_=h(_,7,M),r.push(_),r.push(p.a,p.b,p.c),r.push(p.materialIndex),v){let y=this.faceVertexUvs[0][m];r.push(d(y[0]),d(y[1]),d(y[2]))}if(w&&r.push(u(p.normal)),b){let y=p.vertexNormals;r.push(u(y[0]),u(y[1]),u(y[2]))}if(S&&r.push(f(p.color)),M){let y=p.vertexColors;r.push(f(y[0]),f(y[1]),f(y[2]))}}function h(m,p,g){return g?m|1<<p:m&~(1<<p)}function u(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function f(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function d(m){let p=m.x.toString()+m.y.toString();return c[p]!==void 0||(c[p]=l.length/2,l.push(m.x,m.y)),c[p]}return e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=r,e}clone(){return new Gs().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 f=0,d=t.length;f<d;f++)this.vertices.push(t[f].clone());let r=e.colors;for(let f=0,d=r.length;f<d;f++)this.colors.push(r[f].clone());let i=e.faces;for(let f=0,d=i.length;f<d;f++)this.faces.push(i[f].clone());for(let f=0,d=e.faceVertexUvs.length;f<d;f++){let m=e.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++){let S=x[w];v.push(S.clone())}this.faceVertexUvs[f].push(v)}}let s=e.morphTargets;for(let f=0,d=s.length;f<d;f++){let m={};if(m.name=s[f].name,s[f].vertices!==void 0){m.vertices=[];for(let p=0,g=s[f].vertices.length;p<g;p++)m.vertices.push(s[f].vertices[p].clone())}if(s[f].normals!==void 0){m.normals=[];for(let p=0,g=s[f].normals.length;p<g;p++)m.normals.push(s[f].normals[p].clone())}this.morphTargets.push(m)}let o=e.morphNormals;for(let f=0,d=o.length;f<d;f++){let m={};if(o[f].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[f].vertexNormals.length;p<g;p++){let x=o[f].vertexNormals[p],v={};v.a=x.a.clone(),v.b=x.b.clone(),v.c=x.c.clone(),m.vertexNormals.push(v)}}if(o[f].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[f].faceNormals.length;p<g;p++)m.faceNormals.push(o[f].faceNormals[p].clone())}this.morphNormals.push(m)}let a=e.skinWeights;for(let f=0,d=a.length;f<d;f++)this.skinWeights.push(a[f].clone());let l=e.skinIndices;for(let f=0,d=l.length;f<d;f++)this.skinIndices.push(l[f].clone());let c=e.lineDistances;for(let f=0,d=c.length;f<d;f++)this.lineDistances.push(c[f]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new Zg().fromGeometry(this),t=new Le,r=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Xe(r,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Xe(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Xe(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Xe(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Xe(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let c=o[a],h=new Ae(c.data.length*3,3);h.name=c.name,s.push(h.copyVector3sArray(c.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Ae(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Ae(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(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 Le,r=e.geometry;if(e.isPoints||e.isLine){let i=new Ae(r.vertices.length*3,3),s=new Ae(r.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(r.vertices)),t.setAttribute("color",s.copyColorsArray(r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Ae(r.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(r.lineDistances))}r.boundingSphere!==null&&(t.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(t.boundingBox=r.boundingBox.clone())}else e.isMesh&&(t=r.toBufferGeometry());return t}};Gs.prototype.isGeometry=!0;var Zg=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=[],r,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=i*3-r.start,t.push(r)),r={start:i*3,materialIndex:s})}r!==void 0&&(r.count=i*3-r.start,t.push(r)),this.groups=t}fromGeometry(e){let t=e.faces,r=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,c;if(l>0){c=[];for(let x=0;x<l;x++)c[x]={name:a[x].name,data:[]};this.morphTargets.position=c}let h=e.morphNormals,u=h.length,f;if(u>0){f=[];for(let x=0;x<u;x++)f[x]={name:h[x].name,data:[]};this.morphTargets.normal=f}let d=e.skinIndices,m=e.skinWeights,p=d.length===r.length,g=m.length===r.length;r.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let x=0;x<t.length;x++){let v=t[x];this.vertices.push(r[v.a],r[v.b],r[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=v.normal;this.normals.push(S,S,S)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][x];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",x),this.uvs.push(new O,new O,new O))}if(o===!0){let S=i[1][x];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",x),this.uvs2.push(new O,new O,new O))}for(let S=0;S<l;S++){let M=a[S].vertices;c[S].data.push(M[v.a],M[v.b],M[v.c])}for(let S=0;S<u;S++){let M=h[S].vertexNormals[x];f[S].data.push(M.a,M.b,M.c)}p&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[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}},ol=class{constructor(e,t,r,i,s,o=0){this.a=e,this.b=t,this.c=r,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Se,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}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,r=e.vertexNormals.length;t<r;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,r=e.vertexColors.length;t<r;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var UO=["a","b","c"];function GO(n,e){switch(e){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function $g(n,e,t){let r=Math.min(n,e),i=Math.max(n,e),s=r+"_"+i;return t.get(s)}function ey(n,e,t,r,i,s){let o=Math.min(n,e),a=Math.max(n,e),l=o+"_"+a,c;if(r.has(l))c=r.get(l);else{let h=t[o],u=t[a];c={a:h,b:u,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(i),s[n].edges.push(c),s[e].edges.push(c)}function kO(n,e,t,r){let i,s,o;for(i=0,s=n.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],ey(o.a,o.b,n,r,o,t),ey(o.b,o.c,n,r,o,t),ey(o.c,o.a,n,r,o,t)}function rd(n,e,t,r,i){n.push(new ol(e,t,r,void 0,void 0,i))}function al(n,e){return Math.abs(e-n)/2+Math.min(n,e)}function nd(n,e,t,r){n.push([e.clone(),t.clone(),r.clone()])}var id=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Le?e=new Gs().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 A,r,i,s,o,a,l=e.vertices,c=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,f=[],d=new Map;kO(l,c,f,d);let m=[],p,g,x,v,w,b,S;for(let K of Array.from(d.keys())){for(g=d.get(K),x=new A,w=3/8,b=1/8,S=g.faces.length,S!=2&&(w=.5,b=0,S!=1),x.addVectors(g.a,g.b).multiplyScalar(w),t.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[GO(v,UO[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(b),x.add(t),g.newEdge=m.length,m.push(x)}let M,_,y,T,E,C,I,B=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=f[i].edges,r=E.length,r==3?M=3/16:r>3&&(M=3/(8*r)),_=1-r*Number(M),y=M,r<=2&&(r==2?(_=3/4,y=1/8):r==1||r==0),I=C.clone().multiplyScalar(_),t.set(0,0,0),o=0;o<r;o++)T=E[o],p=T.a!==C?T.a:T.b,t.add(p);t.multiplyScalar(Number(y)),I.add(t),B.push(I)}let N=B.concat(m),H=B.length,j,Q,X,U=[],F=[],V,R,G,W,Y=new O,q=new O,se=new O;for(i=0,s=c.length;i<s;i++)v=c[i],j=Number($g(v.a,v.b,d).newEdge)+H,Q=Number($g(v.b,v.c,d).newEdge)+H,X=Number($g(v.c,v.a,d).newEdge)+H,rd(U,j,Q,X,v.materialIndex),rd(U,v.a,j,X,v.materialIndex),rd(U,v.b,Q,j,v.materialIndex),rd(U,v.c,X,Q,v.materialIndex),u&&(V=h[i],R=V[0],G=V[1],W=V[2],Y.set(al(R.x,G.x),al(R.y,G.y)),q.set(al(G.x,W.x),al(G.y,W.y)),se.set(al(R.x,W.x),al(R.y,W.y)),nd(F,Y,q,se),nd(F,R,Y,se),nd(F,G,q,Y),nd(F,W,se,q));e.vertices=N,e.faces=U,u&&(e.faceVertexUvs[0]=F)}};var fr=new A,JS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=n.geometry??e?.geometry??new Le().copy(new Kr(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(fr),r={width:fr.x,height:fr.y,depth:fr.z,subdivisions:0}):r=e.parameters;let i={...r,...n.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(n){let{width:e,height:t,depth:r,subdivisions:i}=n.parameters,s=n.geometry??new Le().copy(new Kr(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(fr)):fr.set(o.width,o.height,o.depth),(e!==fr.x||t!==fr.y||r!==fr.z)&&s.scale(fr.x===0?1:e/fr.x,fr.y===0?1:t/fr.y,fr.z===0?1:r/fr.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new id(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete n.geometry,Object.assign(s,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,e,t){new Ss(t).load(n,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(fr);let o=100/fr.x;Object.assign(s.parameters,{width:100,height:fr.y*o,depth:fr.z*o}),e(this.build(s))})}};var QS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t,spikes:r,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=n.parameters,l=n.shape,c=e*.5,h=t*.5,u=0,f=0,d=2*Math.PI/r;for(let p=0;p<r;p++){let g=d*p,x=u+Math.sin(g)*c,v=f+Math.cos(g)*h;l.addPoint(l.createPoint(x,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Er.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var KS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=new ry(e*.5,t,i,s,o,a,l);return c.scale(1,1,r/e),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function th(n,e,t){t.x=n.x*e.x,t.y=n.y,t.z=n.x*e.y}function ty(n,e,t,r,i,s){let o=e.clone().sub(n),a=t.clone().sub(n),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===i){let c=o.add(a).normalize();s.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(n),s.addScaledVector(o,i/Math.sin(c)),s.addScaledVector(a,r/Math.sin(c))}}function VO(n,e,t){let r=n.clone().sub(e),i=t.clone().sub(e);return r.projectOnVector(i),r.add(e)}var ry=class extends Le{constructor(e=.5,t=1,r=4,i=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],h=[],u=[],f=0,d=t/2,m=Math.PI/r,p=e*Math.cos(Math.PI/r),g=2*Math.PI/r,x=(r-2)*Math.PI/r,v=Math.PI-x,w=new A(0,-d,0),b=new A(0,d,0),S=new O(e,-d),M=new O(p,-d),_=new O(0,b.y).sub(M),y=new O(0,b.y).sub(S),T=new O(_.y,-_.x).normalize(),E=new O(y.y,-y.x).normalize(),I=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,I);let B;{let F=new A(T.x,T.y,0),V=new A(Math.cos(g)*F.x,F.y,Math.sin(g)*F.x);B=F.angleTo(V)}let N=o/Math.tan((Math.PI-_.angle())/2),H=o/Math.tan((Math.PI-B)/2),j=new A;if(!s){c.push(w.x,w.y,w.z),h.push(0,-1,0),u.push(0,0);let F=f++,V=[],R=S.clone(),G=N/Math.cos(Math.PI/r);R.x-=G;for(let W=0;W<r;W++){let Y=W/r*Math.PI*2+m,q=new O(Math.sin(Y),Math.cos(Y));th(R,q,j),c.push(j.x,j.y,j.z),h.push(0,-1,0),u.push(0,0),V.push(f++)}for(let W=0;W<V.length;W++)l.push(V[W],F,V[(W+1)%V.length])}let Q=[];{let F=new A,V=new A,R=new A,G=new A,W=new A,Y=new A;for(let q=0;q<r;q++){let se=q/r*Math.PI*2+m,K=(q+.5)/r*Math.PI*2+m,te=(q+1)/r*Math.PI*2+m,k=new O(Math.sin(se),Math.cos(se)),le=new O(Math.sin(K),Math.cos(K)),ce=new O(Math.sin(te),Math.cos(te));th(S,k,V),th(S,ce,R),th(T,le,F),ty(b,V,R,H,H,G),c.push(G.x,G.y,G.z),ty(V,b,R,H,N,W),c.push(W.x,W.y,W.z),ty(R,V,b,N,H,Y),c.push(Y.x,Y.y,Y.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),u.push(0,0),u.push(0,0),u.push(0,0);let ae=f++,fe=f++,ge=f++;if(l.push(ae,fe,ge),o>0){{let Ee=V.clone().add(R).multiplyScalar(.5),ye=b.clone().sub(Ee).normalize(),pt=w.clone().sub(Ee).normalize().add(ye).normalize().multiplyScalar(-1),P=Y.clone().sub(W);X(Ee,P,pt,_.angle())}let de,_e;{let Ee=new A;th(E,ce,Ee);let ye=Y.clone().add(G).multiplyScalar(.5);ye=VO(ye,R,b);let Oe=Y.clone().sub(G);[de,_e]=X(ye,Oe,Ee,B,G.y)}{let Ee=de,ye=Ee.clone().setY(0).normalize(),Oe=new A(0,-1,0),pt=ye.clone().cross(Oe);U(Ee,ye,Oe,pt)}Q.concat(_e);{let Ee=_.angle(),ye=Math.PI-Ee,Oe=b.clone();Oe.y-=o/Math.sin(Ee-Math.PI/2);let pt=new A,P=[];for(let Z=0;Z<a;Z++){let ue=[],pe=Math.PI/2-ye*Z/a,Te=Math.cos(pe),Fe=Math.sin(pe),ne=K;for(let Re=0;Re<=Z;Re++){let Ie=Math.cos(ne),ve=Math.sin(ne);F.x=Te*ve,F.y=Fe,F.z=Te*Ie,pt.copy(Oe).addScaledVector(F,o),c.push(pt.x,pt.y,pt.z),h.push(F.x,F.y,F.z),u.push(0,0),ue.push(f++),ne+=Math.PI*2/Z/r}P.push(ue)}_e.reverse(),P.push(_e);let D=P.length-1;for(let Z=0;Z<D;Z++){let ue=P[Z],pe=P[Z+1],Te=ue.length-1;l.push(pe[1],ue[0],pe[0]);for(let Fe=1;Fe<=Te;Fe++)l.push(ue[Fe],ue[Fe-1],pe[Fe]),l.push(pe[Fe+1],ue[Fe],pe[Fe])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(c,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(u,2));function X(F,V,R,G,W){let Y=-G/2,q=(Math.PI-G)/2,se=V.clone().normalize().cross(R);F.addScaledVector(R,-o/Math.sin(q));let K=new A,te=new A,k=1,le=f,ce=[];for(let ae=0;ae<=a;ae++){let fe=Y+ae/a*G;te.set(0,0,0),te.addScaledVector(se,Math.sin(fe)),te.addScaledVector(R,Math.cos(fe));for(let ge=0;ge<=k;ge++){let de=ge/k-.5;if(K.copy(F),K.addScaledVector(V,de),K.addScaledVector(te,o),W!=null){let _e=Math.max(0,K.y-W);K.addScaledVector(V,-_e/V.y)}c.push(K.x,K.y,K.z),h.push(te.x,te.y,te.z),u.push(0,0),ge===0&&ce.push(f),f++}}for(let ae=0;ae<a;ae++)for(let fe=0;fe<k;fe++){let ge=le+fe+(k+1)*ae,de=ge+(k+1),_e=de+1,Ee=ge+1;l.push(ge,de,Ee),l.push(de,_e,Ee)}return[F.clone().addScaledVector(V,.5),ce]}function U(F,V,R,G){let W=Math.PI/2,Y=y.angle()-W,q=[],se=new A,K=new A;for(let k=0;k<=a;k++){let le=[],ce=k/a;for(let ae=0;ae<=k;ae++){let ge=((k?ae/k:0)-.5)*v,de=Math.cos(ge),_e=Math.sin(ge),Ee=Math.atan(Math.tan(Y)*de),ye=(W+Ee)*ce,Oe=Math.cos(ye),pt=Math.sin(ye);se.set(0,0,0),se.addScaledVector(V,pt*de),se.addScaledVector(R,Oe),se.addScaledVector(G,pt*_e),K.copy(F).addScaledVector(se,o),c.push(K.x,K.y,K.z),h.push(se.x,se.y,se.z),u.push(0,0),le.push(f++)}q.push(le)}let te=q.length-1;for(let k=0;k<te;k++){let le=q[k],ce=q[k+1],ae=le.length-1;l.push(le[0],ce[1],ce[0]);for(let fe=1;fe<=ae;fe++)l.push(le[fe-1],le[fe],ce[fe]),l.push(le[fe],ce[fe+1],ce[fe])}}}};var sd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(e?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:r}}static build(n){let e=n.shape,{width:t,height:r,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c={x:t*.5,y:r*.5},h={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function f(b,S,M){return S>t&&M>r?Math.min(b*t/S,b*r/M):S>t?b*t/S:M>r?b*r/M:b}let d=[];d[0]=i[0]===0?0:f(i[0],i[0]+i[3],i[0]+i[1]),d[1]=i[1]===0?0:f(i[1],i[1]+i[2],i[1]+i[0]),d[2]=i[2]===0?0:f(i[2],i[2]+i[1],i[2]+i[3]),d[3]=i[3]===0?0:f(i[3],i[3]+i[0],i[3]+i[2]);let m=h.x,p=u.x,g=u.y,x=h.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,x)),e.addPoint(e.createPoint(m,x)),e.isClosed=!0;let v=!0;for(let b=0,S=e.points.length;b<S;b++)e.points[b].roundness=d[b],b>0&&d[b]!==d[b-1]&&(v=!1);v&&(e.roundness=d[0]),e.useCubicForRoundedCorners=s!==1,e.update();let w=Er.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};var ZS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e=100,height:t=e,depth:r=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,h=new ho(.5*e,i,s,o,a,l,c);return h.scale(1,t/e,r/e),Object.assign(h,{userData:{...n,type:"SphereGeometry"}})}};var $S=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(n){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:i=8}=n.parameters,s=new Ui(e,t,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var e1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,angle:i,cornerRadius:s,cornerSegments:o}=n.parameters,a=new ny(e,t,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},ny=class extends Le{constructor(e=1,t=1,r=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],h=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-h,i),i*=Math.PI/180;let u=[],f=(K=0,te=0,k=0)=>new A(K,te,k),d=f(),m=f(),[p,g,x]=[t/2,e/2,r/2],v=-g,w=+g,[b,S,M]=[f(v,-p,+x),f(v,-p,-x),f(v,+p,-x)],[_,y]=[K=>Math.sin(K),K=>Math.cos(K)],T=(K,te=!1)=>Math.sin(K-Math.PI/(1+ +te)),E=(K,te=!1)=>Math.cos(K-Math.PI/(1+ +te));M.y=_(i)*t-p;let C=y(i)*t-x;i<=Math.PI/2?M.z=Math.min(C,b.z-h):S.z=Math.min(S.z-C-x,b.z-h),d.subVectors(b,S),m.subVectors(M,S);let I=Math.min(d.length(),m.length())*s/100,B=I*Math.tan(i/2),N=I/Math.cos(i/2),H=d.clone().normalize().add(m.normalize()).setLength(N).add(S);d.set(0,T(i,!0),E(i,!0)),u.push([M,d.clone()]);let j=(Math.PI-i)/o;for(let K=0;K<=o;K++){let te=Math.PI/2+i+K*j;d.set(0,_(te)*B,y(te)*B),d.add(H),m.set(0,T(te),E(te)),u.push([d.clone(),m.clone()])}u.push([b,f(0,1,0)]);let Q=Math.sin(j/2)*B*2,X=u.length-1,U=u[0][0].distanceTo(u[1][0]),F=u[X-1][0].distanceTo(u[X][0]),V=U+Q*o+F;u[0].push(1);for(let K=0;K<=o;K++)u[K+1].push(1-(U+K*Q)/V);u[X].push(0);let[R,G,W]=u[0],Y,q,se;for(let K=1;K<u.length;K++)[Y,q,se]=u[K],a.push(v,R.y,R.z,v,Y.y,Y.z,w,R.y,R.z,w,R.y,R.z,v,Y.y,Y.z,w,Y.y,Y.z),l.push(0,G.y,G.z,0,q.y,q.z,0,G.y,G.z,0,G.y,G.z,0,q.y,q.z,0,q.y,q.z),c.push(0,W,0,se,1,W,1,W,0,se,1,se),[R,G,W]=[Y,q,se];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(c,2))}};var t1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t,innerRadiusPercent:r,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,h=n.shape,u=e*.5,f=t*.5,d=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,x=u*r/100,v=f*r/100;if(i===3&&r===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let S=p*b,M=d+Math.sin(S)*u,_=m+Math.cos(S)*f;h.addPoint(h.createPoint(M,_))}}else for(let b=0;b<i;b++){let S=d+Math.cos(g)*u,M=m+Math.sin(g)*f;h.addPoint(h.createPoint(S,M)),g+=p,S=d+Math.cos(g)*x,M=m+Math.sin(g)*v,b<=i,h.addPoint(h.createPoint(S,M)),g+=p}h.isClosed=!0;for(let b=0,S=h.points.length;b<S;b++)h.points[b].roundness=s;h.roundness=s,h.update();let w=Er.create({shape:h,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};var od=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t}=n.parameters,r=new Ui(e,t);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var r1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??t.width*.25);return{parameters:Object.assign(t,{width:r,height:i,depth:s})}}static build(n){let{width:e,height:t,depth:r,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=HO(e,t,r,e*.5,o,s,0,0,i,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function HO(n,e,t,r,i,s,o,a,l,c,h){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(c=0),new $c(!0,n,e,t,r,i,s,o,a,l,c,h)}var n1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(n){let{width:e,tube:t,tubularSegments:r,radialSegments:i,p:s,q:o}=n.parameters,a=e*.5;a!==t&&(a-=t);let l=new ma(a,t,r,i,s,o);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var i1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e=100,height:t,cornerRadius:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=n.parameters,l=n.shape,c=e*.5,h=t*.5;a?(l.addPoint(l.createPoint(-c,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))),l.isClosed=!0;for(let f=0,d=l.points.length;f<d;f++)l.points[f].roundness=r;l.roundness=r,l.update();let u=Er.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};var ad={};ap(ad,{addBarycentricAttribute:()=>qO,fixUvs:()=>XO,loadFromUrl:()=>YO,resizeGeometry:()=>jO,roundShapePolygon:()=>WO});var s1=function(n,e){let t=e.x-n.x,r=e.y-n.y,i=Math.sqrt(t*t+r*r),s=t/i,o=r/i,a=Math.atan2(o,s);return{x:t,y:r,len:i,nx:s,ny:o,ang:a}},WO=(n,e,t)=>{let r,i,s,o,a,l,c,h,u,f,d,m,p,g,x=e.length;for(o=e[x-2],n.curves=[],r=1;r<x-1;r++){a=e[r%x],l=e[(r+1)%x];let v=s1(a,o),w=s1(a,l);c=v.nx*w.ny-v.ny*w.nx,h=v.nx*w.nx-v.ny*-w.ny,d=Math.asin(c),u=1,f=!1,h<0?d<0?d=Math.PI+d:(d=Math.PI-d,u=-1,f=!0):d>0&&(u=-1,f=!0),m=d/2,g=Math.abs(Math.cos(m)*t/Math.sin(m)),g>Math.min(v.len/2,w.len/2)?(g=Math.min(v.len/2,w.len/2),p=Math.abs(g*Math.sin(m)/Math.cos(m))):p=t,i=a.x+w.nx*g,s=a.y+w.ny*g,i+=-w.ny*p*u,s+=w.nx*p*u,n.absarc(i,s,p,v.ang+Math.PI/2*u,w.ang-Math.PI/2*u,f),o=a,a=l}n.closePath()},jO=(n,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let i=n.userData.parameters,s,o,a;e===0?(e=i.width,s=1):s=e/i.width,t===0?(t=i.height,o=1):o=t/i.height,r===0?(r=i.depth,a=1):a=r/i.depth,n.scale(s,o,a),i.width=e,i.height=t,i.depth=r},qO=(n,e)=>{let t=[new A(1,0,0),new A(0,1,0),new A(0,0,1)],r=n.attributes.position,i=new Float32Array(r.count*3);for(let s=0,o=r.count;s<o;s++)t[s%3].toArray(i,s*3);n.setAttribute(e,new Ae(i,3))},YO=n=>new Promise(e=>{new Ss().load(n,r=>e(r))}),XO=(n,e,t)=>{let r=n.getAttribute("uv");if(r)for(let i=0;i<r.count;i++){let s=r.getX(i),o=r.getY(i);r.setXY(i,(s+e/2)/e,1-(o-t/2)/t*-1)}};var JO,ld=new Promise(n=>{JO=n});var rh=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}};var Ue=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=je.generateUUID(),this.type=e,this.name="",this.userData={}}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,r){return r=r??{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r??{},e.addFlow(r.slot,r.cache,r.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,r){t=t??this.getType(e,t);let i=e.getNodeData(r??this);return e.analyzing&&this.appendDepsNode(e,i,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,r)}updateFrame(e){}generateReadonly(e,t,r,i,s,o){return""}generate(e,t,r,i,s){return""}parse(e,t,r,i){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let i=e.getTypeLength(r);(i>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=i,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if(e?.materials&&e?.materials[this.uuid]!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof Ue&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){return this.getJSONNode(e)??this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var iy=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},dr=new iy;var ke=class extends Ue{constructor(t,r){super(t);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(t,r,i,s){if(r=r??this.getType(t),this.getShared(t,r)){let o=this.getUnique(t,r);o&&this.uuid===void 0&&(this.uuid=je.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,r),this.generate(t,r,i)):super.build(t,r,i);if(o)return a.name=a.name||super.build(t,r,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,r,i);i=this.getUUID(!1);let c=this.getTemp(t,i);if(c)return t.format(c,l,r);{c=super.generate(t,r,i,a.output,s);let h=this.generate(t,l,i);return t.addNodeCode(c+" = "+h+";"),t.format(c,l,r)}}return super.build(t,r,i)}getShared(t,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(t,r){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(t,r){r=r||this.uuid;let i=t.getVars()[r];return i?i.name:void 0}generate(t,r,i,s,o){return this.getShared(t,r)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Lt=class extends ke{constructor(t,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(t,r);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(t){let r=super.createJSONNode(t);return this.readonly===!0&&(r.readonly=this.readonly),r}fromJSON(t,r){return super.fromJSON(t,r),t.readonly!==void 0&&this.setReadonly(t.readonly),this}generate(t,r,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,r,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,r))}copy(t){return super.copy(t),this.readonly=t.readonly,this}};var wr=class extends Lt{constructor(t=0,r){super("v2");this.nodeType="Vector2";this.value=t instanceof O?t:new O(t,r)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,r,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Sr=class extends Lt{constructor(t=0,r,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,r,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,r,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Cr=class extends Se{constructor(t,r,i,s){super(t,r,i);this.isColorA=!0;this.a=s}setRGBA(t,r,i,s){super.setRGB(t,r,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var Yn=class extends Lt{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof Cr?t:new Cr(t.r,t.g,t.b,t.a)}generateReadonly(t,r,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var QO=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,o1=/[a-z_0-9]+/gi,Pe=class extends ke{constructor(t,r,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,r,i,s)}getShared(t,r){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===t)return this.inputs[r]}}getIncludeByName(t){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===t)return this.includes[r]}}generate(t,r,i,s,o){let a,l=0,c=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)t.include(this.includes[u],this);for(let u in this.extensions)t.extensions[u]=!0;let h=[];for(;a=o1.exec(this.src);)h.push(a);for(let u=0;u<h.length;u++){let f=h[u],d=f[0],m=this.isMethod?!this.getInputByName(d):!0,p=d;if(this.keywords[d]||this.useKeywords&&m&&dr.containsKeyword(d)){let g=this.keywords[d];if(!g){let x=dr.getKeywordData(d);x.cache&&(g=t.keywords[d]),g=g||dr.getKeyword(d,t),x.cache&&(t.keywords[d]=g)}p=g.build(t)}d!==p&&(c=c.substring(0,f.index+l)+p+c.substring(f.index+d.length+l),l+=p.length-d.length),this.getIncludeByName(p)===void 0&&dr.contains(p)&&t.include(dr.get(p))}return r==="source"?c:this.isMethod?(this.isInterface||t.include(this,void 0,c),this.name):t.format("( "+c+" )",this.getType(t),r)}parse(t,r,i,s){if(this.src=t||"",this.includes=r??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=QO.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(o1);if(a){let l=0;for(;l<a.length;){let c=a[l++],h;c==="in"||c==="out"||c==="inout"?h=a[l++]:(h=c,c="");let u=a[l++];this.inputs.push({name:u,type:h,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(t){return super.copy(t),this.isMethod=t.isMethod,this.useKeywords=t.useKeywords,t.type!==void 0&&(this.type=t.type),this.parse(t.src,t.includes,t.extensions,t.keywords),this}toJSON(t){let r=this.getJSONNode(t);if(!r){r=this.createJSONNode(t),r.src=this.src,r.isMethod=this.isMethod,r.useKeywords=this.useKeywords,this.isMethod||(r.type=this.type),r.extensions=JSON.parse(JSON.stringify(this.extensions));let i={};for(let s in this.keywords)i[s]=this.keywords[s].toJSON(t).uuid;if(r.keywords=i,this.includes?.length){let s=[];for(let o=0;o<this.includes.length;o++)s.push(this.includes[o].toJSON(t).uuid);r.includes=s}r.isMethod=this.isMethod,r.inputs=this.inputs}return r.nodeType=this.nodeType,r}fromJSON(t,r){if(super.fromJSON(t,r),t.inputs!==void 0&&(this.inputs=t.inputs),t.isMethod!==void 0&&(this.isMethod=t.isMethod),t.src&&(this.src=t.src),t.isMethod&&(this.isMethod=t.isMethod),t.useKeywords&&(this.useKeywords=t.useKeywords),t.type&&(this.type=t.type),t.extensions&&(this.extensions=t.extensions),t.keywords&&r){this.keywords={};for(let i in t.keywords)this.keywords[i]=r.getNode(t.keywords[i])}return t.includes&&r&&(this.includes=t.includes.map(i=>r.getNode(i))),this}};var KO=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,sy=class extends ke{constructor(t="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||sy.PI,void 0,void 0,void 0,r)}getType(t){return t.getTypeByFormat(this.type)}parse(t,r,i,s,o){this.src=t||"";let a,l,c="",h=KO.exec(t);this.useDefine=o??this.src.charAt(0)==="#",h&&h.length>1?(l=h[1],a=h[2],c=h[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(t,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return t.include(this),t.format(this.name,this.getType(t),r)}generate(t,r,i,s,o){return t.format(this.name,this.getType(t),r)}copy(t){return super.copy(t),this.parse(t.src,void 0,void 0,void 0,t.useDefine),this}},ct=sy;ct.PI="PI",ct.PI2="PI2",ct.RECIPROCAL_PI="RECIPROCAL_PI",ct.RECIPROCAL_PI2="RECIPROCAL_PI2",ct.LOG2="LOG2",ct.EPSILON="EPSILON";var ZO=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3137
|
+
}`;function lD(n,e,t){let r=new fc,i=new O,s=new O,o=new Ke,a=new vu({depthPacking:m_}),l=new xu,c={},h=t.maxTextureSize,u={0:gr,1:zn,2:Wt},f=new vt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new O},radius:{value:4}},vertexShader:oD,fragmentShader:aD}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let m=new Le;m.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new ir(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ou,this.render=function(b,S,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=n.getRenderTarget(),y=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),E=n.state;E.setBlending(Dt),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,I=b.length;C<I;C++){let B=b[C],N=B.shadow;if(N===void 0){console.warn("THREE.WebGLShadowMap:",B,"has no shadow.");continue}if(N.autoUpdate===!1&&N.needsUpdate===!1)continue;i.copy(N.mapSize);let H=N.getFrameExtents();if(i.multiply(H),s.copy(N.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/H.x),i.x=s.x*H.x,N.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/H.y),i.y=s.y*H.y,N.mapSize.y=s.y)),N.map===null&&!N.isPointLightShadow&&this.type===rc&&(N.map=new ut(i.x,i.y),N.map.texture.name=B.name+".shadowMap",N.mapPass=new ut(i.x,i.y),N.camera.updateProjectionMatrix()),N.map===null){let Q={minFilter:_r,magFilter:_r,format:bn};N.map=new ut(i.x,i.y,Q),N.map.texture.name=B.name+".shadowMap",N.camera.updateProjectionMatrix()}n.setRenderTarget(N.map),n.clear();let j=N.getViewportCount();for(let Q=0;Q<j;Q++){let X=N.getViewport(Q);o.set(s.x*X.x,s.y*X.y,s.x*X.z,s.y*X.w),E.viewport(o),N.updateMatrices(B,Q),r=N.getFrustum(),w(S,M,N.camera,B,this.type)}!N.isPointLightShadow&&this.type===rc&&x(N,M),N.needsUpdate=!1}g.needsUpdate=!1,n.setRenderTarget(_,y,T)};function x(b,S){let M=e.update(p);f.defines.VSM_SAMPLES!==b.blurSamples&&(f.defines.VSM_SAMPLES=b.blurSamples,d.defines.VSM_SAMPLES=b.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),f.uniforms.shadow_pass.value=b.map.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(S,null,M,f,p,null),d.uniforms.shadow_pass.value=b.mapPass.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(S,null,M,d,p,null)}function v(b,S,M,_,y,T){let E=null,C=M.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0?E=C:E=M.isPointLight===!0?l:a,n.localClippingEnabled&&S.clipShadows===!0&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0){let I=E.uuid,B=S.uuid,N=c[I];N===void 0&&(N={},c[I]=N);let H=N[B];H===void 0&&(H=E.clone(),N[B]=H),E=H}return E.visible=S.visible,E.wireframe=S.wireframe,T===rc?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:u[S.side],E.alphaMap=S.alphaMap,E.alphaTest=S.alphaTest,E.clipShadows=S.clipShadows,E.clippingPlanes=S.clippingPlanes,E.clipIntersection=S.clipIntersection,E.displacementMap=S.displacementMap,E.displacementScale=S.displacementScale,E.displacementBias=S.displacementBias,E.wireframeLinewidth=S.wireframeLinewidth,E.linewidth=S.linewidth,M.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(M.matrixWorld),E.nearDistance=_,E.farDistance=y),E}function w(b,S,M,_,y){if(b.visible===!1)return;if(b.layers.test(S.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&y===rc)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,b.matrixWorld);let C=e.update(b),I=b.material;if(Array.isArray(I)){let B=C.groups;for(let N=0,H=B.length;N<H;N++){let j=B[N],Q=I[j.materialIndex];if(Q&&Q.visible){let X=v(b,Q,_,M.near,M.far,y);n.renderBufferDirect(M,null,C,X,b,j)}}}else if(I.visible){let B=v(b,I,_,M.near,M.far,y);n.renderBufferDirect(M,null,C,B,b,null)}}let E=b.children;for(let C=0,I=E.length;C<I;C++)w(E[C],S,M,_,y)}}function cD(n,e,t){let r=t.isWebGL2;function i(){let z=!1,xe=new Ke,Me=null,Ye=new Ke(0,0,0,0);return{setMask:function(Ne){Me!==Ne&&!z&&(n.colorMask(Ne,Ne,Ne,Ne),Me=Ne)},setLocked:function(Ne){z=Ne},setClear:function(Ne,Je,be,Qe,nt){nt===!0&&(Ne*=Qe,Je*=Qe,be*=Qe),xe.set(Ne,Je,be,Qe),Ye.equals(xe)===!1&&(n.clearColor(Ne,Je,be,Qe),Ye.copy(xe))},reset:function(){z=!1,Me=null,Ye.set(-1,0,0,0)}}}function s(){let z=!1,xe=null,Me=null,Ye=null;return{setTest:function(Ne){Ne?Y(2929):q(2929)},setMask:function(Ne){xe!==Ne&&!z&&(n.depthMask(Ne),xe=Ne)},setFunc:function(Ne){if(Me!==Ne){if(Ne)switch(Ne){case zM:n.depthFunc(512);break;case UM:n.depthFunc(519);break;case GM:n.depthFunc(513);break;case Wp:n.depthFunc(515);break;case kM:n.depthFunc(514);break;case VM:n.depthFunc(518);break;case HM:n.depthFunc(516);break;case WM:n.depthFunc(517);break;default:n.depthFunc(515)}else n.depthFunc(515);Me=Ne}},setLocked:function(Ne){z=Ne},setClear:function(Ne){Ye!==Ne&&(n.clearDepth(Ne),Ye=Ne)},reset:function(){z=!1,xe=null,Me=null,Ye=null}}}function o(){let z=!1,xe=null,Me=null,Ye=null,Ne=null,Je=null,be=null,Qe=null,nt=null;return{setTest:function(mt){z||(mt?Y(2960):q(2960))},setMask:function(mt){xe!==mt&&!z&&(n.stencilMask(mt),xe=mt)},setFunc:function(mt,bt,Jr){(Me!==mt||Ye!==bt||Ne!==Jr)&&(n.stencilFunc(mt,bt,Jr),Me=mt,Ye=bt,Ne=Jr)},setOp:function(mt,bt,Jr){(Je!==mt||be!==bt||Qe!==Jr)&&(n.stencilOp(mt,bt,Jr),Je=mt,be=bt,Qe=Jr)},setLocked:function(mt){z=mt},setClear:function(mt){nt!==mt&&(n.clearStencil(mt),nt=mt)},reset:function(){z=!1,xe=null,Me=null,Ye=null,Ne=null,Je=null,be=null,Qe=null,nt=null}}}let a=new i,l=new s,c=new o,h={},u={},f=new WeakMap,d=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,I=null,B=n.getParameter(35661),N=!1,H=0,j=n.getParameter(7938);j.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(j)[1]),N=H>=1):j.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),N=H>=2);let Q=null,X={},U=n.getParameter(3088),F=n.getParameter(2978),V=new Ke().fromArray(U),R=new Ke().fromArray(F);function G(z,xe,Me){let Ye=new Uint8Array(4),Ne=n.createTexture();n.bindTexture(z,Ne),n.texParameteri(z,10241,9728),n.texParameteri(z,10240,9728);for(let Je=0;Je<Me;Je++)n.texImage2D(xe+Je,0,6408,1,1,0,6408,5121,Ye);return Ne}let W={};W[3553]=G(3553,3553,1),W[34067]=G(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),Y(2929),l.setFunc(Wp),fe(!1),ge(vv),Y(2884),ce(Dt);function Y(z){h[z]!==!0&&(n.enable(z),h[z]=!0)}function q(z){h[z]!==!1&&(n.disable(z),h[z]=!1)}function se(z,xe){return u[z]!==xe?(n.bindFramebuffer(z,xe),u[z]=xe,r&&(z===36009&&(u[36160]=xe),z===36160&&(u[36009]=xe)),!0):!1}function K(z,xe){let Me=d,Ye=!1;if(z)if(Me=f.get(xe),Me===void 0&&(Me=[],f.set(xe,Me)),z.isWebGLMultipleRenderTargets){let Ne=z.texture;if(Me.length!==Ne.length||Me[0]!==36064){for(let Je=0,be=Ne.length;Je<be;Je++)Me[Je]=36064+Je;Me.length=Ne.length,Ye=!0}}else Me[0]!==36064&&(Me[0]=36064,Ye=!0);else Me[0]!==1029&&(Me[0]=1029,Ye=!0);Ye&&(t.isWebGL2?n.drawBuffers(Me):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function te(z){return m!==z?(n.useProgram(z),m=z,!0):!1}let k={[$o]:32774,[EM]:32778,[CM]:32779};if(r)k[Sv]=32775,k[Av]=32776;else{let z=e.get("EXT_blend_minmax");z!==null&&(k[Sv]=z.MIN_EXT,k[Av]=z.MAX_EXT)}let le={[DM]:0,[PM]:1,[LM]:768,[Q0]:770,[FM]:776,[OM]:774,[NM]:772,[IM]:769,[K0]:771,[RM]:775,[BM]:773};function ce(z,xe,Me,Ye,Ne,Je,be,Qe){if(z===Dt){p===!0&&(q(3042),p=!1);return}if(p===!1&&(Y(3042),p=!0),z!==TM){if(z!==g||Qe!==_){if((x!==$o||b!==$o)&&(n.blendEquation(32774),x=$o,b=$o),Qe)switch(z){case hs:n.blendFuncSeparate(1,771,1,771);break;case xv:n.blendFunc(1,1);break;case bv:n.blendFuncSeparate(0,769,0,1);break;case wv:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case hs:n.blendFuncSeparate(770,771,1,771);break;case xv:n.blendFunc(770,1);break;case bv:n.blendFuncSeparate(0,769,0,1);break;case wv:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}v=null,w=null,S=null,M=null,g=z,_=Qe}return}Ne=Ne||xe,Je=Je||Me,be=be||Ye,(xe!==x||Ne!==b)&&(n.blendEquationSeparate(k[xe],k[Ne]),x=xe,b=Ne),(Me!==v||Ye!==w||Je!==S||be!==M)&&(n.blendFuncSeparate(le[Me],le[Ye],le[Je],le[be]),v=Me,w=Ye,S=Je,M=be),g=z,_=null}function ae(z,xe){z.side===Wt?q(2884):Y(2884);let Me=z.side===gr;xe&&(Me=!Me),fe(Me),z.blending===hs&&z.transparent===!1?ce(Dt):ce(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.premultipliedAlpha),l.setFunc(z.depthFunc),l.setTest(z.depthTest),l.setMask(z.depthWrite),a.setMask(z.colorWrite);let Ye=z.stencilWrite;c.setTest(Ye),Ye&&(c.setMask(z.stencilWriteMask),c.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),c.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),_e(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?Y(32926):q(32926)}function fe(z){y!==z&&(z?n.frontFace(2304):n.frontFace(2305),y=z)}function ge(z){z!==AM?(Y(2884),z!==T&&(z===vv?n.cullFace(1029):z===MM?n.cullFace(1028):n.cullFace(1032))):q(2884),T=z}function de(z){z!==E&&(N&&n.lineWidth(z),E=z)}function _e(z,xe,Me){z?(Y(32823),(C!==xe||I!==Me)&&(n.polygonOffset(xe,Me),C=xe,I=Me)):q(32823)}function Ee(z){z?Y(3089):q(3089)}function ye(z){z===void 0&&(z=33984+B-1),Q!==z&&(n.activeTexture(z),Q=z)}function Oe(z,xe){Q===null&&ye();let Me=X[Q];Me===void 0&&(Me={type:void 0,texture:void 0},X[Q]=Me),(Me.type!==z||Me.texture!==xe)&&(n.bindTexture(z,xe||W[z]),Me.type=z,Me.texture=xe)}function pt(){let z=X[Q];z!==void 0&&z.type!==void 0&&(n.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function P(){try{n.compressedTexImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function D(){try{n.texSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Z(){try{n.texSubImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ue(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Te(){try{n.texStorage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Fe(){try{n.texImage2D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ne(){try{n.texImage3D.apply(n,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Re(z){V.equals(z)===!1&&(n.scissor(z.x,z.y,z.z,z.w),V.copy(z))}function Ie(z){R.equals(z)===!1&&(n.viewport(z.x,z.y,z.z,z.w),R.copy(z))}function ve(){n.disable(3042),n.disable(2884),n.disable(2929),n.disable(32823),n.disable(3089),n.disable(2960),n.disable(32926),n.blendEquation(32774),n.blendFunc(1,0),n.blendFuncSeparate(1,0,1,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(513),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(519,0,4294967295),n.stencilOp(7680,7680,7680),n.clearStencil(0),n.cullFace(1029),n.frontFace(2305),n.polygonOffset(0,0),n.activeTexture(33984),n.bindFramebuffer(36160,null),r===!0&&(n.bindFramebuffer(36009,null),n.bindFramebuffer(36008,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),h={},Q=null,X={},u={},f=new WeakMap,d=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,I=null,V.set(0,0,n.canvas.width,n.canvas.height),R.set(0,0,n.canvas.width,n.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:Y,disable:q,bindFramebuffer:se,drawBuffers:K,useProgram:te,setBlending:ce,setMaterial:ae,setFlipSided:fe,setCullFace:ge,setLineWidth:de,setPolygonOffset:_e,setScissorTest:Ee,activeTexture:ye,bindTexture:Oe,unbindTexture:pt,compressedTexImage2D:P,texImage2D:Fe,texImage3D:ne,texStorage2D:pe,texStorage3D:Te,texSubImage2D:D,texSubImage3D:Z,compressedTexSubImage2D:ue,scissor:Re,viewport:Ie,reset:ve}}function hD(n,e,t,r,i,s,o){let a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,d=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(P,D){return x?new OffscreenCanvas(P,D):fu("canvas")}function w(P,D,Z,ue){let pe=1;if((P.width>ue||P.height>ue)&&(pe=ue/Math.max(P.width,P.height)),pe<1||D===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){let Te=D?uu:Math.floor,Fe=Te(pe*P.width),ne=Te(pe*P.height);p===void 0&&(p=v(Fe,ne));let Re=Z?v(Fe,ne):p;return Re.width=Fe,Re.height=ne,Re.getContext("2d").drawImage(P,0,0,Fe,ne),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Fe+"x"+ne+")."),Re}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function b(P){return Qp(P.width)&&Qp(P.height)}function S(P){return a?!1:P.wrapS!==mr||P.wrapT!==mr||P.minFilter!==_r&&P.minFilter!==et}function M(P,D){return P.generateMipmaps&&D&&P.minFilter!==_r&&P.minFilter!==et}function _(P){n.generateMipmap(P)}function y(P,D,Z,ue,pe=!1){if(a===!1)return D;if(P!==null){if(n[P]!==void 0)return n[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let Te=D;return D===6403&&(Z===5126&&(Te=33326),Z===5131&&(Te=33325),Z===5121&&(Te=33321)),D===33319&&(Z===5126&&(Te=33328),Z===5131&&(Te=33327),Z===5121&&(Te=33323)),D===6408&&(Z===5126&&(Te=34836),Z===5131&&(Te=34842),Z===5121&&(Te=ue===He&&pe===!1?35907:32856),Z===32819&&(Te=32854),Z===32820&&(Te=32855)),(Te===33325||Te===33326||Te===33327||Te===33328||Te===34842||Te===34836)&&e.get("EXT_color_buffer_float"),Te}function T(P,D,Z){return M(P,Z)===!0||P.isFramebufferTexture&&P.minFilter!==_r&&P.minFilter!==et?Math.log2(Math.max(D.width,D.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?D.mipmaps.length:1}function E(P){return P===_r||P===Mv||P===_v?9728:9729}function C(P){let D=P.target;D.removeEventListener("dispose",C),B(D),D.isVideoTexture&&m.delete(D)}function I(P){let D=P.target;D.removeEventListener("dispose",I),H(D)}function B(P){let D=r.get(P);if(D.__webglInit===void 0)return;let Z=P.source,ue=g.get(Z);if(ue){let pe=ue[D.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&N(P),Object.keys(ue).length===0&&g.delete(Z)}r.remove(P)}function N(P){let D=r.get(P);n.deleteTexture(D.__webglTexture);let Z=P.source,ue=g.get(Z);delete ue[D.__cacheKey],o.memory.textures--}function H(P){let D=P.texture,Z=r.get(P),ue=r.get(D);if(ue.__webglTexture!==void 0&&(n.deleteTexture(ue.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++)n.deleteFramebuffer(Z.__webglFramebuffer[pe]),Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer[pe]);else{if(n.deleteFramebuffer(Z.__webglFramebuffer),Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer),Z.__webglMultisampledFramebuffer&&n.deleteFramebuffer(Z.__webglMultisampledFramebuffer),Z.__webglColorRenderbuffer)for(let pe=0;pe<Z.__webglColorRenderbuffer.length;pe++)Z.__webglColorRenderbuffer[pe]&&n.deleteRenderbuffer(Z.__webglColorRenderbuffer[pe]);Z.__webglDepthRenderbuffer&&n.deleteRenderbuffer(Z.__webglDepthRenderbuffer)}if(P.isWebGLMultipleRenderTargets)for(let pe=0,Te=D.length;pe<Te;pe++){let Fe=r.get(D[pe]);Fe.__webglTexture&&(n.deleteTexture(Fe.__webglTexture),o.memory.textures--),r.remove(D[pe])}r.remove(D),r.remove(P)}let j=0;function Q(){j=0}function X(){let P=j;return P>=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),j+=1,P}function U(P){let D=[];return D.push(P.wrapS),D.push(P.wrapT),D.push(P.magFilter),D.push(P.minFilter),D.push(P.anisotropy),D.push(P.internalFormat),D.push(P.format),D.push(P.type),D.push(P.generateMipmaps),D.push(P.premultiplyAlpha),D.push(P.flipY),D.push(P.unpackAlignment),D.push(P.encoding),D.join()}function F(P,D){let Z=r.get(P);if(P.isVideoTexture&&Oe(P),P.isRenderTargetTexture===!1&&P.version>0&&Z.__version!==P.version){let ue=P.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(Z,P,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,Z.__webglTexture)}function V(P,D){let Z=r.get(P);if(P.version>0&&Z.__version!==P.version){K(Z,P,D);return}t.activeTexture(33984+D),t.bindTexture(35866,Z.__webglTexture)}function R(P,D){let Z=r.get(P);if(P.version>0&&Z.__version!==P.version){K(Z,P,D);return}t.activeTexture(33984+D),t.bindTexture(32879,Z.__webglTexture)}function G(P,D){let Z=r.get(P);if(P.version>0&&Z.__version!==P.version){te(Z,P,D);return}t.activeTexture(33984+D),t.bindTexture(34067,Z.__webglTexture)}let W={[na]:10497,[mr]:33071,[Yp]:33648},Y={[_r]:9728,[Mv]:9984,[_v]:9986,[et]:9729,[ZM]:9985,[As]:9987};function q(P,D,Z){if(Z?(n.texParameteri(P,10242,W[D.wrapS]),n.texParameteri(P,10243,W[D.wrapT]),(P===32879||P===35866)&&n.texParameteri(P,32882,W[D.wrapR]),n.texParameteri(P,10240,Y[D.magFilter]),n.texParameteri(P,10241,Y[D.minFilter])):(n.texParameteri(P,10242,33071),n.texParameteri(P,10243,33071),(P===32879||P===35866)&&n.texParameteri(P,32882,33071),(D.wrapS!==mr||D.wrapT!==mr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(P,10240,E(D.magFilter)),n.texParameteri(P,10241,E(D.minFilter)),D.minFilter!==_r&&D.minFilter!==et&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let ue=e.get("EXT_texture_filter_anisotropic");if(D.type===ls&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===cc&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||r.get(D).__currentAnisotropy)&&(n.texParameterf(P,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),r.get(D).__currentAnisotropy=D.anisotropy)}}function se(P,D){let Z=!1;P.__webglInit===void 0&&(P.__webglInit=!0,D.addEventListener("dispose",C));let ue=D.source,pe=g.get(ue);pe===void 0&&(pe={},g.set(ue,pe));let Te=U(D);if(Te!==P.__cacheKey){pe[Te]===void 0&&(pe[Te]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),pe[Te].usedTimes++;let Fe=pe[P.__cacheKey];Fe!==void 0&&(pe[P.__cacheKey].usedTimes--,Fe.usedTimes===0&&N(D)),P.__cacheKey=Te,P.__webglTexture=pe[Te].texture}return Z}function K(P,D,Z){let ue=3553;D.isDataArrayTexture&&(ue=35866),D.isData3DTexture&&(ue=32879);let pe=se(P,D),Te=D.source;if(t.activeTexture(33984+Z),t.bindTexture(ue,P.__webglTexture),Te.version!==Te.__currentVersion||pe===!0){n.pixelStorei(37440,D.flipY),n.pixelStorei(37441,D.premultiplyAlpha),n.pixelStorei(3317,D.unpackAlignment),n.pixelStorei(37443,0);let Fe=S(D)&&b(D.image)===!1,ne=w(D.image,Fe,!1,h);ne=pt(D,ne);let Re=b(ne)||a,Ie=s.convert(D.format,D.encoding),ve=s.convert(D.type),z=y(D.internalFormat,Ie,ve,D.encoding,D.isVideoTexture);q(ue,D,Re);let xe,Me=D.mipmaps,Ye=a&&D.isVideoTexture!==!0,Ne=Te.__currentVersion===void 0||pe===!0,Je=T(D,ne,Re);if(D.isDepthTexture)z=6402,a?D.type===ls?z=36012:D.type===Fi?z=33190:D.type===us?z=35056:z=33189:D.type===ls&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===no&&z===6402&&D.type!==$0&&D.type!==Fi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Fi,ve=s.convert(D.type)),D.format===ms&&z===6402&&(z=34041,D.type!==us&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=us,ve=s.convert(D.type))),Ne&&(Ye?t.texStorage2D(3553,1,z,ne.width,ne.height):t.texImage2D(3553,0,z,ne.width,ne.height,0,Ie,ve,null));else if(D.isDataTexture)if(Me.length>0&&Re){Ye&&Ne&&t.texStorage2D(3553,Je,z,Me[0].width,Me[0].height);for(let be=0,Qe=Me.length;be<Qe;be++)xe=Me[be],Ye?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,ve,xe.data):t.texImage2D(3553,be,z,xe.width,xe.height,0,Ie,ve,xe.data);D.generateMipmaps=!1}else Ye?(Ne&&t.texStorage2D(3553,Je,z,ne.width,ne.height),t.texSubImage2D(3553,0,0,0,ne.width,ne.height,Ie,ve,ne.data)):t.texImage2D(3553,0,z,ne.width,ne.height,0,Ie,ve,ne.data);else if(D.isCompressedTexture){Ye&&Ne&&t.texStorage2D(3553,Je,z,Me[0].width,Me[0].height);for(let be=0,Qe=Me.length;be<Qe;be++)xe=Me[be],D.format!==bn?Ie!==null?Ye?t.compressedTexSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,xe.data):t.compressedTexImage2D(3553,be,z,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ye?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,ve,xe.data):t.texImage2D(3553,be,z,xe.width,xe.height,0,Ie,ve,xe.data)}else if(D.isDataArrayTexture)Ye?(Ne&&t.texStorage3D(35866,Je,z,ne.width,ne.height,ne.depth),t.texSubImage3D(35866,0,0,0,0,ne.width,ne.height,ne.depth,Ie,ve,ne.data)):t.texImage3D(35866,0,z,ne.width,ne.height,ne.depth,0,Ie,ve,ne.data);else if(D.isData3DTexture)Ye?(Ne&&t.texStorage3D(32879,Je,z,ne.width,ne.height,ne.depth),t.texSubImage3D(32879,0,0,0,0,ne.width,ne.height,ne.depth,Ie,ve,ne.data)):t.texImage3D(32879,0,z,ne.width,ne.height,ne.depth,0,Ie,ve,ne.data);else if(D.isFramebufferTexture){if(Ne)if(Ye)t.texStorage2D(3553,Je,z,ne.width,ne.height);else{let be=ne.width,Qe=ne.height;for(let nt=0;nt<Je;nt++)t.texImage2D(3553,nt,z,be,Qe,0,Ie,ve,null),be>>=1,Qe>>=1}}else if(Me.length>0&&Re){Ye&&Ne&&t.texStorage2D(3553,Je,z,Me[0].width,Me[0].height);for(let be=0,Qe=Me.length;be<Qe;be++)xe=Me[be],Ye?t.texSubImage2D(3553,be,0,0,Ie,ve,xe):t.texImage2D(3553,be,z,Ie,ve,xe);D.generateMipmaps=!1}else Ye?(Ne&&t.texStorage2D(3553,Je,z,ne.width,ne.height),t.texSubImage2D(3553,0,0,0,Ie,ve,ne)):t.texImage2D(3553,0,z,Ie,ve,ne);M(D,Re)&&_(ue),Te.__currentVersion=Te.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function te(P,D,Z){if(D.image.length!==6)return;let ue=se(P,D),pe=D.source;if(t.activeTexture(33984+Z),t.bindTexture(34067,P.__webglTexture),pe.version!==pe.__currentVersion||ue===!0){n.pixelStorei(37440,D.flipY),n.pixelStorei(37441,D.premultiplyAlpha),n.pixelStorei(3317,D.unpackAlignment),n.pixelStorei(37443,0);let Te=D.isCompressedTexture||D.image[0].isCompressedTexture,Fe=D.image[0]&&D.image[0].isDataTexture,ne=[];for(let be=0;be<6;be++)!Te&&!Fe?ne[be]=w(D.image[be],!1,!0,c):ne[be]=Fe?D.image[be].image:D.image[be],ne[be]=pt(D,ne[be]);let Re=ne[0],Ie=b(Re)||a,ve=s.convert(D.format,D.encoding),z=s.convert(D.type),xe=y(D.internalFormat,ve,z,D.encoding),Me=a&&D.isVideoTexture!==!0,Ye=pe.__currentVersion===void 0||ue===!0,Ne=T(D,Re,Ie);q(34067,D,Ie);let Je;if(Te){Me&&Ye&&t.texStorage2D(34067,Ne,xe,Re.width,Re.height);for(let be=0;be<6;be++){Je=ne[be].mipmaps;for(let Qe=0;Qe<Je.length;Qe++){let nt=Je[Qe];D.format!==bn?ve!==null?Me?t.compressedTexSubImage2D(34069+be,Qe,0,0,nt.width,nt.height,ve,nt.data):t.compressedTexImage2D(34069+be,Qe,xe,nt.width,nt.height,0,nt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Me?t.texSubImage2D(34069+be,Qe,0,0,nt.width,nt.height,ve,z,nt.data):t.texImage2D(34069+be,Qe,xe,nt.width,nt.height,0,ve,z,nt.data)}}}else{Je=D.mipmaps,Me&&Ye&&(Je.length>0&&Ne++,t.texStorage2D(34067,Ne,xe,ne[0].width,ne[0].height));for(let be=0;be<6;be++)if(Fe){Me?t.texSubImage2D(34069+be,0,0,0,ne[be].width,ne[be].height,ve,z,ne[be].data):t.texImage2D(34069+be,0,xe,ne[be].width,ne[be].height,0,ve,z,ne[be].data);for(let Qe=0;Qe<Je.length;Qe++){let mt=Je[Qe].image[be].image;Me?t.texSubImage2D(34069+be,Qe+1,0,0,mt.width,mt.height,ve,z,mt.data):t.texImage2D(34069+be,Qe+1,xe,mt.width,mt.height,0,ve,z,mt.data)}}else{Me?t.texSubImage2D(34069+be,0,0,0,ve,z,ne[be]):t.texImage2D(34069+be,0,xe,ve,z,ne[be]);for(let Qe=0;Qe<Je.length;Qe++){let nt=Je[Qe];Me?t.texSubImage2D(34069+be,Qe+1,0,0,ve,z,nt.image[be]):t.texImage2D(34069+be,Qe+1,xe,ve,z,nt.image[be])}}}M(D,Ie)&&_(34067),pe.__currentVersion=pe.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function k(P,D,Z,ue,pe){let Te=s.convert(Z.format,Z.encoding),Fe=s.convert(Z.type),ne=y(Z.internalFormat,Te,Fe,Z.encoding);r.get(D).__hasExternalTextures||(pe===32879||pe===35866?t.texImage3D(pe,0,ne,D.width,D.height,D.depth,0,Te,Fe,null):t.texImage2D(pe,0,ne,D.width,D.height,0,Te,Fe,null)),t.bindFramebuffer(36160,P),ye(D)?f.framebufferTexture2DMultisampleEXT(36160,ue,pe,r.get(Z).__webglTexture,0,Ee(D)):n.framebufferTexture2D(36160,ue,pe,r.get(Z).__webglTexture,0),t.bindFramebuffer(36160,null)}function le(P,D,Z){if(n.bindRenderbuffer(36161,P),D.depthBuffer&&!D.stencilBuffer){let ue=33189;if(Z||ye(D)){let pe=D.depthTexture;pe&&pe.isDepthTexture&&(pe.type===ls?ue=36012:pe.type===Fi&&(ue=33190));let Te=Ee(D);ye(D)?f.renderbufferStorageMultisampleEXT(36161,Te,ue,D.width,D.height):n.renderbufferStorageMultisample(36161,Te,ue,D.width,D.height)}else n.renderbufferStorage(36161,ue,D.width,D.height);n.framebufferRenderbuffer(36160,36096,36161,P)}else if(D.depthBuffer&&D.stencilBuffer){let ue=Ee(D);Z&&ye(D)===!1?n.renderbufferStorageMultisample(36161,ue,35056,D.width,D.height):ye(D)?f.renderbufferStorageMultisampleEXT(36161,ue,35056,D.width,D.height):n.renderbufferStorage(36161,34041,D.width,D.height),n.framebufferRenderbuffer(36160,33306,36161,P)}else{let ue=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let pe=0;pe<ue.length;pe++){let Te=ue[pe],Fe=s.convert(Te.format,Te.encoding),ne=s.convert(Te.type),Re=y(Te.internalFormat,Fe,ne,Te.encoding),Ie=Ee(D);Z&&ye(D)===!1?n.renderbufferStorageMultisample(36161,Ie,Re,D.width,D.height):ye(D)?f.renderbufferStorageMultisampleEXT(36161,Ie,Re,D.width,D.height):n.renderbufferStorage(36161,Re,D.width,D.height)}}n.bindRenderbuffer(36161,null)}function ce(P,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,P),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),F(D.depthTexture,0);let ue=r.get(D.depthTexture).__webglTexture,pe=Ee(D);if(D.depthTexture.format===no)ye(D)?f.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,pe):n.framebufferTexture2D(36160,36096,3553,ue,0);else if(D.depthTexture.format===ms)ye(D)?f.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,pe):n.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ae(P){let D=r.get(P),Z=P.isWebGLCubeRenderTarget===!0;if(P.depthTexture&&!D.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");ce(D.__webglFramebuffer,P)}else if(Z){D.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)t.bindFramebuffer(36160,D.__webglFramebuffer[ue]),D.__webglDepthbuffer[ue]=n.createRenderbuffer(),le(D.__webglDepthbuffer[ue],P,!1)}else t.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=n.createRenderbuffer(),le(D.__webglDepthbuffer,P,!1);t.bindFramebuffer(36160,null)}function fe(P,D,Z){let ue=r.get(P);D!==void 0&&k(ue.__webglFramebuffer,P,P.texture,36064,3553),Z!==void 0&&ae(P)}function ge(P){let D=P.texture,Z=r.get(P),ue=r.get(D);P.addEventListener("dispose",I),P.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=n.createTexture()),ue.__version=D.version,o.memory.textures++);let pe=P.isWebGLCubeRenderTarget===!0,Te=P.isWebGLMultipleRenderTargets===!0,Fe=b(P)||a;if(pe){Z.__webglFramebuffer=[];for(let ne=0;ne<6;ne++)Z.__webglFramebuffer[ne]=n.createFramebuffer()}else{if(Z.__webglFramebuffer=n.createFramebuffer(),Te)if(i.drawBuffers){let ne=P.texture;for(let Re=0,Ie=ne.length;Re<Ie;Re++){let ve=r.get(ne[Re]);ve.__webglTexture===void 0&&(ve.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&P.samples>0&&ye(P)===!1){let ne=Te?D:[D];Z.__webglMultisampledFramebuffer=n.createFramebuffer(),Z.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,Z.__webglMultisampledFramebuffer);for(let Re=0;Re<ne.length;Re++){let Ie=ne[Re];Z.__webglColorRenderbuffer[Re]=n.createRenderbuffer(),n.bindRenderbuffer(36161,Z.__webglColorRenderbuffer[Re]);let ve=s.convert(Ie.format,Ie.encoding),z=s.convert(Ie.type),xe=y(Ie.internalFormat,ve,z,Ie.encoding),Me=Ee(P);n.renderbufferStorageMultisample(36161,Me,xe,P.width,P.height),n.framebufferRenderbuffer(36160,36064+Re,36161,Z.__webglColorRenderbuffer[Re])}n.bindRenderbuffer(36161,null),P.depthBuffer&&(Z.__webglDepthRenderbuffer=n.createRenderbuffer(),le(Z.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(36160,null)}}if(pe){t.bindTexture(34067,ue.__webglTexture),q(34067,D,Fe);for(let ne=0;ne<6;ne++)k(Z.__webglFramebuffer[ne],P,D,36064,34069+ne);M(D,Fe)&&_(34067),t.unbindTexture()}else if(Te){let ne=P.texture;for(let Re=0,Ie=ne.length;Re<Ie;Re++){let ve=ne[Re],z=r.get(ve);t.bindTexture(3553,z.__webglTexture),q(3553,ve,Fe),k(Z.__webglFramebuffer,P,ve,36064+Re,3553),M(ve,Fe)&&_(3553)}t.unbindTexture()}else{let ne=3553;(P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(a?ne=P.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(ne,ue.__webglTexture),q(ne,D,Fe),k(Z.__webglFramebuffer,P,D,36064,ne),M(D,Fe)&&_(ne),t.unbindTexture()}P.depthBuffer&&ae(P)}function de(P){let D=b(P)||a,Z=P.isWebGLMultipleRenderTargets===!0?P.texture:[P.texture];for(let ue=0,pe=Z.length;ue<pe;ue++){let Te=Z[ue];if(M(Te,D)){let Fe=P.isWebGLCubeRenderTarget?34067:3553,ne=r.get(Te).__webglTexture;t.bindTexture(Fe,ne),_(Fe),t.unbindTexture()}}}function _e(P){if(a&&P.samples>0&&ye(P)===!1){let D=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],Z=P.width,ue=P.height,pe=16384,Te=[],Fe=P.stencilBuffer?33306:36096,ne=r.get(P),Re=P.isWebGLMultipleRenderTargets===!0;if(Re)for(let Ie=0;Ie<D.length;Ie++)t.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+Ie,36161,null),t.bindFramebuffer(36160,ne.__webglFramebuffer),n.framebufferTexture2D(36009,36064+Ie,3553,null,0);t.bindFramebuffer(36008,ne.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,ne.__webglFramebuffer);for(let Ie=0;Ie<D.length;Ie++){Te.push(36064+Ie),P.depthBuffer&&Te.push(Fe);let ve=ne.__ignoreDepthValues!==void 0?ne.__ignoreDepthValues:!1;if(ve===!1&&(P.depthBuffer&&(pe|=256),P.stencilBuffer&&(pe|=1024)),Re&&n.framebufferRenderbuffer(36008,36064,36161,ne.__webglColorRenderbuffer[Ie]),ve===!0&&(n.invalidateFramebuffer(36008,[Fe]),n.invalidateFramebuffer(36009,[Fe])),Re){let z=r.get(D[Ie]).__webglTexture;n.framebufferTexture2D(36009,36064,3553,z,0)}n.blitFramebuffer(0,0,Z,ue,0,0,Z,ue,pe,9728),d&&n.invalidateFramebuffer(36008,Te)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Re)for(let Ie=0;Ie<D.length;Ie++){t.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+Ie,36161,ne.__webglColorRenderbuffer[Ie]);let ve=r.get(D[Ie]).__webglTexture;t.bindFramebuffer(36160,ne.__webglFramebuffer),n.framebufferTexture2D(36009,36064+Ie,3553,ve,0)}t.bindFramebuffer(36009,ne.__webglMultisampledFramebuffer)}}function Ee(P){return Math.min(u,P.samples)}function ye(P){let D=r.get(P);return a&&P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function Oe(P){let D=o.render.frame;m.get(P)!==D&&(m.set(P,D),P.update())}function pt(P,D){let Z=P.encoding,ue=P.format,pe=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Jp||Z!==hn&&(Z===He?a===!1?e.has("EXT_sRGB")===!0&&ue===bn?(P.format=Jp,P.minFilter=et,P.generateMipmaps=!1):D=du.sRGBToLinear(D):(ue!==bn||pe!==It)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",Z)),D}this.allocateTextureUnit=X,this.resetTextureUnits=Q,this.setTexture2D=F,this.setTexture2DArray=V,this.setTexture3D=R,this.setTextureCube=G,this.rebindTextures=fe,this.setupRenderTarget=ge,this.updateRenderTargetMipmap=de,this.updateMultisampleRenderTarget=_e,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=k,this.useMultisampledRTT=ye}function uD(n,e,t){let r=t.isWebGL2;function i(s,o=null){let a;if(s===It)return 5121;if(s===r_)return 32819;if(s===n_)return 32820;if(s===$M)return 5120;if(s===e_)return 5122;if(s===$0)return 5123;if(s===t_)return 5124;if(s===Fi)return 5125;if(s===ls)return 5126;if(s===cc)return r?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===i_)return 6406;if(s===bn)return 6408;if(s===o_)return 6409;if(s===a_)return 6410;if(s===no)return 6402;if(s===ms)return 34041;if(s===l_)return 6403;if(s===s_)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===Jp)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===c_)return 36244;if(s===h_)return 33319;if(s===u_)return 33320;if(s===f_)return 36249;if(s===lp||s===cp||s===hp||s===up)if(o===He)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===lp)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===lp)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Tv||s===Ev||s===Cv||s===Dv)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Tv)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Ev)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Cv)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Dv)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===d_)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Pv||s===Lv)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Pv)return o===He?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Lv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Iv||s===Nv||s===Bv||s===Ov||s===Rv||s===Fv||s===zv||s===Uv||s===Gv||s===kv||s===Vv||s===Hv||s===Wv||s===jv)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Iv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Nv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Bv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Ov)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Rv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Fv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===zv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Uv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Gv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===kv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Vv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Hv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Wv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===jv)return o===He?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===qv)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===qv)return o===He?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===us?r?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}var om=class extends Jt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},cs=class extends lt{constructor(){super(),this.isGroup=!0,this.type="Group"}},fD={type:"move"},oc=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new cs,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 cs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new cs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(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,r){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(a!==null&&(i=t.getPose(e.targetRaySpace,r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(fD))),c&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,r);if(c.joints[p.jointName]===void 0){let v=new cs;v.matrixAutoUpdate=!1,v.visible=!1,c.joints[p.jointName]=v,c.add(v)}let x=c.joints[p.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,m=.005;c.inputState.pinching&&f>d+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},ci=class extends Nt{constructor(e,t,r,i,s,o,a,l,c,h){if(h=h!==void 0?h:no,h!==no&&h!==ms)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&h===no&&(r=Fi),r===void 0&&h===ms&&(r=us),super(null,i,s,o,a,l,h,r,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:_r,this.minFilter=l!==void 0?l:_r,this.flipY=!1,this.generateMipmaps=!1}},am=class extends Ot{constructor(e,t){super();let r=this,i=null,s=1,o=null,a="local-floor",l=null,c=null,h=null,u=null,f=null,d=null,m=t.getContextAttributes(),p=null,g=null,x=[],v=new Map,w=new Jt;w.layers.enable(1),w.viewport=new Ke;let b=new Jt;b.layers.enable(2),b.viewport=new Ke;let S=[w,b],M=new om;M.layers.enable(1),M.layers.enable(2);let _=null,y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let F=x[U];return F===void 0&&(F=new oc,x[U]=F),F.getTargetRaySpace()},this.getControllerGrip=function(U){let F=x[U];return F===void 0&&(F=new oc,x[U]=F),F.getGripSpace()},this.getHand=function(U){let F=x[U];return F===void 0&&(F=new oc,x[U]=F),F.getHandSpace()};function T(U){let F=v.get(U.inputSource);F!==void 0&&F.dispatchEvent({type:U.type,data:U.inputSource})}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C),v.forEach(function(U,F){U!==void 0&&U.disconnect(F)}),v.clear(),_=null,y=null,e.setRenderTarget(p),f=null,u=null,h=null,i=null,g=null,X.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(U){l=U},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return h},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(U){if(i=U,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let F={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,t,F),i.updateRenderState({baseLayer:f}),g=new ut(f.framebufferWidth,f.framebufferHeight,{format:bn,type:It,encoding:e.outputEncoding})}else{let F=null,V=null,R=null;m.depth&&(R=m.stencil?35056:33190,F=m.stencil?ms:no,V=m.stencil?us:Fi);let G={colorFormat:e.outputEncoding===He?35907:32856,depthFormat:R,scaleFactor:s};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(G),i.updateRenderState({layers:[u]}),g=new ut(u.textureWidth,u.textureHeight,{format:bn,type:It,depthTexture:new ci(u.textureWidth,u.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,F),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let W=e.properties.get(g);W.__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),X.setContext(i),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function C(U){let F=i.inputSources;for(let V=0;V<F.length;V++){let R=F[V].handedness==="right"?1:0;v.set(F[V],x[R])}for(let V=0;V<U.removed.length;V++){let R=U.removed[V],G=v.get(R);G&&(G.dispatchEvent({type:"disconnected",data:R}),v.delete(R))}for(let V=0;V<U.added.length;V++){let R=U.added[V],G=v.get(R);G&&G.dispatchEvent({type:"connected",data:R})}}let I=new A,B=new A;function N(U,F,V){I.setFromMatrixPosition(F.matrixWorld),B.setFromMatrixPosition(V.matrixWorld);let R=I.distanceTo(B),G=F.projectionMatrix.elements,W=V.projectionMatrix.elements,Y=G[14]/(G[10]-1),q=G[14]/(G[10]+1),se=(G[9]+1)/G[5],K=(G[9]-1)/G[5],te=(G[8]-1)/G[0],k=(W[8]+1)/W[0],le=Y*te,ce=Y*k,ae=R/(-te+k),fe=ae*-te;F.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(fe),U.translateZ(ae),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();let ge=Y+ae,de=q+ae,_e=le-fe,Ee=ce+(R-fe),ye=se*q/de*ge,Oe=K*q/de*ge;U.projectionMatrix.makePerspective(_e,Ee,ye,Oe,ge,de)}function H(U,F){F===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(F.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(i===null)return;M.near=b.near=w.near=U.near,M.far=b.far=w.far=U.far,(_!==M.near||y!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),_=M.near,y=M.far);let F=U.parent,V=M.cameras;H(M,F);for(let G=0;G<V.length;G++)H(V[G],F);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),U.position.copy(M.position),U.quaternion.copy(M.quaternion),U.scale.copy(M.scale),U.matrix.copy(M.matrix),U.matrixWorld.copy(M.matrixWorld);let R=U.children;for(let G=0,W=R.length;G<W;G++)R[G].updateMatrixWorld(!0);V.length===2?N(M,w,b):M.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(u!==null)return u.fixedFoveation;if(f!==null)return f.fixedFoveation},this.setFoveation=function(U){u!==null&&(u.fixedFoveation=U),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=U)};let j=null;function Q(U,F){if(c=F.getViewerPose(l||o),d=F,c!==null){let R=c.views;f!==null&&(e.setRenderTargetFramebuffer(g,f.framebuffer),e.setRenderTarget(g));let G=!1;R.length!==M.cameras.length&&(M.cameras.length=0,G=!0);for(let W=0;W<R.length;W++){let Y=R[W],q=null;if(f!==null)q=f.getViewport(Y);else{let K=h.getViewSubImage(u,Y);q=K.viewport,W===0&&(e.setRenderTargetTextures(g,K.colorTexture,u.ignoreDepthValues?void 0:K.depthStencilTexture),e.setRenderTarget(g))}let se=S[W];se===void 0&&(se=new Jt,se.layers.enable(W),se.viewport=new Ke,S[W]=se),se.matrix.fromArray(Y.transform.matrix),se.projectionMatrix.fromArray(Y.projectionMatrix),se.viewport.set(q.x,q.y,q.width,q.height),W===0&&M.matrix.copy(se.matrix),G===!0&&M.cameras.push(se)}}let V=i.inputSources;for(let R=0;R<x.length;R++){let G=V[R],W=v.get(G);W!==void 0&&W.update(G,F,l||o)}j&&j(U,F),d=null}let X=new rx;X.setAnimationLoop(Q),this.setAnimationLoop=function(U){j=U},this.dispose=function(){}}};function dD(n,e){function t(p,g){p.fogColor.value.copy(g.color),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function r(p,g,x,v,w){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),h(p,g)):g.isMeshPhongMaterial?(i(p,g),c(p,g)):g.isMeshStandardMaterial?(i(p,g),u(p,g),g.isMeshPhysicalMaterial&&f(p,g,w)):g.isMeshMatcapMaterial?(i(p,g),d(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,x,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===gr&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===gr&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x=e.get(g).envMap;if(x&&(p.envMap.value=x,p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let b=n.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let w;g.aoMap?w=g.aoMap:g.lightMap&&(w=g.lightMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uv2Transform.value.copy(w.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,x,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*x,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let w;g.map?w=g.map:g.alphaMap&&(w=g.alphaMap),w!==void 0&&(w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function c(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function h(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function u(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function f(p,g,x){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===gr&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=x.texture,p.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function d(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:r}}function pD(){let n=fu("canvas");return n.style.display="block",n}function zu(n={}){this.isWebGLRenderer=!0;let e=n.canvas!==void 0?n.canvas:pD(),t=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",c=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,h;t!==null?h=t.getContextAttributes().alpha:h=n.alpha!==void 0?n.alpha:!1;let u=null,f=null,d=[],m=[];this.domElement=e,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=hn,this.physicallyCorrectLights=!1,this.toneMapping=zi,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,x=0,v=0,w=null,b=-1,S=null,M=new Ke,_=new Ke,y=null,T=e.width,E=e.height,C=1,I=null,B=null,N=new Ke(0,0,T,E),H=new Ke(0,0,T,E),j=!1,Q=new fc,X=!1,U=!1,F=null,V=new Be,R=new O,G=new A,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return w===null?C:1}let q=t;function se(L,$){for(let ie=0;ie<L.length;ie++){let re=L[ie],he=e.getContext(re,$);if(he!==null)return he}return null}try{let L={alpha:!0,depth:r,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${yo}`),e.addEventListener("webglcontextlost",z,!1),e.addEventListener("webglcontextrestored",xe,!1),e.addEventListener("webglcontextcreationerror",Me,!1),q===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),q=se($,L),q===null)throw se($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}q.getShaderPrecisionFormat===void 0&&(q.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let K,te,k,le,ce,ae,fe,ge,de,_e,Ee,ye,Oe,pt,P,D,Z,ue,pe,Te,Fe,ne,Re;function Ie(){K=new OC(q),te=new DC(q,K,n),K.init(te),ne=new uD(q,K,te),k=new cD(q,K,te),le=new zC(q),ce=new K2,ae=new hD(q,K,k,ce,te,ne,le),fe=new LC(p),ge=new BC(p),de=new Q_(q,te),Re=new EC(q,K,de,te),_e=new RC(q,de,le,Re),Ee=new VC(q,_e,de,le),pe=new kC(q,te,ae),D=new PC(ce),ye=new Q2(p,fe,ge,K,te,Re,D),Oe=new dD(p,ce),pt=new $2,P=new sD(K,te),ue=new TC(p,fe,k,Ee,h,o),Z=new lD(p,Ee,te),Te=new CC(q,K,le,te),Fe=new FC(q,K,le,te),le.programs=ye.programs,p.capabilities=te,p.extensions=K,p.properties=ce,p.renderLists=pt,p.shadowMap=Z,p.state=k,p.info=le}Ie();let ve=new am(p,q);this.xr=ve,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){let L=K.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=K.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(L){L!==void 0&&(C=L,this.setSize(T,E,!1))},this.getSize=function(L){return L.set(T,E)},this.setSize=function(L,$,ie){if(ve.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=L,E=$,e.width=Math.floor(L*C),e.height=Math.floor($*C),ie!==!1&&(e.style.width=L+"px",e.style.height=$+"px"),this.setViewport(0,0,L,$)},this.getDrawingBufferSize=function(L){return L.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(L,$,ie){T=L,E=$,C=ie,e.width=Math.floor(L*ie),e.height=Math.floor($*ie),this.setViewport(0,0,L,$)},this.getCurrentViewport=function(L){return L.copy(M)},this.getViewport=function(L){return L.copy(N)},this.setViewport=function(L,$,ie,re){L.isVector4?N.set(L.x,L.y,L.z,L.w):N.set(L,$,ie,re),k.viewport(M.copy(N).multiplyScalar(C).floor())},this.getScissor=function(L){return L.copy(H)},this.setScissor=function(L,$,ie,re){L.isVector4?H.set(L.x,L.y,L.z,L.w):H.set(L,$,ie,re),k.scissor(_.copy(H).multiplyScalar(C).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(L){k.setScissorTest(j=L)},this.setOpaqueSort=function(L){I=L},this.setTransparentSort=function(L){B=L},this.getClearColor=function(L){return L.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(L=!0,$=!0,ie=!0){let re=0;L&&(re|=16384),$&&(re|=256),ie&&(re|=1024),q.clear(re)},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(){e.removeEventListener("webglcontextlost",z,!1),e.removeEventListener("webglcontextrestored",xe,!1),e.removeEventListener("webglcontextcreationerror",Me,!1),pt.dispose(),P.dispose(),ce.dispose(),fe.dispose(),ge.dispose(),Ee.dispose(),Re.dispose(),ye.dispose(),ve.dispose(),ve.removeEventListener("sessionstart",nt),ve.removeEventListener("sessionend",mt),F&&(F.dispose(),F=null),bt.stop()};function z(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=le.autoReset,$=Z.enabled,ie=Z.autoUpdate,re=Z.needsUpdate,he=Z.type;Ie(),le.autoReset=L,Z.enabled=$,Z.autoUpdate=ie,Z.needsUpdate=re,Z.type=he}function Me(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function Ye(L){let $=L.target;$.removeEventListener("dispose",Ye),Ne($)}function Ne(L){Je(L),ce.remove(L)}function Je(L){let $=ce.get(L).programs;$!==void 0&&($.forEach(function(ie){ye.releaseProgram(ie)}),L.isShaderMaterial&&ye.releaseShaderCache(L))}this.renderBufferDirect=function(L,$,ie,re,he,Ze){$===null&&($=W);let rt=he.isMesh&&he.matrixWorld.determinant()<0,st=dM(L,$,ie,re,he);k.setMaterial(re,rt);let it=ie.index,Tt=ie.attributes.position;if(it===null){if(Tt===void 0||Tt.count===0)return}else if(it.count===0)return;let ht=1;re.wireframe===!0&&(it=_e.getWireframeAttribute(ie),ht=2),Re.setup(he,re,st,ie,it);let gt,kt=Te;it!==null&&(gt=de.get(it),kt=Fe,kt.setIndex(gt));let Qs=it!==null?it.count:Tt.count,Ro=ie.drawRange.start*ht,Fo=ie.drawRange.count*ht,ri=Ze!==null?Ze.start*ht:0,wt=Ze!==null?Ze.count*ht:1/0,zo=Math.max(Ro,ri),tr=Math.min(Qs,Ro+Fo,ri+wt)-1,ni=Math.max(0,tr-zo+1);if(ni!==0){if(he.isMesh)re.wireframe===!0?(k.setLineWidth(re.wireframeLinewidth*Y()),kt.setMode(1)):kt.setMode(4);else if(he.isLine){let es=re.linewidth;es===void 0&&(es=1),k.setLineWidth(es*Y()),he.isLineSegments?kt.setMode(1):he.isLineLoop?kt.setMode(2):kt.setMode(3)}else he.isPoints?kt.setMode(0):he.isSprite&&kt.setMode(4);if(he.isInstancedMesh)kt.renderInstances(zo,ni,he.count);else if(ie.isInstancedBufferGeometry){let es=Math.min(ie.instanceCount,ie._maxInstanceCount);kt.renderInstances(zo,ni,es)}else kt.render(zo,ni)}},this.compile=function(L,$){f=P.get(L),f.init(),m.push(f),L.traverseVisible(function(ie){ie.isLight&&ie.layers.test($.layers)&&(f.pushLight(ie),ie.castShadow&&f.pushShadow(ie))}),f.setupLights(p.physicallyCorrectLights),L.traverse(function(ie){let re=ie.material;if(re)if(Array.isArray(re))for(let he=0;he<re.length;he++){let Ze=re[he];ip(Ze,L,ie)}else ip(re,L,ie)}),m.pop(),f=null};let be=null;function Qe(L){be&&be(L)}function nt(){bt.stop()}function mt(){bt.start()}let bt=new rx;bt.setAnimationLoop(Qe),typeof self<"u"&&bt.setContext(self),this.setAnimationLoop=function(L){be=L,ve.setAnimationLoop(L),L===null?bt.stop():bt.start()},ve.addEventListener("sessionstart",nt),ve.addEventListener("sessionend",mt),this.render=function(L,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.autoUpdate===!0&&L.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),ve.enabled===!0&&ve.isPresenting===!0&&(ve.cameraAutoUpdate===!0&&ve.updateCamera($),$=ve.getCamera()),L.isScene===!0&&L.onBeforeRender(p,L,$,w),f=P.get(L,m.length),f.init(),m.push(f),V.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),Q.setFromProjectionMatrix(V),U=this.localClippingEnabled,X=D.init(this.clippingPlanes,U,$),u=pt.get(L,d.length),u.init(),d.push(u),Jr(L,$,0,p.sortObjects),u.finish(),p.sortObjects===!0&&u.sort(I,B),X===!0&&D.beginShadows();let ie=f.state.shadowsArray;if(Z.render(ie,L,$),X===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(u,L),f.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let re=$.cameras;for(let he=0,Ze=re.length;he<Ze;he++){let rt=re[he];Lh(u,L,rt,rt.viewport)}}else Lh(u,L,$);w!==null&&(ae.updateMultisampleRenderTarget(w),ae.updateRenderTargetMipmap(w)),L.isScene===!0&&L.onAfterRender(p,L,$),Re.resetDefaultState(),b=-1,S=null,m.pop(),m.length>0?f=m[m.length-1]:f=null,d.pop(),d.length>0?u=d[d.length-1]:u=null};function Jr(L,$,ie,re){if(L.visible===!1)return;if(L.layers.test($.layers)){if(L.isGroup)ie=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update($);else if(L.isLight)f.pushLight(L),L.castShadow&&f.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||Q.intersectsSprite(L)){re&&G.setFromMatrixPosition(L.matrixWorld).applyMatrix4(V);let rt=Ee.update(L),st=L.material;st.visible&&u.push(L,rt,st,ie,G.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==le.render.frame&&(L.skeleton.update(),L.skeleton.frame=le.render.frame),!L.frustumCulled||Q.intersectsObject(L))){re&&G.setFromMatrixPosition(L.matrixWorld).applyMatrix4(V);let rt=Ee.update(L),st=L.material;if(Array.isArray(st)){let it=rt.groups;for(let Tt=0,ht=it.length;Tt<ht;Tt++){let gt=it[Tt],kt=st[gt.materialIndex];kt&&kt.visible&&u.push(L,rt,kt,ie,G.z,gt)}}else st.visible&&u.push(L,rt,st,ie,G.z,null)}}let Ze=L.children;for(let rt=0,st=Ze.length;rt<st;rt++)Jr(Ze[rt],$,ie,re)}function Lh(L,$,ie,re){let he=L.opaque,Ze=L.transmissive,rt=L.transparent;f.setupLightsView(ie),Ze.length>0&&Oo(he,$,ie),re&&k.viewport(M.copy(re)),he.length>0&&Ih(he,$,ie),Ze.length>0&&Ih(Ze,$,ie),rt.length>0&&Ih(rt,$,ie),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function Oo(L,$,ie){let re=te.isWebGL2;F===null&&(F=new ut(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?cc:It,minFilter:As,samples:re&&s===!0?4:0})),p.getDrawingBufferSize(R),re?F.setSize(R.x,R.y):F.setSize(uu(R.x),uu(R.y));let he=p.getRenderTarget();p.setRenderTarget(F),p.clear();let Ze=p.toneMapping;p.toneMapping=zi,Ih(L,$,ie),p.toneMapping=Ze,ae.updateMultisampleRenderTarget(F),ae.updateRenderTargetMipmap(F),p.setRenderTarget(he)}function Ih(L,$,ie){let re=$.isScene===!0?$.overrideMaterial:null;for(let he=0,Ze=L.length;he<Ze;he++){let rt=L[he],st=rt.object,it=rt.geometry,Tt=re===null?rt.material:re,ht=rt.group;st.layers.test(ie.layers)&&fM(st,$,ie,it,Tt,ht)}}function fM(L,$,ie,re,he,Ze){L.onBeforeRender(p,$,ie,re,he,Ze),L.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),he.onBeforeRender(p,$,ie,re,L,Ze),he.transparent===!0&&he.side===Wt?(he.side=gr,he.needsUpdate=!0,p.renderBufferDirect(ie,$,re,he,L,Ze),he.side=zn,he.needsUpdate=!0,p.renderBufferDirect(ie,$,re,he,L,Ze),he.side=Wt):p.renderBufferDirect(ie,$,re,he,L,Ze),L.onAfterRender(p,$,ie,re,he,Ze)}function ip(L,$,ie){$.isScene!==!0&&($=W);let re=ce.get(L),he=f.state.lights,Ze=f.state.shadowsArray,rt=he.state.version,st=ye.getParameters(L,he.state,Ze,$,ie),it=ye.getProgramCacheKey(st),Tt=re.programs;re.environment=L.isMeshStandardMaterial?$.environment:null,re.fog=$.fog,re.envMap=(L.isMeshStandardMaterial?ge:fe).get(L.envMap||re.environment),Tt===void 0&&(L.addEventListener("dispose",Ye),Tt=new Map,re.programs=Tt);let ht=Tt.get(it);if(ht!==void 0){if(re.currentProgram===ht&&re.lightsStateVersion===rt)return mv(L,st),ht}else st.uniforms=ye.getUniforms(L),L.onBuild(ie,st,p),L.onBeforeCompile(st,p),ht=ye.acquireProgram(st,it),Tt.set(it,ht),re.uniforms=st.uniforms;let gt=re.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(gt.clippingPlanes=D.uniform),mv(L,st),re.needsLights=mM(L),re.lightsStateVersion=rt,re.needsLights&&(gt.ambientLightColor.value=he.state.ambient,gt.lightProbe.value=he.state.probe,gt.directionalLights.value=he.state.directional,gt.directionalLightShadows.value=he.state.directionalShadow,gt.spotLights.value=he.state.spot,gt.spotLightShadows.value=he.state.spotShadow,gt.rectAreaLights.value=he.state.rectArea,gt.ltc_1.value=he.state.rectAreaLTC1,gt.ltc_2.value=he.state.rectAreaLTC2,gt.pointLights.value=he.state.point,gt.pointLightShadows.value=he.state.pointShadow,gt.hemisphereLights.value=he.state.hemi,gt.directionalShadowMap.value=he.state.directionalShadowMap,gt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,gt.spotShadowMap.value=he.state.spotShadowMap,gt.spotShadowMatrix.value=he.state.spotShadowMatrix,gt.pointShadowMap.value=he.state.pointShadowMap,gt.pointShadowMatrix.value=he.state.pointShadowMatrix);let kt=ht.getUniforms(),Qs=ra.seqWithValue(kt.seq,gt);return re.currentProgram=ht,re.uniformsList=Qs,ht}function mv(L,$){let ie=ce.get(L);ie.outputEncoding=$.outputEncoding,ie.instancing=$.instancing,ie.skinning=$.skinning,ie.morphTargets=$.morphTargets,ie.morphNormals=$.morphNormals,ie.morphColors=$.morphColors,ie.morphTargetsCount=$.morphTargetsCount,ie.numClippingPlanes=$.numClippingPlanes,ie.numIntersection=$.numClipIntersection,ie.vertexAlphas=$.vertexAlphas,ie.vertexTangents=$.vertexTangents,ie.toneMapping=$.toneMapping}function dM(L,$,ie,re,he){$.isScene!==!0&&($=W),ae.resetTextureUnits();let Ze=$.fog,rt=re.isMeshStandardMaterial?$.environment:null,st=w===null?p.outputEncoding:w.isXRRenderTarget===!0?w.texture.encoding:hn,it=(re.isMeshStandardMaterial?ge:fe).get(re.envMap||rt),Tt=re.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,ht=!!re.normalMap&&!!ie.attributes.tangent,gt=!!ie.morphAttributes.position,kt=!!ie.morphAttributes.normal,Qs=!!ie.morphAttributes.color,Ro=re.toneMapped?p.toneMapping:zi,Fo=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,ri=Fo!==void 0?Fo.length:0,wt=ce.get(re),zo=f.state.lights;if(X===!0&&(U===!0||L!==S)){let ii=L===S&&re.id===b;D.setState(re,L,ii)}let tr=!1;re.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==zo.state.version||wt.outputEncoding!==st||he.isInstancedMesh&&wt.instancing===!1||!he.isInstancedMesh&&wt.instancing===!0||he.isSkinnedMesh&&wt.skinning===!1||!he.isSkinnedMesh&&wt.skinning===!0||wt.envMap!==it||re.fog===!0&&wt.fog!==Ze||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==D.numPlanes||wt.numIntersection!==D.numIntersection)||wt.vertexAlphas!==Tt||wt.vertexTangents!==ht||wt.morphTargets!==gt||wt.morphNormals!==kt||wt.morphColors!==Qs||wt.toneMapping!==Ro||te.isWebGL2===!0&&wt.morphTargetsCount!==ri)&&(tr=!0):(tr=!0,wt.__version=re.version);let ni=wt.currentProgram;tr===!0&&(ni=ip(re,$,he));let es=!1,Ql=!1,sp=!1,zr=ni.getUniforms(),Kl=wt.uniforms;if(k.useProgram(ni.program)&&(es=!0,Ql=!0,sp=!0),re.id!==b&&(b=re.id,Ql=!0),es||S!==L){if(zr.setValue(q,"projectionMatrix",L.projectionMatrix),te.logarithmicDepthBuffer&&zr.setValue(q,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),S!==L&&(S=L,Ql=!0,sp=!0),re.isShaderMaterial||re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshStandardMaterial||re.envMap){let ii=zr.map.cameraPosition;ii!==void 0&&ii.setValue(q,G.setFromMatrixPosition(L.matrixWorld))}(re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshLambertMaterial||re.isMeshBasicMaterial||re.isMeshStandardMaterial||re.isShaderMaterial)&&zr.setValue(q,"isOrthographic",L.isOrthographicCamera===!0),(re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshLambertMaterial||re.isMeshBasicMaterial||re.isMeshStandardMaterial||re.isShaderMaterial||re.isShadowMaterial||he.isSkinnedMesh)&&zr.setValue(q,"viewMatrix",L.matrixWorldInverse)}if(he.isSkinnedMesh){zr.setOptional(q,he,"bindMatrix"),zr.setOptional(q,he,"bindMatrixInverse");let ii=he.skeleton;ii&&(te.floatVertexTextures?(ii.boneTexture===null&&ii.computeBoneTexture(),zr.setValue(q,"boneTexture",ii.boneTexture,ae),zr.setValue(q,"boneTextureSize",ii.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 op=ie.morphAttributes;return(op.position!==void 0||op.normal!==void 0||op.color!==void 0&&te.isWebGL2===!0)&&pe.update(he,ie,re,ni),(Ql||wt.receiveShadow!==he.receiveShadow)&&(wt.receiveShadow=he.receiveShadow,zr.setValue(q,"receiveShadow",he.receiveShadow)),Ql&&(zr.setValue(q,"toneMappingExposure",p.toneMappingExposure),wt.needsLights&&pM(Kl,sp),Ze&&re.fog===!0&&Oe.refreshFogUniforms(Kl,Ze),Oe.refreshMaterialUniforms(Kl,re,C,E,F),ra.upload(q,wt.uniformsList,Kl,ae)),re.isShaderMaterial&&re.uniformsNeedUpdate===!0&&(ra.upload(q,wt.uniformsList,Kl,ae),re.uniformsNeedUpdate=!1),re.isSpriteMaterial&&zr.setValue(q,"center",he.center),zr.setValue(q,"modelViewMatrix",he.modelViewMatrix),zr.setValue(q,"normalMatrix",he.normalMatrix),zr.setValue(q,"modelMatrix",he.matrixWorld),ni}function pM(L,$){L.ambientLightColor.needsUpdate=$,L.lightProbe.needsUpdate=$,L.directionalLights.needsUpdate=$,L.directionalLightShadows.needsUpdate=$,L.pointLights.needsUpdate=$,L.pointLightShadows.needsUpdate=$,L.spotLights.needsUpdate=$,L.spotLightShadows.needsUpdate=$,L.rectAreaLights.needsUpdate=$,L.hemisphereLights.needsUpdate=$}function mM(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return x},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(L,$,ie){ce.get(L.texture).__webglTexture=$,ce.get(L.depthTexture).__webglTexture=ie;let re=ce.get(L);re.__hasExternalTextures=!0,re.__hasExternalTextures&&(re.__autoAllocateDepthBuffer=ie===void 0,re.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),re.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,$){let ie=ce.get(L);ie.__webglFramebuffer=$,ie.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(L,$=0,ie=0){w=L,x=$,v=ie;let re=!0;if(L){let it=ce.get(L);it.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),re=!1):it.__webglFramebuffer===void 0?ae.setupRenderTarget(L):it.__hasExternalTextures&&ae.rebindTextures(L,ce.get(L.texture).__webglTexture,ce.get(L.depthTexture).__webglTexture)}let he=null,Ze=!1,rt=!1;if(L){let it=L.texture;(it.isData3DTexture||it.isDataArrayTexture)&&(rt=!0);let Tt=ce.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(he=Tt[$],Ze=!0):te.isWebGL2&&L.samples>0&&ae.useMultisampledRTT(L)===!1?he=ce.get(L).__webglMultisampledFramebuffer:he=Tt,M.copy(L.viewport),_.copy(L.scissor),y=L.scissorTest}else M.copy(N).multiplyScalar(C).floor(),_.copy(H).multiplyScalar(C).floor(),y=j;if(k.bindFramebuffer(36160,he)&&te.drawBuffers&&re&&k.drawBuffers(L,he),k.viewport(M),k.scissor(_),k.setScissorTest(y),Ze){let it=ce.get(L.texture);q.framebufferTexture2D(36160,36064,34069+$,it.__webglTexture,ie)}else if(rt){let it=ce.get(L.texture),Tt=$||0;q.framebufferTextureLayer(36160,36064,it.__webglTexture,ie||0,Tt)}b=-1},this.readRenderTargetPixels=function(L,$,ie,re,he,Ze,rt){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let st=ce.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&rt!==void 0&&(st=st[rt]),st){k.bindFramebuffer(36160,st);try{let it=L.texture,Tt=it.format,ht=it.type;if(Tt!==bn&&ne.convert(Tt)!==q.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=ht===cc&&(K.has("EXT_color_buffer_half_float")||te.isWebGL2&&K.has("EXT_color_buffer_float"));if(ht!==It&&ne.convert(ht)!==q.getParameter(35738)&&!(ht===ls&&(te.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=L.width-re&&ie>=0&&ie<=L.height-he&&q.readPixels($,ie,re,he,ne.convert(Tt),ne.convert(ht),Ze)}finally{let it=w!==null?ce.get(w).__webglFramebuffer:null;k.bindFramebuffer(36160,it)}}},this.copyFramebufferToTexture=function(L,$,ie=0){let re=Math.pow(2,-ie),he=Math.floor($.image.width*re),Ze=Math.floor($.image.height*re);ae.setTexture2D($,0),q.copyTexSubImage2D(3553,ie,0,0,L.x,L.y,he,Ze),k.unbindTexture()},this.copyTextureToTexture=function(L,$,ie,re=0){let he=$.image.width,Ze=$.image.height,rt=ne.convert(ie.format),st=ne.convert(ie.type);ae.setTexture2D(ie,0),q.pixelStorei(37440,ie.flipY),q.pixelStorei(37441,ie.premultiplyAlpha),q.pixelStorei(3317,ie.unpackAlignment),$.isDataTexture?q.texSubImage2D(3553,re,L.x,L.y,he,Ze,rt,st,$.image.data):$.isCompressedTexture?q.compressedTexSubImage2D(3553,re,L.x,L.y,$.mipmaps[0].width,$.mipmaps[0].height,rt,$.mipmaps[0].data):q.texSubImage2D(3553,re,L.x,L.y,rt,st,$.image),re===0&&ie.generateMipmaps&&q.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(L,$,ie,re,he=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ze=L.max.x-L.min.x+1,rt=L.max.y-L.min.y+1,st=L.max.z-L.min.z+1,it=ne.convert(re.format),Tt=ne.convert(re.type),ht;if(re.isData3DTexture)ae.setTexture3D(re,0),ht=32879;else if(re.isDataArrayTexture)ae.setTexture2DArray(re,0),ht=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}q.pixelStorei(37440,re.flipY),q.pixelStorei(37441,re.premultiplyAlpha),q.pixelStorei(3317,re.unpackAlignment);let gt=q.getParameter(3314),kt=q.getParameter(32878),Qs=q.getParameter(3316),Ro=q.getParameter(3315),Fo=q.getParameter(32877),ri=ie.isCompressedTexture?ie.mipmaps[0]:ie.image;q.pixelStorei(3314,ri.width),q.pixelStorei(32878,ri.height),q.pixelStorei(3316,L.min.x),q.pixelStorei(3315,L.min.y),q.pixelStorei(32877,L.min.z),ie.isDataTexture||ie.isData3DTexture?q.texSubImage3D(ht,he,$.x,$.y,$.z,Ze,rt,st,it,Tt,ri.data):ie.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),q.compressedTexSubImage3D(ht,he,$.x,$.y,$.z,Ze,rt,st,it,ri.data)):q.texSubImage3D(ht,he,$.x,$.y,$.z,Ze,rt,st,it,Tt,ri),q.pixelStorei(3314,gt),q.pixelStorei(32878,kt),q.pixelStorei(3316,Qs),q.pixelStorei(3315,Ro),q.pixelStorei(32877,Fo),he===0&&re.generateMipmaps&&q.generateMipmap(ht),k.unbindTexture()},this.initTexture=function(L){ae.setTexture2D(L,0),k.unbindTexture()},this.resetState=function(){x=0,v=0,w=null,k.reset(),Re.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var lm=class extends zu{};lm.prototype.isWebGL1Renderer=!0;var aa=class{constructor(e,t=1,r=1e3){this.isFog=!0,this.name="",this.color=new Se(e),this.near=t,this.far=r}clone(){return new aa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},un=class extends lt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,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()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},bu=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Xp,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=li()}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,r){e*=this.stride,r*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[r+i];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=li()),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]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}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=li()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ur=new A,oo=class{constructor(e,t,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=i===!0}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,r=this.data.count;t<r;t++)Ur.fromBufferAttribute(this,t),Ur.applyMatrix4(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)Ur.fromBufferAttribute(this,t),Ur.applyNormalMatrix(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)Ur.fromBufferAttribute(this,t),Ur.transformDirection(e),this.setXYZ(t,Ur.x,Ur.y,Ur.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Xe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new oo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+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}}},cm=class extends cr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Se(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var hm=class extends Xe{constructor(e,t,r,i=1){typeof r=="number"&&(i=r,r=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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}};var Zr=class extends cr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Se(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}},P0=new A,L0=new A,I0=new Be,Up=new so,tu=new Br,ao=class extends lt{constructor(e=new Le,t=new Zr){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,r=[0];for(let i=1,s=t.count;i<s;i++)P0.fromBufferAttribute(t,i-1),L0.fromBufferAttribute(t,i),r[i]=r[i-1],r[i]+=P0.distanceTo(L0);e.setAttribute("lineDistance",new Ae(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),tu.copy(r.boundingSphere),tu.applyMatrix4(i),tu.radius+=s,e.ray.intersectsSphere(tu)===!1)return;I0.copy(i).invert(),Up.copy(e.ray).applyMatrix4(I0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new A,h=new A,u=new A,f=new A,d=this.isLineSegments?2:1,m=r.index,g=r.attributes.position;if(m!==null){let x=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=d){let S=m.getX(w),M=m.getX(w+1);if(c.fromBufferAttribute(g,S),h.fromBufferAttribute(g,M),Up.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);let y=e.ray.origin.distanceTo(f);y<e.near||y>e.far||t.push({distance:y,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{let x=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=d){if(c.fromBufferAttribute(g,w),h.fromBufferAttribute(g,w+1),Up.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(f);M<e.near||M>e.far||t.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){let i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},N0=new A,B0=new A,ys=class extends ao{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,r=[];for(let i=0,s=t.count;i<s;i+=2)N0.fromBufferAttribute(t,i),B0.fromBufferAttribute(t,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+N0.distanceTo(B0);e.setAttribute("lineDistance",new Ae(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var um=class extends cr{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Se(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var wu=class extends Nt{constructor(e,t,r,i,s,o,a,l,c){super(e,t,r,i,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:et,this.magFilter=s!==void 0?s:et,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Sn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){let t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){let t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/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=[],r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let r=this.getLengths(),i=0,s=r.length,o;t?o=t:o=e*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);let h=r[i],f=r[i+1]-h,d=(o-h)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new O:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t){let r=new A,i=[],s=[],o=[],a=new A,l=new Be;for(let d=0;d<=e;d++){let m=d/e;i[d]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let c=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),u<=c&&(c=u,r.set(0,1,0)),f<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(nr(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(a,m))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(nr(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],d*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}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}},lo=class extends Sn{constructor(e=0,t=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let r=t||new O,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),f=l-this.aX,d=c-this.aY;l=f*h-d*u+this.aX,c=f*u+d*h+this.aY}return r.set(l,c)}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}},fm=class extends lo{constructor(e,t,r,i,s,o){super(e,t,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Wm(){let n=0,e=0,t=0,r=0;function i(s,o,a,l){n=s,e=a,t=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,u){let f=(o-s)/c-(a-s)/(c+h)+(a-o)/h,d=(a-o)/h-(l-o)/(h+u)+(l-a)/u;f*=h,d*=h,i(o,a,f,d)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+r*a}}}var ru=new A,Gp=new Wm,kp=new Wm,Vp=new Wm,dm=class extends Sn{constructor(e=[],t=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=r,this.tension=i}getPoint(e,t=new A){let r=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(ru.subVectors(i[0],i[1]).add(i[0]),c=ru);let u=i[a%s],f=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(ru.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=ru),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(u),d),p=Math.pow(u.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(h),d);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),Gp.initNonuniformCatmullRom(c.x,u.x,f.x,h.x,m,p,g),kp.initNonuniformCatmullRom(c.y,u.y,f.y,h.y,m,p,g),Vp.initNonuniformCatmullRom(c.z,u.z,f.z,h.z,m,p,g)}else this.curveType==="catmullrom"&&(Gp.initCatmullRom(c.x,u.x,f.x,h.x,this.tension),kp.initCatmullRom(c.y,u.y,f.y,h.y,this.tension),Vp.initCatmullRom(c.z,u.z,f.z,h.z,this.tension));return r.set(Gp.calc(l),kp.calc(l),Vp.calc(l)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(i.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,r=this.points.length;t<r;t++){let i=this.points[t];e.points.push(i.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,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function O0(n,e,t,r,i){let s=(r-e)*.5,o=(i-t)*.5,a=n*n,l=n*a;return(2*t-2*r+s+o)*l+(-3*t+3*r-2*s-o)*a+s*n+t}function mD(n,e){let t=1-n;return t*t*e}function gD(n,e){return 2*(1-n)*n*e}function yD(n,e){return n*n*e}function ac(n,e,t,r){return mD(n,e)+gD(n,t)+yD(n,r)}function vD(n,e){let t=1-n;return t*t*t*e}function xD(n,e){let t=1-n;return 3*t*t*n*e}function bD(n,e){return 3*(1-n)*n*n*e}function wD(n,e){return n*n*n*e}function lc(n,e,t,r,i){return vD(n,e)+xD(n,t)+bD(n,r)+wD(n,i)}var $r=class extends Sn{constructor(e=new O,t=new O,r=new O,i=new O){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new O){let r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(lc(e,i.x,s.x,o.x,a.x),lc(e,i.y,s.y,o.y,a.y)),r}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}},pm=class extends Sn{constructor(e=new A,t=new A,r=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new A){let r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(lc(e,i.x,s.x,o.x,a.x),lc(e,i.y,s.y,o.y,a.y),lc(e,i.z,s.z,o.z,a.z)),r}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}},en=class extends Sn{constructor(e=new O,t=new O){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new O){let r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let r=t||new O;return r.copy(this.v2).sub(this.v1).normalize(),r}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}},dc=class extends Sn{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){let r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}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}},kn=class extends Sn{constructor(e=new O,t=new O,r=new O){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new O){let r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(ac(e,i.x,s.x,o.x),ac(e,i.y,s.y,o.y)),r}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}},mm=class extends Sn{constructor(e=new A,t=new A,r=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new A){let r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(ac(e,i.x,s.x,o.x),ac(e,i.y,s.y,o.y),ac(e,i.z,s.z,o.z)),r}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}},la=class extends Sn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new O){let r=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return r.set(O0(a,l.x,c.x,h.x,u.x),O0(a,l.y,c.y,h.y,u.y)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,r=this.points.length;t<r;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){let i=e.points[t];this.points.push(new O().fromArray(i))}return this}},SD=Object.freeze({__proto__:null,ArcCurve:fm,CatmullRomCurve3:dm,CubicBezierCurve:$r,CubicBezierCurve3:pm,EllipseCurve:lo,LineCurve:en,LineCurve3:dc,QuadraticBezierCurve:kn,QuadraticBezierCurve3:mm,SplineCurve:la}),gm=class extends Sn{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 en(t,e))}getPoint(e,t){let r=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=r){let o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,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 r=0,i=this.curves.length;r<i;r++)t+=this.curves[r].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],r;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let h=l[c];r&&r.equals(h)||(t.push(h),r=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,r=e.curves.length;t<r;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,r=this.curves.length;t<r;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,r=e.curves.length;t<r;t++){let i=e.curves[t];this.curves.push(new SD[i.type]().fromJSON(i))}return this}},pc=class extends gm{constructor(e){super(),this.type="Path",this.currentPoint=new O,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,r=e.length;t<r;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 r=new en(this.currentPoint.clone(),new O(e,t));return this.curves.push(r),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,r,i){let s=new kn(this.currentPoint.clone(),new O(e,t),new O(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(e,t,r,i,s,o){let a=new $r(this.currentPoint.clone(),new O(e,t),new O(r,i),new O(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),r=new la(t);return this.curves.push(r),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,r,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,r,i,s,o),this}absarc(e,t,r,i,s,o){return this.absellipse(e,t,r,r,i,s,o),this}ellipse(e,t,r,i,s,o,a,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,r,i,s,o,a,l),this}absellipse(e,t,r,i,s,o,a,l){let c=new lo(e,t,r,i,s,o,a,l);if(this.curves.length>0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let h=c.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}},ca=class extends Le{constructor(e=[new O(0,.5),new O(.5,0),new O(0,-.5)],t=12,r=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:i},t=Math.floor(t),i=nr(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],h=1/t,u=new A,f=new O,d=new A,m=new A,p=new A,g=0,x=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,d.x=x*1,d.y=-g,d.z=x*0,p.copy(d),d.normalize(),l.push(d.x,d.y,d.z);break;case e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,d.x=x*1,d.y=-g,d.z=x*0,m.copy(d),d.x+=p.x,d.y+=p.y,d.z+=p.z,d.normalize(),l.push(d.x,d.y,d.z),p.copy(m)}for(let v=0;v<=t;v++){let w=r+v*h*i,b=Math.sin(w),S=Math.cos(w);for(let M=0;M<=e.length-1;M++){u.x=e[M].x*b,u.y=e[M].y,u.z=e[M].x*S,o.push(u.x,u.y,u.z),f.x=v/t,f.y=M/(e.length-1),a.push(f.x,f.y);let _=l[3*M+0]*b,y=l[3*M+1],T=l[3*M+0]*S;c.push(_,y,T)}}for(let v=0;v<t;v++)for(let w=0;w<e.length-1;w++){let b=w+v*e.length,S=b,M=b+e.length,_=b+e.length+1,y=b+1;s.push(S,M,y),s.push(_,y,M)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(c,3))}static fromJSON(e){return new ca(e.points,e.segments,e.phiStart,e.phiLength)}};var co=class extends Le{constructor(e=1,t=1,r=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let h=[],u=[],f=[],d=[],m=0,p=[],g=r/2,x=0;v(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(f,3)),this.setAttribute("uv",new Ae(d,2));function v(){let b=new A,S=new A,M=0,_=(t-e)/r;for(let y=0;y<=s;y++){let T=[],E=y/s,C=E*(t-e)+e;for(let I=0;I<=i;I++){let B=I/i,N=B*l+a,H=Math.sin(N),j=Math.cos(N);S.x=C*H,S.y=-E*r+g,S.z=C*j,u.push(S.x,S.y,S.z),b.set(H,_,j).normalize(),f.push(b.x,b.y,b.z),d.push(B,1-E),T.push(m++)}p.push(T)}for(let y=0;y<i;y++)for(let T=0;T<s;T++){let E=p[T][y],C=p[T+1][y],I=p[T+1][y+1],B=p[T][y+1];h.push(E,C,B),h.push(C,I,B),M+=6}c.addGroup(x,M,0),x+=M}function w(b){let S=m,M=new O,_=new A,y=0,T=b===!0?e:t,E=b===!0?1:-1;for(let I=1;I<=i;I++)u.push(0,g*E,0),f.push(0,E,0),d.push(.5,.5),m++;let C=m;for(let I=0;I<=i;I++){let N=I/i*l+a,H=Math.cos(N),j=Math.sin(N);_.x=T*j,_.y=g*E,_.z=T*H,u.push(_.x,_.y,_.z),f.push(0,E,0),M.x=H*.5+.5,M.y=j*.5*E+.5,d.push(M.x,M.y),m++}for(let I=0;I<i;I++){let B=S+I,N=C+I;b===!0?h.push(N,N+1,B):h.push(N+1,N,B),y+=3}c.addGroup(x,y,b===!0?1:2),x+=y}}static fromJSON(e){return new co(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ha=class extends co{constructor(e=1,t=1,r=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,r,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new ha(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ua=class extends Le{constructor(e=[],t=[],r=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:i};let s=[],o=[];a(i),c(r),h(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let w=new A,b=new A,S=new A;for(let M=0;M<t.length;M+=3)d(t[M+0],w),d(t[M+1],b),d(t[M+2],S),l(w,b,S,v)}function l(v,w,b,S){let M=S+1,_=[];for(let y=0;y<=M;y++){_[y]=[];let T=v.clone().lerp(b,y/M),E=w.clone().lerp(b,y/M),C=M-y;for(let I=0;I<=C;I++)I===0&&y===M?_[y][I]=T:_[y][I]=T.clone().lerp(E,I/C)}for(let y=0;y<M;y++)for(let T=0;T<2*(M-y)-1;T++){let E=Math.floor(T/2);T%2===0?(f(_[y][E+1]),f(_[y+1][E]),f(_[y][E])):(f(_[y][E+1]),f(_[y+1][E+1]),f(_[y+1][E]))}}function c(v){let w=new A;for(let b=0;b<s.length;b+=3)w.x=s[b+0],w.y=s[b+1],w.z=s[b+2],w.normalize().multiplyScalar(v),s[b+0]=w.x,s[b+1]=w.y,s[b+2]=w.z}function h(){let v=new A;for(let w=0;w<s.length;w+=3){v.x=s[w+0],v.y=s[w+1],v.z=s[w+2];let b=g(v)/2/Math.PI+.5,S=x(v)/Math.PI+.5;o.push(b,1-S)}m(),u()}function u(){for(let v=0;v<o.length;v+=6){let w=o[v+0],b=o[v+2],S=o[v+4],M=Math.max(w,b,S),_=Math.min(w,b,S);M>.9&&_<.1&&(w<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function f(v){s.push(v.x,v.y,v.z)}function d(v,w){let b=v*3;w.x=e[b+0],w.y=e[b+1],w.z=e[b+2]}function m(){let v=new A,w=new A,b=new A,S=new A,M=new O,_=new O,y=new O;for(let T=0,E=0;T<s.length;T+=9,E+=6){v.set(s[T+0],s[T+1],s[T+2]),w.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),M.set(o[E+0],o[E+1]),_.set(o[E+2],o[E+3]),y.set(o[E+4],o[E+5]),S.copy(v).add(w).add(b).divideScalar(3);let C=g(S);p(M,E+0,v,C),p(_,E+2,w,C),p(y,E+4,b,C)}}function p(v,w,b,S){S<0&&v.x===1&&(o[w]=v.x-1),b.x===0&&b.z===0&&(o[w]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function x(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new ua(e.vertices,e.indices,e.radius,e.details)}},fa=class extends ua{constructor(e=1,t=0){let r=(1+Math.sqrt(5))/2,i=1/r,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fa(e.radius,e.detail)}},tU=new A,rU=new A,nU=new A,iU=new Qr;var Fn=class extends pc{constructor(e){super(e),this.uuid=li(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let r=0,i=this.holes.length;r<i;r++)t[r]=this.holes[r].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,r=e.holes.length;t<r;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,r=this.holes.length;t<r;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,r=e.holes.length;t<r;t++){let i=e.holes[t];this.holes.push(new pc().fromJSON(i))}return this}},AD={triangulate:function(n,e,t=2){let r=e&&e.length,i=r?e[0]*t:n.length,s=lx(n,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,h,u,f,d;if(r&&(s=CD(n,e,s,t)),n.length>80*t){a=c=n[0],l=h=n[1];for(let m=t;m<i;m+=t)u=n[m],f=n[m+1],u<a&&(a=u),f<l&&(l=f),u>c&&(c=u),f>h&&(h=f);d=Math.max(c-a,h-l),d=d!==0?1/d:0}return mc(s,o,t,a,l,d),o}};function lx(n,e,t,r,i){let s,o;if(i===UD(n,e,t,r)>0)for(s=e;s<t;s+=r)o=R0(s,n[s],n[s+1],o);else for(s=t-r;s>=e;s-=r)o=R0(s,n[s],n[s+1],o);return o&&Uu(o,o.next)&&(yc(o),o=o.next),o}function vs(n,e){if(!n)return n;e||(e=n);let t=n,r;do if(r=!1,!t.steiner&&(Uu(t,t.next)||Ut(t.prev,t,t.next)===0)){if(yc(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function mc(n,e,t,r,i,s,o){if(!n)return;!o&&s&&ND(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?_D(n,r,i,s):MD(n)){e.push(l.i/t),e.push(n.i/t),e.push(c.i/t),yc(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=TD(vs(n),e,t),mc(n,e,t,r,i,s,2)):o===2&&ED(n,e,t,r,i,s):mc(vs(n),e,t,r,i,s,1);break}}}function MD(n){let e=n.prev,t=n,r=n.next;if(Ut(e,t,r)>=0)return!1;let i=n.next.next;for(;i!==n.prev;){if(ta(e.x,e.y,t.x,t.y,r.x,r.y,i.x,i.y)&&Ut(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function _D(n,e,t,r){let i=n.prev,s=n,o=n.next;if(Ut(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,c=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,h=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,u=ym(a,l,e,t,r),f=ym(c,h,e,t,r),d=n.prevZ,m=n.nextZ;for(;d&&d.z>=u&&m&&m.z<=f;){if(d!==n.prev&&d!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ut(d.prev,d,d.next)>=0||(d=d.prevZ,m!==n.prev&&m!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Ut(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;d&&d.z>=u;){if(d!==n.prev&&d!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ut(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;m&&m.z<=f;){if(m!==n.prev&&m!==n.next&&ta(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Ut(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function TD(n,e,t){let r=n;do{let i=r.prev,s=r.next.next;!Uu(i,s)&&cx(i,r,r.next,s)&&gc(i,s)&&gc(s,i)&&(e.push(i.i/t),e.push(r.i/t),e.push(s.i/t),yc(r),yc(r.next),r=n=s),r=r.next}while(r!==n);return vs(r)}function ED(n,e,t,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&RD(o,a)){let l=hx(o,a);o=vs(o,o.next),l=vs(l,l.next),mc(o,e,t,r,i,s),mc(l,e,t,r,i,s);return}a=a.next}o=o.next}while(o!==n)}function CD(n,e,t,r){let i=[],s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*r,l=s<o-1?e[s+1]*r:n.length,c=lx(n,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(OD(c));for(i.sort(DD),s=0;s<i.length;s++)PD(i[s],t),t=vs(t,t.next);return t}function DD(n,e){return n.x-e.x}function PD(n,e){if(e=LD(n,e),e){let t=hx(e,n);vs(e,e.next),vs(t,t.next)}}function LD(n,e){let t=e,r=n.x,i=n.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>s){if(s=f,f===r){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(r===s)return o;let a=o,l=o.x,c=o.y,h=1/0,u;t=o;do r>=t.x&&t.x>=l&&r!==t.x&&ta(i<c?r:s,i,l,c,i<c?s:r,i,t.x,t.y)&&(u=Math.abs(i-t.y)/(r-t.x),gc(t,n)&&(u<h||u===h&&(t.x>o.x||t.x===o.x&&ID(o,t)))&&(o=t,h=u)),t=t.next;while(t!==a);return o}function ID(n,e){return Ut(n.prev,n,e.prev)<0&&Ut(e.next,n,n.next)<0}function ND(n,e,t,r){let i=n;do i.z===null&&(i.z=ym(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,BD(i)}function BD(n){let e,t,r,i,s,o,a,l,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,r=t,a=0,e=0;e<c&&(a++,r=r.nextZ,!!r);e++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||t.z<=r.z)?(i=t,t=t.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;t=r}s.nextZ=null,c*=2}while(o>1);return n}function ym(n,e,t,r,i){return n=32767*(n-t)*i,e=32767*(e-r)*i,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function OD(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function ta(n,e,t,r,i,s,o,a){return(i-o)*(e-a)-(n-o)*(s-a)>=0&&(n-o)*(r-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(r-a)>=0}function RD(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!FD(n,e)&&(gc(n,e)&&gc(e,n)&&zD(n,e)&&(Ut(n.prev,n,e.prev)||Ut(n,e.prev,e))||Uu(n,e)&&Ut(n.prev,n,n.next)>0&&Ut(e.prev,e,e.next)>0)}function Ut(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Uu(n,e){return n.x===e.x&&n.y===e.y}function cx(n,e,t,r){let i=iu(Ut(n,e,t)),s=iu(Ut(n,e,r)),o=iu(Ut(t,r,n)),a=iu(Ut(t,r,e));return!!(i!==s&&o!==a||i===0&&nu(n,t,e)||s===0&&nu(n,r,e)||o===0&&nu(t,n,r)||a===0&&nu(t,e,r))}function nu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function iu(n){return n>0?1:n<0?-1:0}function FD(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&cx(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function gc(n,e){return Ut(n.prev,n,n.next)<0?Ut(n,e,n.next)>=0&&Ut(n,n.prev,e)>=0:Ut(n,e,n.prev)<0||Ut(n,n.next,e)<0}function zD(n,e){let t=n,r=!1,i=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==n);return r}function hx(n,e){let t=new vm(n.i,n.x,n.y),r=new vm(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function R0(n,e,t,r){let i=new vm(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function yc(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function vm(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function UD(n,e,t,r){let i=0;for(let s=e,o=t-r;s<t;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}var fs=class{static area(e){let t=e.length,r=0;for(let i=t-1,s=0;s<t;i=s++)r+=e[i].x*e[s].y-e[s].x*e[i].y;return r*.5}static isClockWise(e){return fs.area(e)<0}static triangulateShape(e,t){let r=[],i=[],s=[];F0(e),z0(r,e);let o=e.length;t.forEach(F0);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,z0(r,t[l]);let a=AD.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function F0(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function z0(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var da=class extends ua{constructor(e=1,t=0){let r=(1+Math.sqrt(5))/2,i=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new da(e.radius,e.detail)}};var pa=class extends Le{constructor(e=new Fn([new O(0,.5),new O(-.5,-.5),new O(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let r=[],i=[],s=[],o=[],a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new Ae(i,3)),this.setAttribute("normal",new Ae(s,3)),this.setAttribute("uv",new Ae(o,2));function c(h){let u=i.length/3,f=h.extractPoints(t),d=f.shape,m=f.holes;fs.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,x=m.length;g<x;g++){let v=m[g];fs.isClockWise(v)===!0&&(m[g]=v.reverse())}let p=fs.triangulateShape(d,m);for(let g=0,x=m.length;g<x;g++){let v=m[g];d=d.concat(v)}for(let g=0,x=d.length;g<x;g++){let v=d[g];i.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let g=0,x=p.length;g<x;g++){let v=p[g],w=v[0]+u,b=v[1]+u,S=v[2]+u;r.push(w,b,S),l+=3}}}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return GD(t,e)}static fromJSON(e,t){let r=[];for(let i=0,s=e.shapes.length;i<s;i++){let o=t[e.shapes[i]];r.push(o)}return new pa(r,e.curveSegments)}};function GD(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let i=n[t];e.shapes.push(i.uuid)}else e.shapes.push(n.uuid);return e}var ho=class extends Le{constructor(e=1,t=32,r=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),c=0,h=[],u=new A,f=new A,d=[],m=[],p=[],g=[];for(let x=0;x<=r;x++){let v=[],w=x/r,b=0;x==0&&o==0?b=.5/t:x==r&&l==Math.PI&&(b=-.5/t);for(let S=0;S<=t;S++){let M=S/t;u.x=-e*Math.cos(i+M*s)*Math.sin(o+w*a),u.y=e*Math.cos(o+w*a),u.z=e*Math.sin(i+M*s)*Math.sin(o+w*a),m.push(u.x,u.y,u.z),f.copy(u).normalize(),p.push(f.x,f.y,f.z),g.push(M+b,1-w),v.push(c++)}h.push(v)}for(let x=0;x<r;x++)for(let v=0;v<t;v++){let w=h[x][v+1],b=h[x][v],S=h[x+1][v],M=h[x+1][v+1];(x!==0||o>0)&&d.push(w,b,M),(x!==r-1||l<Math.PI)&&d.push(b,S,M)}this.setIndex(d),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(e){return new ho(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var ma=class extends Le{constructor(e=1,t=.4,r=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:r,radialSegments:i,p:s,q:o},r=Math.floor(r),i=Math.floor(i);let a=[],l=[],c=[],h=[],u=new A,f=new A,d=new A,m=new A,p=new A,g=new A,x=new A;for(let w=0;w<=r;++w){let b=w/r*s*Math.PI*2;v(b,s,o,e,d),v(b+.01,s,o,e,m),g.subVectors(m,d),x.addVectors(m,d),p.crossVectors(g,x),x.crossVectors(p,g),p.normalize(),x.normalize();for(let S=0;S<=i;++S){let M=S/i*Math.PI*2,_=-t*Math.cos(M),y=t*Math.sin(M);u.x=d.x+(_*x.x+y*p.x),u.y=d.y+(_*x.y+y*p.y),u.z=d.z+(_*x.z+y*p.z),l.push(u.x,u.y,u.z),f.subVectors(u,d).normalize(),c.push(f.x,f.y,f.z),h.push(w/r),h.push(S/i)}}for(let w=1;w<=r;w++)for(let b=1;b<=i;b++){let S=(i+1)*(w-1)+(b-1),M=(i+1)*w+(b-1),_=(i+1)*w+b,y=(i+1)*(w-1)+b;a.push(S,M,y),a.push(M,_,y)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(h,2));function v(w,b,S,M,_){let y=Math.cos(w),T=Math.sin(w),E=S/b*w,C=Math.cos(E);_.x=M*(2+C)*.5*y,_.y=M*(2+C)*T*.5,_.z=M*Math.sin(E)*.5}}static fromJSON(e){return new ma(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var xm=class extends cr{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Se(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},bm=class extends vt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Su=class extends cr{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Se(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},wm=class extends Su{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new O(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return nr(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Se(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Se(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Se(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Sm=class extends cr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Se(16777215),this.specular=new Se(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ru,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Am=class extends cr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Se(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Mm=class extends cr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},_m=class extends cr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Se(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ru,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Tm=class extends cr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Se(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Em=class extends Zr{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}},kD={ShadowMaterial:xm,SpriteMaterial:cm,RawShaderMaterial:bm,ShaderMaterial:vt,PointsMaterial:um,MeshPhysicalMaterial:wm,MeshStandardMaterial:Su,MeshPhongMaterial:Sm,MeshToonMaterial:Am,MeshNormalMaterial:Mm,MeshLambertMaterial:_m,MeshDepthMaterial:vu,MeshDistanceMaterial:xu,MeshBasicMaterial:Un,MeshMatcapMaterial:Tm,LineDashedMaterial:Em,LineBasicMaterial:Zr,Material:cr};cr.fromType=function(n){return new kD[n]};var lr={arraySlice:function(n,e,t){return lr.isTypedArray(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)},convertArray:function(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)},isTypedArray:function(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)},getKeyframeOrder:function(n){function e(i,s){return n[i]-n[s]}let t=n.length,r=new Array(t);for(let i=0;i!==t;++i)r[i]=i;return r.sort(e),r},sortedArray:function(n,e,t){let r=n.length,i=new n.constructor(r);for(let s=0,o=0;o!==r;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=n[a+l]}return i},flattenJSON:function(n,e,t,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(e.push(s.time),t.push(o)),s=n[i++];while(s!==void 0)},subclip:function(n,e,t,r,i=30){let s=n.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],h=c.getValueSize(),u=[],f=[];for(let d=0;d<c.times.length;++d){let m=c.times[d]*i;if(!(m<t||m>=r)){u.push(c.times[d]);for(let p=0;p<h;++p)f.push(c.values[d*h+p])}}u.length!==0&&(c.times=lr.convertArray(u,c.times.constructor),c.values=lr.convertArray(f,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(n,e=0,t=n,r=30){r<=0&&(r=30);let i=t.tracks.length,s=e/r;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let c=n.tracks.find(function(x){return x.name===a.name&&x.ValueTypeName===l});if(c===void 0)continue;let h=0,u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let f=0,d=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let m=a.times.length-1,p;if(s<=a.times[0]){let x=h,v=u-h;p=lr.arraySlice(a.values,x,v)}else if(s>=a.times[m]){let x=m*u+h,v=x+u-h;p=lr.arraySlice(a.values,x,v)}else{let x=a.createInterpolant(),v=h,w=u-h;x.evaluate(s),p=lr.arraySlice(x.resultBuffer,v,w)}l==="quaternion"&&new jt().fromArray(p).normalize().conjugate().toArray(p);let g=c.times.length;for(let x=0;x<g;++x){let v=x*d+f;if(l==="quaternion")jt.multiplyQuaternionsFlat(c.values,v,p,0,c.values,v);else{let w=d-f*2;for(let b=0;b<w;++b)c.values[v+b]-=p[b]}}}return n.blendMode=p_,n}},ga=class{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,r=this._cachedIndex,i=t[r],s=t[r-1];r:{e:{let o;t:{n:if(!(e<i)){for(let a=r+2;;){if(i===void 0){if(e<s)break n;return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=i,i=t[++r],e<i)break e}o=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=t[--r-1],e>=s)break e}o=r,r=0;break t}break r}for(;r<o;){let a=r+o>>>1;e<t[a]?o=a:r=a+1}if(i=t[r],s=t[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=r[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Cm=class extends ga{constructor(e,t,r,i){super(e,t,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Yv,endingEnd:Yv}}intervalChanged_(e,t,r){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Xv:s=e,a=2*t-r;break;case Jv:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case Xv:o=e,l=2*r-t;break;case Jv:o=1,l=r+i[1]-i[0];break;default:o=e-1,l=t}let c=(r-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-r),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(e,t,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,m=(r-t)/(i-t),p=m*m,g=p*m,x=-f*g+2*f*p-f*m,v=(1+f)*g+(-1.5-2*f)*p+(-.5+f)*m+1,w=(-1-d)*g+(1.5+d)*p+.5*m,b=d*g-d*p;for(let S=0;S!==a;++S)s[S]=x*o[h+S]+v*o[c+S]+w*o[l+S]+b*o[u+S];return s}},Dm=class extends ga{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(r-t)/(i-t),u=1-h;for(let f=0;f!==a;++f)s[f]=o[c+f]*u+o[l+f]*h;return s}},Pm=class extends ga{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Vn=class{constructor(e,t,r,i){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=lr.convertArray(t,this.TimeBufferType),this.values=lr.convertArray(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:lr.convertArray(e.times,Array),values:lr.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(r.interpolation=i)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new Pm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Cm(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case cu:t=this.InterpolantFactoryMethodDiscrete;break;case hu:t=this.InterpolantFactoryMethodLinear;break;case fp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let r="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(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return cu;case this.InterpolantFactoryMethodLinear:return hu;case this.InterpolantFactoryMethodSmooth:return fp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]*=e}return this}trim(e,t){let r=this.times,i=r.length,s=0,o=i-1;for(;s!==i&&r[s]<e;)++s;for(;o!==-1&&r[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=lr.arraySlice(r,s,o),this.values=lr.arraySlice(this.values,s*a,o*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 r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&lr.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=lr.arraySlice(this.times),t=lr.arraySlice(this.values),r=this.getValueSize(),i=this.getInterpolation()===fp,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(i)l=!0;else{let u=a*r,f=u-r,d=u+r;for(let m=0;m!==r;++m){let p=t[u+m];if(p!==t[f+m]||p!==t[d+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let u=a*r,f=o*r;for(let d=0;d!==r;++d)t[f+d]=t[u+d]}++o}}if(s>0){e[o]=e[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=lr.arraySlice(e,0,o),this.values=lr.arraySlice(t,0,o*r)):(this.times=e,this.values=t),this}clone(){let e=lr.arraySlice(this.times,0),t=lr.arraySlice(this.values,0),r=this.constructor,i=new r(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Vn.prototype.TimeBufferType=Float32Array;Vn.prototype.ValueBufferType=Float32Array;Vn.prototype.DefaultInterpolation=hu;var uo=class extends Vn{};uo.prototype.ValueTypeName="bool";uo.prototype.ValueBufferType=Array;uo.prototype.DefaultInterpolation=cu;uo.prototype.InterpolantFactoryMethodLinear=void 0;uo.prototype.InterpolantFactoryMethodSmooth=void 0;var Lm=class extends Vn{};Lm.prototype.ValueTypeName="color";var Im=class extends Vn{};Im.prototype.ValueTypeName="number";var Nm=class extends ga{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-t)/(i-t),c=e*a;for(let h=c+a;c!==h;c+=4)jt.slerpFlat(s,0,o,c-a,o,c,l);return s}},vc=class extends Vn{InterpolantFactoryMethodLinear(e){return new Nm(this.times,this.values,this.getValueSize(),e)}};vc.prototype.ValueTypeName="quaternion";vc.prototype.DefaultInterpolation=hu;vc.prototype.InterpolantFactoryMethodSmooth=void 0;var fo=class extends Vn{};fo.prototype.ValueTypeName="string";fo.prototype.ValueBufferType=Array;fo.prototype.DefaultInterpolation=cu;fo.prototype.InterpolantFactoryMethodLinear=void 0;fo.prototype.InterpolantFactoryMethodSmooth=void 0;var Bm=class extends Vn{};Bm.prototype.ValueTypeName="vector";var U0={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},po=class{constructor(e,t,r){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u<f;u+=2){let d=c[u],m=c[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return m}return null}}},VD=new po,xs=class{constructor(e){this.manager=e!==void 0?e:VD,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let r=this;return new Promise(function(i,s){r.load(e,i,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}},Oi={},bs=class extends xs{constructor(e){super(e)}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=U0.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Oi[e]!==void 0){Oi[e].push({onLoad:t,onProgress:r,onError:i});return}Oi[e]=[],Oi[e].push({onLoad:t,onProgress:r,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Oi[e],u=c.body.getReader(),f=c.headers.get("Content-Length"),d=f?parseInt(f):0,m=d!==0,p=0,g=new ReadableStream({start(x){v();function v(){u.read().then(({done:w,value:b})=>{if(w)x.close();else{p+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:d});for(let M=0,_=h.length;M<_;M++){let y=h[M];y.onProgress&&y.onProgress(S)}x.enqueue(b),v()}})}}});return new Response(g)}else throw Error(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(m=>d.decode(m))}}}).then(c=>{U0.add(e,c);let h=Oi[e];delete Oi[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onLoad&&d.onLoad(c)}}).catch(c=>{let h=Oi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Oi[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onError&&d.onError(c)}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}};var ws=class extends lt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Se(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}},mo=class extends ws{constructor(e,t,r){super(e,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(lt.DefaultUp),this.updateMatrix(),this.groundColor=new Se(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},G0=new Be,k0=new A,V0=new A,xc=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new O(512,512),this.map=null,this.mapPass=null,this.matrix=new Be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fc,this._frameExtents=new O(1,1),this._viewportCount=1,this._viewports=[new Ke(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,r=this.matrix;k0.setFromMatrixPosition(e.matrixWorld),t.position.copy(k0),V0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(V0),t.updateMatrixWorld(),G0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(G0),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(t.projectionMatrix),r.multiply(t.matrixWorldInverse)}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}},Om=class extends xc{constructor(){super(new Jt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,r=hc*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Au=class extends ws{constructor(e,t,r=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(lt.DefaultUp),this.updateMatrix(),this.target=new lt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Om}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}},H0=new Be,tc=new A,Hp=new A,Rm=class extends xc{constructor(){super(new Jt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new O(4,2),this._viewportCount=6,this._viewports=[new Ke(2,1,1,1),new Ke(0,1,1,1),new Ke(3,1,1,1),new Ke(1,1,1,1),new Ke(3,0,1,1),new Ke(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(e,t=0){let r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),tc.setFromMatrixPosition(e.matrixWorld),r.position.copy(tc),Hp.copy(r.position),Hp.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Hp),r.updateMatrixWorld(),i.makeTranslation(-tc.x,-tc.y,-tc.z),H0.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(H0)}},Mu=class extends ws{constructor(e,t,r=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Rm}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}},Fm=class extends xc{constructor(){super(new oa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},_u=class extends ws{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(lt.DefaultUp),this.updateMatrix(),this.target=new lt,this.shadow=new Fm}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var zm=class extends Le{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Ss=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},r,i)}parse(e){let t={},r={};function i(d,m){if(t[m]!==void 0)return t[m];let g=d.interleavedBuffers[m],x=s(d,g.buffer),v=Bh(g.type,x),w=new bu(v,g.stride);return w.uuid=g.uuid,t[m]=w,w}function s(d,m){if(r[m]!==void 0)return r[m];let g=d.arrayBuffers[m],x=new Uint32Array(g).buffer;return r[m]=x,x}let o=e.isInstancedBufferGeometry?new zm:new Le,a=e.data.index;if(a!==void 0){let d=Bh(a.type,a.array);o.setIndex(new Xe(d,1))}let l=e.data.attributes;for(let d in l){let m=l[d],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new oo(g,m.itemSize,m.offset,m.normalized)}else{let g=Bh(m.type,m.array),x=m.isInstancedBufferAttribute?hm:Xe;p=new x(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(d,p)}let c=e.data.morphAttributes;if(c)for(let d in c){let m=c[d],p=[];for(let g=0,x=m.length;g<x;g++){let v=m[g],w;if(v.isInterleavedBufferAttribute){let b=i(e.data,v.data);w=new oo(b,v.itemSize,v.offset,v.normalized)}else{let b=Bh(v.type,v.array);w=new Xe(b,v.itemSize,v.normalized)}v.name!==void 0&&(w.name=v.name),p.push(w)}o.morphAttributes[d]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,m=u.length;d!==m;++d){let p=u[d];o.addGroup(p.start,p.count,p.materialIndex)}let f=e.data.boundingSphere;if(f!==void 0){let d=new A;f.center!==void 0&&d.fromArray(f.center),o.boundingSphere=new Br(d,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var Tu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=W0(),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=W0();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function W0(){return(typeof performance>"u"?Date:performance).now()}var jm="\\[\\]\\.:\\/",HD=new RegExp("["+jm+"]","g"),qm="[^"+jm+"]",WD="[^"+jm.replace("\\.","")+"]",jD=/((?:WC+[\/:])*)/.source.replace("WC",qm),qD=/(WCOD+)?/.source.replace("WCOD",WD),YD=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",qm),XD=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",qm),JD=new RegExp("^"+jD+qD+YD+XD+"$"),QD=["material","materials","bones"],Um=class{constructor(e,t,r){let i=r||St.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,t)}setValue(e,t){let r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}},St=class{constructor(e,t,r){this.path=t,this.parsedPath=r||St.parseTrackName(t),this.node=St.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new St.Composite(e,t,r):new St(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(HD,"")}static parseTrackName(e){let t=JD.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=r.nodeName.substring(i+1);QD.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=r(a.children);if(l)return l}return null},i=r(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)e[t++]=r[i]}_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 r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=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,r=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=St.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(r){let c=t.objectIndex;switch(r){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===c){c=h;break}break;default:if(e[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[r]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[i];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" 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 l=this.BindingType.Direct;if(s!==void 0){if(i==="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])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};St.Composite=Um;St.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};St.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};St.prototype.GetterByBindingType=[St.prototype._getValue_direct,St.prototype._getValue_array,St.prototype._getValue_arrayElement,St.prototype._getValue_toArray];St.prototype.SetterByBindingTypeAndVersioning=[[St.prototype._setValue_direct,St.prototype._setValue_direct_setNeedsUpdate,St.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[St.prototype._setValue_array,St.prototype._setValue_array_setNeedsUpdate,St.prototype._setValue_array_setMatrixWorldNeedsUpdate],[St.prototype._setValue_arrayElement,St.prototype._setValue_arrayElement_setNeedsUpdate,St.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[St.prototype._setValue_fromArray,St.prototype._setValue_fromArray_setNeedsUpdate,St.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var we=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new we(this.value.clone===void 0?this.value:this.value.clone())}};var Eu=class{constructor(e,t,r=0,i=1/0){this.ray=new so(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new uc,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,r=[]){return Gm(e,this,r,t),r.sort(j0),r}intersectObjects(e,t=!0,r=[]){for(let i=0,s=e.length;i<s;i++)Gm(e[i],this,r,t);return r.sort(j0),r}};function j0(n,e){return n.distance-e.distance}function Gm(n,e,t,r){if(n.layers.test(e.layers)&&n.raycast(e,t),r===!0){let i=n.children;for(let s=0,o=i.length;s<o;s++)Gm(i[s],e,t,!0)}}var bc=class{constructor(e=1,t=0,r=0){return this.radius=e,this.phi=t,this.theta=r,this}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,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,r){return this.radius=Math.sqrt(e*e+t*t+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(nr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var q0=new A,su=new A,Cu=class{constructor(e=new A,t=new A){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){q0.subVectors(e,this.start),su.subVectors(this.end,this.start);let r=su.dot(su),s=su.dot(q0)/r;return t&&(s=nr(s,0,1)),s}closestPointToPoint(e,t,r){let i=this.closestPointToPointParameter(e,t);return this.delta(r).multiplyScalar(i).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)}},Y0=new A,Du=class extends lt{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let r=new Le,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,h=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}r.setAttribute("position",new Ae(i,3));let s=new Zr({fog:!1,toneMapped:!1});this.cone=new ys(r,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Y0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Y0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Pu=class extends ir{constructor(e,t,r){let i=new ho(t,4,2),s=new Un({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var X0=new A,ou=new A,J0=new A,Lu=class extends lt{constructor(e,t,r){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,t===void 0&&(t=1);let i=new Le;i.setAttribute("position",new Ae([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Zr({fog:!1,toneMapped:!1});this.lightPlane=new ao(i,s),this.add(this.lightPlane),i=new Le,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new ao(i,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(){X0.setFromMatrixPosition(this.light.matrixWorld),ou.setFromMatrixPosition(this.light.target.matrixWorld),J0.subVectors(ou,X0),this.lightPlane.lookAt(ou),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(ou),this.targetLine.scale.z=J0.length()}},au=new A,Vt=new Gn,An=class extends ys{constructor(e){let t=new Le,r=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={},a=new Se(16755200),l=new Se(16711680),c=new Se(43775),h=new Se(16777215),u=new Se(3355443);f("n1","n2",a),f("n2","n4",a),f("n4","n3",a),f("n3","n1",a),f("f1","f2",a),f("f2","f4",a),f("f4","f3",a),f("f3","f1",a),f("n1","f1",a),f("n2","f2",a),f("n3","f3",a),f("n4","f4",a),f("p","n1",l),f("p","n2",l),f("p","n3",l),f("p","n4",l),f("u1","u2",c),f("u2","u3",c),f("u3","u1",c),f("c","t",h),f("p","c",u),f("cn1","cn2",u),f("cn3","cn4",u),f("cf1","cf2",u),f("cf3","cf4",u);function f(m,p,g){d(m,g),d(p,g)}function d(m,p){i.push(0,0,0),s.push(p.r,p.g,p.b),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Ae(i,3)),t.setAttribute("color",new Ae(s,3)),super(t,r),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){let e=this.geometry,t=this.pointMap,r=1,i=1;Vt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Xt("c",t,e,Vt,0,0,-1),Xt("t",t,e,Vt,0,0,1),Xt("n1",t,e,Vt,-r,-i,-1),Xt("n2",t,e,Vt,r,-i,-1),Xt("n3",t,e,Vt,-r,i,-1),Xt("n4",t,e,Vt,r,i,-1),Xt("f1",t,e,Vt,-r,-i,1),Xt("f2",t,e,Vt,r,-i,1),Xt("f3",t,e,Vt,-r,i,1),Xt("f4",t,e,Vt,r,i,1),Xt("u1",t,e,Vt,r*.7,i*1.1,-1),Xt("u2",t,e,Vt,-r*.7,i*1.1,-1),Xt("u3",t,e,Vt,0,i*2,-1),Xt("cf1",t,e,Vt,-r,0,1),Xt("cf2",t,e,Vt,r,0,1),Xt("cf3",t,e,Vt,0,-i,1),Xt("cf4",t,e,Vt,0,i,1),Xt("cn1",t,e,Vt,-r,0,-1),Xt("cn2",t,e,Vt,r,0,-1),Xt("cn3",t,e,Vt,0,-i,-1),Xt("cn4",t,e,Vt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Xt(n,e,t,r,i,s,o){au.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],au.x,au.y,au.z)}}var go=class extends ys{constructor(e,t=16776960){let r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[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 Le;s.setIndex(new Xe(r,1)),s.setAttribute("position",new Ae(i,3)),super(s,new Zr({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))}};var Iu=class extends ys{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Le;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(r,3));let s=new Zr({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,r){let i=new Se,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Nu=class{constructor(){this.type="ShapePath",this.color=new Se,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new pc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}bezierCurveTo(e,t,r,i,s,o){return this.currentPath.bezierCurveTo(e,t,r,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function r(v){let w=[];for(let b=0,S=v.length;b<S;b++){let M=v[b],_=new Fn;_.curves=M.curves,w.push(_)}return w}function i(v,w){let b=w.length,S=!1;for(let M=b-1,_=0;_<b;M=_++){let y=w[M],T=w[_],E=T.x-y.x,C=T.y-y.y;if(Math.abs(C)>Number.EPSILON){if(C<0&&(y=w[_],E=-E,T=w[M],C=-C),v.y<y.y||v.y>T.y)continue;if(v.y===y.y){if(v.x===y.x)return!0}else{let I=C*(v.x-y.x)-E*(v.y-y.y);if(I===0)return!0;if(I<0)continue;S=!S}}else{if(v.y!==y.y)continue;if(T.x<=v.x&&v.x<=y.x||y.x<=v.x&&v.x<=T.x)return!0}}return S}let s=fs.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return r(o);let a,l,c,h=[];if(o.length===1)return l=o[0],c=new Fn,c.curves=l.curves,h.push(c),h;let u=!s(o[0].getPoints());u=e?!u:u;let f=[],d=[],m=[],p=0,g;d[p]=void 0,m[p]=[];for(let v=0,w=o.length;v<w;v++)l=o[v],g=l.getPoints(),a=s(g),a=e?!a:a,a?(!u&&d[p]&&p++,d[p]={s:new Fn,p:g},d[p].s.curves=l.curves,u&&p++,m[p]=[]):m[p].push({h:l,p:g[0]});if(!d[0])return r(o);if(d.length>1){let v=!1,w=0;for(let b=0,S=d.length;b<S;b++)f[b]=[];for(let b=0,S=d.length;b<S;b++){let M=m[b];for(let _=0;_<M.length;_++){let y=M[_],T=!0;for(let E=0;E<d.length;E++)i(y.p,d[E].p)&&(b!==E&&w++,T?(T=!1,f[E].push(y)):v=!0);T&&f[b].push(y)}}w>0&&v===!1&&(m=f)}let x;for(let v=0,w=d.length;v<w;v++){c=d[v].s,h.push(c),x=m[v];for(let b=0,S=x.length;b<S;b++)c.holes.push(x[b].h)}return h}};var ux=new ArrayBuffer(4),sU=new Float32Array(ux),oU=new Uint32Array(ux),si=new Uint32Array(512),oi=new Uint32Array(512);for(let n=0;n<256;++n){let e=n-127;e<-27?(si[n]=0,si[n|256]=32768,oi[n]=24,oi[n|256]=24):e<-14?(si[n]=1024>>-e-14,si[n|256]=1024>>-e-14|32768,oi[n]=-e-1,oi[n|256]=-e-1):e<=15?(si[n]=e+15<<10,si[n|256]=e+15<<10|32768,oi[n]=13,oi[n|256]=13):e<128?(si[n]=31744,si[n|256]=64512,oi[n]=24,oi[n|256]=24):(si[n]=31744,si[n|256]=64512,oi[n]=13,oi[n|256]=13)}var fx=new Uint32Array(2048),wc=new Uint32Array(64),KD=new Uint32Array(64);for(let n=1;n<1024;++n){let e=n<<13,t=0;for(;(e&8388608)===0;)e<<=1,t-=8388608;e&=-8388609,t+=947912704,fx[n]=e|t}for(let n=1024;n<2048;++n)fx[n]=939524096+(n-1024<<13);for(let n=1;n<31;++n)wc[n]=n<<23;wc[31]=1199570944;wc[32]=2147483648;for(let n=33;n<63;++n)wc[n]=2147483648+(n-32<<23);wc[63]=3347054592;for(let n=1;n<64;++n)n!==32&&(KD[n]=1024);var Bu=class extends ut{constructor(e,t,r){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,r),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=yo);var ba=".",Sc=Symbol("target"),Ym=Symbol("unsubscribe");function Ac(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function dx(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var dn=Array.isArray;function vo(n){return typeof n=="symbol"}var ZD={after:(n,e)=>dn(n)?n.slice(e.length):e===""?n:n.slice(e.length+1),concat:(n,e)=>dn(n)?(n=[...n],e&&n.push(e),n):e&&e.toString!==void 0?(n!==""&&(n+=ba),vo(e)?n+e.toString():n+e):n,initial:n=>{if(dn(n))return n.slice(0,-1);if(n==="")return n;let e=n.lastIndexOf(ba);return e===-1?"":n.slice(0,e)},last:n=>{if(dn(n))return n[n.length-1]||"";if(n==="")return n;let e=n.lastIndexOf(ba);return e===-1?n:n.slice(e+1)},walk:(n,e)=>{if(dn(n))for(let t of n)e(t);else if(n!==""){let t=0,r=n.indexOf(ba);if(r===-1)e(n);else for(;t<n.length;)r===-1&&(r=n.length),e(n.slice(t,r)),t=r+1,r=n.indexOf(ba,t)}},get(n,e){return this.walk(e,t=>{n&&(n=n[t])}),n}},Hr=ZD;function Xm(n){return typeof n=="object"&&typeof n.next=="function"}function Jm(n,e,t,r,i){let s=n.next;if(e.name==="entries")n.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],r),o.value[1]=i(o.value[1],e,o.value[0],r)),o};else if(e.name==="values"){let o=t[Sc].keys();n.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,r)),a}}else n.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,r)),o};return n}function Gu(n,e,t){return n.isUnsubscribed||e.ignoreSymbols&&vo(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Mc=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(),r=t.get(e);return r===void 0&&(r={},t.set(e,r)),r}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let r=this._getProperties(e),i=r[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),r[t]=i),i}getProxy(e,t,r,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,r):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Hr.get(t,this.getPath(e)))}defineProperty(e,t,r){return Reflect.defineProperty(e,t,r)?(this.isUnsubscribed||(this._getProperties(e)[t]=r),!0):!1}setProperty(e,t,r,i,s){if(!this._equals(s,r)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,r,i):Reflect.set(e,t,r)}return!0}deleteProperty(e,t,r){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(e,t,r){let i=this._getOwnPropertyDescriptor(t,r);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let r=this._getOwnPropertyDescriptor(e,t);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function wa(n){return toString.call(n)==="[object Object]"}function Sa(){return!0}function Ms(n,e){return n.length!==e.length||n.some((t,r)=>e[r]!==t)}var ku=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var $D=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Qm={push:Sa,pop:Sa,shift:Sa,unshift:Sa,copyWithin:Ms,reverse:Ms,sort:Ms,splice:Ms,flat:Ms,fill:Ms},px=new Set([...ku,...$D,...Object.keys(Qm)]);function Aa(n,e){if(n.size!==e.size)return!0;for(let t of n)if(!e.has(t))return!0;return!1}var Km=["keys","values","entries"],Zm=new Set(["has","toString"]),$m={add:Aa,clear:Aa,delete:Aa,forEach:Aa},mx=new Set([...Zm,...Object.keys($m),...Km]);function Ma(n,e){if(n.size!==e.size)return!0;let t;for(let[r,i]of n)if(t=e.get(r),t!==i||t===void 0&&!e.has(r))return!0;return!1}var eP=new Set([...Zm,"get"]),eg={set:Ma,clear:Ma,delete:Ma,forEach:Ma},gx=new Set([...eP,...Object.keys(eg),...Km]);var xr=class{constructor(e,t,r,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return ku.has(e)}_shallowClone(e){let t=e;if(wa(e))t={...e};else if(dn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(r=>this._shallowClone(r)));else if(e instanceof Map){t=new Map;for(let[r,i]of e.entries())t.set(r,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,r,i){return e?(dn(i)?this._onIsChanged=Qm[t]:i instanceof Set?this._onIsChanged=$m[t]:i instanceof Map&&(this._onIsChanged=eg[t]),i):r}update(e,t,r){let i=Hr.after(e,this._path);if(t!=="length"){let s=this.clone;Hr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:r}),s&&s[t]&&(s[t]=r)}this._isChanged=!0}undo(e){let t;for(let r=this._changes.length-1;r!==-1;r--)t=this._changes[r],Hr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var _a=class extends xr{static isHandledMethod(e){return px.has(e)}};var _c=class extends xr{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var Ta=class extends xr{static isHandledMethod(e){return mx.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)}};var Ea=class extends xr{static isHandledMethod(e){return gx.has(e)}undo(e){for(let[t,r]of this.clone.entries())e.set(t,r);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Tc=class extends xr{constructor(e,t,r,i){super(void 0,t,r,i),this._arg1=r[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)}};var Ec=class extends xr{constructor(e,t,r,i){super(void 0,t,r,i),this._weakKey=r[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)}};var Wn=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return wa(e)||dn(e)||Ac(e)}static isHandledMethod(e,t){return wa(e)?xr.isHandledMethod(t):dn(e)?_a.isHandledMethod(t):e instanceof Set?Ta.isHandledMethod(t):e instanceof Map?Ea.isHandledMethod(t):Ac(e)}get isCloning(){return this._stack.length>0}start(e,t,r){let i=xr;dn(e)?i=_a:e instanceof Date?i=_c:e instanceof Set?i=Ta:e instanceof Map?i=Ea:e instanceof WeakSet?i=Tc:e instanceof WeakMap&&(i=Ec),this._stack.push(new i(e,t,r,this._hasOnValidate))}update(e,t,r){this._stack[this._stack.length-1].update(e,t,r)}preferredThisArg(e,t,r){let{name:i}=e,s=Wn.isHandledMethod(r,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,r)}isChanged(e,t,r){return this._stack[this._stack.length-1].isChanged(e,t,r)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var tP={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},tg=(n,e,t={})=>{t={...tP,...t};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new Mc(i),c=typeof t.onValidate=="function",h=new Wn(c),u=(v,w,b,S,M)=>!c||h.isCloning||t.onValidate(Hr.concat(l.getPath(v),w),b,S,M)===!0,f=(v,w,b,S)=>{!Gu(l,t,w)&&!(o&&l.isDetached(v,n))&&d(l.getPath(v),w,b,S)},d=(v,w,b,S,M)=>{h.isCloning?h.update(v,w,S):e(Hr.concat(v,w),b,S,M)},m=v=>v&&(v[r]||v),p=(v,w,b,S)=>dx(v)||b==="constructor"||s&&!Wn.isHandledMethod(w,b)||Gu(l,t,b)||l.isGetInvariant(w,b)||o&&l.isDetached(w,n)?v:(S===void 0&&(S=l.getPath(w)),l.getProxy(v,Hr.concat(S,b),g,r)),g={get(v,w,b){if(vo(w)){if(w===r||w===Sc)return v;if(w===Ym&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Ac(v)?Reflect.get(v,w):Reflect.get(v,w,b);return p(S,v,w)},set(v,w,b,S){b=m(b);let M=v[r]||v,_=M[w];if(i(_,b)&&w in v)return!0;let y=u(v,w,b,_);return y&&l.setProperty(M,w,b,S,_)?(f(v,w,v[w],_),!0):!y},defineProperty(v,w,b){if(!l.isSameDescriptor(b,v,w)){let S=v[w];u(v,w,b.value,S)&&l.defineProperty(v,w,b,S)&&f(v,w,b.value,S)}return!0},deleteProperty(v,w){if(!Reflect.has(v,w))return!0;let b=Reflect.get(v,w),S=u(v,w,void 0,b);return S&&l.deleteProperty(v,w,b)?(f(v,w,void 0,b),!0):!S},apply(v,w,b){let S=w[r]||w;if(l.isUnsubscribed)return Reflect.apply(v,S,b);if((a===!1||a!==!0&&!a.includes(v.name))&&Wn.isHandledType(S)){let M=Hr.initial(l.getPath(v)),_=Wn.isHandledMethod(S,v.name);h.start(S,M,b);let y=Reflect.apply(v,h.preferredThisArg(v,w,S),_?b.map(C=>m(C)):b),T=h.isChanged(S,i),E=h.stop();if(Wn.isHandledType(y)&&_&&(w instanceof Map&&v.name==="get"&&(M=Hr.concat(M,b[0])),y=l.getProxy(y,M,g)),T){let C={name:v.name,args:b,result:y},I=h.isCloning?Hr.initial(M):M,B=h.isCloning?Hr.last(M):"";u(Hr.get(n,I),B,S,E,C)?d(I,B,S,E,C):h.undo(S)}return(w instanceof Map||w instanceof Set)&&Xm(y)?Jm(y,v,w,M,p):y}return Reflect.apply(v,w,b)}},x=l.getProxy(n,t.pathAsArray?[]:"",g);return e=e.bind(x),c&&(t.onValidate=t.onValidate.bind(x)),x};tg.target=n=>n&&n[Sc]||n;tg.unsubscribe=n=>n[Ym]||n;var rg=tg;var rP=typeof global=="object"&&global&&global.Object===Object&&global,Vu=rP;var nP=typeof self=="object"&&self&&self.Object===Object&&self,iP=Vu||nP||Function("return this")(),qt=iP;var sP=qt.Symbol,Wr=sP;var yx=Object.prototype,oP=yx.hasOwnProperty,aP=yx.toString,Cc=Wr?Wr.toStringTag:void 0;function lP(n){var e=oP.call(n,Cc),t=n[Cc];try{n[Cc]=void 0;var r=!0}catch{}var i=aP.call(n);return r&&(e?n[Cc]=t:delete n[Cc]),i}var vx=lP;var cP=Object.prototype,hP=cP.toString;function uP(n){return hP.call(n)}var xx=uP;var fP="[object Null]",dP="[object Undefined]",bx=Wr?Wr.toStringTag:void 0;function pP(n){return n==null?n===void 0?dP:fP:bx&&bx in Object(n)?vx(n):xx(n)}var pn=pP;function mP(n){return n!=null&&typeof n=="object"}var Or=mP;var gP="[object Symbol]";function yP(n){return typeof n=="symbol"||Or(n)&&pn(n)==gP}var _s=yP;function vP(n,e){for(var t=-1,r=n==null?0:n.length,i=Array(r);++t<r;)i[t]=e(n[t],t,n);return i}var Hu=vP;var xP=Array.isArray,Tr=xP;var bP=1/0,wx=Wr?Wr.prototype:void 0,Sx=wx?wx.toString:void 0;function Ax(n){if(typeof n=="string")return n;if(Tr(n))return Hu(n,Ax)+"";if(_s(n))return Sx?Sx.call(n):"";var e=n+"";return e=="0"&&1/n==-bP?"-0":e}var Mx=Ax;var wP=/\s/;function SP(n){for(var e=n.length;e--&&wP.test(n.charAt(e)););return e}var _x=SP;var AP=/^\s+/;function MP(n){return n&&n.slice(0,_x(n)+1).replace(AP,"")}var Tx=MP;function _P(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Qt=_P;var Ex=0/0,TP=/^[-+]0x[0-9a-f]+$/i,EP=/^0b[01]+$/i,CP=/^0o[0-7]+$/i,DP=parseInt;function PP(n){if(typeof n=="number")return n;if(_s(n))return Ex;if(Qt(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Qt(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=Tx(n);var t=EP.test(n);return t||CP.test(n)?DP(n.slice(2),t?2:8):TP.test(n)?Ex:+n}var ng=PP;function LP(n){return n}var Wu=LP;var IP="[object AsyncFunction]",NP="[object Function]",BP="[object GeneratorFunction]",OP="[object Proxy]";function RP(n){if(!Qt(n))return!1;var e=pn(n);return e==NP||e==BP||e==IP||e==OP}var Ca=RP;var FP=qt["__core-js_shared__"],ju=FP;var Cx=function(){var n=/[^.]+$/.exec(ju&&ju.keys&&ju.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function zP(n){return!!Cx&&Cx in n}var Dx=zP;var UP=Function.prototype,GP=UP.toString;function kP(n){if(n!=null){try{return GP.call(n)}catch{}try{return n+""}catch{}}return""}var Gi=kP;var VP=/[\\^$.*+?()[\]{}|]/g,HP=/^\[object .+?Constructor\]$/,WP=Function.prototype,jP=Object.prototype,qP=WP.toString,YP=jP.hasOwnProperty,XP=RegExp("^"+qP.call(YP).replace(VP,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function JP(n){if(!Qt(n)||Dx(n))return!1;var e=Ca(n)?XP:HP;return e.test(Gi(n))}var Px=JP;function QP(n,e){return n?.[e]}var Lx=QP;function KP(n,e){var t=Lx(n,e);return Px(t)?t:void 0}var tn=KP;var ZP=tn(qt,"WeakMap"),qu=ZP;var Ix=Object.create,$P=function(){function n(){}return function(e){if(!Qt(e))return{};if(Ix)return Ix(e);n.prototype=e;var t=new n;return n.prototype=void 0,t}}(),Nx=$P;function eL(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}var Bx=eL;function tL(n,e){var t=-1,r=n.length;for(e||(e=Array(r));++t<r;)e[t]=n[t];return e}var Yu=tL;var rL=800,nL=16,iL=Date.now;function sL(n){var e=0,t=0;return function(){var r=iL(),i=nL-(r-t);if(t=r,i>0){if(++e>=rL)return arguments[0]}else e=0;return n.apply(void 0,arguments)}}var Ox=sL;function oL(n){return function(){return n}}var Rx=oL;var aL=function(){try{var n=tn(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Da=aL;var lL=Da?function(n,e){return Da(n,"toString",{configurable:!0,enumerable:!1,value:Rx(e),writable:!0})}:Wu,Fx=lL;var cL=Ox(Fx),Xu=cL;function hL(n,e){for(var t=-1,r=n==null?0:n.length;++t<r&&e(n[t],t,n)!==!1;);return n}var zx=hL;var uL=9007199254740991,fL=/^(?:0|[1-9]\d*)$/;function dL(n,e){var t=typeof n;return e=e??uL,!!e&&(t=="number"||t!="symbol"&&fL.test(n))&&n>-1&&n%1==0&&n<e}var Ju=dL;function pL(n,e,t){e=="__proto__"&&Da?Da(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):n[e]=t}var Pa=pL;function mL(n,e){return n===e||n!==n&&e!==e}var Ts=mL;var gL=Object.prototype,yL=gL.hasOwnProperty;function vL(n,e,t){var r=n[e];(!(yL.call(n,e)&&Ts(r,t))||t===void 0&&!(e in n))&&Pa(n,e,t)}var Qu=vL;function xL(n,e,t,r){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=r?r(t[a],n[a],a,t,n):void 0;l===void 0&&(l=n[a]),i?Pa(t,a,l):Qu(t,a,l)}return t}var Mn=xL;var Ux=Math.max;function bL(n,e,t){return e=Ux(e===void 0?n.length-1:e,0),function(){for(var r=arguments,i=-1,s=Ux(r.length-e,0),o=Array(s);++i<s;)o[i]=r[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=r[i];return a[e]=t(o),Bx(n,this,a)}}var Ku=bL;function wL(n,e){return Xu(Ku(n,e,Wu),n+"")}var Gx=wL;var SL=9007199254740991;function AL(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=SL}var Zu=AL;function ML(n){return n!=null&&Zu(n.length)&&!Ca(n)}var Es=ML;function _L(n,e,t){if(!Qt(t))return!1;var r=typeof e;return(r=="number"?Es(t)&&Ju(e,t.length):r=="string"&&e in t)?Ts(t[e],n):!1}var kx=_L;function TL(n){return Gx(function(e,t){var r=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=n.length>3&&typeof s=="function"?(i--,s):void 0,o&&kx(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++r<i;){var a=t[r];a&&n(e,a,r,s)}return e})}var Vx=TL;var EL=Object.prototype;function CL(n){var e=n&&n.constructor,t=typeof e=="function"&&e.prototype||EL;return n===t}var La=CL;function DL(n,e){for(var t=-1,r=Array(n);++t<n;)r[t]=e(t);return r}var Hx=DL;var PL="[object Arguments]";function LL(n){return Or(n)&&pn(n)==PL}var ig=LL;var Wx=Object.prototype,IL=Wx.hasOwnProperty,NL=Wx.propertyIsEnumerable,BL=ig(function(){return arguments}())?ig:function(n){return Or(n)&&IL.call(n,"callee")&&!NL.call(n,"callee")},xo=BL;function OL(){return!1}var jx=OL;var Xx=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qx=Xx&&typeof module=="object"&&module&&!module.nodeType&&module,RL=qx&&qx.exports===Xx,Yx=RL?qt.Buffer:void 0,FL=Yx?Yx.isBuffer:void 0,zL=FL||jx,Ia=zL;var UL="[object Arguments]",GL="[object Array]",kL="[object Boolean]",VL="[object Date]",HL="[object Error]",WL="[object Function]",jL="[object Map]",qL="[object Number]",YL="[object Object]",XL="[object RegExp]",JL="[object Set]",QL="[object String]",KL="[object WeakMap]",ZL="[object ArrayBuffer]",$L="[object DataView]",eI="[object Float32Array]",tI="[object Float64Array]",rI="[object Int8Array]",nI="[object Int16Array]",iI="[object Int32Array]",sI="[object Uint8Array]",oI="[object Uint8ClampedArray]",aI="[object Uint16Array]",lI="[object Uint32Array]",Bt={};Bt[eI]=Bt[tI]=Bt[rI]=Bt[nI]=Bt[iI]=Bt[sI]=Bt[oI]=Bt[aI]=Bt[lI]=!0;Bt[UL]=Bt[GL]=Bt[ZL]=Bt[kL]=Bt[$L]=Bt[VL]=Bt[HL]=Bt[WL]=Bt[jL]=Bt[qL]=Bt[YL]=Bt[XL]=Bt[JL]=Bt[QL]=Bt[KL]=!1;function cI(n){return Or(n)&&Zu(n.length)&&!!Bt[pn(n)]}var Jx=cI;function hI(n){return function(e){return n(e)}}var Na=hI;var Qx=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dc=Qx&&typeof module=="object"&&module&&!module.nodeType&&module,uI=Dc&&Dc.exports===Qx,sg=uI&&Vu.process,fI=function(){try{var n=Dc&&Dc.require&&Dc.require("util").types;return n||sg&&sg.binding&&sg.binding("util")}catch{}}(),ki=fI;var Kx=ki&&ki.isTypedArray,dI=Kx?Na(Kx):Jx,$u=dI;var pI=Object.prototype,mI=pI.hasOwnProperty;function gI(n,e){var t=Tr(n),r=!t&&xo(n),i=!t&&!r&&Ia(n),s=!t&&!r&&!i&&$u(n),o=t||r||i||s,a=o?Hx(n.length,String):[],l=a.length;for(var c in n)(e||mI.call(n,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ju(c,l)))&&a.push(c);return a}var ef=gI;function yI(n,e){return function(t){return n(e(t))}}var tf=yI;var vI=tf(Object.keys,Object),Zx=vI;var xI=Object.prototype,bI=xI.hasOwnProperty;function wI(n){if(!La(n))return Zx(n);var e=[];for(var t in Object(n))bI.call(n,t)&&t!="constructor"&&e.push(t);return e}var $x=wI;function SI(n){return Es(n)?ef(n):$x(n)}var Ba=SI;function AI(n){var e=[];if(n!=null)for(var t in Object(n))e.push(t);return e}var eb=AI;var MI=Object.prototype,_I=MI.hasOwnProperty;function TI(n){if(!Qt(n))return eb(n);var e=La(n),t=[];for(var r in n)r=="constructor"&&(e||!_I.call(n,r))||t.push(r);return t}var tb=TI;function EI(n){return Es(n)?ef(n,!0):tb(n)}var hi=EI;var CI=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,DI=/^\w*$/;function PI(n,e){if(Tr(n))return!1;var t=typeof n;return t=="number"||t=="symbol"||t=="boolean"||n==null||_s(n)?!0:DI.test(n)||!CI.test(n)||e!=null&&n in Object(e)}var rb=PI;var LI=tn(Object,"create"),Vi=LI;function II(){this.__data__=Vi?Vi(null):{},this.size=0}var nb=II;function NI(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}var ib=NI;var BI="__lodash_hash_undefined__",OI=Object.prototype,RI=OI.hasOwnProperty;function FI(n){var e=this.__data__;if(Vi){var t=e[n];return t===BI?void 0:t}return RI.call(e,n)?e[n]:void 0}var sb=FI;var zI=Object.prototype,UI=zI.hasOwnProperty;function GI(n){var e=this.__data__;return Vi?e[n]!==void 0:UI.call(e,n)}var ob=GI;var kI="__lodash_hash_undefined__";function VI(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=Vi&&e===void 0?kI:e,this}var ab=VI;function Oa(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}Oa.prototype.clear=nb;Oa.prototype.delete=ib;Oa.prototype.get=sb;Oa.prototype.has=ob;Oa.prototype.set=ab;var og=Oa;function HI(){this.__data__=[],this.size=0}var lb=HI;function WI(n,e){for(var t=n.length;t--;)if(Ts(n[t][0],e))return t;return-1}var Cs=WI;var jI=Array.prototype,qI=jI.splice;function YI(n){var e=this.__data__,t=Cs(e,n);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():qI.call(e,t,1),--this.size,!0}var cb=YI;function XI(n){var e=this.__data__,t=Cs(e,n);return t<0?void 0:e[t][1]}var hb=XI;function JI(n){return Cs(this.__data__,n)>-1}var ub=JI;function QI(n,e){var t=this.__data__,r=Cs(t,n);return r<0?(++this.size,t.push([n,e])):t[r][1]=e,this}var fb=QI;function Ra(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}Ra.prototype.clear=lb;Ra.prototype.delete=cb;Ra.prototype.get=hb;Ra.prototype.has=ub;Ra.prototype.set=fb;var Ds=Ra;var KI=tn(qt,"Map"),Ps=KI;function ZI(){this.size=0,this.__data__={hash:new og,map:new(Ps||Ds),string:new og}}var db=ZI;function $I(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}var pb=$I;function eN(n,e){var t=n.__data__;return pb(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Ls=eN;function tN(n){var e=Ls(this,n).delete(n);return this.size-=e?1:0,e}var mb=tN;function rN(n){return Ls(this,n).get(n)}var gb=rN;function nN(n){return Ls(this,n).has(n)}var yb=nN;function iN(n,e){var t=Ls(this,n),r=t.size;return t.set(n,e),this.size+=t.size==r?0:1,this}var vb=iN;function Fa(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}Fa.prototype.clear=db;Fa.prototype.delete=mb;Fa.prototype.get=gb;Fa.prototype.has=yb;Fa.prototype.set=vb;var Pc=Fa;var sN="Expected a function";function ag(n,e){if(typeof n!="function"||e!=null&&typeof e!="function")throw new TypeError(sN);var t=function(){var r=arguments,i=e?e.apply(this,r):r[0],s=t.cache;if(s.has(i))return s.get(i);var o=n.apply(this,r);return t.cache=s.set(i,o)||s,o};return t.cache=new(ag.Cache||Pc),t}ag.Cache=Pc;var xb=ag;var oN=500;function aN(n){var e=xb(n,function(r){return t.size===oN&&t.clear(),r}),t=e.cache;return e}var bb=aN;var lN=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cN=/\\(\\)?/g,hN=bb(function(n){var e=[];return n.charCodeAt(0)===46&&e.push(""),n.replace(lN,function(t,r,i,s){e.push(i?s.replace(cN,"$1"):r||t)}),e}),wb=hN;function uN(n){return n==null?"":Mx(n)}var Sb=uN;function fN(n,e){return Tr(n)?n:rb(n,e)?[n]:wb(Sb(n))}var za=fN;var dN=1/0;function pN(n){if(typeof n=="string"||_s(n))return n;var e=n+"";return e=="0"&&1/n==-dN?"-0":e}var rf=pN;function mN(n,e){e=za(e,n);for(var t=0,r=e.length;n!=null&&t<r;)n=n[rf(e[t++])];return t&&t==r?n:void 0}var Ab=mN;function gN(n,e){for(var t=-1,r=e.length,i=n.length;++t<r;)n[i+t]=e[t];return n}var Ua=gN;var Mb=Wr?Wr.isConcatSpreadable:void 0;function yN(n){return Tr(n)||xo(n)||!!(Mb&&n&&n[Mb])}var _b=yN;function Tb(n,e,t,r,i){var s=-1,o=n.length;for(t||(t=_b),i||(i=[]);++s<o;){var a=n[s];e>0&&t(a)?e>1?Tb(a,e-1,t,r,i):Ua(i,a):r||(i[i.length]=a)}return i}var Eb=Tb;function vN(n){var e=n==null?0:n.length;return e?Eb(n,1):[]}var Cb=vN;function xN(n){return Xu(Ku(n,void 0,Cb),n+"")}var Db=xN;var bN=tf(Object.getPrototypeOf,Object),Ga=bN;var wN="[object Object]",SN=Function.prototype,AN=Object.prototype,Pb=SN.toString,MN=AN.hasOwnProperty,_N=Pb.call(Object);function TN(n){if(!Or(n)||pn(n)!=wN)return!1;var e=Ga(n);if(e===null)return!0;var t=MN.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Pb.call(t)==_N}var nf=TN;function EN(n,e,t){var r=-1,i=n.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++r<i;)s[r]=n[r+e];return s}var Lb=EN;function CN(){this.__data__=new Ds,this.size=0}var Ib=CN;function DN(n){var e=this.__data__,t=e.delete(n);return this.size=e.size,t}var Nb=DN;function PN(n){return this.__data__.get(n)}var Bb=PN;function LN(n){return this.__data__.has(n)}var Ob=LN;var IN=200;function NN(n,e){var t=this.__data__;if(t instanceof Ds){var r=t.__data__;if(!Ps||r.length<IN-1)return r.push([n,e]),this.size=++t.size,this;t=this.__data__=new Pc(r)}return t.set(n,e),this.size=t.size,this}var Rb=NN;function ka(n){var e=this.__data__=new Ds(n);this.size=e.size}ka.prototype.clear=Ib;ka.prototype.delete=Nb;ka.prototype.get=Bb;ka.prototype.has=Ob;ka.prototype.set=Rb;var sf=ka;function BN(n,e){return n&&Mn(e,Ba(e),n)}var Fb=BN;function ON(n,e){return n&&Mn(e,hi(e),n)}var zb=ON;var Vb=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ub=Vb&&typeof module=="object"&&module&&!module.nodeType&&module,RN=Ub&&Ub.exports===Vb,Gb=RN?qt.Buffer:void 0,kb=Gb?Gb.allocUnsafe:void 0;function FN(n,e){if(e)return n.slice();var t=n.length,r=kb?kb(t):new n.constructor(t);return n.copy(r),r}var of=FN;function zN(n,e){for(var t=-1,r=n==null?0:n.length,i=0,s=[];++t<r;){var o=n[t];e(o,t,n)&&(s[i++]=o)}return s}var Hb=zN;function UN(){return[]}var af=UN;var GN=Object.prototype,kN=GN.propertyIsEnumerable,Wb=Object.getOwnPropertySymbols,VN=Wb?function(n){return n==null?[]:(n=Object(n),Hb(Wb(n),function(e){return kN.call(n,e)}))}:af,Va=VN;function HN(n,e){return Mn(n,Va(n),e)}var jb=HN;var WN=Object.getOwnPropertySymbols,jN=WN?function(n){for(var e=[];n;)Ua(e,Va(n)),n=Ga(n);return e}:af,lf=jN;function qN(n,e){return Mn(n,lf(n),e)}var qb=qN;function YN(n,e,t){var r=e(n);return Tr(n)?r:Ua(r,t(n))}var cf=YN;function XN(n){return cf(n,Ba,Va)}var Yb=XN;function JN(n){return cf(n,hi,lf)}var hf=JN;var QN=tn(qt,"DataView"),uf=QN;var KN=tn(qt,"Promise"),ff=KN;var ZN=tn(qt,"Set"),df=ZN;var Xb="[object Map]",$N="[object Object]",Jb="[object Promise]",Qb="[object Set]",Kb="[object WeakMap]",Zb="[object DataView]",e3=Gi(uf),t3=Gi(Ps),r3=Gi(ff),n3=Gi(df),i3=Gi(qu),bo=pn;(uf&&bo(new uf(new ArrayBuffer(1)))!=Zb||Ps&&bo(new Ps)!=Xb||ff&&bo(ff.resolve())!=Jb||df&&bo(new df)!=Qb||qu&&bo(new qu)!=Kb)&&(bo=function(n){var e=pn(n),t=e==$N?n.constructor:void 0,r=t?Gi(t):"";if(r)switch(r){case e3:return Zb;case t3:return Xb;case r3:return Jb;case n3:return Qb;case i3:return Kb}return e});var Ha=bo;var s3=Object.prototype,o3=s3.hasOwnProperty;function a3(n){var e=n.length,t=new n.constructor(e);return e&&typeof n[0]=="string"&&o3.call(n,"index")&&(t.index=n.index,t.input=n.input),t}var $b=a3;var l3=qt.Uint8Array,lg=l3;function c3(n){var e=new n.constructor(n.byteLength);return new lg(e).set(new lg(n)),e}var Wa=c3;function h3(n,e){var t=e?Wa(n.buffer):n.buffer;return new n.constructor(t,n.byteOffset,n.byteLength)}var ew=h3;var u3=/\w*$/;function f3(n){var e=new n.constructor(n.source,u3.exec(n));return e.lastIndex=n.lastIndex,e}var tw=f3;var rw=Wr?Wr.prototype:void 0,nw=rw?rw.valueOf:void 0;function d3(n){return nw?Object(nw.call(n)):{}}var iw=d3;function p3(n,e){var t=e?Wa(n.buffer):n.buffer;return new n.constructor(t,n.byteOffset,n.length)}var pf=p3;var m3="[object Boolean]",g3="[object Date]",y3="[object Map]",v3="[object Number]",x3="[object RegExp]",b3="[object Set]",w3="[object String]",S3="[object Symbol]",A3="[object ArrayBuffer]",M3="[object DataView]",_3="[object Float32Array]",T3="[object Float64Array]",E3="[object Int8Array]",C3="[object Int16Array]",D3="[object Int32Array]",P3="[object Uint8Array]",L3="[object Uint8ClampedArray]",I3="[object Uint16Array]",N3="[object Uint32Array]";function B3(n,e,t){var r=n.constructor;switch(e){case A3:return Wa(n);case m3:case g3:return new r(+n);case M3:return ew(n,t);case _3:case T3:case E3:case C3:case D3:case P3:case L3:case I3:case N3:return pf(n,t);case y3:return new r;case v3:case w3:return new r(n);case x3:return tw(n);case b3:return new r;case S3:return iw(n)}}var sw=B3;function O3(n){return typeof n.constructor=="function"&&!La(n)?Nx(Ga(n)):{}}var mf=O3;var R3="[object Map]";function F3(n){return Or(n)&&Ha(n)==R3}var ow=F3;var aw=ki&&ki.isMap,z3=aw?Na(aw):ow,lw=z3;var U3="[object Set]";function G3(n){return Or(n)&&Ha(n)==U3}var cw=G3;var hw=ki&&ki.isSet,k3=hw?Na(hw):cw,uw=k3;var V3=1,H3=2,W3=4,fw="[object Arguments]",j3="[object Array]",q3="[object Boolean]",Y3="[object Date]",X3="[object Error]",dw="[object Function]",J3="[object GeneratorFunction]",Q3="[object Map]",K3="[object Number]",pw="[object Object]",Z3="[object RegExp]",$3="[object Set]",eB="[object String]",tB="[object Symbol]",rB="[object WeakMap]",nB="[object ArrayBuffer]",iB="[object DataView]",sB="[object Float32Array]",oB="[object Float64Array]",aB="[object Int8Array]",lB="[object Int16Array]",cB="[object Int32Array]",hB="[object Uint8Array]",uB="[object Uint8ClampedArray]",fB="[object Uint16Array]",dB="[object Uint32Array]",Pt={};Pt[fw]=Pt[j3]=Pt[nB]=Pt[iB]=Pt[q3]=Pt[Y3]=Pt[sB]=Pt[oB]=Pt[aB]=Pt[lB]=Pt[cB]=Pt[Q3]=Pt[K3]=Pt[pw]=Pt[Z3]=Pt[$3]=Pt[eB]=Pt[tB]=Pt[hB]=Pt[uB]=Pt[fB]=Pt[dB]=!0;Pt[X3]=Pt[dw]=Pt[rB]=!1;function gf(n,e,t,r,i,s){var o,a=e&V3,l=e&H3,c=e&W3;if(t&&(o=i?t(n,r,i,s):t(n)),o!==void 0)return o;if(!Qt(n))return n;var h=Tr(n);if(h){if(o=$b(n),!a)return Yu(n,o)}else{var u=Ha(n),f=u==dw||u==J3;if(Ia(n))return of(n,a);if(u==pw||u==fw||f&&!i){if(o=l||f?{}:mf(n),!a)return l?qb(n,zb(o,n)):jb(n,Fb(o,n))}else{if(!Pt[u])return i?n:{};o=sw(n,u,a)}}s||(s=new sf);var d=s.get(n);if(d)return d;s.set(n,o),uw(n)?n.forEach(function(g){o.add(gf(g,e,t,g,n,s))}):lw(n)&&n.forEach(function(g,x){o.set(x,gf(g,e,t,x,n,s))});var m=c?l?hf:Yb:l?hi:Ba,p=h?void 0:m(n);return zx(p||n,function(g,x){p&&(x=g,g=n[x]),Qu(o,x,gf(g,e,t,x,n,s))}),o}var yf=gf;var pB=1,mB=4;function gB(n){return yf(n,pB|mB)}var Lc=gB;function yB(n){return function(e,t,r){for(var i=-1,s=Object(e),o=r(e),a=o.length;a--;){var l=o[n?a:++i];if(t(s[l],l,s)===!1)break}return e}}var mw=yB;var vB=mw(),gw=vB;var xB=function(){return qt.Date.now()},vf=xB;var bB="Expected a function",wB=Math.max,SB=Math.min;function AB(n,e,t){var r,i,s,o,a,l,c=0,h=!1,u=!1,f=!0;if(typeof n!="function")throw new TypeError(bB);e=ng(e)||0,Qt(t)&&(h=!!t.leading,u="maxWait"in t,s=u?wB(ng(t.maxWait)||0,e):s,f="trailing"in t?!!t.trailing:f);function d(M){var _=r,y=i;return r=i=void 0,c=M,o=n.apply(y,_),o}function m(M){return c=M,a=setTimeout(x,e),h?d(M):o}function p(M){var _=M-l,y=M-c,T=e-_;return u?SB(T,s-y):T}function g(M){var _=M-l,y=M-c;return l===void 0||_>=e||_<0||u&&y>=s}function x(){var M=vf();if(g(M))return v(M);a=setTimeout(x,p(M))}function v(M){return a=void 0,f&&r?d(M):(r=i=void 0,o)}function w(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function b(){return a===void 0?o:v(vf())}function S(){var M=vf(),_=g(M);if(r=arguments,i=this,l=M,_){if(a===void 0)return m(l);if(u)return clearTimeout(a),a=setTimeout(x,e),d(l)}return a===void 0&&(a=setTimeout(x,e)),o}return S.cancel=w,S.flush=b,S}var Ic=AB;function MB(n,e,t){(t!==void 0&&!Ts(n[e],t)||t===void 0&&!(e in n))&&Pa(n,e,t)}var Nc=MB;function _B(n){return Or(n)&&Es(n)}var yw=_B;function TB(n,e){if(!(e==="constructor"&&typeof n[e]=="function")&&e!="__proto__")return n[e]}var Bc=TB;function EB(n){return Mn(n,hi(n))}var vw=EB;function CB(n,e,t,r,i,s,o){var a=Bc(n,t),l=Bc(e,t),c=o.get(l);if(c){Nc(n,t,c);return}var h=s?s(a,l,t+"",n,e,o):void 0,u=h===void 0;if(u){var f=Tr(l),d=!f&&Ia(l),m=!f&&!d&&$u(l);h=l,f||d||m?Tr(a)?h=a:yw(a)?h=Yu(a):d?(u=!1,h=of(l,!0)):m?(u=!1,h=pf(l,!0)):h=[]:nf(l)||xo(l)?(h=a,xo(a)?h=vw(a):(!Qt(a)||Ca(a))&&(h=mf(l))):u=!1}u&&(o.set(l,h),i(h,l,r,s,o),o.delete(l)),Nc(n,t,h)}var xw=CB;function bw(n,e,t,r,i){n!==e&&gw(e,function(s,o){if(i||(i=new sf),Qt(s))xw(n,e,o,t,bw,r,i);else{var a=r?r(Bc(n,o),s,o+"",n,e,i):void 0;a===void 0&&(a=s),Nc(n,o,a)}},hi)}var ww=bw;function DB(n){var e=n==null?0:n.length;return e?n[e-1]:void 0}var Sw=DB;function PB(n,e){return e.length<2?n:Ab(n,Lb(e,0,-1))}var Aw=PB;var LB=Vx(function(n,e,t){ww(n,e,t)}),wo=LB;function IB(n,e){return e=za(e,n),n=Aw(n,e),n==null||delete n[rf(Sw(e))]}var Mw=IB;function NB(n){return nf(n)?void 0:n}var _w=NB;var BB=1,OB=2,RB=4,FB=Db(function(n,e){var t={};if(n==null)return t;var r=!1;e=Hu(e,function(s){return s=za(s,n),r||(r=s.length>1),s}),Mn(n,hf(n),t),r&&(t=yf(t,BB|OB|RB,_w));for(var i=e.length;i--;)Mw(t,e[i]);return t}),ja=FB;var zB=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),UB=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),GB=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Oc&&"ontouchend"in document,kB=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,VB=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,HB=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(e)},WB=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},k6=zB(),Oc=UB(),So=GB(),Tw=kB(),xf=VB(),Ew=HB(),Cw=Number(WB());function Dw(n){return Array.isArray(n)?n:[n]}function Rc(n){return Oc?n.metaKey:n.ctrlKey}var Is;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(Is||(Is={}));var Ao;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=r})(Ao||(Ao={}));var Hi;(t=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]}t.isEqual=n;function e(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s]}t.lerp=e})(Hi||(Hi={}));var sr;(i=>{function n(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=n;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function r(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=r})(sr||(sr={}));var Fc;(t=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}t.isEqual=n;function e(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s,r[2]+(i[2]-r[2])*s,r[3]+(i[3]-r[3])*s]}t.lerp=e})(Fc||(Fc={}));var ui;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let h=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/h,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/h,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/h}return a}i.applyMatrix4=r})(ui||(ui={}));var hr;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function i(c){return{r:c.r,g:c.g,b:c.b}}l.clone=i;function s(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=s;function o(c,h){return c.r===h.r&&c.g===h.g&&c.b===h.b}l.equals=o;function a(c,h,u){return{r:c.r+(h.r-c.r)*u,g:c.g+(h.g-c.g)*u,b:c.b+(h.b-c.b)*u}}l.lerp=a})(hr||(hr={}));var mn;(o=>{o.white={...hr.white,a:1};function e(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}o.from0to1=e;function t(a,l){return{...hr.fromHex(a),a:l}}o.fromHexAndA=t;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}}o.toRgb255a1=r;function i(a,l){return hr.equals(a,l)&&a.a===l.a}o.equals=i;function s(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}o.lerp=s})(mn||(mn={}));var bf;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(bf||(bf={}));var wf;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(wf||(wf={}));var Sf;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(Sf||(Sf={}));var Af;(e=>{function n(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+r)),useCenter:!0}}}e.defaultData=n})(Af||(Af={}));var _n=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let s={...r,[e]:t};return Object.setPrototypeOf(s,_n.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let r=t[e.id],i;r===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:r};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,_n.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:r}=e,i=t[r];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,_n.prototype),delete s[r],{data:s,actual:e,reverse:{type:1,id:r,data:i}}}}throw new Error("illegal arg")}};function zc(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let e=Object.getOwnPropertyNames(n);for(let t of e){let r=n[t];r&&typeof r=="object"&&zc(r)}return Object.freeze(n)}function Pw(n,e){let t=0;for(;t<n.length&&t<e.length;){if(n[t]<e[t])return-1;if(n[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==n.length?1:0}var Mf=class extends Error{};function fi(n,e,t){if(n===void 0?e===void 0?(n=0,e=10):n=e-10:e===void 0&&(e=n+10),n>e){let s=n;n=e,e=s}let r=[],i=1/(t+1);for(let s=0;s<t;s++){let o=n+(e-n)*(s+.75+Math.random()*.5)*i;r.push(o)}return r}function _f(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function Lw(){return typeof process<"u"}function Iw(n,e){for(let t of n)e(t.id,t.data),Iw(t.children,e)}function Nw(n,e){e(n.id,n.data);for(let t of n.children)Nw(t,e)}var Tn=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Tn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t,r){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,r);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}isDescendantOf(t,r){for(;t;){let i=this.parent(t);if(i===r)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,r){if(t===null)this.traverse(r);else{let i=this.get(t);i&&Nw(i,r)}}traverse(t){Iw(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,r){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(h=>h.id===t);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(t,r){let i=t,s=r;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(h=>h.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,Tn.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}}checkDuplicatedIdRec({id:t,children:r}){if(this.get(t)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:r,fi:i,id:s,data:o,children:a}=t;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=r,c=this.childrenArray(l),h={fi:i,id:s,data:o,children:a};return c=[...c,h],c.sort((f,d)=>f.fi-d.fi),t.localIndex=c.indexOf(h),{data:this.modifyArrayBy(l,c),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:r}=t;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===r);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:r,fi:i,id:s}=t;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let d=r;for(;d!==null;){if(d===void 0)throw new Error;if(d===s)throw new Mf("cyclic tree");d=this.parent(d)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(d=>d.id===s);l=[...l];let h=l.splice(c,1)[0],u=this.modifyArrayBy(o,l);o=r,l=u.childrenArray(o);let f=h.fi;return h={...h,fi:i},l=[...l,h],l.sort((d,m)=>d.fi-m.fi),t.localIndex=l.indexOf(h),u=u.modifyArrayBy(o,l),{data:u,actual:t,reverse:{type:9,parent:a,fi:f,id:s}}}previous(t,r){if(r===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===r)return i;i=s.id}return null}traverseSortNext(t){let r=this.parent(t);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(r)return this.traverseSortNext(r)}}sortNext(t){let r=this.childrenArray(t);return r.length>0?r[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let r=this.childrenArray(t);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):t}sortPrevious(t){let r=this.parent(t);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):r}}getAllSorted(t){let r=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&r.push({...i,...s})}r.sort((i,s)=>Pw(i.sortKey,s.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(t){var r=t;let i=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)i.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:i}}}insertBeforeHelper(t,r,i){return this.insertAfterHelper(t,this.previous(t,r),i)}insertAfterHelper(t,r,i){let s=this.childrenArray(t);if(r===null){if(s.length===0)return fi(0,i,i);{let o=s[0].fi;return fi(o-i,o,i)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==t)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return fi(l,l+i,i)}else return fi(o.fi,a.fi,i)}}};var Tf;(e=>{function n(t,r){if(Array.isArray(t)){let i=r.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let i=r.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}e.runOp=n})(Tf||(Tf={}));var Gt=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Gt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,r){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,Gt.prototype);let r=t;return Lw()||r.fillCaches(),r}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}}addOp(t){let{fi:r,id:i,data:s}=t,o=this,a={fi:r,id:i,data:s};return o=[...o,a],o.sort((c,h)=>c.fi-h.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:r}=t,i=this,s=i.findIndex(l=>l.id===r);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:r,id:i}=t,s=this;s=[...s];let o=s.findIndex(h=>h.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((h,u)=>h.fi-u.fi),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let i of this){if(i.id===t)return r;r=i.id}return null}insertBeforeHelper(t,r){return this.insertAfterHelper(this.previous(t),r)}insertAfterHelper(t,r){let i=this;if(t===null){if(i.length===0)return fi(0,r,r);{let s=i[0].fi;return fi(s-r,s,r)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return fi(a,a+r,r)}else return fi(s.fi,o.fi,r)}}};var Bw=Symbol(),Cf=Symbol(),qa=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let i=[];for(;!(r instanceof Ef);){let s=r._path,o=r._current;if(s!==""&&i.splice(0,0,s),r=r._parent,r===null)return;r.update(s,o)}r.push(i,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[Cf];r&&r(),delete this._children[e]}}}},hg=class extends qa{constructor(e,t,r){super(),this._parent=e,this._path=t,this._current=r}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,Tf.runOp(this._current,e))}},ug=class extends qa{constructor(e,t,r){super(),this._parent=e,this._path=t,this._current=r}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,_n.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Ow={get(n,e){if(e===Cf)return()=>{n._parent=null};if(e===Bw)return n._current;let{_current:t,_children:r}=n;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[e];if(i!==void 0)return i;let s=t[e],o=Df(n,e,s);return o!==s?(r===void 0&&(r={},n._children=r),r[e]=o,o):s},has(n,e){return e in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,e){let t=n._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},jB={...Ow,set(n,e,t){let r={type:0,props:{[e]:pg(t)??t}};return n.deleteChildren(e),n.runOp(r),!0},deleteProperty(n,e){let t={type:0,props:{[e]:void 0}};return n.deleteChildren(e),n.runOp(t),!0}},qB={...Ow,set(n,e,t){return t===void 0?this.deleteProperty(n,e):(n.deleteChildren(e),n.runOp({type:1,id:e,data:t})),!0},deleteProperty(n,e){return n.runOp({type:2,id:e}),!0}},Ya=class extends qa{constructor(e,t,r){super(),this._children={},this._parent=e,this._path=t,this._current=r,this[Cf]=()=>{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,r)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:r}=this,i=r===void 0?void 0:r[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Df(this,e,s);return o!==s?(r===void 0&&(r={},this._children=r),r[e]=o,o):s}add(e,t,r,i,s){this.runOp({type:7,parent:e,fi:t,id:r,data:i,children:s})}move(e,t,r){this.runOp({type:9,parent:e,fi:t,id:r})}insertAfter(e,t,r){let i=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,r){let i=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,r){let i=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(e,i[s],o)}}moveBefore(e,t,r){let i=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(e,i[s],o)}}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)}},Xa=class extends qa{constructor(e,t,r){super(),this._children={},this._parent=e,this._path=t,this._current=r,this[Cf]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let i=this._current[r].id;e(this.data(this._current[r].id),i)}}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:r}=this,i=r===void 0?void 0:r[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Df(this,e,s);return o!==s?(r===void 0&&(r={},this._children=r),r[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:4,fi:e,id:t,data:r})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r[i],s.id,s.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r[i],s.id,s.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r[i],s)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function cg(n,e,t){if(n.length>0){let r=n[n.length-1];if(r.type===0&&e.type===0&&Pf.equal(r.path,t)){Object.assign(r.props,e.props);return}}n.push({...e,path:t})}var Ef=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,i){cg(this.ts,t,e),cg(this.actual,r,e),cg(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Df(n,e,t){return t instanceof Tn?new Ya(n,e,t):t instanceof Gt?new Xa(n,e,t):t instanceof _n?new Proxy(new ug(n,e,t),qB):t!==null&&typeof t=="object"?_f(t)?t:new Proxy(new hg(n,e,t),jB):t}function fg(n){let e=new Ef(n);return[Df(e,"",n),e]}function dg(n,e){let[t,r]=fg(n);return e(t),r.result()}function pg(n){return n instanceof Ya||n instanceof Xa?n._current:n!==null&&typeof n=="object"?n[Bw]:n}var Pf;(r=>{function n(i,s){if(s.length===i.length)for(var o=0;o<i.length;){if(i[o]!==s[o])return!1;o+=1}else return!1;return!0}r.equal=n;function e(i,s,o){let a=t(o,i);if(a!==void 0&&typeof a=="object"&&a!==null){let l={...s};return Object.keys(a).forEach(c=>{delete l[c]}),l}else return s}r.removeOverridden=e;function t(i,s,o=0){if(s.length<=o)return i;if((i instanceof Tn||i instanceof Ya)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if((i instanceof Gt||i instanceof Xa)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if(typeof s[o]=="number"&&Array.isArray(i))return t(i[s[o]],s,o+1);if(typeof s[o]=="string"&&typeof i=="object")return t(i[s[o]],s,o+1)}r.zoom=t})(Pf||(Pf={}));var Lf=class{},Uc=class extends Lf{constructor(t){super();this.id=t}},Gc=class extends Lf{constructor(t){super();this.data=t}};var gg;try{gg=new TextDecoder}catch{}var Ce,Bs,J=0;var Hw=[],yg=Hw,vg=0,rn={},yt,Ns,En=0,di=0,gn,Wi,jr=[],At,Rw={useRecords:!1,mapsAsObjects:!0},kc=class{},bg=new kc;bg.name="MessagePack 0xC1";var Ja=!1,pi=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(Ce)return Xw(()=>(Nf(),this?this.unpack(e,t):pi.prototype.unpack.call(Rw,e,t)));Bs=t>-1?t:e.length,J=0,vg=0,di=0,Ns=null,yg=Hw,gn=null,Ce=e;try{At=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw Ce=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof pi){if(rn=this,this.structures)return yt=this.structures,If();(!yt||yt.length>0)&&(yt=[])}else rn=Rw,(!yt||yt.length>0)&&(yt=[]);return If()}unpackMultiple(e,t){let r,i=0;try{Ja=!0;let s=e.length,o=this?this.unpack(e,s):Rf.unpack(e,s);if(t){for(t(o);J<s;)if(i=J,t(If())===!1)return}else{for(r=[o];J<s;)i=J,r.push(If());return r}}catch(s){throw s.lastPosition=i,s.values=r,s}finally{Ja=!1,Nf()}}_mergeStructures(e,t){e=e||[];for(let r=0,i=e.length;r<i;r++){let s=e[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let i=e[r],s=t[r];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[r]=i),e[r]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function If(){try{if(!rn.trusted&&!Ja){let e=yt.sharedLength||0;e<yt.length&&(yt.length=e)}let n=Yt();if(J==Bs)yt.restoreStructures&&Fw(),yt=null,Ce=null,Wi&&(Wi=null);else if(J>Bs){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Ja)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw yt.restoreStructures&&Fw(),Nf(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Fw(){for(let n in yt.restoreStructures)yt[n]=yt.restoreStructures[n];yt.restoreStructures=null}function Yt(){let n=Ce[J++];if(n<160)if(n<128){if(n<64)return n;{let e=yt[n&63]||rn.getStructures&&Ww()[n&63];return e?(e.read||(e.read=wg(e,n&63)),e.read()):n}}else if(n<144)if(n-=128,rn.mapsAsObjects){let e={};for(let t=0;t<n;t++)e[qw()]=Yt();return e}else{let e=new Map;for(let t=0;t<n;t++)e.set(Yt(),Yt());return e}else{n-=144;let e=new Array(n);for(let t=0;t<n;t++)e[t]=Yt();return e}else if(n<192){let e=n-160;if(di>=J)return Ns.slice(J-En,(J+=e)-En);if(di==0&&Bs<140){let t=e<16?Sg(e):jw(e);if(t!=null)return t}return xg(e)}else{let e;switch(n){case 192:return null;case 193:return gn?(e=Yt(),e>0?gn[1].slice(gn.position1,gn.position1+=e):gn[0].slice(gn.position0,gn.position0-=e)):bg;case 194:return!1;case 195:return!0;case 196:return mg(Ce[J++]);case 197:return e=At.getUint16(J),J+=2,mg(e);case 198:return e=At.getUint32(J),J+=4,mg(e);case 199:return Mo(Ce[J++]);case 200:return e=At.getUint16(J),J+=2,Mo(e);case 201:return e=At.getUint32(J),J+=4,Mo(e);case 202:if(e=At.getFloat32(J),rn.useFloat32>2){let t=Of[(Ce[J]&127)<<1|Ce[J+1]>>7];return J+=4,(t*e+(e>0?.5:-.5)>>0)/t}return J+=4,e;case 203:return e=At.getFloat64(J),J+=8,e;case 204:return Ce[J++];case 205:return e=At.getUint16(J),J+=2,e;case 206:return e=At.getUint32(J),J+=4,e;case 207:return rn.int64AsNumber?(e=At.getUint32(J)*4294967296,e+=At.getUint32(J+4)):e=At.getBigUint64(J),J+=8,e;case 208:return At.getInt8(J++);case 209:return e=At.getInt16(J),J+=2,e;case 210:return e=At.getInt32(J),J+=4,e;case 211:return rn.int64AsNumber?(e=At.getInt32(J)*4294967296,e+=At.getUint32(J+4)):e=At.getBigInt64(J),J+=8,e;case 212:if(e=Ce[J++],e==114)return Vw(Ce[J++]&63);{let t=jr[e];if(t)return t.read?(J++,t.read(Yt())):t.noBuffer?(J++,t()):t(Ce.subarray(J,++J));throw new Error("Unknown extension "+e)}case 213:return e=Ce[J],e==114?(J++,Vw(Ce[J++]&63,Ce[J++])):Mo(2);case 214:return Mo(4);case 215:return Mo(8);case 216:return Mo(16);case 217:return e=Ce[J++],di>=J?Ns.slice(J-En,(J+=e)-En):XB(e);case 218:return e=At.getUint16(J),J+=2,di>=J?Ns.slice(J-En,(J+=e)-En):JB(e);case 219:return e=At.getUint32(J),J+=4,di>=J?Ns.slice(J-En,(J+=e)-En):QB(e);case 220:return e=At.getUint16(J),J+=2,Uw(e);case 221:return e=At.getUint32(J),J+=4,Uw(e);case 222:return e=At.getUint16(J),J+=2,Gw(e);case 223:return e=At.getUint32(J),J+=4,Gw(e);default:if(n>=224)return n-256;if(n===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+n)}}}var YB=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function wg(n,e){function t(){if(t.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>YB.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Yt);return n.highByte===0&&(n.read=zw(e,n.read)),i()}let r={};for(let i=0,s=n.length;i<s;i++){let o=n[i];r[o]=Yt()}return r}return t.count=0,n.highByte===0?zw(e,t):t}var zw=(n,e)=>function(){let t=Ce[J++];if(t===0)return e();let r=n<32?-(n+(t<<5)):n+(t<<5),i=yt[r]||Ww()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=wg(i,n)),i.read()};function Ww(){let n=Xw(()=>(Ce=null,rn.getStructures()));return yt=rn._mergeStructures(n,yt)}var xg=Bf,XB=Bf,JB=Bf,QB=Bf;function Bf(n){let e;if(n<16&&(e=Sg(n)))return e;if(n>64&&gg)return gg.decode(Ce.subarray(J,J+=n));let t=J+n,r=[];for(e="";J<t;){let i=Ce[J++];if((i&128)===0)r.push(i);else if((i&224)===192){let s=Ce[J++]&63;r.push((i&31)<<6|s)}else if((i&240)===224){let s=Ce[J++]&63,o=Ce[J++]&63;r.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ce[J++]&63,o=Ce[J++]&63,a=Ce[J++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(e+=br.apply(String,r),r.length=0)}return r.length>0&&(e+=br.apply(String,r)),e}function Uw(n){let e=new Array(n);for(let t=0;t<n;t++)e[t]=Yt();return e}function Gw(n){if(rn.mapsAsObjects){let e={};for(let t=0;t<n;t++)e[qw()]=Yt();return e}else{let e=new Map;for(let t=0;t<n;t++)e.set(Yt(),Yt());return e}}var br=String.fromCharCode;function jw(n){let e=J,t=new Array(n);for(let r=0;r<n;r++){let i=Ce[J++];if((i&128)>0){J=e;return}t[r]=i}return br.apply(String,t)}function Sg(n){if(n<4)if(n<2){if(n===0)return"";{let e=Ce[J++];if((e&128)>1){J-=1;return}return br(e)}}else{let e=Ce[J++],t=Ce[J++];if((e&128)>0||(t&128)>0){J-=2;return}if(n<3)return br(e,t);let r=Ce[J++];if((r&128)>0){J-=3;return}return br(e,t,r)}else{let e=Ce[J++],t=Ce[J++],r=Ce[J++],i=Ce[J++];if((e&128)>0||(t&128)>0||(r&128)>0||(i&128)>0){J-=4;return}if(n<6){if(n===4)return br(e,t,r,i);{let s=Ce[J++];if((s&128)>0){J-=5;return}return br(e,t,r,i,s)}}else if(n<8){let s=Ce[J++],o=Ce[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(n<7)return br(e,t,r,i,s,o);let a=Ce[J++];if((a&128)>0){J-=7;return}return br(e,t,r,i,s,o,a)}else{let s=Ce[J++],o=Ce[J++],a=Ce[J++],l=Ce[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(n<10){if(n===8)return br(e,t,r,i,s,o,a,l);{let c=Ce[J++];if((c&128)>0){J-=9;return}return br(e,t,r,i,s,o,a,l,c)}}else if(n<12){let c=Ce[J++],h=Ce[J++];if((c&128)>0||(h&128)>0){J-=10;return}if(n<11)return br(e,t,r,i,s,o,a,l,c,h);let u=Ce[J++];if((u&128)>0){J-=11;return}return br(e,t,r,i,s,o,a,l,c,h,u)}else{let c=Ce[J++],h=Ce[J++],u=Ce[J++],f=Ce[J++];if((c&128)>0||(h&128)>0||(u&128)>0||(f&128)>0){J-=12;return}if(n<14){if(n===12)return br(e,t,r,i,s,o,a,l,c,h,u,f);{let d=Ce[J++];if((d&128)>0){J-=13;return}return br(e,t,r,i,s,o,a,l,c,h,u,f,d)}}else{let d=Ce[J++],m=Ce[J++];if((d&128)>0||(m&128)>0){J-=14;return}if(n<15)return br(e,t,r,i,s,o,a,l,c,h,u,f,d,m);let p=Ce[J++];if((p&128)>0){J-=15;return}return br(e,t,r,i,s,o,a,l,c,h,u,f,d,m,p)}}}}}function mg(n){return rn.copyBuffers?Uint8Array.prototype.slice.call(Ce,J,J+=n):Ce.subarray(J,J+=n)}function Mo(n){let e=Ce[J++];if(jr[e])return jr[e](Ce.subarray(J,J+=n));throw new Error("Unknown extension type "+e)}var kw=new Array(4096);function qw(){let n=Ce[J++];if(n>=160&&n<192){if(n=n-160,di>=J)return Ns.slice(J-En,(J+=n)-En);if(!(di==0&&Bs<180))return xg(n)}else return J--,Yt();let e=(n<<5^(n>1?At.getUint16(J):n>0?Ce[J]:0))&4095,t=kw[e],r=J,i=J+n-3,s,o=0;if(t&&t.bytes==n){for(;r<i;){if(s=At.getUint32(r),s!=t[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(s=Ce[r++],s!=t[o++]){r=1879048192;break}if(r===i)return J=r,t.string;i-=3,r=J}for(t=[],kw[e]=t,t.bytes=n;r<i;)s=At.getUint32(r),t.push(s),r+=4;for(i+=3;r<i;)s=Ce[r++],t.push(s);let a=n<16?Sg(n):jw(n);return a!=null?t.string=a:t.string=xg(n)}var Vw=(n,e)=>{var t=Yt();let r=n;e!==void 0&&(n=n<32?-((e<<5)+n):(e<<5)+n,t.highByte=e);let i=yt[n];return i&&i.isShared&&((yt.restoreStructures||(yt.restoreStructures=[]))[n]=i),yt[n]=t,t.read=wg(t,r),t.read()},Yw=typeof self=="object"?self:global;jr[0]=()=>{};jr[0].noBuffer=!0;jr[101]=()=>{let n=Yt();return(Yw[n[0]]||Error)(n[1])};jr[105]=n=>{let e=At.getUint32(J-4);Wi||(Wi=new Map);let t=Ce[J],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let i={target:r};Wi.set(e,i);let s=Yt();return i.used?Object.assign(r,s):(i.target=s,s)};jr[112]=n=>{let e=At.getUint32(J-4),t=Wi.get(e);return t.used=!0,t.target};jr[115]=()=>new Set(Yt());var Ag=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");jr[116]=n=>{let e=n[0],t=Ag[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Yw[t](Uint8Array.prototype.slice.call(n,1).buffer)};jr[120]=()=>{let n=Yt();return new RegExp(n[0],n[1])};jr[98]=n=>{let e=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],t=J;J+=e-4,gn=[Yt(),Yt()],gn.position0=0,gn.position1=0;let r=J;J=t;try{return Yt()}finally{J=r}};jr[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Xw(n){let e=Bs,t=J,r=vg,i=En,s=di,o=Ns,a=yg,l=Wi,c=gn,h=new Uint8Array(Ce.slice(0,Bs)),u=yt,f=yt.slice(0,yt.length),d=rn,m=Ja,p=n();return Bs=e,J=t,vg=r,En=i,di=s,Ns=o,yg=a,Wi=l,gn=c,Ce=h,Ja=m,yt=u,yt.splice(0,yt.length,...f),rn=d,At=new DataView(Ce.buffer,Ce.byteOffset,Ce.byteLength),p}function Nf(){Ce=null,Wi=null,yt=null}function Jw(n){n.unpack?jr[n.type]=n.unpack:jr[n.type]=n}var Of=new Array(147);for(let n=0;n<256;n++)Of[n]=+("1e"+Math.floor(45.15-n*.30103));var Rf=new pi({useRecords:!1}),KB=Rf.unpack,ZB=Rf.unpackMultiple,$B=Rf.unpack,Ff={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},eO=new Float32Array(1),xj=new Uint8Array(eO.buffer,0,4);var zf;try{zf=new TextEncoder}catch{}var Uf,_g,Gf=typeof Buffer<"u",Mg=Gf?Buffer.allocUnsafeSlow:Uint8Array,$w=Gf?Buffer:Uint8Array,Qw=Gf?4294967296:2144337920,oe,Kt,ee=0,mi,gi=null,tO=/[\u0080-\uFFFF]/,Vc=Symbol("record-id"),_o=class extends pi{constructor(e){super(e),this.offset=0;let t,r,i,s,o,a,l=0,c=$w.prototype.utf8Write?function(y,T,E){return oe.utf8Write(y,T,E)}:zf&&zf.encodeInto?function(y,T){return zf.encodeInto(y,oe.subarray(T)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,f=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=f?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=f?32:64),u&&!e.saveStructures&&(this.structures=[]);let p=d>32||m+d>64,g=d+64,x=d+m+64;if(x>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,b=0;this.pack=this.encode=function(y,T){if(oe||(oe=new Mg(8192),Kt=new DataView(oe.buffer,0,8192),ee=0),mi=oe.length-10,mi-ee<2048?(oe=new Mg(oe.length),Kt=new DataView(oe.buffer,0,oe.length),mi=oe.length-10,ee=0):ee=ee+7&2147483640,r=ee,a=h.structuredClone?new Map:null,h.bundleStrings?(gi=["",""],oe[ee++]=214,oe[ee++]=98,gi.position=ee-r,ee+=4):gi=null,i=h.structures,i){i.uninitialized&&(i=h._mergeStructures(h.getStructures()));let E=i.sharedLength||0;if(E>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let I=i[C];if(!I)continue;let B,N=i.transitions;for(let H=0,j=I.length;H<j;H++){let Q=I[H];B=N[Q],B||(B=N[Q]=Object.create(null)),N=B}N[Vc]=C+64}l=E}u||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(y),gi){Kt.setUint32(gi.position+r,ee-gi.position-r);let E=gi;gi=null,S(E[0]),S(E[1])}if(h.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>mi&&_(ee),h.offset=ee;let E=nO(oe.subarray(r,ee),a.idsToInsert);return a=null,E}return T&tS?(oe.start=r,oe.end=ee,oe):oe.subarray(r,ee)}finally{if(i){if(b<10&&b++,w>1e4)i.transitions=null,b=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let E=0,C=v.length;E<C;E++)v[E][Vc]=0;v=[]}if(s&&h.saveStructures){let E=i.sharedLength||d;i.length>E&&(i=i.slice(0,E));let C=oe.subarray(r,ee);return h.saveStructures(i,l)===!1?(h._mergeStructures(h.getStructures()),h.pack(y)):(l=E,C)}}T&hO&&(ee=r)}};let S=y=>{ee>mi&&(oe=_(ee));var T=typeof y,E;if(T==="string"){let C=y.length;if(gi&&C>=8&&C<4096){let N=tO.test(y);gi[N?0:1]+=y,oe[ee++]=193,S(N?-C:C);return}let I;C<32?I=1:C<256?I=2:C<65536?I=3:I=5;let B=C*3;if(ee+B>mi&&(oe=_(ee+B)),C<64||!c){let N,H,j,Q=ee+I;for(N=0;N<C;N++)H=y.charCodeAt(N),H<128?oe[Q++]=H:H<2048?(oe[Q++]=H>>6|192,oe[Q++]=H&63|128):(H&64512)===55296&&((j=y.charCodeAt(N+1))&64512)===56320?(H=65536+((H&1023)<<10)+(j&1023),N++,oe[Q++]=H>>18|240,oe[Q++]=H>>12&63|128,oe[Q++]=H>>6&63|128,oe[Q++]=H&63|128):(oe[Q++]=H>>12|224,oe[Q++]=H>>6&63|128,oe[Q++]=H&63|128);E=Q-ee-I}else E=c(y,ee+I,B);E<32?oe[ee++]=160|E:E<256?(I<2&&oe.copyWithin(ee+2,ee+1,ee+1+E),oe[ee++]=217,oe[ee++]=E):E<65536?(I<3&&oe.copyWithin(ee+3,ee+2,ee+2+E),oe[ee++]=218,oe[ee++]=E>>8,oe[ee++]=E&255):(I<5&&oe.copyWithin(ee+5,ee+3,ee+3+E),oe[ee++]=219,Kt.setUint32(ee,E),ee+=4),ee+=E}else if(T==="number")if(y>>>0===y)y<64?oe[ee++]=y:y<256?(oe[ee++]=204,oe[ee++]=y):y<65536?(oe[ee++]=205,oe[ee++]=y>>8,oe[ee++]=y&255):(oe[ee++]=206,Kt.setUint32(ee,y),ee+=4);else if(y>>0===y)y>=-32?oe[ee++]=256+y:y>=-128?(oe[ee++]=208,oe[ee++]=y+256):y>=-32768?(oe[ee++]=209,Kt.setInt16(ee,y),ee+=2):(oe[ee++]=210,Kt.setInt32(ee,y),ee+=4);else{let C;if((C=this.useFloat32)>0&&y<4294967296&&y>=-2147483648){oe[ee++]=202,Kt.setFloat32(ee,y);let I;if(C<4||(I=y*Of[(oe[ee]&127)<<1|oe[ee+1]>>7])>>0===I){ee+=4;return}else ee--}oe[ee++]=203,Kt.setFloat64(ee,y),ee+=8}else if(T==="object")if(!y)oe[ee++]=192;else{if(a){let I=a.get(y);if(I){if(!I.id){let B=a.idsToInsert||(a.idsToInsert=[]);I.id=B.push(I)}oe[ee++]=214,oe[ee++]=112,Kt.setUint32(ee,I.id),ee+=4;return}else a.set(y,{offset:ee-r})}let C=y.constructor;if(C===Object)M(y,!0);else if(C===Array){E=y.length,E<16?oe[ee++]=144|E:E<65536?(oe[ee++]=220,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=221,Kt.setUint32(ee,E),ee+=4);for(let I=0;I<E;I++)S(y[I])}else if(C===Map){E=y.size,E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,Kt.setUint32(ee,E),ee+=4);for(let[I,B]of y)S(I),S(B)}else{for(let I=0,B=Uf.length;I<B;I++){let N=_g[I];if(y instanceof N){let H=Uf[I];if(H.write){H.type&&(oe[ee++]=212,oe[ee++]=H.type,oe[ee++]=0),S(H.write.call(this,y));return}let j=oe,Q=Kt,X=ee;oe=null;let U;try{U=H.pack.call(this,y,F=>(oe=j,j=null,ee+=F,ee>mi&&_(ee),{target:oe,targetView:Kt,position:ee-F}),S)}finally{j&&(oe=j,Kt=Q,ee=X,mi=oe.length-10)}U&&(U.length+ee>mi&&_(U.length+ee),ee=rO(U,oe,ee,H.type));return}}M(y,!y.hasOwnProperty)}}else if(T==="boolean")oe[ee++]=y?195:194;else if(T==="bigint"){if(y<BigInt(1)<<BigInt(63)&&y>=-(BigInt(1)<<BigInt(63)))oe[ee++]=211,Kt.setBigInt64(ee,y);else if(y<BigInt(1)<<BigInt(64)&&y>0)oe[ee++]=207,Kt.setBigUint64(ee,y);else if(this.largeBigIntToFloat)oe[ee++]=203,Kt.setFloat64(ee,Number(y));else throw new RangeError(y+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ee+=8}else if(T==="undefined")this.encodeUndefinedAsNil?oe[ee++]=192:(oe[ee++]=212,oe[ee++]=0,oe[ee++]=0);else if(T==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},M=this.useRecords===!1?this.variableMapSize?y=>{let T=Object.keys(y),E=T.length;E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,Kt.setUint32(ee,E),ee+=4);let C;for(let I=0;I<E;I++)S(C=T[I]),S(y[C])}:(y,T)=>{oe[ee++]=222;let E=ee-r;ee+=2;let C=0;for(let I in y)(T||y.hasOwnProperty(I))&&(S(I),S(y[I]),C++);oe[E+++r]=C>>8,oe[E+r]=C&255}:y=>{let T=Object.keys(y),E,C=o.transitions||(o.transitions=Object.create(null)),I=0;for(let N=0,H=T.length;N<H;N++){let j=T[N];E=C[j],E||(E=C[j]=Object.create(null),I++),C=E}let B=C[Vc];if(B)B>=96&&p?(oe[ee++]=((B-=96)&31)+96,oe[ee++]=B>>5):oe[ee++]=B;else{B=o.nextId,B||(B=64),B<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(B=o.nextOwnId,B<x||(B=g),o.nextOwnId=B+1):(B>=x&&(B=g),o.nextId=B+1);let N=T.highByte=B>=96&&p?B-96>>5:-1;C[Vc]=B,o[B-64]=T,B<g?(T.isShared=!0,o.sharedLength=B-63,s=!0,N>=0?(oe[ee++]=(B&31)+96,oe[ee++]=N):oe[ee++]=B):(N>=0?(oe[ee++]=213,oe[ee++]=114,oe[ee++]=(B&31)+96,oe[ee++]=N):(oe[ee++]=212,oe[ee++]=114,oe[ee++]=B),I&&(w+=b*I),v.length>=m&&(v.shift()[Vc]=0),v.push(C),S(T))}for(let N=0,H=T.length;N<H;N++)S(y[T[N]])},_=y=>{let T;if(y>16777216){if(y-r>Qw)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(Qw,Math.round(Math.max((y-r)*(y>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(y-r<<2,oe.length-1)>>12)+1<<12;let E=new Mg(T);return Kt=new DataView(E.buffer,0,T),oe.copy?oe.copy(E,0,r,y):E.set(oe.slice(r,y)),ee-=r,r=0,mi=E.length-10,oe=E}}useBuffer(e){oe=e,Kt=new DataView(oe.buffer,oe.byteOffset,oe.byteLength),ee=0}};_g=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,kc];Uf=[{pack(n,e,t){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,n.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(n,e,t){let r=Array.from(n),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(r)}},{pack(n,e,t){let{target:r,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),t([n.name,n.message])}},{pack(n,e,t){let{target:r,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),t([n.source,n.flags])}},{pack(n,e){this.structuredClone?Kw(n,16,e):Zw(Gf?Buffer.from(n):new Uint8Array(n),e)}},{pack(n,e){let t=n.constructor;t!==$w&&this.structuredClone?Kw(n,Ag.indexOf(t.name),e):Zw(n,e)}},{pack(n,e){let{target:t,position:r}=e(1);t[r]=193}}];function Kw(n,e,t,r){let i=n.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),o)}function Zw(n,e){let t=n.byteLength;var r,i;if(t<256){var{target:r,position:i}=e(t+2);r[i++]=196,r[i++]=t}else if(t<65536){var{target:r,position:i}=e(t+3);r[i++]=197,r[i++]=t>>8,r[i++]=t&255}else{var{target:r,position:i,targetView:s}=e(t+5);r[i++]=198,s.setUint32(i,t),i+=4}r.set(n,i)}function rO(n,e,t,r){let i=n.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=r,e.set(n,t),t+=i,t}function nO(n,e){let t,r=e.length*6,i=n.length-r;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;n.copyWithin(s+r,s,i),r-=6;let a=s+r;n[a++]=214,n[a++]=105,n[a++]=o>>24,n[a++]=o>>16&255,n[a++]=o>>8&255,n[a++]=o&255,i=s}return n}function To(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");_g.unshift(n.Class),Uf.unshift(n)}Jw(n)}var eS=new _o({useRecords:!1}),iO=eS.pack,sO=eS.pack;var{NEVER:oO,ALWAYS:aO,DECIMAL_ROUND:lO,DECIMAL_FIT:cO}=Ff,tS=512,hO=1024;var rS=new _o({structuredClone:!0});To({Class:_n.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,_n.prototype),n}});To({Class:Gt.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Gt.prototype),n}});To({Class:Tn.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Tn.prototype),n}});To({Class:Uc.prototype.constructor,type:4,write(n){return n.id},read(n){return new Uc(n)}});To({Class:Gc.prototype.constructor,type:5,write(n){return n.data},read(n){return new Gc(n)}});function uO(n){var e=0;if(n.length===0)return e;for(let t=0;t<n.length;t++){let r=n[t];e=(e<<5)-e+r,e=e&e}return e}function Tg(n){if(_f(n))return n;if(Array.isArray(n))return n.map(Tg);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=Tg(n[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else return n}var kf;(r=>{function n(i){return rS.pack(i)}r.serialize=n;function e(i){return rS.unpack(i)}r.deserialize=e;function t(i){return uO(n(Tg(i))).toString()}r.checksum=t})(kf||(kf={}));var Vf;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(Vf||(Vf={}));var Hf;(t=>{function n(r){return e(r)}t.defaultData=n;function e(r){if(r==="PointLight")return{type:r,color:mn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5,helper:!0};if(r==="SpotLight")return{type:r,color:mn.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,helper:!0,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:mn.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,helper:!0,shadowRadius:1};throw new Error("not implemented")}})(Hf||(Hf={}));var Eg;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}t.equals=e})(Eg||(Eg={}));var Cg;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}t.equals=e})(Cg||(Cg={}));var Wf;(e=>e.defaultData={...Cg.defaultData,...Eg.defaultData,cloner:null,booleanExclude:null})(Wf||(Wf={}));var Dg=(i=>(i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Center=3]="Center",i[i.Justify=4]="Justify",i))(Dg||{}),Pg=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Pg||{}),Lg=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(Lg||{}),jf;(e=>e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:mn.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(jf||(jf={}));var nS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"];var Qa;(r=>{function n(i,s){return i==="light"&&s?e(s):t(i)}r.defaultData=n;function e(i){switch(i){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:hr.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...hr.fromHex(6710886),a:1},colorB:{...hr.fromHex(6710886),a:1},colorC:{...hr.fromHex(16777215),a:1},colorD:{...hr.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:mn.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Qa||(Qa={}));var jn;(a=>{function n(l){return!l.layers.some(h=>{if(h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")return!0})&&!t(l)}a.isMergable=n;function e(l){let c="";return l.layers.forEach(h=>{Object.entries(h.data).forEach(([u,f])=>{c+=`${u}${f}`,Array.isArray(f)?f.forEach(d=>c+=`${d}`):typeof f=="object"?Object.values(f).forEach(d=>{typeof d=="number"?c+=`${d.toFixed(4)}`:c+=`${d}`}):c+=`${f}`})}),c}a.getHash=e;function t(l){let c=0;for(let h of l.layers)"alpha"in h.data&&h.data.type!=="light"&&h.data.type!=="fresnel"&&(c+=(1-c)*h.data.alpha);return c<1}a.isTransparent=t;function r(){return{layers:new Gt}}a.defaultEmptyData=r;function i(l="layer1",c="layer2"){return s("phong",l,c)}a.defaultData=i;function s(l,c="layer1",h="layer2"){let u=new Gt;return u.push({fi:0,data:Qa.defaultData("light",l),id:c}),u.push({fi:1,data:Qa.defaultData("color"),id:h}),{layers:u}}a.defaultTwoLayerData=s;function o(l,c="basic",h="layer1",u="layer2"){let f=Qa.defaultData("texture");Object.assign(f.texture,{image:l});let d=new Gt;return d.push({fi:0,data:f,id:h}),d.push({fi:1,data:Qa.defaultData("light",c),id:u}),{layers:d}}a.defaultTwoLayerTextureData=o})(jn||(jn={}));var Ka;(e=>{function n(){return{points:new Gt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=n})(Ka||(Ka={}));var qf;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=n})(qf||(qf={}));var Hc;(e=>{function n(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Ka.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};throw new Error("not implemented")}e.defaultData=n})(Hc||(Hc={}));var Wc;(i=>{i.identity={...bf.identity,hiddenMatrix:ui.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function r(s,o){return{position:sr.isEqual(s.position,o.position)?null:o.position,rotation:sr.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:sr.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:ui.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=r})(Wc||(Wc={}));var ji;(e=>e.defaultData={states:new Gt,events:new Gt,visible:!0,raycastLock:!1,...Wc.identity})(ji||(ji={}));var iS;(e=>e.defaultData={type:"Empty",...ji.defaultData})(iS||(iS={}));var Yf;(e=>e.defaultData={type:"Mesh",...ji.defaultData,...Wf.defaultData})(Yf||(Yf={}));var sS;(e=>e.defaultData={type:"TextFrame",...ji.defaultData,...jf.defaultData})(sS||(sS={}));var Xf;(e=>e.defaultData={...ji.defaultData,...Wc.identity,...Ao.defaultData})(Xf||(Xf={}));var oS;(e=>{function n(t){return{...ji.defaultData,...Hf.defaultData(t)}}e.defaultData=n})(oS||(oS={}));var aS;(r=>(r.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:ui.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Gt,events:new Gt,...Ao.defaultData},r.defaultMeshObject={name:"Rectangle",...ji.defaultData,...Yf.defaultData,geometry:Hc.defaultData("RectangleGeometry"),material:jn.defaultTwoLayerData("basic","layer1","layer2")},r.defaultBooleanObject={name:"Boolean",...ji.defaultData,...Yf.defaultData,geometry:Hc.defaultData("BooleanGeometry"),material:jn.defaultTwoLayerData("phong","layer1","layer2")}))(aS||(aS={}));var jc;(t=>{function n(r,i){if(i===void 0)return r;let s={...r};return"material"in s&&"material"in i&&i.material&&(s.material=dg(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let c=o.layers.data(a);c&&wo(c,l)}}).data),s.materials&&i.materials&&(s.materials=dg(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[c,h]of Object.entries(l.layers)){let u=o[a]?.layers?.data(c);u&&wo(u,h)}}}).data),s}t.patchMaterialState=n;function e(r,i){if(i===void 0)return r;let s={...r};if(Object.assign(s,Wc.merge(s,i)),Is.is(r.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(r.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=n(s,i);else if(Vf.is(r.type)){let o=i;s.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=hr.clone(o.color))}return s}t.patch=e})(jc||(jc={}));function cS(n,e=!1){let t=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,l=new Le,c=0;for(let h=0;h<n.length;++h){let u=n[h],f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let d in u.attributes){if(!r.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(u.attributes[d]),f++}if(f!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(u.userData),e){let d;if(t)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,d,h),c+=d}}if(t){let h=0,u=[];for(let f=0;f<n.length;++f){let d=n[f].index;for(let m=0;m<d.count;++m)u.push(d.getX(m)+h);h+=n[f].attributes.position.count}l.setIndex(u)}for(let h in s){let u=lS(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(let h in o){let u=o[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let f=0;f<u;++f){let d=[];for(let p=0;p<o[h].length;++p)d.push(o[h][p][f]);let m=lS(d);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function lS(n){let e,t,r,i=0;for(let a=0;a<n.length;++a){let l=n[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==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;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<n.length;++a)s.set(n[a].array,o),o+=n[a].array.length;return new Xe(s,t,r)}var Ig={type:"change"},hS={type:"changeZoom"},fO={type:"changePan"},Za={type:"start"},qc={type:"end"},Ng=new jt,dO=new O,pO=2*Math.PI,mO=1e-8,gO=.01,uS=2,Bg=.125,fS=2,Og=1,Rg=1,Fg=.1;var Jf=class extends Ot{constructor(t,r){super();this.object=t;this.domElement=r;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.preventScroll=!0;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,fn.DOLLY_ROTATE,fn.PAN];this.offset=new A;this.eye=new A;this.lastPosition=new A;this.lastQuaternion=new jt;this.current=new O;this.overShoot=new O;this.overRatio=new O;this.spherical=new bc;this.sphericalDelta=new bc;this.panOffset=new A;this.panLeftV=new A;this.panUpV=new A;this.panV=new A;this.rotateStart=new O;this.rotateEnd=new O;this.rotateDelta=new O;this.panStart=new O;this.panEnd=new O;this.panDelta=new O;this.dollyStart=new O;this.dollyEnd=new O;this.dollyDelta=new O;this.rotationRangeFactor=new O;this.panRangeFactor=new O;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(Ng.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(Ng),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-Bg),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let r=this.spherical.phi%pO;return this.eye.copy(this.offset).normalize(),this.object.up.copy(lt.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),r>0&&r>Math.PI||r<0&&r>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-Bg,this.sphericalDelta.phi*=1-Bg):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>gO||8*(1-this.lastQuaternion.dot(this.object.quaternion))>mO?(this.dispatchEvent(Ig),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,ft.length===0&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),vO(t),t.pointerType==="touch"?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{pS(t),this.isPointerDown=!1,ft.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(qc),this.state=-1};this.onPointerCancel=t=>{pS(t)};this.onPointerDownMouse=t=>{let r;switch(this.useKeyEvents?r=this.mouseButtons[t.button]:r=this.mouseButtonsPlay[t.button],r){case 0:if(t.altKey===!0&&!t.shiftKey&&!Rc(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(Rc(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(Rc(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Za)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(mS(t),this.touches[ft.length-1]){case fn.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case fn.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case fn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case fn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Za)};this.onPointerMoveTouch=t=>{switch(mS(t),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Ic(()=>this.dispatchEvent(qc),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||((this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth||this.preventScroll)&&t.preventDefault(),this.dispatchEvent(Za),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Za),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(qc)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchMove=t=>{(t.touches.length>1||this.preventScroll)&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp(ft[0]))};this.onPointerHover=t=>{if(!(xf||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let r={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(r):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(r),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,Fg):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,Fg),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.object=t,this.domElement=r,this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ig),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,r,i){this.target.copy(t),this.object.position.copy(r),this.object.zoom=i,this.object.updateProjectionMatrix(),this.dispatchEvent(Ig),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),Fg=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,uS=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(Ng.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Os(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=Os(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=Os(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=Os(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,this.preventScroll=t.preventScroll,t.orbitTouches===1&&(this.touches[0]=fn.ROTATE),t.panTouches===1&&(this.touches[0]=fn.PAN),t.orbitTouches===2&&(this.touches[1]=fn.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=fn.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=fn.ROTATE),t.panTouches===3&&(this.touches[2]=fn.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),So||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchmove",this.onTouchMove),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),So||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchmove",this.onTouchMove),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,r,i,s,o,a,l,c){this.overShoot.set(0,0);let h,u,f;t instanceof A?(h=t.x,u=t.y,this.current.set(this.target.x,this.target.y),f=!0):(h=t.theta,u=t.phi,this.current.set(Os(this.spherical.theta),Os(this.spherical.phi)),f=!1),i===0&&(this.current.x+=h,this.current.y+=u),(r===3||r===2)&&(!f&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(h=0)),(r===3||r===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(u=0)),f||(this.overShoot.x=Os(this.overShoot.x),this.overShoot.y=Os(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(c),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=dS(Math.abs(this.overRatio.x)),this.overRatio.y=dS(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(h*this.overShoot.x<0&&(h*=1-this.overRatio.x),u*this.overShoot.y<0&&(u*=1-this.overRatio.y)):i===2&&(!f&&(this.overRatio.x>.002||this.overRatio.y>.002)||f&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(h=this.overShoot.x*.05,u=this.overShoot.y*.05,f?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):f?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,u+=this.overShoot.y),t instanceof A?(t.x=h,t.y=u):(t.theta=h,t.phi=u)}setEnableDampingSpeed(t){this.enableDamping=t,Og=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*uS}getZoomScale(){return Math.pow(.95,fS)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,r){this.panLeftV.setFromMatrixColumn(r,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,r){this.panUpV.setFromMatrixColumn(r,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,r){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*r*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(r*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(fO)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(hS)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(hS)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Za),this.dollyOut(t),this.dispatchEvent(qc)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Za),this.dollyIn(t),this.dispatchEvent(qc)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,r=1){this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og*r).rotateAround(dO,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,r=1){this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Rg*r),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(t){if(Tw===!1&&Rc(t)===!1&&yO(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(Rg),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),r=.5*(ft[0].pageY+ft[1].pageY);this.rotateStart.set(t,r)}else this.rotateStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartPan(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),r=.5*(ft[0].pageY+ft[1].pageY);this.panStart.set(t,r)}else this.panStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartDolly(){let t=ft[0].pageX-ft[1].pageX,r=ft[0].pageY-ft[1].pageY,i=Math.sqrt(t*t+r*r);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(ft.length===2){let i=zg(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==ft[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og);let r=this.domElement;r&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/r.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/r.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(ft.length===2){let r=zg(t),i=.5*(t.pageX+r.x),s=.5*(t.pageY+r.y);this.panEnd.set(i,s)}else{if(t.pointerId!==ft[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Rg),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let r=zg(t),i=t.pageX-r.x,s=t.pageY-r.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,fS)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function Os(n){let e=Math.PI*2;for(;n<=-Math.PI;)n+=e;for(;n>Math.PI;)n-=e;return n}function dS(n){return 1-Math.pow(1-n,4)}function yO(n){return n.wheelDeltaY===0||n.deltaY===0?Oc&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120?!1:n.wheelDeltaX?n.wheelDeltaX===-3*n.deltaX:n.deltaMode===0:n.wheelDeltaY?n.wheelDeltaY===-3*n.deltaY:n.deltaMode===0}var ft=[],Qf={};function vO(n){ft.push(n)}function pS(n){delete Qf[n.pointerId];for(let e=0;e<ft.length;e++)if(ft[e].pointerId===n.pointerId){ft.splice(e,1);return}}function mS(n){let e=Qf[n.pointerId];e===void 0&&(e=new O,Qf[n.pointerId]=e),e.set(n.pageX,n.pageY)}function zg(n){let e=n.pointerId===ft[0].pointerId?ft[1]:ft[0];return Qf[e.pointerId]}var Rs=class extends Eu{constructor(){super(),this.layers.enable(3)}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,r=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,r)}),r}createRaycastLineHelper(){let e=new Zr({color:65280,linewidth:10}),t=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new A().addVectors(t,r.multiplyScalar(i)),o=new Le;return o.setFromPoints([t,s]),new ao(o,e)}};var yS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},n.parameters),r=t.width/2,i=t.radiusTop??r,s=t.radiusBottom??r;return i===s?(i=r,s=r):i>s?(i=r,s=s*r/i):(i=i*r/s,s=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(n){let{width:e,depth:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:h,cornerRadius:u,cornerSegments:f,hollow:d}=n.parameters,m;return u||d?m=new Yc(c,h,r,i,s,o,a,l*Math.PI/180,u,u,f,d):m=new co(c,h,r,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Fs(n,e,t){t.x=n.x*e.x,t.y=n.y,t.z=n.x*e.y}function gS(n){return new O(n.y,-n.x)}var Yc=class extends Le{constructor(e,t,r,i,s,o,a,l,c,h,u,f,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,h=0);let m=[],p=[],g=[],x=[],v=0,w=r/2,b=new A,S=new A;d&&e==0&&(e=c),d&&t==0&&(t=h);let M=new O(e,w),_=new O(t,-w),y=null,T=null,E=null,C=null,I=M.clone().sub(_),B=0,N=0,H=0;f>0&&(B=Math.min(e,t)*(1-f),N=e-B,H=t-B);let j=M.clone();j.x-=B;let Q=Math.PI-I.angle(),X=I.angle(),U=Math.tan(X/2),F=Math.tan(Q/2),V=U+F,R=f?V:F,G=f?V:U;if(c=Math.min(c,(e-N)/R,I.length()/V),h=Math.min(h,(t-H)/G,I.length()/V),c>0){let te=c/U;y=M.clone().sub(new O(te,c)),f&&(E=y.clone(),E.x-=B-V*c),M.sub(I.clone().setLength(te))}if(h>0){let te=h/F;T=_.clone().sub(new O(te,-h)),_.add(I.clone().setLength(te)),f&&(C=T.clone(),C.x-=B-V*h,j.sub(I.clone().setLength(te)))}I=M.clone().sub(_);let W=I.length()<.5,Y=[];for(let te=0;te<=i;te++){let k=[],le=te/i,ce=le*l+a,ae=new O(Math.sin(ce),Math.cos(ce));C&&T?(q(k,le,ae,Q,h,C,-1,!0),q(k,le,ae,X,h,T,-1,!1)):T?(se(k,ae,T.x,0,-1),q(k,le,ae,X,h,T,-1,!1)):o||se(k,ae,t,H,-1);let fe=gS(I).normalize();if(Fs(fe,ae,b),!W)for(let ge=0;ge<=s;ge++){let de=ge/s,_e=I.clone().multiplyScalar(de).add(_);Fs(_e,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/r),k.push(v++)}if(E&&y?(q(k,le,ae,Q,c,y,1,!1),q(k,le,ae,X,c,E,1,!0)):y?(q(k,le,ae,Q,c,y,1,!1),se(k,ae,y.x,0,1)):o||se(k,ae,e,N,1),f&&!W){let ge=gS(I).multiplyScalar(-1).normalize();Fs(ge,ae,b);for(let de=0;de<=s;de++){let _e=de/s,Ee=I.clone().multiplyScalar(-_e).add(j);Fs(Ee,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/r),k.push(v++)}}f&&!o&&k.push(k[0]),Y.push(k)}for(let te=0;te<Y.length-1;te++)for(let k=0;k<Y[0].length-1;k++){if(o&&f&&k==s)continue;let le=Y[te][k],ce=Y[te+1][k],ae=Y[te+1][k+1],fe=Y[te][k+1],ge=p[ae*3+0],de=p[ae*3+2];m.push(le,ce,fe),(ge!=0||de!=0)&&m.push(ce,ae,fe)}l<Math.PI*2&&(K(-1,Y[0],a),K(1,Y[Y.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(x,2));function q(te,k,le,ce,ae,fe,ge,de){for(let _e=0;_e<u+1;_e++){let Ee=_e/u,ye=ge<0?Ee:1-Ee;de&&(ye-=1),ye*=ce;let Oe=new O(Math.sin(ye),Math.cos(ye)*ge),pt=Oe.clone().multiplyScalar(ae).add(fe);Fs(pt,le,S),p.push(S.x,S.y,S.z),Fs(Oe,le,b),g.push(b.x,b.y,b.z),x.push(k,.5+S.y/r),te.push(v++)}}function se(te,k,le,ce,ae){let fe=new A,ge=new O,de=[le,ce];ae<0&&de.reverse();for(let _e of de)ge.set(_e,w*ae),Fs(ge,k,fe),p.push(fe.x,fe.y,fe.z),g.push(0,ae,0),x.push(.5,.5),te.push(v++)}function K(te,k,le){let ce=new O(Math.sin(le),Math.cos(le)),ae=new O(-Math.cos(le),Math.sin(le)),fe=new A,ge=te<0?(Ee,ye,Oe)=>m.push(Ee,ye,Oe):(Ee,ye,Oe)=>m.push(Ee,Oe,ye),de=new O((e+t+N+H)/4,0);Fs(de,ce,fe),p.push(fe.x,fe.y,fe.z),g.push(ae.x,0,ae.y),x.push(.5,.5);let _e=v++;for(let Ee of k){let ye=p.slice(Ee*3,Ee*3+3);p.push(...ye),g.push(ae.x,0,ae.y);let Oe=x.slice(Ee*2,Ee*2+2);x.push(...Oe),v++}for(let Ee=_e+1;Ee<v-1;Ee++)ge(_e,Ee,Ee+1);ge(_e,v-1,_e+1)}}};var vS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,depth:t,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:h,cornerSegments:u}=n.parameters,f;return c>0||h>0||l<360?f=new Yc(0,e/2,r,i,s,o,a,l*Math.PI/180,c,h,u,0,!0):f=new ha(e/2,r,i,s,o),f.scale(1,1,t/e),Object.assign(f,{userData:{...n,type:"ConeGeometry"}})}};var xS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a==0?c=new Kr(e,t,r,i,s,o):c=new Gg(e,t,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},Ug=Math.PI/2,Gg=class extends Le{constructor(e=1,t=1,r=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,r/2);let h=[],u=[],f=[],d=[],m=0,p=0;g("z","y","x",-1,-1,r,t,e,o,s,0),g("z","y","x",1,-1,r,t,-e,o,s,1),g("x","z","y",1,1,e,r,t,i,o,2),g("x","z","y",1,-1,e,r,-t,i,o,3),g("x","y","z",1,-1,e,t,r,i,s,4),g("x","y","z",-1,-1,e,t,-r,i,s,5),a>0&&(x("z","y","x",-1,-1,1,r,t,e,o,0),x("z","y","x",1,-1,-1,r,t,e,o,1),x("z","y","x",-1,1,-1,r,t,e,o,1),x("z","y","x",1,1,1,r,t,e,o,0),x("x","y","z",-1,-1,-1,e,t,r,i,0),x("x","y","z",1,-1,1,e,t,r,i,1),x("x","y","z",-1,1,1,e,t,r,i,0),x("x","y","z",1,1,-1,e,t,r,i,1),x("y","x","z",-1,-1,1,t,e,r,s,0),x("y","x","z",1,-1,-1,t,e,r,s,1),x("y","x","z",1,1,1,t,e,r,s,1),x("y","x","z",-1,1,-1,t,e,r,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(f,3)),this.setAttribute("uv",new Ae(d,2));function g(w,b,S,M,_,y,T,E,C,I,B){let N=(y-2*a)/C,H=(T-2*a)/I,j=y/2-a,Q=T/2-a,X=E/2,U=C+1,F=I+1,V=0,R=0,G=new A;for(let W=0;W<F;W++){let Y=W*H-Q;for(let q=0;q<U;q++){let se=q*N-j;G[w]=se*M,G[b]=Y*_,G[S]=X,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[S]=E>0?1:-1,f.push(G.x,G.y,G.z),d.push(q/C),d.push(1-W/I),V+=1}}for(let W=0;W<I;W++)for(let Y=0;Y<C;Y++){let q=m+Y+U*W,se=m+Y+U*(W+1),K=m+(Y+1)+U*(W+1),te=m+(Y+1)+U*W;h.push(q,se,te),h.push(se,K,te),R+=6}c.addGroup(p,R,B),p+=R,m+=V}function x(w,b,S,M,_,y,T,E,C,I,B){let N=(T-2*a)/I,H=T/2-a,j=E/2-a,Q=C/2,X=I+1,U=0,F=0,V=new A,R=new A;for(let G=0;G<l+1;G++){let W=G/l*Ug,Y=Math.sin(W)*a,q=(1-Math.cos(W))*a,se=Math.sin(W),K=Math.cos(W);V[b]=(j+Y)*_,V[S]=(Q-q)*y,R[w]=0,R[b]=se*Math.sign(V[b]),R[S]=K*Math.sign(V[S]);for(let te=0;te<X;te++){let k=te*N-H;V[w]=k*M,u.push(V.x,V.y,V.z),f.push(R.x,R.y,R.z),d.push(te/I),d.push(0),U+=1}}for(let G=0;G<l;G++)for(let W=0;W<I;W++){let Y=m+W+X*G,q=m+W+X*(G+1),se=m+(W+1)+X*(G+1),K=m+(W+1)+X*G;h.push(Y,q,K),h.push(q,se,K),F+=6}c.addGroup(p,F,B),p+=F,m+=U}function v(w,b,S){let M=new A,_=new A(e/2,t/2,r/2);_.subScalar(a);let y=[],T=w*b*S>0?(C,I,B)=>h.push(C,I,B):(C,I,B)=>h.push(C,B,I);for(let C=0;C<=l;C++){let I=[],B=Ug*(1-C/l),N=Math.cos(B),H=Math.sin(B),j=0;for(let Q=0;Q<=C;Q++){let X=Math.cos(j),U=Math.sin(j);M.x=N*X,M.y=H,M.z=N*U;let F=_.clone().addScaledVector(M,a);u.push(w*F.x,b*F.y,S*F.z),f.push(w*M.x,b*M.y,S*M.z),d.push(0,0),I.push(m++),j+=Ug/C}y.push(I)}let E=y.length-1;for(let C=0;C<E;C++){let I=y[C],B=y[C+1],N=I.length-1;T(I[0],B[1],B[0]);for(let H=1;H<=N;H++)T(I[H-1],I[H],B[H]),T(I[H],B[H+1],B[H])}}}};var zs=class extends Le{constructor(e=[],t=[],r="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];h(),u(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(l,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(o=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new A,p=m.clone(),g=new Qr,x=s*i,v=i-x,w=o+1,b=new A,S=(U,F)=>b.subVectors(U,F).normalize(),M=(U,F)=>Array(U).fill(void 0).map(F),_=M(e.length/3,(U,F)=>new A().fromArray(e,F*3).setLength(i)),y=[],T=1e6;for(let U=0;U<_.length;U++){let F=_[U],V=[],R,G,W,Y=1e10,q=-1;for(;(q=t.indexOf(U,q+1))!=-1;){let k=q-q%3;R=t[k+(q+1)%3],G=t[k+(q+2)%3],W=F.distanceToSquared(_[R]),Y=Math.min(Y,W),V.push([R,G,W])}Y+=1e-6;let se=[],K=0,te=V.length;for(let k=0;k<te;k++){[R,G,W]=V[K];let le=y[R]?.includes(U)==!0;W<=Y&&se.push(R+ +le*T),K=V.findIndex(ce=>ce[0]==G)}y.push(se)}let E=[];{let U=0,F=0,V,R,G=d==3;for(let W=0;W<=o;W++){V=W*(W+1)/2,R=(W+1)*(W+2)/2;for(let Y=0;Y<o-W;Y++)[U,F]=[V+Y+W+2,R+Y+W+3],E.push(V,R,...G?[F,V]:[U,R],F,U),[V,R]=[U,F];E.push(V,R,V+o+2)}}let C=m.clone(),I=m.clone(),B=m.clone(),N=m.clone(),H=m.clone(),j=[],Q=M(_.length,()=>M(d,()=>m.clone()));for(let U=0;U<_.length;U++){m.copy(_[U]).normalize(),C.copy(m).multiplyScalar(v);let F=y[U];for(let se=0;se<F.length;se++){let K=F[se],te=F[(se+1)%d];g.setFromPointsAndIndices(_,U,K%T,te%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,Q[U][se])}let V=[],R=[],G=[],W=new A;o==0&&[...Q[U]].reduce((se,K)=>se.add(K),W).multiplyScalar(1/d);for(let se=0;se<d;se++){let K=[],te=(se-1+d)%d,k=Q[U][te],le=Q[U][se];m.copy(k).sub(C),p.copy(le).sub(C);let ce=C.angleTo(m),ae=m.angleTo(p),fe=Math.cos(ce)*x;o==0?I.copy(W):I.copy(C).setLength(v+fe),R.push(fe);let ge=[I,k,le];for(let de=0;de<2;de++){let _e=ge[de],Ee=ge[de+1];N.subVectors(_e,C),H.subVectors(Ee,C),B.crossVectors(N,H).normalize();for(let ye=0;ye<w;ye++){let Oe=[ce,ae][de]*ye/w;m.copy(N).applyAxisAngle(B,Oe).add(C),V.push(m.clone()),de&&(S(m,C),K.push([ye==0?_e:m.clone(),b.clone()]))}de&&(S(Ee,C),K.push([Ee,b.clone()]))}G.push(K)}j.push(G);let Y=2*w,q=2;for(let se=0;se<d;se++){let K=Y*se,te=Y*((se+1)%d),k=[V[K]];for(let ce=1;ce<w;ce++){N=V[K+ce],H=V[te+ce],k.push(N);for(let ae=1,fe=ce-q+1;ae<=fe;ae++)m.lerpVectors(N,H,ae/(fe+1)),m.sub(C).setLength(R[se]).add(C),k.push(m.clone());k.push(H)}for(let ce=0;ce<w;ce++)k.push(V[ce+w+K]);k.push(V[te+w]);let le=E.map(ce=>k[ce]);a.push(...le.map(ce=>[ce.x,ce.y,ce.z]).flat()),c.push(...le.map(ce=>(S(ce,C),[b.x,b.y,b.z])).flat())}}let X=[];for(let U=0;U<y.length;U++)for(let F=0;F<d;F++){let V=y[U][F];if(V<T){let R=y[V].findIndex(Y=>Y%T==U),G=j[U][F],W=j[V][R];for(let Y=0;Y<w;Y++){let q=G[Y],se=W[w-Y],K=G[Y+1],te=W[w-(Y+1)];[q,se,K,K,se,te].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}X.push(G[0][0],W[w][0],G[w][0],W[0][0])}}for(;X.length;){let U,F,V,R;[U,F]=X.splice(0,2);let G=[U];for(;U!=F;)G.push(F),V=X.indexOf(F),R=V%2,F=X.splice(V-R,2)[1-R];b.subVectors(G[0],G[1]).cross(m.subVectors(G[0],G[2])).normalize();let W=b.dot(G[0])<0;W&&b.negate();for(let Y=1;Y<=G.length-2;Y++)[G[Y+ +W],G[Y+1-+W],G[0]].forEach(q=>{a.push(q.x,q.y,q.z),c.push(b.x,b.y,b.z)})}}function u(){let f=new A;for(let _=0;_<a.length;_+=3){f.x=a[_+0],f.y=a[_+1],f.z=a[_+2];let y=S(f)/2/Math.PI+.5,T=M(f)/Math.PI+.5;l.push(y,1-T)}let d=new A,m=new A,p=new A,g=new A,x=new O,v=new O,w=new O,b=(_,y,T,E)=>{E<0&&_.x===1&&(l[y]=_.x-1),T.x===0&&T.z===0&&(l[y]=E/2/Math.PI+.5)};for(let _=0,y=0;_<a.length;_+=9,y+=6){d.set(a[_+0],a[_+1],a[_+2]),m.set(a[_+3],a[_+4],a[_+5]),p.set(a[_+6],a[_+7],a[_+8]),x.set(l[y+0],l[y+1]),v.set(l[y+2],l[y+3]),w.set(l[y+4],l[y+5]),g.copy(d).add(m).add(p).divideScalar(3);let T=S(g);b(x,y+0,d,T),b(v,y+2,m,T),b(w,y+4,p,T)}for(let _=0;_<l.length;_+=6){let y=l[_+0],T=l[_+2],E=l[_+4],C=Math.max(y,T,E),I=Math.min(y,T,E);C>.9&&I<.1&&(y<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),E<.2&&(l[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function M(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(e){return new zs(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var bS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new Xc(e*.5,s,o):new fa(e*.5,i);return a.scale(1,t/e,r/e),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Xc=class extends zs{constructor(e=1,t=.2,r=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,r),this.type=l}static fromJSON(e){return new Xc(e.radius,e.corner,e.cornerSides)}};var Jc=1e-12,$a=class{constructor(e){this.position=new O;this.startPosition=new O;this.uuid=je.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 $a(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},el=class extends $a{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new el(this.parent).copy(this)}},qn=class extends $a{constructor(t,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new el(this),new el(this))}static create(t,r){let i=new qn(t,new O(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(t){let r=this.controls.indexOf(t);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(t,r=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new qn(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[t,r]}computeNormals(t=new O,r=new O){let[i,s]=this.computeTangents();return i&&s&&(wS(i,t),wS(s,r)),[t,r]}computeTangent(t=new O){let[r,i]=this.computeTangents();return r&&i&&t.copy(r).add(i).normalize(),t}computeNormal(t=new O){let[r,i]=this.computeNormals();return t.copy(r).add(i).normalize(),t}};function wS(n,e=new O){let t=n.length();return e.set(-n.y/t,n.x/t)}var Vg=n=>n,tl=new O,Kf=new O,xO=new O,bO=new O,wO=new O,SO=new O,AS=new A,MS=new A;function _S(n){let e=new O;e.addVectors(n.v0,tl.subVectors(n.v1,n.v0).multiplyScalar(2/3));let t=new O;return t.addVectors(n.v2,Kf.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new $r(n.v0,e,t,n.v2)}function Qc(n,e,t=Number.EPSILON){return Math.abs(n-e)<t}function AO(n,e,t=Number.EPSILON){return n.distanceTo(e)<t}function MO(n,e,t=Number.EPSILON){return n.distanceTo(e)<t}function Hg(n,e,t){let r=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2));return Math.acos((i*i+r*r-s*s)/(2*i*r))}function TS(n,e,t){return SS(n,e)&&SS(e,t)&&kg(n.position,e.position,t.position)}function kg(n,e,t){return tl.copy(e).sub(n).cross(Kf.copy(t).sub(n))===0}function ES(n,e,t,r,i){let s=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)),o=(n.y+e.y)/2,a=(n.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(n.y-e.y)/s,c=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-n.x)/s;return r.set(a+l,o+c),i.set(a-l,o-c),[r,i]}function CS(n,e,t){let r=n.distanceTo(t),i=e.distanceTo(t);return r<i?e:n}function DS(n,e,t,r,i,s){let o=e.x-n.x,a=e.y-n.y,l=t.x-n.x,c=t.y-n.y,h=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),u;return Hg(e,n,t)>Math.PI&&(h*=-1),Qc(c,a)?u=(a+c)*(r/h-.5)*8/3/(o-l):u=(o+l)*(r/h-.5)*8/3/(c-a),i.set(e.x-u*a,e.y+u*o),s.set(t.x+u*c,t.y-u*l),[i,s]}function Wg(n,e){return n.position.equals(n.controls[1].position)&&e.position.equals(e.controls[0].position)}function SS(n,e){return kg(n.position,n.controls[1].position,e.position)&&kg(n.position,e.controls[0].position,e.position)}function PS(n,e,t,r,i=.5){let s=tl.subVectors(e,n).multiplyScalar(i).add(n),o=Kf.subVectors(t,e).multiplyScalar(i).add(e),a=xO.subVectors(r,t).multiplyScalar(i).add(t),l=s,c=bO.subVectors(o,s).multiplyScalar(i).add(s),h=wO.subVectors(a,o).multiplyScalar(i).add(o),u=a,f=SO.subVectors(h,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,f.x,f.y,h.x,h.y,u.x,u.y,r.x,r.y]}function LS(n,e,t=12,r=!0){let i=MS.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let c=Vg(e[l]),h=tl,u=Us(c,t);a.push(u);for(let f=0;f<=u;f++)if(c instanceof $r||c instanceof kn||c instanceof en){if(c.getPoint(f/u,h),i.set(h.x,h.y,0),s!==void 0&&MO(s,i))continue;s===void 0&&(s=AS),s.copy(i),n.setXYZ(o,i.x,i.y,i.z),o++}}return r&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),n}function IS(n,e,t,r=12,i=!0){let s=MS.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,h=Vg(e[l]),u=tl,f=Us(h,r);a.push(f);for(let d=0;d<=f;d++)if(h instanceof $r||h instanceof kn||h instanceof en){if(h.getPoint(d/f,u),s.set(u.x,u.y,0),c?.equals(s))continue;c===void 0?c=AS:(n.setXYZ(o,c.x,c.y,c.z),o++,n.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return i&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),a}function jg(n,e=12,t=!1){let r=[];for(let i=0,s=n.length;i<s;i++){let o=n[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=Us(o.roundedCurveCorner,e)*.5;i>0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Us(o.curveAfter,e)),r.push(a)}return n.length>0&&t&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Us(n[0].roundedCurveCorner,e)*.5),r}function Us(n,e=12){return n&&n instanceof lo?e*2:n&&(n instanceof en||n instanceof dc)?1:n&&n instanceof la?e*n.points.length:e}function NS(n,e,t=12,r=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=Vg(e[o]),l=Us(a,t),c=tl;for(let h=0;h<=l;h++)if(a instanceof $r||a instanceof kn||a instanceof en){if(a.getPoint(h/l,c),i!==void 0&&AO(i,c,Jc))continue;i===void 0&&(i=Kf),i.copy(c),n.push(c.x,c.y),s++}}return Qc(n[0],n[n.length-2],Jc)&&Qc(n[1],n[n.length-1],Jc)&&(n.pop(),n.pop()),r&&s>1&&!(Qc(n[s-1],n[1],Jc)&&Qc(n[s-2],n[0],Jc))&&(n.push(n[0],n[1]),s++),n}var qg=new O,_O=new O,TO=new O,EO=new O,CO=new O,DO=new O,dt=class extends Fn{constructor(t=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Ot;this.plane=new Gr(new A(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=je.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=r}static createFromState(t,r,i){let s=new dt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>qn.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>dt.createFromState(o)),r!==void 0&&i!==void 0&&s.applySize(r,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let r=0,i=this.points.length;r<i;r++)this.points[r].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(t){let r=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length-1,h=l.getPointIndexById(t);if(h<0)s+=c;else return h+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0)for(let r=0,i=this.shapeHoles.length;r<i;r++){let s=this.shapeHoles[r],o=t-this.points.length;if(o<=s.points.length-1)return s.points[o]}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let r=this.points.indexOf(t);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...t]}applySize(t,r){t===0&&(t=.001),r===0&&(r=.001),this._width=t,this._height=r}applyScale(t,r){let i=qg.set(t,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,r);this._update(!1)}createPoint(t,r=0,i=je.generateUUID()){let s;t instanceof O?s=t:s=new O(t,r);let o=new qn(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,r){this.points.splice(r,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let r=0,i=this.points.length;r<i;r++){let s=this.points[r];if(s.uuid===t)return s}for(let r=0,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let r=this.points.indexOf(t);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(t){let r=this.points.find(i=>i.uuid===t);r&&this.removePoint(r)}update(t=!0){for(let r=0,i=this.shapeHoles.length;r<i;r++)this.shapeHoles[r].update(!1);this._update(t)}extractShapePointsToBuffer(t,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=i?this.roundedCurveDivisions:this.curveDivisions;return LS(t,i?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=jg(this.points,t,!1),this.roundedCurveDivisions=jg(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,r,i=12){return IS(t,this.curves,r,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),NS(t,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(t,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=Us(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let h=s[l];if(a<i+h)return[l,(a-i+1)/h];i+=h}return[0,1]}getCurveT(t,r,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(Wg(s,o)){let u=s.position.distanceTo(o.position);return s.position.distanceTo(qg.set(i.x,i.y))/u}let c=0;for(let u=0;u<t;u++)c+=a[u];return(r-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,r){Wg(r,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,r.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,r.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let r=this.getLastPoint();if(r?.curveAfter&&(r.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],c=this.points[s+1]??this.points[0],h=a.roundness,u=l&&c&&TS(l,a,c);if(!a.controlsMoved()&&h>0&&!u){let f=a.curveBefore,d=a.curveAfter;if(f===void 0||d===void 0)continue;let m=a.roundedCurveBefore,p=a.roundedCurveAfter,g=f.getLength(),x=d.getLength(),v=Math.min(h,g*.499),w=Math.min(h,x*.499),b=Math.min(v,w),S=1-b/g,M=b/x,_=f.getPointAt(S,qg),y=d.getPointAt(M,_O);this._subSplitCurve(f,m,S,_,void 0),this._subSplitCurve(d,p,M,void 0,y);let T;if(this.useCubicForRoundedCorners){let E=Hg(_,a.position,y)/2,C=Math.tan(E)*_.distanceTo(a.position),[I,B]=ES(_,y,C,TO,EO),N=CS(I,B,a.position),[H,j]=DS(N,_,y,C,CO,DO);T=new $r(_.clone(),H.clone(),j.clone(),y.clone())}else T=new kn(_.clone(),a.position.clone(),y.clone());a.roundedCurveCorner=T,this.roundedCurves.splice(s+i,0,T),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,r,i,s,o){if(t instanceof en)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=t,l=r,c=a.getUtoTmapping(i,0),h=PS(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(h[0],h[1]),l.v1.set(h[2],h[3]),l.v2.set(h[4],h[5]),l.v3.set(h[6],h[7])),o!==void 0&&(l.v0.set(h[6],h[7]),l.v1.set(h[8],h[9]),l.v2.set(h[10],h[11]),l.v3.set(h[12],h[13])),l}return r}clone(){let t=new dt(this._width,this._height);return t.points=this.points.map(r=>r.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(r=>r.clone()),t}toJSON(){return{points:this.points.reduce((t,r)=>t.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let r=t.points.length/7;for(let i=0;i<r;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],c=t.points[s+3],h=t.points[s+4],u=t.points[s+5],f=t.points[s+6],d=new qn(je.generateUUID(),new O(o,a));d.controls[0].position.set(l,c),d.controls[1].position.set(h,u),d.roundness=f,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new dt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let r=(s,o)=>{o instanceof $r&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof kn&&(s[a]=_S(s[a]));for(a=0,l=s.length;a<l;a++){let u=s[a],f=a>0?s[a-1]:null,d;u instanceof $r?(d=this.createPoint(u.v0),d.controls[1].position.copy(u.v1)):u instanceof en&&(d=this.createPoint(u.v1)),d!==void 0&&(f!==null&&r(d,f),o.push(d))}let c=s[s.length-1],h=!1;return c instanceof $r?c.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(c.v2),h=!0):c instanceof en&&c.v2.equals(o[0].position)&&(h=!0),this.isClosed=h,o};return this.points=i(t.curves),t instanceof Fn&&(this.shapeHoles=t.holes.map(s=>{let o=new dt;return o.fromShape(s),o})),this.update(),this}};var Xg=Math.PI*2;function Yg({x:n,y:e},t,r,i,s){return{x:n*t+i,y:e*r+s}}function PO(n,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(n),i=Math.sin(n),s=Math.cos(n+e),o=Math.sin(n+e);return[{x:r-i*t,y:i+r*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function BS(n,e,t,r){let i=n*r-e*t<0?-1:1,s=Math.min(1,Math.max(-1,n*t+e*r));return i*Math.acos(s)}function LO(n,e,t,r,i,s,o,a,l,c){let h=Math.pow(i,2),u=Math.pow(s,2),f=Math.pow(o,2),d=Math.pow(a,2),m=h*u-h*d-u*f;m<0&&(m=0),m/=h*d+u*f,m=Math.sqrt(m)*(l===c?-1:1);let p=m*i/s*a,g=m*-s/i*o,x=p+(n+t)/2,v=g+(e+r)/2,w=(o-p)/i,b=(a-g)/s,S=(-o-p)/i,M=(-a-g)/s,_=BS(1,0,w,b),y=BS(w,b,S,M);return!c&&y>0&&(y-=Xg),c&&y<0&&(y+=Xg),{centerx:x,centery:v,ang1:_,ang2:y}}function OS({px:n,py:e,cx:t,cy:r,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(n-t)/2,h=(e-r)/2;if(c===0&&h===0)return[];i=Math.abs(i),s=Math.abs(s);let u=Math.pow(c,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);u>1&&(i*=Math.sqrt(u),s*=Math.sqrt(u));let f=LO(n,e,t,r,i,s,c,h,o,a),{ang1:d,ang2:m}=f,{centerx:p,centery:g}=f,x=Math.abs(m)/(Xg/4);Math.abs(1-x)<1e-7&&(x=1);let v=Math.max(Math.ceil(x),1);m/=v;for(let w=0;w<v;w++)l.push(PO(d,m)),d+=m;return l.map(w=>{let{x:b,y:S}=Yg(w[0],i,s,p,g),{x:M,y:_}=Yg(w[1],i,s,p,g),{x:y,y:T}=Yg(w[2],i,s,p,g);return{x1:b,y1:S,x2:M,y2:_,x:y,y:T}})}var Rt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Rt||(Rt={}));var ur;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ur||(ur={}));function Ge(n,e){if(!n)throw e||"Assertion Failed!"}var ze=function(){function n(){}return n.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},n.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},n.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},n.edgeGoesLeft=function(e){return n.vertLeq(e.Dst,e.Org)},n.edgeGoesRight=function(e){return n.vertLeq(e.Org,e.Dst)},n.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},n.edgeEval=function(e,t,r){Ge(n.vertLeq(e,t)&&n.vertLeq(t,r));var i=t.s-e.s,s=r.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-r.t)*(i/(i+s)):t.t-r.t+(r.t-e.t)*(s/(i+s)):0},n.edgeSign=function(e,t,r){Ge(n.vertLeq(e,t)&&n.vertLeq(t,r));var i=t.s-e.s,s=r.s-t.s;return i+s>0?(t.t-r.t)*i+(t.t-e.t)*s:0},n.transEval=function(e,t,r){Ge(n.transLeq(e,t)&&n.transLeq(t,r));var i=t.t-e.t,s=r.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-r.s)*(i/(i+s)):t.s-r.s+(r.s-e.s)*(s/(i+s)):0},n.transSign=function(e,t,r){Ge(n.transLeq(e,t)&&n.transLeq(t,r));var i=t.t-e.t,s=r.t-t.t;return i+s>0?(t.s-r.s)*i+(t.s-e.s)*s:0},n.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},n.interpolate=function(e,t,r,i){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+i)/2:t+(i-t)*(e/(e+r)):i+(t-i)*(r/(e+r))},n.intersect=function(e,t,r,i,s){var o,a,l;n.vertLeq(e,t)||(l=e,e=t,t=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(e,r)||(l=e,e=r,r=l,l=t,t=i,i=l),n.vertLeq(r,t)?n.vertLeq(t,i)?(o=n.edgeEval(e,r,t),a=n.edgeEval(r,t,i),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,t.s)):(o=n.edgeSign(e,r,t),a=-n.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,i.s)):s.s=(r.s+t.s)/2,n.transLeq(e,t)||(l=e,e=t,t=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(e,r)||(l=e,e=r,r=l,l=t,t=i,i=l),n.transLeq(r,t)?n.transLeq(t,i)?(o=n.transEval(e,r,t),a=n.transEval(r,t,i),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,t.t)):(o=n.transSign(e,r,t),a=-n.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,i.t)):s.t=(r.t+t.t)/2},n}(),Kc=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Zf=function(){function n(e){this.side=e,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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),n}(),rl=function(){function n(){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 n}(),RS=function(){function n(){var e=new rl,t=new Kc,r=new Zf(0),i=new Zf(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(e){var t=new Zf(0),r=new Zf(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return r.next=i,i.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},n.prototype.splice_=function(e,t){var r=e.Onext,i=t.Onext;r.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=r},n.prototype.makeVertex_=function(e,t,r){var i=e;Ge(i,"Vertex can't be null!");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},n.prototype.makeFace_=function(e,t,r){var i=e;Ge(i,"Face can't be null");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=r.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},n.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},n.prototype.killVertex_=function(e,t){var r=e.anEdge,i=r;do i.Org=t,i=i.Onext;while(i!==r);var s=e.prev,o=e.next;o.prev=s,s.next=o},n.prototype.killFace_=function(e,t){var r=e.anEdge,i=r;do i.Lface=t,i=i.Lnext;while(i!==r);var s=e.prev,o=e.next;o.prev=s,s.next=o},n.prototype.makeEdge=function(){var e=new rl,t=new rl,r=new Kc,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(e,t){var r=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new rl;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!r){var o=new Kc;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},n.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var i=new Kc;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},n.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new rl;return this.makeVertex_(i,r,t.Org),t.Lface=r.Lface=e.Lface,t},n.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},n.prototype.connect=function(e,t){var r=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!r){var o=new Kc;this.makeFace_(o,i,e.Lface)}return i},n.prototype.zapFace=function(e){var t=e.anEdge,r,i,s,o,a;i=t.Lnext;do r=i,i=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},n.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},n.prototype.mergeConvexFaces=function(e){var t,r,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,o=r.Org;i=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&ze.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&ze.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=i;return!0},n.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,i,s,o,a,l,c;for(s=e,s=e;(i=s.next)!==e;s=i){Ge(i.prev===s),l=i.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===i),l=l.Lnext;while(l!==i.anEdge)}for(Ge(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){Ge(o.prev===a),l=o.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===o),l=l.Onext;while(l!==o.anEdge)}for(Ge(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Ge(l.Sym.next===c.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===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),FS=function(){function n(){this.handle=null}return n}(),zS=function(){function n(){this.key=null,this.node=0}return n}(),IO=function(){function n(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new FS,this.handles[r]=new zS;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(r[t[o+1].handle].key,r[t[o].handle].key)&&++o,Ge(o<=this.max),s=t[o].handle,o>this.size||this.leq(r[i].key,r[s].key)){t[e].handle=i,r[i].node=e;break}t[e].handle=s,r[s].node=e,e=o}},n.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(r[s].key,r[i].key)){t[e].handle=i,r[i].node=e;break}t[e].handle=s,r[s].node=e,e=o}},n.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new FS;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new zS}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},n.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,i=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(e){var t=this.nodes,r=this.handles,i;Ge(e>=1&&e<=this.max&&r[e].key!==null),i=r[e].node,t[i].handle=t[this.size].handle,r[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[t[i>>1].handle].key,r[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},n}(),Jg=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),US=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),NO=function(){function n(e,t){this.frame=e,this.leq=t,this.head=new US,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(e){return this.insertBefore(this.head,e)},n.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},n.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new US;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},n.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},n}(),BO=function(){function n(){}return n.regionBelow=function(e){return e.nodeUp.prev.key},n.regionAbove=function(e){return e.nodeUp.next.key},n.debugEvent=function(e){},n.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},n.edgeLeq=function(e,t,r){var i=e.event,s=t.eUp,o=r.eUp;if(s.Dst===i)return o.Dst===i?ze.vertLeq(s.Org,o.Org)?ze.edgeSign(o.Dst,s.Org,o.Org)<=0:ze.edgeSign(s.Dst,o.Org,s.Org)>=0:ze.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ze.edgeSign(s.Dst,i,s.Org)>=0;var a=ze.edgeEval(s.Dst,i,s.Org),l=ze.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(e,t){t.fixUpperEdge&&Ge(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},n.fixUpperEdge=function(e,t,r){Ge(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},n.topLeftRegion=function(e,t){var r=t.eUp.Org,i;do t=n.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(i=e.mesh.connect(n.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;n.fixUpperEdge(e,t,i),t=n.regionAbove(t)}return t},n.topRightRegion=function(e){var t=e.eUp.Dst;do e=n.regionAbove(e);while(e.eUp.Dst===t);return e},n.addRegionBelow=function(e,t,r){var i=new Jg;return i.eUp=r,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(e,t){switch(e.windingRule){case Rt.ODD:return(t&1)!==0;case Rt.NONZERO:return t!==0;case Rt.POSITIVE:return t>0;case Rt.NEGATIVE:return t<0;case Rt.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(e,t){t.windingNumber=n.regionAbove(t).windingNumber+t.eUp.winding,t.inside=n.isWindingInside(e,t.windingNumber)},n.finishRegion=function(e,t){var r=t.eUp,i=r.Lface;i.inside=t.inside,i.anEdge=r,n.deleteRegion(e,t)},n.finishLeftRegions=function(e,t,r){for(var i,s=null,o=t,a=t.eUp;o!==r;){if(o.fixUpperEdge=!1,s=n.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){n.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),n.finishRegion(e,o),a=s.eUp,o=s}return a},n.addRightEdges=function(e,t,r,i,s,o){var a,l,c,h,u=!0;c=r;do Ge(ze.vertLeq(c.Org,c.Dst)),n.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=n.regionBelow(t).eUp.Rprev),l=t,h=s;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===h.Org;)c.Onext!==h&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(h.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(e,a.windingNumber),l.dirty=!0,!u&&n.checkForRightSplice(e,l)&&(n.addWinding(c,h),n.deleteRegion(e,l),e.mesh.delete(h)),u=!1,l=a,h=c;l.dirty=!0,Ge(l.windingNumber-c.winding===a.windingNumber),o&&n.walkDirtyRegions(e,l)},n.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},n.vertexWeights=function(e,t,r){var i=ze.vertL1dist(t,e),s=ze.vertL1dist(r,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*r.coords[0],e.coords[1]+=o*t.coords[1]+a*r.coords[1],e.coords[2]+=o*t.coords[2]+a*r.coords[2]},n.getIntersectData=function(e,t,r,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,n.vertexWeights(t,r,i),n.vertexWeights(t,s,o)},n.checkForRightSplice=function(e,t){var r=n.regionBelow(t),i=t.eUp,s=r.eUp;if(ze.vertLeq(i.Org,s.Org)){if(ze.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ze.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=r.dirty=!0)}else{if(ze.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;n.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},n.checkForLeftSplice=function(e,t){var r=n.regionBelow(t),i=t.eUp,s=r.eUp,o;if(Ge(!ze.vertEq(i.Dst,s.Dst)),ze.vertLeq(i.Dst,s.Dst)){if(ze.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;n.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(ze.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=r.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},n.checkForIntersect=function(e,t){var r=n.regionBelow(t),i=t.eUp,s=r.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,h,u,f=new rl,d,m;if(Ge(!ze.vertEq(c,l)),Ge(ze.edgeSign(l,e.event,o)<=0),Ge(ze.edgeSign(c,e.event,a)>=0),Ge(o!==e.event&&a!==e.event),Ge(!t.fixUpperEdge&&!r.fixUpperEdge),o===a||(h=Math.min(o.t,l.t),u=Math.max(a.t,c.t),h>u))return!1;if(ze.vertLeq(o,a)){if(ze.edgeSign(c,o,a)>0)return!1}else if(ze.edgeSign(l,a,o)<0)return!1;return n.debugEvent(e),ze.intersect(l,o,c,a,f),Ge(Math.min(o.t,l.t)<=f.t),Ge(f.t<=Math.max(a.t,c.t)),Ge(Math.min(c.s,l.s)<=f.s),Ge(f.s<=Math.max(a.s,o.s)),ze.vertLeq(f,e.event)&&(f.s=e.event.s,f.t=e.event.t),d=ze.vertLeq(o,a)?o:a,ze.vertLeq(d,f)&&(f.s=d.s,f.t=d.t),ze.vertEq(f,o)||ze.vertEq(f,a)?(n.checkForRightSplice(e,t),!1):!ze.vertEq(l,e.event)&&ze.edgeSign(l,e.event,f)>=0||!ze.vertEq(c,e.event)&&ze.edgeSign(c,e.event,f)<=0?c===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=n.topLeftRegion(e,t),i=n.regionBelow(t).eUp,n.finishLeftRegions(e,n.regionBelow(t),r),n.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),r=t,t=n.topRightRegion(t),m=n.regionBelow(t).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(e,r,null),n.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(ze.edgeSign(l,e.event,f)>=0&&(n.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),ze.edgeSign(c,e.event,f)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=f.s,i.Org.t=f.t,i.Org.pqHandle=e.pq.insert(i.Org),n.getIntersectData(e,i.Org,o,l,a,c),n.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(e,t){for(var r=n.regionBelow(t),i,s;;){for(;r.dirty;)t=r,r=n.regionBelow(r);if(!t.dirty&&(r=t,t=n.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=r.eUp,i.Dst!==s.Dst&&n.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(n.deleteRegion(e,r),e.mesh.delete(s),r=n.regionBelow(t),s=r.eUp):t.fixUpperEdge&&(n.deleteRegion(e,t),e.mesh.delete(i),t=n.regionAbove(r),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(n.checkForIntersect(e,t))return}else n.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(n.addWinding(s,i),n.deleteRegion(e,t),e.mesh.delete(i),t=n.regionAbove(r))}},n.connectRightVertex=function(e,t,r){var i,s=r.Onext,o=n.regionBelow(t),a=t.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(e,t),ze.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=n.topLeftRegion(e,t),s=n.regionBelow(t).eUp,n.finishLeftRegions(e,n.regionBelow(t),o),c=!0),ze.vertEq(l.Org,e.event)&&(e.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(e,o,null),c=!0),c){n.addRightEdges(e,t,r.Onext,s,s,!0);return}ze.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(r.Lprev,i),n.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(e,t)},n.connectLeftDegenerate=function(e,t,r){var i,s,o,a,l;if(i=t.eUp,ze.vertEq(i.Org,r)){Ge(!1),n.spliceMergeVertices(e,i,r.anEdge);return}if(!ze.vertEq(i.Dst,r)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,i),n.sweepEvent(e,r);return}Ge(!1),t=n.topRightRegion(t),l=n.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ge(s!==o),n.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(r.anEdge,o),ze.edgeGoesLeft(s)||(s=null),n.addRightEdges(e,t,o.Onext,a,s,!0)},n.connectLeftVertex=function(e,t){var r,i,s,o,a,l,c=new Jg;if(c.eUp=t.anEdge.Sym,r=e.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,ze.edgeSign(o.Dst,t,o.Org)===0){n.connectLeftDegenerate(e,r,t);return}if(s=ze.vertLeq(a.Dst,o.Dst)?r:i,r.inside||s.fixUpperEdge){if(s===r)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var h=e.mesh.connect(a.Dnext,t.anEdge);l=h.Sym}s.fixUpperEdge?n.fixUpperEdge(e,s,l):n.computeWinding(e,n.addRegionBelow(e,r,l)),n.sweepEvent(e,t)}else n.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},n.sweepEvent=function(e,t){e.event=t,n.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){n.connectLeftVertex(e,t);return}var i=n.topLeftRegion(e,r.activeRegion);Ge(i!==null);var s=n.regionBelow(i),o=s.eUp,a=n.finishLeftRegions(e,s,null);a.Onext===o?n.connectRightVertex(e,i,a):n.addRightEdges(e,i,a.Onext,o,o,!0)},n.addSentinel=function(e,t,r,i){var s=new Jg,o=e.mesh.makeEdge();o.Org.s=r,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},n.initEdgeDict=function(e){e.dict=new NO(e,n.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-r,a=e.bmax[1]+r;n.addSentinel(e,i,s,o),n.addSentinel(e,i,s,a)},n.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ge(t.fixUpperEdge),Ge(++r===1)),Ge(t.windingNumber===0),n.deleteRegion(e,t)},n.removeDegenerateEdges=function(e){var t,r,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=r)r=t.next,i=t.Lnext,ze.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(n.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===r||i===r.Sym)&&(r=r.next),e.mesh.delete(i)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},n.initPriorityQ=function(e){var t,r,i,s=0;for(i=e.mesh.vHead,r=i.next;r!==i;r=r.next)s++;for(s+=8,t=e.pq=new IO(s,ze.vertLeq),i=e.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=t.insert(r);return r!==i?!1:(t.init(),!0)},n.donePriorityQ=function(e){e.pq=null},n.removeDegenerateFaces=function(e,t){var r,i,s;for(r=t.fHead.next;r!==t.fHead;r=i)i=r.next,s=r.anEdge,Ge(s.Lnext!==s),s.Lnext.Lnext===s&&(n.addWinding(s.Onext,s),e.mesh.delete(s));return!0},n.computeInterior=function(e,t){t===void 0&&(t=!0);var r,i;if(n.removeDegenerateEdges(e),!n.initPriorityQ(e))return!1;for(n.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!ze.vertEq(i,r));)i=e.pq.extractMin(),n.spliceMergeVertices(e,r.anEdge,i.anEdge);n.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,n.debugEvent(e),n.doneEdgeDict(e),n.donePriorityQ(e),n.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},n}(),OO=function(){function n(){this.mesh=new RS,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=Rt.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 n.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},n.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},n.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},n.prototype.computeNormal_=function(e){var t,r,i,s,o,a,l=[0,0,0],c=[0,0,0],h=[0,0,0],u=[0,0,0],f=[0,0,0],d=[null,null,null],m=[null,null,null],p=this.mesh.vHead;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],c[g]=s,m[g]=t,l[g]=s,d[g]=t;for(t=p.next;t!==p;t=t.next)for(var x=0;x<3;++x)s=t.coords[x],s<c[x]&&(c[x]=s,m[x]=t),s>l[x]&&(l[x]=s,d[x]=t);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,r=m[v],i=d[v],h[0]=r.coords[0]-i.coords[0],h[1]=r.coords[1]-i.coords[1],h[2]=r.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)u[0]=t.coords[0]-i.coords[0],u[1]=t.coords[1]-i.coords[1],u[2]=t.coords[2]-i.coords[2],f[0]=h[1]*u[2]-h[2]*u[1],f[1]=h[2]*u[0]-h[0]*u[2],f[2]=h[0]*u[1]-h[1]*u[0],o=f[0]*f[0]+f[1]*f[1]+f[2]*f[2],o>a&&(a=o,e[0]=f[0],e[1]=f[1],e[2]=f[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(h)]=1)},n.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),r=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},n.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},n.prototype.tessellateMonoRegion_=function(e,t){var r,i;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ze.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(ze.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ze.edgeGoesLeft(i.Lnext)||ze.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(ze.edgeGoesRight(r.Lprev)||ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=e.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},n.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},n.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},n.prototype.setWindingNumber_=function(e,t,r){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:r?e.delete(s):s.winding=0},n.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},n.prototype.outputPolymesh_=function(e,t,r,i){var s,o=0,a=0,l;r>3&&e.mergeConvexFaces(r);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var h=e.fHead.next;h!==e.fHead;h=h.next)if(h.n=-1,!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==h.anEdge);if(l>r)throw"Face vertex greater that support polygon";h.n=o,++o}this.elementCount=o,t===ur.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var u=c.n*i;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],i>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var f=0,h=e.fHead.next;h!==e.fHead;h=h.next)if(!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;this.elements[f++]=c.n,l++,s=s.Lnext}while(s!==h.anEdge);for(var d=l;d<r;++d)this.elements[f++]=-1;if(t===ur.CONNECTED_POLYGONS){s=h.anEdge;do this.elements[f++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==h.anEdge);for(var m=l;m<r;++m)this.elements[f++]=-1}}},n.prototype.outputContours_=function(e,t){var r,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,h=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],t>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==i);this.elements[h++]=s,this.elements[h++]=o,s+=o}},n.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new RS),e<2&&(e=2),e>3&&(e=3);for(var r=null,i=0;i<t.length;i+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[i+0],r.Org.coords[1]=t[i+1],e>2?r.Org.coords[2]=t[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(e,t,r,i,s,o){if(e===void 0&&(e=Rt.ODD),t===void 0&&(t=ur.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),BO.computeInterior(this,o);var a=this.mesh;return t===ur.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===ur.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,r,i),!0},n}();function Eo(n){var e=n.windingRule,t=e===void 0?Rt.ODD:e,r=n.elementType,i=r===void 0?ur.POLYGONS:r,s=n.polySize,o=s===void 0?3:s,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,h=c===void 0?[0,0,1]:c,u=n.contours,f=u===void 0?[]:u,d=n.strict,m=d===void 0?!0:d,p=n.debug,g=p===void 0?!1:p;if(!f&&m)throw new Error("Contours can't be empty");if(!!f){var x=new OO;n.edgeCreateCallback&&(x.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(x.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<f.length;v++)x.addContour(l||2,f[v]);return x.tesselate(t,i,o,l,h,m),{vertices:x.vertices,vertexIndices:x.vertexIndices,vertexCount:x.vertexCount,elements:x.elements,elementCount:x.elementCount,mesh:g?x.mesh:void 0}}}var Aq=Rt.ODD,Mq=Rt.NONZERO,_q=Rt.POSITIVE,Tq=Rt.NEGATIVE,Eq=Rt.ABS_GEQ_TWO,Cq=ur.POLYGONS,Dq=ur.CONNECTED_POLYGONS,Pq=ur.BOUNDARY_CONTOURS;var nl=class extends Le{constructor(t,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=Rt.ODD;this.elementType=ur.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Rt.ODD,elementType:ur.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,h,u;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,x=s[g+0],v=s[g+1];if(h!==void 0&&x!==h&&(l=!1),u!==void 0&&v!==u&&(c=!1),h=x,u=v,!l&&!c)break}!l&&!c&&(a=Eo({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let f=a?.vertexCount??1,d=a?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(f*3),3),this._normalAttribute=new Xe(new Float32Array(f*3),3),this._uvAttribute=new Xe(new Float32Array(f*2),2),this._indexAttribute=new Xe(new Uint32Array(d*3),1),a){let m=1/0,p=-1/0,g=1/0,x=-1/0;for(let b=0,S=f;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1];_<m&&(m=_),_>p&&(p=_),y<g&&(g=y),y>x&&(x=y)}let v=p-m,w=x-g;for(let b=0,S=f;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1],T=(_-m)/v,E=(y-g)/w;this._positionAttribute.setXYZ(b,_,y,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,E)}for(let b=0,S=d;b<S;b++){let M=b*3,_=a.elements[M+0],y=a.elements[M+1],T=a.elements[M+2];this._indexAttribute.setX(M+0,_),this._indexAttribute.setX(M+1,y),this._indexAttribute.setX(M+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new nl(this._shape,this._curveSegments);return t.userData=Lc(this.userData),t}};var $f=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*$f.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,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 r=e*$f.eSize,i=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let c=new Float32Array(i,o*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=t,r}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)}},Zc=$f;Zc.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Qg=(n,e)=>([t,r])=>(r<t&&(r+=e),(n>=t?n:n+e)<=r),il=class extends Le{constructor(t,r,i=0,s=12,o=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=r,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,r/2-1e-12),this._bevelSegments=Math.floor(o));let a=this._shape.extractShapePointsToFlatArray([],s),l=this._shape.shapeHoles.map(_=>{let y=_.extractShapePointsToFlatArray([],s),T=[];for(let E=y.length-1;E>=1;E-=2){let C=y[E-1],I=y[E-0];T.push(C,I)}return T}),c=Eo({windingRule:Rt.ODD,elementType:ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),h=Eo({windingRule:Rt.ODD,elementType:ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let u=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let y=h.elements[_],T=_%2===0?c.vertexCount:0;c.elements.push(y+T)}for(let _=0;_<h.vertexIndices.length;_++){let y=h.vertexIndices[_],T=c.vertexCount;c.vertexIndices.push(y+T)}for(let _=0;_<h.vertices.length;_++){let y=h.vertices[_];c.vertices.push(y)}}let f=1/0,d=-1/0,m=1/0,p=-1/0;for(let _=0,y=c.vertexCount;_<y;_++){let T=_*2,E=c.vertices[T+0],C=c.vertices[T+1];E<f&&(f=E),E>d&&(d=E),C<m&&(m=C),C>p&&(p=C)}this._minX=f,this._minY=m,this._width=d-f,this._height=p-m;let g=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new Zc(g);let x=[],v=[];for(let _=c.elementCount-1;_>=0;_--){let y=_>=u,T=_*2,E=c.elements[T+0],C=c.elements[T+1],I=E+C,B={start:E,count:C,normals:[],continuous:[],concave:[]},N=E,H=I-1,j=E+1,Q=this._shape.roundedCurves.length;do{let V=N-E,R=c.vertices[H*2+0],G=c.vertices[H*2+1],W=c.vertices[N*2+0],Y=c.vertices[N*2+1],q=c.vertices[j*2+0],se=c.vertices[j*2+1],K=W-R,te=Y-G,k=Math.sqrt(K*K+te*te);K/=k,te/=k;let le=W-q,ce=Y-se,ae=Math.sqrt(le*le+ce*ce);le/=ae,ce/=ae,B.normals[V*2+0]=-ce,B.normals[V*2+1]=le,B.concave[V]=K*ce-te*le>0;let fe=c.vertexIndices[N];if(Array.isArray(fe))B.continuous[V]=!1;else{let[ge,de]=this._shape.getCurveIndexFromVertexId(fe-1,!0);if(de>0&&de<1)B.continuous[V]=!0;else{let _e=de===1?ge+1:ge-1;_e=(_e+Q)%Q;let Ee=de===1?0:1,ye=this._shape.roundedCurves[ge].getTangent(de),Oe=this._shape.roundedCurves[_e].getTangent(Ee);B.continuous[V]=ye.dot(Oe)>.95}}y&&(B.normals[V*2+0]*=-1,B.normals[V*2+1]*=-1),[H,N,j]=[N,j,j+1],j>=I&&(j-=C)}while(j!==E+1);let X=[];X.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(E*2,I*2),vertexCount:C,vertexIndices:new Array(C).fill(!0).map((V,R)=>[R,R]),elements:[0,C],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(E*2,I*2)});for(let V=1;V<=this._bevelSegments;V++){let R=V/this._bevelSegments*Math.PI/2,G=(1-Math.cos(R))*this._bevelSize,W=[],Y=[],q=[],se=[],K=0;for(let k=0;k<C;k++){let le=k*2,ce=(k-1+C)%C*2,ae=c.vertices[B.start*2+le+0],fe=c.vertices[B.start*2+le+1],ge=-B.normals[ce+0]*G,de=-B.normals[ce+1]*G,_e=-B.normals[le+0]*G,Ee=-B.normals[le+1]*G;if(B.concave[k]||!B.concave[k]&&y){let ye=Math.atan2(de,ge),Oe=Math.atan2(Ee,_e);Oe>ye&&(Oe-=Math.PI*2);let pt=Oe-ye;if(B.continuous[k]||y){let P=ye+pt/2,D=Math.cos(P)*G,Z=Math.sin(P)*G;W[2*K+0]=ae+D*(y?-1:1),W[2*K+1]=fe+Z*(y?-1:1),se[K]=k,K++}else{let P=Math.max(1,Math.floor(s/4*Math.abs(pt)/Math.PI));for(let D=0;D<=P;D++){let Z=ye+pt*(D/P),ue=Math.cos(Z)*G,pe=Math.sin(Z)*G;W[2*K+0]=ae+ue,W[2*K+1]=fe+pe,se[K]=k,K++}}}else W[2*K+0]=ae+ge,W[2*K+1]=fe+de,se[K]=k,Y[k]=K,K++,W[2*K+0]=ae,W[2*K+1]=fe,se[K]=k,K++,W[2*K+0]=ae+_e,W[2*K+1]=fe+Ee,se[K]=k,q[k]=K,K++}let te=Eo({windingRule:Rt.POSITIVE,elementType:ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[W],edgeCreateCallback:k=>{let ce=k.Org.idx,ae=se[ce],fe=se[(ce+1)%se.length];k.idx=[ae,fe],k.Sym.idx=[fe,ae]},vertexIdCallback:k=>{let le=k.Lprev.idx;return[le?le[1]:0,k.idx[0]]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!te.vertexCount)break;for(let k=0;k<te.vertexIndices.length;k++){let[le,ce]=te.vertexIndices[k];if(le===ce)continue;let ae=ce;ce<le&&(ae+=C);for(let fe=le;fe<ae;fe++){let ge=fe%C,de=(fe+1)%C;if(!B.continuous[ge]||!B.continuous[de]){te.vertexIndices[k]=[le,ge],te.vertexIndices.splice(k+1,0,[de,ce]),te.vertices.splice((k+1)*2,0,te.vertices[k*2],te.vertices[k*2+1]);break}}}X.push({bevelI:V,angle:R,size:G,boundary:te,reverseMap:se,insetPoints:W})}let U=(V,R,G)=>{let W=0,Y=V.boundary.vertexIndices.length;for(;W<Y&&G(V.boundary.vertexIndices[R]);)R=(R+1)%Y,W++;return W},F=x.length;for(let V=1;V<X.length;V++){let R=X[V-1],G=X[V],W=R.boundary.vertexIndices.length,Y=G.boundary.vertexIndices.length;if(!W||!Y)break;let q=B.concave.length,se=0,K=Qg(se,C);for(;!R.boundary.vertexIndices.filter(K).length||!G.boundary.vertexIndices.filter(K).length;)se++,K=Qg(se,C);let te=R.boundary.vertexIndices.findIndex(K),k=G.boundary.vertexIndices.findIndex(K);do te=(te+1)%W;while(K(R.boundary.vertexIndices[te]));do k=(k+1)%Y;while(K(G.boundary.vertexIndices[k]));se=(se+1)%C;let le=se,ce=this.buildBevelVert(B,R,(te-1+W)%W),ae=this.buildBevelVert(B,G,(k-1+Y)%Y),fe=ce,ge=ae,de,_e,Ee=!1;do{K=Qg(se,C);let ye=U(R,te,K),Oe=U(G,k,K),pt=Ee;if(Ee=!1,ye&&!Oe){for(let P=0;P<ye;P++)de=this.buildBevelVert(B,R,(te+P)%W,P/(ye-1)),x.push(fe.topN,de.topP,ge.topN),x.push(de.bottomP,fe.bottomN,ge.bottomN),fe=de;Ee=!0}else if(!ye&&Oe)for(let P=0;P<Oe;P++)_e=this.buildBevelVert(B,G,(k+P)%Y,P/(Oe-1)),x.push(ge.topN,fe.topP,_e.topP),x.push(fe.bottomP,ge.bottomN,_e.bottomP),ge=_e;else if(ye&&Oe)if(de=this.buildBevelVert(B,R,te,0),_e=this.buildBevelVert(B,G,k,0),pt?(x.push(fe.topN,_e.topP,ge.topN),x.push(fe.topN,de.topP,_e.topP),x.push(_e.bottomP,fe.bottomN,ge.bottomN),x.push(_e.bottomP,de.bottomP,fe.bottomN)):(x.push(ge.topN,fe.topN,de.topP),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,fe.bottomN,ge.bottomN),x.push(de.bottomP,ge.bottomN,_e.bottomP)),fe=de,ge=_e,ye===Oe)for(let P=1;P<ye;P++)de=this.buildBevelVert(B,R,(te+P)%W,P/(ye-1)),_e=this.buildBevelVert(B,G,(k+P)%Y,P/(Oe-1)),x.push(fe.topN,de.topP,ge.topN),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,fe.bottomN,ge.bottomN),x.push(de.bottomP,ge.bottomN,_e.bottomP),fe=de,ge=_e;else if(ye>Oe){let P=ye/Oe,D=0;for(let Z=1;Z<ye;Z++)de=this.buildBevelVert(B,R,(te+Z)%W,Z/(ye-1)),x.push(fe.topN,de.topP,ge.topN),x.push(de.bottomP,fe.bottomN,ge.bottomN),fe=de,Z>(D+1)*P&&(D++,_e=this.buildBevelVert(B,G,(k+D)%Y,D/(Oe-1)),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,ge.bottomN,_e.bottomP),ge=_e)}else{let P=Oe/ye,D=0;for(let Z=1;Z<Oe;Z++)_e=this.buildBevelVert(B,G,(k+Z)%Y,Z/(Oe-1)),x.push(ge.topN,de.topP,_e.topP),x.push(de.bottomP,ge.bottomN,_e.bottomP),ge=_e,Z>(D+1)*P&&(D++,de=this.buildBevelVert(B,R,(te+D)%W,D/(ye-1)),x.push(fe.topN,de.topP,ge.topN),x.push(de.bottomP,fe.bottomN,ge.bottomN),fe=de)}te=(te+ye)%W,k=(k+Oe)%Y,se=(se+1)%q}while(se!==le)}{let V=X[0];for(let R=0,G=V.boundary.vertexCount;R<G;R++){let W=this.buildBevelVert(B,V,R),Y=this.buildBevelVert(B,V,(R+1)%G);x.push(Y.topP,W.topN,W.bottomN),x.push(Y.topP,W.bottomN,Y.bottomP)}}if(y){let V=[];for(let R=x.length-1;R>=F+2;R-=3){let G=x[R-2],W=x[R-1],Y=x[R-0];V.push(Y,W,G)}x.splice(F,x.length-F,...V)}if(y){let V=[];for(let R=X[X.length-1].boundary.vertices.length-1;R>=1;R-=2){let G=X[X.length-1].boundary.vertices[R-1],W=X[X.length-1].boundary.vertices[R-0];V.push(G,W)}v.push(V)}if(!y){let V=X[X.length-1],R=Eo({windingRule:X.length>1?Rt.POSITIVE:Rt.ODD,elementType:ur.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]});if(!R)throw new Error("Error generating geometry for surface");Object.assign(this,{capStartIndex:x.length});for(let G=0;G<R.elementCount*3;G+=3){let W=this.buildSurfaceVert(R,R.elements[G+0]),Y=this.buildSurfaceVert(R,R.elements[G+1]),q=this.buildSurfaceVert(R,R.elements[G+2]);x.push(W.top,Y.top,q.top),x.push(q.bottom,Y.bottom,W.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Xe(Uint32Array.from(x),1),b=new Xe(this._buffer.positions,3),S=new Xe(this._buffer.normals,3),M=new Xe(this._buffer.uvs,2);b.needsUpdate=!0,S.needsUpdate=!0,M.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",S),this.setAttribute("uv",M),this.setIndex(w)}buildSurfaceVert(t,r){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[r*2+0],o=t.vertices[r*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,c=this._buffer.get(2),h=c*3,u=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=o,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=a,this._buffer.uvs[u+1]=l,this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=o,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=a,this._buffer.uvs[u+3]=l,this.vertexCache[i]=f,f}buildBevelVert(t,r,i,s=1){let o=`${r.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=r.boundary.vertexIndices[i],c,h,u,f;a!==l?(h=a,c=l,f=!1,u=t.continuous[h]&&t.continuous[c]):(c=a,h=(c-1+t.count)%t.count,f=t.concave[c]&&r.bevelI>0,u=t.continuous[c]||f);let d=Math.cos(r.angle),m=Math.sin(r.angle),p=i*2,g=c*2,x=h*2,v=r.boundary.vertices[p+0],w=r.boundary.vertices[p+1],b=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,M=(w-this._minY)/this._height,_=t.normals[g+0],y=t.normals[g+1],T=t.normals[x+0],E=t.normals[x+1];if(f){let H=T-_,j=E-y;_=_+H*(1-s),y=y+j*(1-s);let Q=Math.sqrt(_*_+y*y);_/=Q,y/=Q}let C=this._buffer.get(u?2:4),I=C*3,B=C*2,N={i,fi:c,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=w,this._buffer.positions[I+2]=this._depth-b,this._buffer.normals[I+0]=_*d,this._buffer.normals[I+1]=y*d,this._buffer.normals[I+2]=m,this._buffer.uvs[B+0]=S,this._buffer.uvs[B+1]=M,this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=w,this._buffer.positions[I+5]=b,this._buffer.normals[I+3]=_*d,this._buffer.normals[I+4]=y*d,this._buffer.normals[I+5]=-m,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=S,u||(C+=2,I+=6,B+=4,N.topP=C+0,N.bottomP=C+1,this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=w,this._buffer.positions[I+2]=this._depth-b,this._buffer.normals[I+0]=T*d,this._buffer.normals[I+1]=E*d,this._buffer.normals[I+2]=m,this._buffer.uvs[B+0]=S,this._buffer.uvs[B+1]=M,this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=w,this._buffer.positions[I+5]=b,this._buffer.normals[I+3]=T*d,this._buffer.normals[I+4]=E*d,this._buffer.normals[I+5]=-m,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=S),this.vertexCache[o]=N,N}clone(){let t=new il(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=Lc(this.userData),t}};var Er=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=n.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof dt?(o.width!==r||o.height!==i)&&o.applySize(r,i):o=new dt(r,i).fromJSON(o),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&o.update(!1));let l=o??new dt(r,i);return{parameters:Object.assign(t,{width:r,height:i,depth:s,roundness:a}),shape:l}}static build(n){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:i,roundness:s}=n.parameters;n.shape.roundness=s;let o;return e<=0?o=new nl(n.shape,i):o=new il(n.shape,e,t,i,r),Object.assign(o,{userData:{...n,type:"VectorGeometry"}})}};var kS=Math.PI*2,VS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t,spikes:r,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c=n.shape,h=e*.5,u=t*.5,f=RO(c,h,u,i*Math.PI/180,r,s);c.isClosed=!0,c.update();let d=Er.create({shape:c,parameters:{subdivisions:f,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(d,{userData:{...n,type:"EllipseGeometry"}})}};function RO(n,e,t,r,i,s){if(r>=kS)return i>30||i%4===0?(zO(n,e,t,s),Math.round(i/4)):GS(n,r,i,e,t,s);let o={x:0,y:t},a=r+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=OS({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?FO(n,o.x,o.y,c,i,e,t,s):GS(n,r,i,e,t,s)}function FO(n,e,t,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(sl(e,t));for(let c=0,h=r.length;c<h;c++){let u=r[c],f=n.points[c],d=sl(u.x,u.y);f.controls[1].position.set(u.x1,u.y1),d.controls[0].position.set(u.x2,u.y2),n.addPoint(d)}return a>0?HS(n,s,o,a):n.addPoint(sl(0,0)),l}function GS(n,e,t,r,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,c=Math.sin(l)*r,h=Math.cos(l)*i;n.addPoint(sl(c,h))}return e<kS?s>0?HS(n,r,i,s):n.addPoint(sl(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&WS(n,r,i,s)),1}function zO(n,e,t,r=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;n.addPoint(ed(i-e,s,i-e,s-l,i-e,s+l)),n.addPoint(ed(i,s+t,i-a,s+t,i+a,s+t)),n.addPoint(ed(i+e,s,i+e,s+l,i+e,s-l)),n.addPoint(ed(i,s-t,i+a,s-t,i-a,s-t)),r>0&&WS(n,e,t,r)}function sl(n,e){return new qn(je.generateUUID(),new O(n,e))}function ed(n,e,t,r,i,s){let o=sl(n,e);return o.controls[0].position.set(t,r),o.controls[1].position.set(i,s),o}function HS(n,e,t,r){jS(n,e,t,r).forEach(s=>n.addPoint(s))}function WS(n,e,t,r){let i=jS(n,e,t,r),s=new dt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function jS(n,e,t,r){let i=r*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new O(i/e,s/t),a=n.points.map(l=>{let c=l.clone();return c.uuid=je.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),h=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(h),l.controls[1].position.copy(c)}),a}var qS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(t.width),i=Math.abs(t.height??r),s=Math.abs(t.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(t,{width:r,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(n){let{width:e,height:t,depth:r,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:u}=n.parameters,f=new $c(!1,e,t,r,i,s,o,a,l,c,h,u);return Object.assign(f,{userData:{...n,type:"HelixGeometry"}})}},$c=class extends Le{constructor(e=!0,t=1,r=1,i=1,s=1,o=1,a=1,l=1,c=1,h=1,u=1,f=1){super();let d=e&&o===1;d&&(f=0),u>100&&(u=100);let m=()=>new A,p=new A,g=m(),x=m(),v=m(),w,b,S,M,_,y,T,E,C=m(),I=m(),B=m(),N=m(),H=m(),j=m(),Q=m(),X=m(),U=r-2*l+.001,F=U/o,V=Math.ceil(a*o),R=V+1,G=U/V,W=-U/2,Y=h+1,q=2*Math.PI/h,se=Math.PI/2/f,K=.01,te=Math.min((1-u/100)*l,l-K),k=l-te,le=0,ce=2,ae=f*ce+ce,fe=Y*ae/ce,ge=fe+Y*R,de=Y*(R+ae),[_e,Ee,ye]=[3,3,2].map(ve=>Array(de*ve).fill(0)),Oe=[],pt=s-l;function P(ve,z){let xe=Math.PI/2;y=z*G,E=2*Math.PI*(y%F)/F+xe,y+=W,T=Math.sin(E)*pt,_=Math.cos(E)*pt,e?ve.set(_,T,y):ve.set(_,y,T)}P(p,-1e-10),P(g,0),C.copy(p),P(p,1);let D=p.distanceTo(g),Z=k+te,ue=D*V+2*Z,pe=te,Te=ue-Z;for(let ve=0;ve<=V;ve++){P(x,ve),X.subVectors(x,C).normalize(),C.copy(x),j.copy(x).setComponent(+e+1,0).normalize(),Q.crossVectors(X,j).normalize();let z=ve===0,xe=ve===V,Me=z?3*Math.PI/2:se,Ye=z?pe:Te,Ne=z?Y:ge,Je=z?0:de-Y,be=X.clone().multiplyScalar(z?-k:k).add(x),Qe=X.clone().multiplyScalar(z?-1:1).normalize();for(let nt=0;nt<Y;nt++){let mt=nt*q;if(I.addVectors(p.copy(j).multiplyScalar(l*Math.cos(mt)),g.copy(Q).multiplyScalar(l*Math.sin(mt))),B.copy(I).normalize(),z||xe){d||(le=Je+nt,[0,1,2].forEach(bt=>{_e[le*3+bt]=be.getComponent(bt),Ee[le*3+bt]=Qe.getComponent(bt)}),ye[le*2]=+xe,ye[le*2+1]=nt/h),g.copy(B).multiplyScalar(te),v.addVectors(x,g);for(let bt=0;bt<f;bt++){let Jr=bt*se+Me;N.addVectors(p.copy(X).multiplyScalar(k*Math.sin(Jr)),g.copy(B).multiplyScalar(k*Math.cos(Jr))),H.copy(N).normalize(),g.addVectors(v,N),N.normalize(),le=Ne+bt*Y+nt,[0,1,2].forEach(Oo=>{_e[le*3+Oo]=g.getComponent(Oo),Ee[le*3+Oo]=H.getComponent(Oo)});let Lh=+z+Math.sin(Jr);ye[le*2]=(Ye+k*Lh)/ue,ye[le*2+1]=nt/h}}g.addVectors(x,I),le=fe+ve*Y+nt,[0,1,2].forEach(bt=>{_e[le*3+bt]=g.getComponent(bt),Ee[le*3+bt]=B.getComponent(bt)}),ye[le*2]=(Z+ve*D)/ue,ye[le*2+1]=nt/h}}let Fe=R+2*f+ce,ne=1,[Re,Ie]=d?[ne,ne+R-1]:[0,Fe-1];for(let ve=Re;ve<=Ie-1;ve++){let z=d&&ve===Ie-1;for(let xe=0;xe<Y-1;xe++)w=ve*Y+xe,b=w+1,S=(z?xe:w)+Y,M=(z?xe+1:b)+Y,ve===0?Oe.push(b,M,S):ve===Fe-2?Oe.push(w,b,S):Oe.push(w,b,S,b,M,S)}this.setIndex(Oe),this.setAttribute("position",new Ae(_e,3)),this.setAttribute("normal",new Ae(Ee,3)),this.setAttribute("uv",new Ae(ye,2))}};var YS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new eh(e*.5,s,o):new da(e*.5,i);return a.scale(1,t/e,r/e),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},eh=class extends zs{constructor(e=1,t=.2,r=4){let i=(1+Math.sqrt(5))/2,s=[-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],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,r),this.type=a}static fromJSON(e){return new eh(e.radius,e.corner,e.cornerSides)}};var XS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let t=Object.assign({},e?.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}]},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{points:e,segments:t,verticalSegments:r}=n.parameters,i=new Fn;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new ca(i.extractPoints(r).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var yi=new Be,Kg=new lt,td=new A,Gs=class extends Ot{constructor(){super(),this.uuid=je.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 Ht().getNormalMatrix(e);for(let r=0,i=this.vertices.length;r<i;r++)this.vertices[r].applyMatrix4(e);for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return yi.makeRotationX(e),this.applyMatrix4(yi),this}rotateY(e){return yi.makeRotationY(e),this.applyMatrix4(yi),this}rotateZ(e){return yi.makeRotationZ(e),this.applyMatrix4(yi),this}translate(e,t,r){return yi.makeTranslation(e,t,r),this.applyMatrix4(yi),this}scale(e,t,r){return yi.makeScale(e,t,r),this.applyMatrix4(yi),this}lookAt(e){return Kg.lookAt(e),Kg.updateMatrix(),this.applyMatrix4(Kg.matrix),this}fromBufferGeometry(e){let t=this,r=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,c=i.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let f=0;f<s.count;f++)t.vertices.push(new A().fromBufferAttribute(s,f)),a!==void 0&&t.colors.push(new Se().fromBufferAttribute(a,f));function h(f,d,m,p){let g=a===void 0?[]:[t.colors[f].clone(),t.colors[d].clone(),t.colors[m].clone()],x=o===void 0?[]:[new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,m)],v=new ol(f,d,m,x,g,p);t.faces.push(v),l!==void 0&&t.faceVertexUvs[0].push([new O().fromBufferAttribute(l,f),new O().fromBufferAttribute(l,d),new O().fromBufferAttribute(l,m)]),c!==void 0&&t.faceVertexUvs[1].push([new O().fromBufferAttribute(c,f),new O().fromBufferAttribute(c,d),new O().fromBufferAttribute(c,m)])}let u=e.groups;if(u.length>0)for(let f=0;f<u.length;f++){let d=u[f],m=d.start,p=d.count;for(let g=m,x=m+p;g<x;g+=3)r!==void 0?h(r.getX(g),r.getX(g+1),r.getX(g+2),d.materialIndex):h(g,g+1,g+2,d.materialIndex)}else if(r!==void 0)for(let f=0;f<r.count;f+=3)h(r.getX(f),r.getX(f+1),r.getX(f+2));else for(let f=0;f<s.count;f+=3)h(f,f+1,f+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(td).negate(),this.translate(td.x,td.y,td.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,r=t===0?1:1/t,i=new Be;return i.set(r,0,0,-r*e.x,0,r,0,-r*e.y,0,0,r,-r*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new A,t=new A;for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let r=0,i=this.vertices.length;r<i;r++)t[r]=new A;if(e){let r=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],h=this.vertices[a.c];r.subVectors(h,c),i.subVectors(l,c),r.cross(i),t[a.a].add(r),t[a.b].add(r),t[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let r=0,i=this.vertices.length;r<i;r++)t[r].normalize();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[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 r=this.faces[e],i=r.vertexNormals;i.length===3?(i[0].copy(r.normal),i[1].copy(r.normal),i[2].copy(r.normal)):(i[0]=r.normal.clone(),i[1]=r.normal.clone(),i[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,r=this.faces.length;t<r;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new Gs;e.faces=this.faces;for(let t=0,r=this.morphTargets.length;t<r;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new A,h={a:new A,b:new A,c:new A};s.push(c),o.push(h)}}let i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],c=i.vertexNormals[s];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let t=0,r=this.faces.length;t<r;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new yr),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Br),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,r=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,c=e.faces,h=this.colors,u=e.colors;t!==void 0&&(i=new Ht().getNormalMatrix(t));for(let f=0,d=a.length;f<d;f++){let p=a[f].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone());for(let f=0,d=c.length;f<d;f++){let m=c[f],p,g,x=m.vertexNormals,v=m.vertexColors,w=new ol(m.a+s,m.b+s,m.c+s);w.normal.copy(m.normal),i!==void 0&&w.normal.applyMatrix3(i).normalize();for(let b=0,S=x.length;b<S;b++)p=x[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),w.vertexNormals.push(p);w.color.copy(m.color);for(let b=0,S=v.length;b<S;b++)g=v[b],w.vertexColors.push(g.clone());w.materialIndex=m.materialIndex+r,l.push(w)}for(let f=0,d=e.faceVertexUvs.length;f<d;f++){let m=e.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++)v.push(x[w].clone());this.faceVertexUvs[f].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={},r=[],i=[],s=Math.pow(10,e);for(let l=0,c=this.vertices.length;l<c;l++){let h=this.vertices[l],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=l,r.push(this.vertices[l]),i[l]=r.length-1):i[l]=i[t[u]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let h=this.faces[l];h.a=i[h.a],h.b=i[h.b],h.c=i[h.c];let u=[h.a,h.b,h.c];for(let f=0;f<3;f++)if(u[f]===u[(f+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(c,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(e){this.vertices=[];for(let t=0,r=e.length;t<r;t++){let i=e[t];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}e.sort(r);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let c=e[l]._id;o&&o.push(i[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),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 m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let r=[],i=[],s={},o=[],a={},l=[],c={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,x=!1,v=this.faceVertexUvs[0][m]!==void 0,w=p.normal.length()>0,b=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,M=p.vertexColors.length>0,_=0;if(_=h(_,0,0),_=h(_,1,g),_=h(_,2,x),_=h(_,3,v),_=h(_,4,w),_=h(_,5,b),_=h(_,6,S),_=h(_,7,M),r.push(_),r.push(p.a,p.b,p.c),r.push(p.materialIndex),v){let y=this.faceVertexUvs[0][m];r.push(d(y[0]),d(y[1]),d(y[2]))}if(w&&r.push(u(p.normal)),b){let y=p.vertexNormals;r.push(u(y[0]),u(y[1]),u(y[2]))}if(S&&r.push(f(p.color)),M){let y=p.vertexColors;r.push(f(y[0]),f(y[1]),f(y[2]))}}function h(m,p,g){return g?m|1<<p:m&~(1<<p)}function u(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function f(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function d(m){let p=m.x.toString()+m.y.toString();return c[p]!==void 0||(c[p]=l.length/2,l.push(m.x,m.y)),c[p]}return e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=r,e}clone(){return new Gs().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 f=0,d=t.length;f<d;f++)this.vertices.push(t[f].clone());let r=e.colors;for(let f=0,d=r.length;f<d;f++)this.colors.push(r[f].clone());let i=e.faces;for(let f=0,d=i.length;f<d;f++)this.faces.push(i[f].clone());for(let f=0,d=e.faceVertexUvs.length;f<d;f++){let m=e.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++){let S=x[w];v.push(S.clone())}this.faceVertexUvs[f].push(v)}}let s=e.morphTargets;for(let f=0,d=s.length;f<d;f++){let m={};if(m.name=s[f].name,s[f].vertices!==void 0){m.vertices=[];for(let p=0,g=s[f].vertices.length;p<g;p++)m.vertices.push(s[f].vertices[p].clone())}if(s[f].normals!==void 0){m.normals=[];for(let p=0,g=s[f].normals.length;p<g;p++)m.normals.push(s[f].normals[p].clone())}this.morphTargets.push(m)}let o=e.morphNormals;for(let f=0,d=o.length;f<d;f++){let m={};if(o[f].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[f].vertexNormals.length;p<g;p++){let x=o[f].vertexNormals[p],v={};v.a=x.a.clone(),v.b=x.b.clone(),v.c=x.c.clone(),m.vertexNormals.push(v)}}if(o[f].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[f].faceNormals.length;p<g;p++)m.faceNormals.push(o[f].faceNormals[p].clone())}this.morphNormals.push(m)}let a=e.skinWeights;for(let f=0,d=a.length;f<d;f++)this.skinWeights.push(a[f].clone());let l=e.skinIndices;for(let f=0,d=l.length;f<d;f++)this.skinIndices.push(l[f].clone());let c=e.lineDistances;for(let f=0,d=c.length;f<d;f++)this.lineDistances.push(c[f]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new Zg().fromGeometry(this),t=new Le,r=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Xe(r,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Xe(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Xe(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Xe(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Xe(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let c=o[a],h=new Ae(c.data.length*3,3);h.name=c.name,s.push(h.copyVector3sArray(c.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Ae(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Ae(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(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 Le,r=e.geometry;if(e.isPoints||e.isLine){let i=new Ae(r.vertices.length*3,3),s=new Ae(r.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(r.vertices)),t.setAttribute("color",s.copyColorsArray(r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Ae(r.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(r.lineDistances))}r.boundingSphere!==null&&(t.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(t.boundingBox=r.boundingBox.clone())}else e.isMesh&&(t=r.toBufferGeometry());return t}};Gs.prototype.isGeometry=!0;var Zg=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=[],r,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=i*3-r.start,t.push(r)),r={start:i*3,materialIndex:s})}r!==void 0&&(r.count=i*3-r.start,t.push(r)),this.groups=t}fromGeometry(e){let t=e.faces,r=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,c;if(l>0){c=[];for(let x=0;x<l;x++)c[x]={name:a[x].name,data:[]};this.morphTargets.position=c}let h=e.morphNormals,u=h.length,f;if(u>0){f=[];for(let x=0;x<u;x++)f[x]={name:h[x].name,data:[]};this.morphTargets.normal=f}let d=e.skinIndices,m=e.skinWeights,p=d.length===r.length,g=m.length===r.length;r.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let x=0;x<t.length;x++){let v=t[x];this.vertices.push(r[v.a],r[v.b],r[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=v.normal;this.normals.push(S,S,S)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][x];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",x),this.uvs.push(new O,new O,new O))}if(o===!0){let S=i[1][x];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",x),this.uvs2.push(new O,new O,new O))}for(let S=0;S<l;S++){let M=a[S].vertices;c[S].data.push(M[v.a],M[v.b],M[v.c])}for(let S=0;S<u;S++){let M=h[S].vertexNormals[x];f[S].data.push(M.a,M.b,M.c)}p&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[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}},ol=class{constructor(e,t,r,i,s,o=0){this.a=e,this.b=t,this.c=r,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Se,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}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,r=e.vertexNormals.length;t<r;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,r=e.vertexColors.length;t<r;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var UO=["a","b","c"];function GO(n,e){switch(e){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function $g(n,e,t){let r=Math.min(n,e),i=Math.max(n,e),s=r+"_"+i;return t.get(s)}function ey(n,e,t,r,i,s){let o=Math.min(n,e),a=Math.max(n,e),l=o+"_"+a,c;if(r.has(l))c=r.get(l);else{let h=t[o],u=t[a];c={a:h,b:u,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(i),s[n].edges.push(c),s[e].edges.push(c)}function kO(n,e,t,r){let i,s,o;for(i=0,s=n.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],ey(o.a,o.b,n,r,o,t),ey(o.b,o.c,n,r,o,t),ey(o.c,o.a,n,r,o,t)}function rd(n,e,t,r,i){n.push(new ol(e,t,r,void 0,void 0,i))}function al(n,e){return Math.abs(e-n)/2+Math.min(n,e)}function nd(n,e,t,r){n.push([e.clone(),t.clone(),r.clone()])}var id=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Le?e=new Gs().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 A,r,i,s,o,a,l=e.vertices,c=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,f=[],d=new Map;kO(l,c,f,d);let m=[],p,g,x,v,w,b,S;for(let K of Array.from(d.keys())){for(g=d.get(K),x=new A,w=3/8,b=1/8,S=g.faces.length,S!=2&&(w=.5,b=0,S!=1),x.addVectors(g.a,g.b).multiplyScalar(w),t.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[GO(v,UO[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(b),x.add(t),g.newEdge=m.length,m.push(x)}let M,_,y,T,E,C,I,B=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=f[i].edges,r=E.length,r==3?M=3/16:r>3&&(M=3/(8*r)),_=1-r*Number(M),y=M,r<=2&&(r==2?(_=3/4,y=1/8):r==1||r==0),I=C.clone().multiplyScalar(_),t.set(0,0,0),o=0;o<r;o++)T=E[o],p=T.a!==C?T.a:T.b,t.add(p);t.multiplyScalar(Number(y)),I.add(t),B.push(I)}let N=B.concat(m),H=B.length,j,Q,X,U=[],F=[],V,R,G,W,Y=new O,q=new O,se=new O;for(i=0,s=c.length;i<s;i++)v=c[i],j=Number($g(v.a,v.b,d).newEdge)+H,Q=Number($g(v.b,v.c,d).newEdge)+H,X=Number($g(v.c,v.a,d).newEdge)+H,rd(U,j,Q,X,v.materialIndex),rd(U,v.a,j,X,v.materialIndex),rd(U,v.b,Q,j,v.materialIndex),rd(U,v.c,X,Q,v.materialIndex),u&&(V=h[i],R=V[0],G=V[1],W=V[2],Y.set(al(R.x,G.x),al(R.y,G.y)),q.set(al(G.x,W.x),al(G.y,W.y)),se.set(al(R.x,W.x),al(R.y,W.y)),nd(F,Y,q,se),nd(F,R,Y,se),nd(F,G,q,Y),nd(F,W,se,q));e.vertices=N,e.faces=U,u&&(e.faceVertexUvs[0]=F)}};var fr=new A,JS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=n.geometry??e?.geometry??new Le().copy(new Kr(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(fr),r={width:fr.x,height:fr.y,depth:fr.z,subdivisions:0}):r=e.parameters;let i={...r,...n.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(n){let{width:e,height:t,depth:r,subdivisions:i}=n.parameters,s=n.geometry??new Le().copy(new Kr(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(fr)):fr.set(o.width,o.height,o.depth),(e!==fr.x||t!==fr.y||r!==fr.z)&&s.scale(fr.x===0?1:e/fr.x,fr.y===0?1:t/fr.y,fr.z===0?1:r/fr.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new id(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete n.geometry,Object.assign(s,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,e,t){new Ss(t).load(n,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(fr);let o=100/fr.x;Object.assign(s.parameters,{width:100,height:fr.y*o,depth:fr.z*o}),e(this.build(s))})}};var QS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t,spikes:r,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=n.parameters,l=n.shape,c=e*.5,h=t*.5,u=0,f=0,d=2*Math.PI/r;for(let p=0;p<r;p++){let g=d*p,x=u+Math.sin(g)*c,v=f+Math.cos(g)*h;l.addPoint(l.createPoint(x,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Er.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var KS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=new ry(e*.5,t,i,s,o,a,l);return c.scale(1,1,r/e),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function th(n,e,t){t.x=n.x*e.x,t.y=n.y,t.z=n.x*e.y}function ty(n,e,t,r,i,s){let o=e.clone().sub(n),a=t.clone().sub(n),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===i){let c=o.add(a).normalize();s.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(n),s.addScaledVector(o,i/Math.sin(c)),s.addScaledVector(a,r/Math.sin(c))}}function VO(n,e,t){let r=n.clone().sub(e),i=t.clone().sub(e);return r.projectOnVector(i),r.add(e)}var ry=class extends Le{constructor(e=.5,t=1,r=4,i=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],h=[],u=[],f=0,d=t/2,m=Math.PI/r,p=e*Math.cos(Math.PI/r),g=2*Math.PI/r,x=(r-2)*Math.PI/r,v=Math.PI-x,w=new A(0,-d,0),b=new A(0,d,0),S=new O(e,-d),M=new O(p,-d),_=new O(0,b.y).sub(M),y=new O(0,b.y).sub(S),T=new O(_.y,-_.x).normalize(),E=new O(y.y,-y.x).normalize(),I=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,I);let B;{let F=new A(T.x,T.y,0),V=new A(Math.cos(g)*F.x,F.y,Math.sin(g)*F.x);B=F.angleTo(V)}let N=o/Math.tan((Math.PI-_.angle())/2),H=o/Math.tan((Math.PI-B)/2),j=new A;if(!s){c.push(w.x,w.y,w.z),h.push(0,-1,0),u.push(0,0);let F=f++,V=[],R=S.clone(),G=N/Math.cos(Math.PI/r);R.x-=G;for(let W=0;W<r;W++){let Y=W/r*Math.PI*2+m,q=new O(Math.sin(Y),Math.cos(Y));th(R,q,j),c.push(j.x,j.y,j.z),h.push(0,-1,0),u.push(0,0),V.push(f++)}for(let W=0;W<V.length;W++)l.push(V[W],F,V[(W+1)%V.length])}let Q=[];{let F=new A,V=new A,R=new A,G=new A,W=new A,Y=new A;for(let q=0;q<r;q++){let se=q/r*Math.PI*2+m,K=(q+.5)/r*Math.PI*2+m,te=(q+1)/r*Math.PI*2+m,k=new O(Math.sin(se),Math.cos(se)),le=new O(Math.sin(K),Math.cos(K)),ce=new O(Math.sin(te),Math.cos(te));th(S,k,V),th(S,ce,R),th(T,le,F),ty(b,V,R,H,H,G),c.push(G.x,G.y,G.z),ty(V,b,R,H,N,W),c.push(W.x,W.y,W.z),ty(R,V,b,N,H,Y),c.push(Y.x,Y.y,Y.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),u.push(0,0),u.push(0,0),u.push(0,0);let ae=f++,fe=f++,ge=f++;if(l.push(ae,fe,ge),o>0){{let Ee=V.clone().add(R).multiplyScalar(.5),ye=b.clone().sub(Ee).normalize(),pt=w.clone().sub(Ee).normalize().add(ye).normalize().multiplyScalar(-1),P=Y.clone().sub(W);X(Ee,P,pt,_.angle())}let de,_e;{let Ee=new A;th(E,ce,Ee);let ye=Y.clone().add(G).multiplyScalar(.5);ye=VO(ye,R,b);let Oe=Y.clone().sub(G);[de,_e]=X(ye,Oe,Ee,B,G.y)}{let Ee=de,ye=Ee.clone().setY(0).normalize(),Oe=new A(0,-1,0),pt=ye.clone().cross(Oe);U(Ee,ye,Oe,pt)}Q.concat(_e);{let Ee=_.angle(),ye=Math.PI-Ee,Oe=b.clone();Oe.y-=o/Math.sin(Ee-Math.PI/2);let pt=new A,P=[];for(let Z=0;Z<a;Z++){let ue=[],pe=Math.PI/2-ye*Z/a,Te=Math.cos(pe),Fe=Math.sin(pe),ne=K;for(let Re=0;Re<=Z;Re++){let Ie=Math.cos(ne),ve=Math.sin(ne);F.x=Te*ve,F.y=Fe,F.z=Te*Ie,pt.copy(Oe).addScaledVector(F,o),c.push(pt.x,pt.y,pt.z),h.push(F.x,F.y,F.z),u.push(0,0),ue.push(f++),ne+=Math.PI*2/Z/r}P.push(ue)}_e.reverse(),P.push(_e);let D=P.length-1;for(let Z=0;Z<D;Z++){let ue=P[Z],pe=P[Z+1],Te=ue.length-1;l.push(pe[1],ue[0],pe[0]);for(let Fe=1;Fe<=Te;Fe++)l.push(ue[Fe],ue[Fe-1],pe[Fe]),l.push(pe[Fe+1],ue[Fe],pe[Fe])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(c,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(u,2));function X(F,V,R,G,W){let Y=-G/2,q=(Math.PI-G)/2,se=V.clone().normalize().cross(R);F.addScaledVector(R,-o/Math.sin(q));let K=new A,te=new A,k=1,le=f,ce=[];for(let ae=0;ae<=a;ae++){let fe=Y+ae/a*G;te.set(0,0,0),te.addScaledVector(se,Math.sin(fe)),te.addScaledVector(R,Math.cos(fe));for(let ge=0;ge<=k;ge++){let de=ge/k-.5;if(K.copy(F),K.addScaledVector(V,de),K.addScaledVector(te,o),W!=null){let _e=Math.max(0,K.y-W);K.addScaledVector(V,-_e/V.y)}c.push(K.x,K.y,K.z),h.push(te.x,te.y,te.z),u.push(0,0),ge===0&&ce.push(f),f++}}for(let ae=0;ae<a;ae++)for(let fe=0;fe<k;fe++){let ge=le+fe+(k+1)*ae,de=ge+(k+1),_e=de+1,Ee=ge+1;l.push(ge,de,Ee),l.push(de,_e,Ee)}return[F.clone().addScaledVector(V,.5),ce]}function U(F,V,R,G){let W=Math.PI/2,Y=y.angle()-W,q=[],se=new A,K=new A;for(let k=0;k<=a;k++){let le=[],ce=k/a;for(let ae=0;ae<=k;ae++){let ge=((k?ae/k:0)-.5)*v,de=Math.cos(ge),_e=Math.sin(ge),Ee=Math.atan(Math.tan(Y)*de),ye=(W+Ee)*ce,Oe=Math.cos(ye),pt=Math.sin(ye);se.set(0,0,0),se.addScaledVector(V,pt*de),se.addScaledVector(R,Oe),se.addScaledVector(G,pt*_e),K.copy(F).addScaledVector(se,o),c.push(K.x,K.y,K.z),h.push(se.x,se.y,se.z),u.push(0,0),le.push(f++)}q.push(le)}let te=q.length-1;for(let k=0;k<te;k++){let le=q[k],ce=q[k+1],ae=le.length-1;l.push(le[0],ce[1],ce[0]);for(let fe=1;fe<=ae;fe++)l.push(le[fe-1],le[fe],ce[fe]),l.push(le[fe],ce[fe+1],ce[fe])}}}};var sd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(e?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:r}}static build(n){let e=n.shape,{width:t,height:r,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c={x:t*.5,y:r*.5},h={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function f(b,S,M){return S>t&&M>r?Math.min(b*t/S,b*r/M):S>t?b*t/S:M>r?b*r/M:b}let d=[];d[0]=i[0]===0?0:f(i[0],i[0]+i[3],i[0]+i[1]),d[1]=i[1]===0?0:f(i[1],i[1]+i[2],i[1]+i[0]),d[2]=i[2]===0?0:f(i[2],i[2]+i[1],i[2]+i[3]),d[3]=i[3]===0?0:f(i[3],i[3]+i[0],i[3]+i[2]);let m=h.x,p=u.x,g=u.y,x=h.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,x)),e.addPoint(e.createPoint(m,x)),e.isClosed=!0;let v=!0;for(let b=0,S=e.points.length;b<S;b++)e.points[b].roundness=d[b],b>0&&d[b]!==d[b-1]&&(v=!1);v&&(e.roundness=d[0]),e.useCubicForRoundedCorners=s!==1,e.update();let w=Er.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};var ZS=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e=100,height:t=e,depth:r=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,h=new ho(.5*e,i,s,o,a,l,c);return h.scale(1,t/e,r/e),Object.assign(h,{userData:{...n,type:"SphereGeometry"}})}};var $S=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(n){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:i=8}=n.parameters,s=new Ui(e,t,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var e1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(n){let{width:e,height:t,depth:r,angle:i,cornerRadius:s,cornerSegments:o}=n.parameters,a=new ny(e,t,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},ny=class extends Le{constructor(e=1,t=1,r=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],h=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-h,i),i*=Math.PI/180;let u=[],f=Math.PI/2,d=(K=0,te=0,k=0)=>new A(K,te,k),m=d(),p=d(),[g,x,v]=[t/2,e/2,r/2],w=-x,b=+x,[S,M,_]=[d(w,-g,+v),d(w,-g,-v),d(w,+g,-v)],y=(K,te=!1)=>Math.sin(K-Math.PI/(1+ +te)),T=(K,te=!1)=>Math.cos(K-Math.PI/(1+ +te));_.y=Math.sin(i)*t-g;let E=Math.cos(i)*t-v,C=S.z-h;i<=f?(_.z=Math.min(E,C),_.z==C&&(_.y-=(E-C)/Math.tan(f-i))):M.z=Math.min(M.z-E-v,S.z-h),m.subVectors(S,M),p.subVectors(_,M);let I=Math.min(m.length(),p.length())*s/100,B=I*Math.tan(i/2),N=I/Math.cos(i/2),H=m.clone().normalize().add(p.normalize()).setLength(N).add(M);m.set(0,y(i,!0),T(i,!0)),u.push([_,m.clone()]);let j=(Math.PI-i)/o;for(let K=0;K<=o;K++){let te=f+i+K*j;m.set(0,Math.sin(te)*B,Math.cos(te)*B),m.add(H),p.set(0,y(te),T(te)),u.push([m.clone(),p.clone()])}u.push([S,d(0,1,0)]);let Q=Math.sin(j/2)*B*2,X=u.length-1,U=u[0][0].distanceTo(u[1][0]),F=u[X-1][0].distanceTo(u[X][0]),V=U+Q*o+F;u[0].push(1);for(let K=0;K<=o;K++)u[K+1].push(1-(U+K*Q)/V);u[X].push(0);let[R,G,W]=u[0],Y,q,se;for(let K=1;K<u.length;K++)[Y,q,se]=u[K],a.push(w,R.y,R.z,w,Y.y,Y.z,b,R.y,R.z,b,R.y,R.z,w,Y.y,Y.z,b,Y.y,Y.z),l.push(0,G.y,G.z,0,q.y,q.z,0,G.y,G.z,0,G.y,G.z,0,q.y,q.z,0,q.y,q.z),c.push(0,W,0,se,1,W,1,W,0,se,1,se),[R,G,W]=[Y,q,se];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(c,2))}};var t1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t,innerRadiusPercent:r,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,h=n.shape,u=e*.5,f=t*.5,d=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,x=u*r/100,v=f*r/100;if(i===3&&r===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let S=p*b,M=d+Math.sin(S)*u,_=m+Math.cos(S)*f;h.addPoint(h.createPoint(M,_))}}else for(let b=0;b<i;b++){let S=d+Math.cos(g)*u,M=m+Math.sin(g)*f;h.addPoint(h.createPoint(S,M)),g+=p,S=d+Math.cos(g)*x,M=m+Math.sin(g)*v,b<=i,h.addPoint(h.createPoint(S,M)),g+=p}h.isClosed=!0;for(let b=0,S=h.points.length;b<S;b++)h.points[b].roundness=s;h.roundness=s,h.update();let w=Er.create({shape:h,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};var od=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e,height:t}=n.parameters,r=new Ui(e,t);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var r1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??t.width*.25);return{parameters:Object.assign(t,{width:r,height:i,depth:s})}}static build(n){let{width:e,height:t,depth:r,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=HO(e,t,r,e*.5,o,s,0,0,i,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function HO(n,e,t,r,i,s,o,a,l,c,h){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(c=0),new $c(!0,n,e,t,r,i,s,o,a,l,c,h)}var n1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(n){let{width:e,tube:t,tubularSegments:r,radialSegments:i,p:s,q:o}=n.parameters,a=e*.5;a!==t&&(a-=t);let l=new ma(a,t,r,i,s,o);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var i1=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof dt?n.shape:new dt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(n){let{width:e=100,height:t,cornerRadius:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=n.parameters,l=n.shape,c=e*.5,h=t*.5;a?(l.addPoint(l.createPoint(-c,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))),l.isClosed=!0;for(let f=0,d=l.points.length;f<d;f++)l.points[f].roundness=r;l.roundness=r,l.update();let u=Er.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};var ad={};ap(ad,{addBarycentricAttribute:()=>qO,fixUvs:()=>XO,loadFromUrl:()=>YO,resizeGeometry:()=>jO,roundShapePolygon:()=>WO});var s1=function(n,e){let t=e.x-n.x,r=e.y-n.y,i=Math.sqrt(t*t+r*r),s=t/i,o=r/i,a=Math.atan2(o,s);return{x:t,y:r,len:i,nx:s,ny:o,ang:a}},WO=(n,e,t)=>{let r,i,s,o,a,l,c,h,u,f,d,m,p,g,x=e.length;for(o=e[x-2],n.curves=[],r=1;r<x-1;r++){a=e[r%x],l=e[(r+1)%x];let v=s1(a,o),w=s1(a,l);c=v.nx*w.ny-v.ny*w.nx,h=v.nx*w.nx-v.ny*-w.ny,d=Math.asin(c),u=1,f=!1,h<0?d<0?d=Math.PI+d:(d=Math.PI-d,u=-1,f=!0):d>0&&(u=-1,f=!0),m=d/2,g=Math.abs(Math.cos(m)*t/Math.sin(m)),g>Math.min(v.len/2,w.len/2)?(g=Math.min(v.len/2,w.len/2),p=Math.abs(g*Math.sin(m)/Math.cos(m))):p=t,i=a.x+w.nx*g,s=a.y+w.ny*g,i+=-w.ny*p*u,s+=w.nx*p*u,n.absarc(i,s,p,v.ang+Math.PI/2*u,w.ang-Math.PI/2*u,f),o=a,a=l}n.closePath()},jO=(n,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let i=n.userData.parameters,s,o,a;e===0?(e=i.width,s=1):s=e/i.width,t===0?(t=i.height,o=1):o=t/i.height,r===0?(r=i.depth,a=1):a=r/i.depth,n.scale(s,o,a),i.width=e,i.height=t,i.depth=r},qO=(n,e)=>{let t=[new A(1,0,0),new A(0,1,0),new A(0,0,1)],r=n.attributes.position,i=new Float32Array(r.count*3);for(let s=0,o=r.count;s<o;s++)t[s%3].toArray(i,s*3);n.setAttribute(e,new Ae(i,3))},YO=n=>new Promise(e=>{new Ss().load(n,r=>e(r))}),XO=(n,e,t)=>{let r=n.getAttribute("uv");if(r)for(let i=0;i<r.count;i++){let s=r.getX(i),o=r.getY(i);r.setXY(i,(s+e/2)/e,1-(o-t/2)/t*-1)}};var JO,ld=new Promise(n=>{JO=n});var rh=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}};var Ue=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=je.generateUUID(),this.type=e,this.name="",this.userData={}}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,r){return r=r??{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r??{},e.addFlow(r.slot,r.cache,r.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,r){t=t??this.getType(e,t);let i=e.getNodeData(r??this);return e.analyzing&&this.appendDepsNode(e,i,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,r)}updateFrame(e){}generateReadonly(e,t,r,i,s,o){return""}generate(e,t,r,i,s){return""}parse(e,t,r,i){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let i=e.getTypeLength(r);(i>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=i,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if(e?.materials&&e?.materials[this.uuid]!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof Ue&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){return this.getJSONNode(e)??this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var iy=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},dr=new iy;var ke=class extends Ue{constructor(t,r){super(t);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(t,r,i,s){if(r=r??this.getType(t),this.getShared(t,r)){let o=this.getUnique(t,r);o&&this.uuid===void 0&&(this.uuid=je.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,r),this.generate(t,r,i)):super.build(t,r,i);if(o)return a.name=a.name||super.build(t,r,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,r,i);i=this.getUUID(!1);let c=this.getTemp(t,i);if(c)return t.format(c,l,r);{c=super.generate(t,r,i,a.output,s);let h=this.generate(t,l,i);return t.addNodeCode(c+" = "+h+";"),t.format(c,l,r)}}return super.build(t,r,i)}getShared(t,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(t,r){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(t,r){r=r||this.uuid;let i=t.getVars()[r];return i?i.name:void 0}generate(t,r,i,s,o){return this.getShared(t,r)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Lt=class extends ke{constructor(t,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(t,r);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(t){let r=super.createJSONNode(t);return this.readonly===!0&&(r.readonly=this.readonly),r}fromJSON(t,r){return super.fromJSON(t,r),t.readonly!==void 0&&this.setReadonly(t.readonly),this}generate(t,r,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,r,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,r))}copy(t){return super.copy(t),this.readonly=t.readonly,this}};var wr=class extends Lt{constructor(t=0,r){super("v2");this.nodeType="Vector2";this.value=t instanceof O?t:new O(t,r)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,r,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Sr=class extends Lt{constructor(t=0,r,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,r,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,r,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Cr=class extends Se{constructor(t,r,i,s){super(t,r,i);this.isColorA=!0;this.a=s}setRGBA(t,r,i,s){super.setRGB(t,r,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var Yn=class extends Lt{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof Cr?t:new Cr(t.r,t.g,t.b,t.a)}generateReadonly(t,r,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var QO=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,o1=/[a-z_0-9]+/gi,Pe=class extends ke{constructor(t,r,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,r,i,s)}getShared(t,r){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===t)return this.inputs[r]}}getIncludeByName(t){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===t)return this.includes[r]}}generate(t,r,i,s,o){let a,l=0,c=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)t.include(this.includes[u],this);for(let u in this.extensions)t.extensions[u]=!0;let h=[];for(;a=o1.exec(this.src);)h.push(a);for(let u=0;u<h.length;u++){let f=h[u],d=f[0],m=this.isMethod?!this.getInputByName(d):!0,p=d;if(this.keywords[d]||this.useKeywords&&m&&dr.containsKeyword(d)){let g=this.keywords[d];if(!g){let x=dr.getKeywordData(d);x.cache&&(g=t.keywords[d]),g=g||dr.getKeyword(d,t),x.cache&&(t.keywords[d]=g)}p=g.build(t)}d!==p&&(c=c.substring(0,f.index+l)+p+c.substring(f.index+d.length+l),l+=p.length-d.length),this.getIncludeByName(p)===void 0&&dr.contains(p)&&t.include(dr.get(p))}return r==="source"?c:this.isMethod?(this.isInterface||t.include(this,void 0,c),this.name):t.format("( "+c+" )",this.getType(t),r)}parse(t,r,i,s){if(this.src=t||"",this.includes=r??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=QO.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(o1);if(a){let l=0;for(;l<a.length;){let c=a[l++],h;c==="in"||c==="out"||c==="inout"?h=a[l++]:(h=c,c="");let u=a[l++];this.inputs.push({name:u,type:h,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(t){return super.copy(t),this.isMethod=t.isMethod,this.useKeywords=t.useKeywords,t.type!==void 0&&(this.type=t.type),this.parse(t.src,t.includes,t.extensions,t.keywords),this}toJSON(t){let r=this.getJSONNode(t);if(!r){r=this.createJSONNode(t),r.src=this.src,r.isMethod=this.isMethod,r.useKeywords=this.useKeywords,this.isMethod||(r.type=this.type),r.extensions=JSON.parse(JSON.stringify(this.extensions));let i={};for(let s in this.keywords)i[s]=this.keywords[s].toJSON(t).uuid;if(r.keywords=i,this.includes?.length){let s=[];for(let o=0;o<this.includes.length;o++)s.push(this.includes[o].toJSON(t).uuid);r.includes=s}r.isMethod=this.isMethod,r.inputs=this.inputs}return r.nodeType=this.nodeType,r}fromJSON(t,r){if(super.fromJSON(t,r),t.inputs!==void 0&&(this.inputs=t.inputs),t.isMethod!==void 0&&(this.isMethod=t.isMethod),t.src&&(this.src=t.src),t.isMethod&&(this.isMethod=t.isMethod),t.useKeywords&&(this.useKeywords=t.useKeywords),t.type&&(this.type=t.type),t.extensions&&(this.extensions=t.extensions),t.keywords&&r){this.keywords={};for(let i in t.keywords)this.keywords[i]=r.getNode(t.keywords[i])}return t.includes&&r&&(this.includes=t.includes.map(i=>r.getNode(i))),this}};var KO=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,sy=class extends ke{constructor(t="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||sy.PI,void 0,void 0,void 0,r)}getType(t){return t.getTypeByFormat(this.type)}parse(t,r,i,s,o){this.src=t||"";let a,l,c="",h=KO.exec(t);this.useDefine=o??this.src.charAt(0)==="#",h&&h.length>1?(l=h[1],a=h[2],c=h[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(t,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return t.include(this),t.format(this.name,this.getType(t),r)}generate(t,r,i,s,o){return t.format(this.name,this.getType(t),r)}copy(t){return super.copy(t),this.parse(t.src,void 0,void 0,void 0,t.useDefine),this}},ct=sy;ct.PI="PI",ct.PI2="PI2",ct.RECIPROCAL_PI="RECIPROCAL_PI",ct.RECIPROCAL_PI2="RECIPROCAL_PI2",ct.LOG2="LOG2",ct.EPSILON="EPSILON";var ZO=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3138
3138
|
)*?)}`,"gim"),$O=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ll=class extends ke{constructor(t=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(t)}getType(t){return t.getTypeByFormat(this.name)}getInputByName(t){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===t)return this.inputs[r]}generate(t,r,i,s,o){return r==="source"?this.src+";":t.format("( "+this.src+" )",this.getType(t),r)}parse(t=""){this.src=t,this.inputs=[];let r=ZO.exec(t);if(r){let i=r[2],s;for(;s=$O.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var cl=class extends ke{constructor(t){super("v2",{shared:!1});this.nodeType="UV";this.index=t??0}generate(t,r){t.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=t.isShader("vertex")?"uv"+i:"vUv"+i;return t.format(s,this.getType(t),r)}copy(t){return super.copy(t),this.index=t.index,this}toJSON(t){let r=this.getJSONNode(t);return r||(r=this.createJSONNode(t),r.index=this.index),r.nodeType=this.nodeType,r}fromJSON(t,r){return super.fromJSON(t,r),t.index&&(this.index=t.index),this}};dr.addKeyword("uv",function(){return new cl});dr.addKeyword("uv2",function(){return new cl(1)});var Co=class extends ke{constructor(t=new Ue,r){super("v4");this.nodeType="ColorSpace";this.factor=new Ue;this.input=t,this.method=r??Co.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(t){switch(t){case hn:return["Linear"];case He:return["sRGB"];default:return[]}}generate(t,r){let i=this.input.build(t,"v4"),s=this.getType(t),o=Co.Nodes[this.method],a=t.include(o);if(a===Co.LINEAR_TO_LINEAR)return t.format(i,s,r);if(o.inputs?.length===2){let l=this.factor.build(t,"f");return t.format(a+"( "+i+", "+l+" )",s,r)}else return t.format(a+"( "+i+" )",s,r)}fromEncoding(t){let r=Co.getEncodingComponents(t);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(t){let r=Co.getEncodingComponents(t);this.method=r[0]+"ToLinear",this.factor=r[1]}copy(t){return super.copy(t),this.input.copy(t.input),this.method=t.method,this.factor.copy(t.factor),this}},qr=Co;qr.Nodes={LinearToLinear:new Pe(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3139
3139
|
`)),sRGBToLinear:new Pe(["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(`
|
|
3140
3140
|
`)),LinearTosRGB:new Pe(["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(`
|
|
@@ -4488,7 +4488,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
|
|
|
4488
4488
|
}
|
|
4489
4489
|
|
|
4490
4490
|
#endif
|
|
4491
|
-
`,xR=$e.lights_fragment_begin,bR=$e.shadowmask_pars_fragment,gy=!1,wR=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},yy=(n="medium")=>{if(!gy){gy=!0;let e=wR(n);$e.shadowmap_pars_fragment=vR(e);let t=xR.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let r=bR.slice();r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=r}},m1=n=>{gy=!1,yy(n)};var Xi=n=>"isEntity"in n,zt=n=>"isAbstractMesh"in n,xt=n=>n!==null&&n.isBooleanMesh,g1=n=>n.objectType==="CombinedCamera",y1=n=>Xi(n)&&(n.objectType==="LightDirectional"||n.objectType==="LightSpot"||n.objectType==="LightPoint");var vy=n=>n.objectType==="EmptyObject",Ji=n=>"objectHelper"in n;function xy(n,e){let t=!1;e.position&&(n.position.fromArray(e.position),t=!0),e.rotation&&(n.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,n.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(t=!0,n.hiddenMatrix.fromArray(e.hiddenMatrix??ui.identity)),t&&(n.updateMatrix(),xt(n.parent)&&zt(n)&&n.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=e.isUpVectorFlipped),n.updateUp())}function SR(n,e){xy(n,e),e.name!==void 0&&(n.name=e.name),e.visible!==void 0&&(n.isEntity?n.visibility=e.visible:n.visible=e.visible)}function v1(n,e,t){SR(n,e),e.color!==void 0&&(n.color=Zt(e.color,t)),e.intensity!==void 0&&(n.intensity=e.intensity),e.shadows!==void 0&&!(n instanceof mo)&&(n.castShadow=e.shadows),n.shadow&&!(n instanceof mo)&&e.depth!==void 0&&(n.shadow.camera.far=e.depth,n.shadow.needsUpdate=!0),e.helper!==void 0&&Ji(n)&&(n.enableHelper=e.helper,n.gizmos.shadowmap.visible=e.helper)}function x1(n,e){n.shadow.camera.right=e/2,n.shadow.camera.left=-e/2,n.shadow.camera.top=e/2,n.shadow.camera.bottom=-e/2,n.shadow.needsUpdate=!0}var bl=new yr,wi=new A,Si=new A,wl=new Be,w1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],AR=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],MR=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function _R(n,e,t=0,r=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<r;h++){let u=e.getX(h),f=e.getY(h),d=e.getZ(h);u<i&&(i=u),f<s&&(s=f),d<o&&(o=d),u>a&&(a=u),f>l&&(l=f),d>c&&(c=d)}return n.min.set(i,s,o),n.max.set(a,l,c),n}var b1=(n,e,t,r)=>{if(zt(n)){let i=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?wi.copy(n.originalGeometry.boundingSphere.center):s!==void 0&&(_R(bl,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),bl.getCenter(wi)),n.forceComputeSize?bl.getSize(Si).multiplyScalar(.5):Si.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Ji(n)&&r===!0){let i=n.geometryHelper.getAttribute("position");bl.setFromArray(i.array),bl.getCenter(wi),bl.getSize(Si).multiplyScalar(.5)}else wi.setScalar(0),Si.setScalar(0);wl.copy(e).multiply(n.matrixWorld),Si.x===0&&Si.y===0&&Si.z===0?t.push(new A(wi.x,wi.y,wi.z).applyMatrix4(wl)):w1.forEach(i=>{t.push(i.clone().multiply(Si).add(wi).applyMatrix4(wl))})},xh=class extends yr{constructor(){super(...arguments);this.matrix=new Be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(r=>r.clone()),this.faces=t.faces.map(r=>r.clone()),this.edges=t.edges.map(r=>r.clone()),this.centerEdges=t.centerEdges.map(r=>r.clone()),this}setFromObjectSize(t,r=!1){t.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,r)}expandByObjectSize(t,r,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&b1(o,r,s,t.enableHelper===!0)}):b1(t,r,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(wl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Si).multiplyScalar(.5),this.getCenter(wi),wl.copy(this.matrix).setPosition(wi),this.vertices=w1.map(t=>t.clone().multiply(Si).applyMatrix4(wl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=AR.map(([t,r])=>new Cu(this.vertices[t],this.vertices[r])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=MR.map(([t,r])=>this.vertices[t].clone().add(this.vertices[r]).multiplyScalar(.5))}};function bh(n){let e=[];for(let t in n){let r=n[t];delete r.metadata,e.push(r)}return e}function TR(n){let e=[];for(let t in n)e.push(n[t]);return e}var Md=n=>class extends n{hasEntityChild(){return this.children.some(t=>Xi(t))}isDescendantOf(t){t instanceof lt&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let i=new Be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Xi(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,i={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Xi(o)||o instanceof ws)&&s.children.push(o.toJSON(t).object)}if(r){let o=bh(t.geometries),a=bh(t.materials),l=bh(t.textures),c=bh(t.images),h=bh(t.interactionStates),u=TR(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.interactionStates=h),u.length>0&&(i.nodes=u)}return i.object=s,i}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var Cn=n=>"isEntity"in n,S1=n=>"isAbstractMesh"in n,Dn=n=>class extends Md(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Be;this._singleBBox=new xh;this._recursiveBBox=new xh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Cn(i)&&i.traverseEntity(s=>{Ji(s)&&s.visible&&(s.objectHelper.visible=r)})}get visibility(){return this.visible}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{Cn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Cn(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let r=new Be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let s of this.children)Cn(s)&&s.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),s=i.object;return this.raycastLock===!0&&(s.raycastLock=!0),this.scaleLock===!0&&(s.scaleLock=!0),s.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Be}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){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 ja(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ja(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};var wh=class extends lt{constructor(t,r={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=Af.defaultData(i.toArray(),s),wo(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(t){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let r=0,i=t-this.children.length;r<i;++r){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-t;r<i;++r)this.remove(this.children[0])}_updateRadial(t){let r=t.radial,i=r.start*je.DEG2RAD,s=r.end*je.DEG2RAD,o=i-s,a=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD),l;switch(r.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=r.scale[0],h.scale.y=r.scale[1],h.scale.z=r.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(r.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0],h.position.y+=r.position[1],h.position.z+=r.position[2],r.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let r=t.linear,i=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(r.scale[0]-1)*s,o.scale.y=1+(r.scale[1]-1)*s,o.scale.z=1+(r.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=r.position[0]*s,o.position.y=r.position[1]*s,o.position.z=r.position[2]*s}_updateGrid(t){let r=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[r++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromJSON(t){return this}toJSON(){return{}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),wo(this.parameters,t),this.update(),this}};var Ct=class extends Dn(ir){constructor(t,r){super(t,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Be;this.booleanExclude=null;Array.isArray(r)&&(this.selectedMaterial=0,t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}getSelectedMaterial(t){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t??0),this.material[t??this.selectedMaterial]):this.material}setSelectedMaterial(t,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r??0),r=r??this.selectedMaterial,this.material[r].dispose(),this.material[r]=t):(this.material.dispose(),this.material=t)}updateGeometry(t){let r=this.geometry,i=by[r.userData.type],s=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,o=i.build(i.normalizeInputs(t,s)),a=r.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(t,r,i){ad.resizeGeometry(this.geometry,{width:t,height:r,depth:i})}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Sh(r),s=Array.isArray(this.material)?this.material.map(o=>o.clone()):this.material.clone();return new this.constructor(i,s).copy(this,t)}copy(t,r=!0){return super.copy(t,r),t.cloner&&(this.cloner=new wh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new wh(this)),this.cloner.fromClonerState(t))}fromState(t,r){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Kn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),xt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)zt(t)&&(t.freeBooleanPointer(),xt(t)&&t.invalidateUpstreamBooleanData())}};var ER=new A(0,0,1),A1=new A,M1=new A,_1=new Ht,Vs=class extends Ct{constructor(t=Er.create({}),r=new Ir({side:Wt})){super(t,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Ot;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="VectorObject",r}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),_1.getNormalMatrix(this.matrixWorld),A1.copy(ER).applyMatrix3(_1).normalize(),M1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(A1,M1)}clone(t){let r=this.shape.clone(),i=this.material.clone(),s=this.geometry.userData,o=Er.create(Object.assign({},s,{shape:r})),a=new Vs(o,i).copy(this,t);return a.shape=r,r.update(),a}raycast(t,r){Ct.prototype.raycast.call(this,t,r)}};function _d(n,e){return CR(n)}function CR(n){let e={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=dt.createFromState(n.shape,n.width,n.height);e.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),e.geometry=new Ss().parse(n));let t;try{t=Sh(e)}catch(r){console.error(r)}if(!t){let r=dt.createFromState(Ka.defaultData(),100,100);e.shape=r,t=Sh(e)}return t}var We;ld.then(n=>{We=n});var T1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),E1=new Uint32Array([0,1,2,3]),C1=new Uint8Array([4]),Pn=class{static build(n,e,t,r,i){let s,o,a,l=n?.phongAngle??e?.phongAngle??35;if(r===!1&&(l=-1),n.positionWASM!==void 0){t&&t!==0&&(We.free_bvh(t),We.free_subdivision_surface(t));try{s=Pn.allocate(n,i)}catch(c){console.error(c,n),s=Pn.allocate({positionWASM:T1,indexWASM:E1,verticesPerFaceWASM:C1},i)}We.set_destination_refinement_level(s,0),o=Pn.buildLevel(s,!0,l)}else s=t,n.phongAngle!==void 0&&(o=Pn.buildLevel(s,!0,l));return n.subdivisions!==void 0&&(We.set_destination_refinement_level(s,n.subdivisions),n.subdivisions>0?a=Pn.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(n,e){n.widthSegments>16&&(n.widthSegments=16),n.heightSegments>16&&(n.heightSegments=16),n.depthSegments>16&&(n.depthSegments=16),n.radialSegments>16&&(n.radialSegments=16),n.type==="DodecahedronGeometry"&&(n.detail=0);let t=n.shape!==void 0?e.geometry:_d(n),r,i,s,o;return{positions:r,triIndices:o}=My(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=_y(r,o,t),{positions:r,indices:i,verticesPerFace:s}}static allocate(n,e){let t,r,i,s=[],o=[];n.positionWASM&&n.positionWASM.length>0?(t=n.positionWASM,r=n.indexWASM,i=n.verticesPerFaceWASM):(t=T1,r=E1,i=C1);let a=t.length,l=r.length,c=i.length,h=t.length+s.length+o.length,u=r.length+i.length,f=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=We._malloc(f),g=new Float32Array(We.HEAPF32.buffer,p,h),x=new Uint32Array(We.HEAPU32.buffer,p+d,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(r,0),x.set(i,r.length);let v;n?.scaleBaked?.some(b=>b!==1)&&(v=new Be().makeScale(...n.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?We.alloc_subdivision_surface2(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):We.alloc_subdivision_surface(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return We._free(p),w}static buildLevel(n,e,t,r,i){let s=i?We.get_mesh_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t,i.elements):We.get_mesh_data(n,e?We.Level.CONTROL:We.Level.REFINED,t),o=8,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=We.HEAPU32[a[c]>>2],u=We.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=We.HEAPU32[a[c]>>2],d=We.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=We.HEAPU32[a[c]>>2],p=We.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=We.HEAPU32[a[c]>>2],x=We.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,r===void 0){let v=new Le;if(v.setIndex(new gs(x,1)),v.setAttribute("position",new Ae(u,3)),v.setAttribute("normal",new Ae(d,3)),e){v.setAttribute("faceMap",new gs(p,1));let w=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return We.free_mesh_data(s),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,We.free_mesh_data(s)}static buildControlCageWireframe(n,e,t){let r=We.get_wireframe_data_for_base_level(n),i=4,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(2,2+2),a=0,l=We.HEAPU32[s[a]>>2],c=We.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=We.HEAPU32[s[a]>>2],u=We.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Ae(c,3));let d=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new Xe(d,3)),f.setIndex(new gs(u,1)),We.free_wireframe_data_for_base_level(r),f}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,e,t){e||We.set_destination_refinement_level(n,1);let r=t?We.get_topological_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t.elements):We.get_topological_data(n,e?We.Level.CONTROL:We.Level.REFINED),i=6,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=We.HEAPU32[s[a]>>2],c=new Float32Array(We.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=We.HEAPU32[s[a]>>2],u=new Uint32Array(We.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=We.HEAPU32[s[a]>>2],d=new Uint8Array(We.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return We.free_topological_data(r),{positions:c,indices:u,verticesPerFace:d}}};var D1=["getX","getY","getZ"];function My(n,e){let t={},r=e?e.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let h=e?e.getX(c):c,u="";for(let f=0;f<3;f++)u+=`${~~(n[D1[f]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let f=0;f<3;f++)o.push(n[D1[f]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Td=new A,wy=new A,Sy=new A,Ay=new A;function _y(n,e,t){let r=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);n.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)n.push(s[l],s[l+1],0),r.push(a++);else for(let l=s.length-2;l>=0;l-=2)n.push(s[l],s[l+1],0),r.push(a++);return i.push(a),{indices:r,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){Td.set(n[e[s]*3],n[e[s]*3+1],n[e[s]*3+2]),wy.set(n[e[s+1]*3],n[e[s+1]*3+1],n[e[s+1]*3+2]),Sy.set(n[e[s+4]*3],n[e[s+4]*3+1],n[e[s+4]*3+2]),Ay.set(n[e[s+5]*3],n[e[s+5]*3+1],n[e[s+5]*3+2]),wy.sub(Td).normalize(),Sy.sub(Td).normalize(),Ay.sub(Td).normalize();let a=wy.cross(Sy).dot(Ay);Math.abs(a)>.005?(r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(r.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<n.length;l+=3,c++)n[l+2]===0&&(s.push(c),a++),n[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),r.push(...s,...o),i.push(a,a)}return{indices:r,verticesPerFace:i}}var Kn={};ap(Kn,{calcBoolean:()=>LR,calcBooleanTopological:()=>PR,freeMeshSet:()=>BR,getMeshSet:()=>IR,transformMeshSet:()=>NR});var L1,I1=new Promise(n=>{L1=n}),P1=!1;async function N1(){if(P1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.68/build",[t,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:r});L1(s),P1=!0}var ot,Sl;I1.then(n=>ot=n);function DR(n,e){let t,{positions:r,triIndices:i}=My(n.getAttribute("position"),n.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=_y(r,i,n);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:r,faceIndices:t,nFaces:s}}function B1(n){let e=n.length,t=e*Uint32Array.BYTES_PER_ELEMENT,r=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?t:r,s=ot._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(n,0),s}function O1(n){switch(n){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 "+n)}}function PR(n,e){Sl===void 0&&(Sl=ot.init_csg());let t=B1(n),r=ot.csg_calc_topological(Sl,t,n.length,O1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=ot.HEAPU32[s[a]>>2],d=new Uint8Array(ot.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return ot.free_mesh_data(r),{positions:c,indices:u,verticesPerFace:d}}function LR(n,e,t,r){Sl===void 0&&(Sl=ot.init_csg());let i=B1(n),s=ot.csg_calc(Sl,i,n.length,r,O1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=ot.HEAPU32[a[c]>>2],d=ot.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Ae(u,3)),t.setAttribute("normal",new Ae(d,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Br),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function IR(n,e){if(ot===void 0)return-1;let t,r,i;if(e&&n.userData.positions!==void 0){let p=n.userData;i=p.verticesPerFace.length,t=p.positions,r=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){r[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)r[v++]=p.indices[x++]}}else({positions:t,faceIndices:r,nFaces:i}=DR(n,e));let s=t.length,o=r.length,a=t.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,f=ot._malloc(c),d=new Float32Array(ot.HEAPF32.buffer,f,a),m=new Uint32Array(ot.HEAPU32.buffer,f+h,l);return d.set(t,0),m.set(r,0),ot.get_csg_mesh(f,s,f+h,o,i)}function NR(n,e){ot.transform_csg_mesh(n,e.elements)}function BR(n){ot.free_csg_mesh(n)}var by={ConeGeometry:vS,CubeGeometry:xS,CylinderGeometry:yS,DodecahedronGeometry:bS,EllipseGeometry:VS,HelixGeometry:qS,IcosahedronGeometry:YS,LatheGeometry:XS,NonParametricGeometry:JS,PolygonGeometry:QS,PyramidGeometry:KS,RectangleGeometry:sd,SphereGeometry:ZS,PlaneGeometry:$S,BackdropGeometry:e1,StarGeometry:t1,TextFrameGeometry:od,TorusGeometry:r1,TorusKnotGeometry:n1,TriangleGeometry:i1,VectorGeometry:Er},Sh=n=>by[n.type].create(n);var R1=new Be;function Ty(n){let e=!1;return n.scene.objects.traverse((t,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Ed=class extends Ct{constructor(t=new Le,r=new Yr){super(t,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];xt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(S1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Kn.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else xt(s)&&s.needsTransformForDownstream===!0?(Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(R1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Kn.transformMeshSet(s.booleanMeshSetAddress,R1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Kn.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Le,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Kn.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}updateGeometry(t){let r=t.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=n=>{var e;return e=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Kr(30,30,30),e};var Cd=new so,Ey=new Br,F1=new Be,Mi=(n,e,t,r,i=!1)=>{let s=e,o=n.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ey.copy(s.boundingSphere),Ey.applyMatrix4(o),t.ray.intersectsSphere(Ey)===!1||(F1.copy(o).invert(),Cd.copy(t.ray).applyMatrix4(F1),s.boundingBox!==null&&Cd.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,f=s.attributes.position,d=s.drawRange,m,p;if(i===!1){let x=Math.max(0,d.start),v=Math.min(u.count,d.start+d.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(n,t,Cd,f,l,c,h),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),E=T*T,C=Math.max(0,d.start),I=Math.min(v.count,d.start+d.count);for(let B=C,N=I-1;B<N;B+=_){if(w.fromBufferAttribute(v,B),b.fromBufferAttribute(v,B+1),Cd.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(n.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||r.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,I=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;I.copy(C),I.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(I);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:I.clone(),object:x}}};var Dd=new A,Ln=new Gn,Cy=class extends ys{constructor(t){let r=new Le,i=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Se(15711266),c=new Se(15711266),h=new Se(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(d,m,p){f(d,p),f(m,p)}function f(d,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(s.length/3-1)}r.setAttribute("position",new Ae(s,3)),r.setAttribute("color",new Ae(o,3));super(r,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,r=this.pointMap,i=!0;Ln.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Zn("n1",r,t,Ln,-s,-o,a),Zn("n2",r,t,Ln,s,-o,a),Zn("n3",r,t,Ln,-s,o,a),Zn("n4",r,t,Ln,s,o,a);let l=a;Zn("f1",r,t,Ln,-s,-o,l),Zn("f2",r,t,Ln,s,-o,l),Zn("f3",r,t,Ln,-s,o,l),Zn("f4",r,t,Ln,s,o,l);let c=l,h=.5;Zn("u1",r,t,Ln,s*.7*h,o*1.1,c),Zn("u2",r,t,Ln,-s*.7*h,o*1.1,c),Zn("u3",r,t,Ln,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Zn(n,e,t,r,i,s,o){Dd.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Dd.x,Dd.y,Dd.z)}}var Pd=class extends Ai(Cy){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,r){Mi(this.object,this.geometry,t,r,!0)}};var Al=class extends Ai(Lu){constructor(t,r=15,i=10066329){super(t,r,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Al.geometryHelper,t,r)}};var Ml=class extends Ai(Iu){constructor(t,r=15){super(r);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,r){Mi(this.object,Ml.geometryHelper,t,r)}update(){}};var _l=class extends Ai(Pu){constructor(t,r=15,i=6710886){super(t,r,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,_l.geometryHelper,t,r)}};var Ld=class extends Ai(Du){constructor(t,r=6710886){super(t,r);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Ld.geometryHelper,t,r)}update(){if(this.object!==void 0){let t=Ld._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Ah=Ld;Ah._vector=new A;var _i=(n,e)=>class extends n{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cn(s)&&s.traverseEntity(o=>{Ji(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}copy(i,s=!0){return super.copy(i,s),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let s=super.toJSON(i),o=s.object;return o.enableHelper=this.enableHelper,s}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Zt(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Dy=new A,vn=class extends _i(Dn(Gn),Pd){constructor(t=window.innerWidth,r=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=r,this.orthoCamera=new oa(t*-.5,t*.5,r*.5,r*-.5,s??-5e4,o),this.perspCamera=new Jt(i,t/r,s??50,o),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,r){let i=new vn().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,r){t==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(t,r){r>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Dy),this.getWorldPosition(Tl),Dy.multiplyScalar(this.targetOffset),t.copy(Tl).add(Dy),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new jt),r=new A(0,0,1).applyQuaternion(t),i=new A().copy(lt.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(lt.DefaultUp).projectOnPlane(r),o=new A().crossVectors(s,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let r=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToObject(t){let r=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().sub(s),target:r}}setViewplaneSize(t,r){this.left=-t*.5,this.right=t*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=t/r,this.updateProjectionMatrix()}toOrthographic(t){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,r,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,r,i,s,o,a):this.orthoCamera.setViewOffset(t,r,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,r){return super.copy(t,r),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(t){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(t),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(t){if(super.fromJSON(t),this.cameraType=t.cameraType,t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),i=new A().fromArray(t.orbitControlsTarget);this.targetOffset=i.distanceTo(r)}else t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=t.angleOffsetFromUp??0,t.left!==void 0&&(this.left=t.left),t.right!==void 0&&(this.right=t.right),t.top!==void 0&&(this.top=t.top),t.bottom!==void 0&&(this.bottom=t.bottom),t.view!==void 0&&(this.view=Object.assign({},t.view)),t.zoomOrtho!==void 0&&(this.orthoCamera.zoom=t.zoomOrtho),t.nearOrtho!==void 0&&(this.orthoCamera.near=t.nearOrtho),t.far!==void 0&&(this.far=t.far),t.aspect!==void 0&&(this.aspect=t.aspect),t.fov!==void 0&&(this.fov=t.fov),t.focus!==void 0&&(this.focus=t.focus),t.filmGauge!==void 0&&(this.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(this.filmOffset=t.filmOffset),t.zoomPersp!==void 0&&(this.perspCamera.zoom=t.zoomPersp),t.nearPersp!==void 0&&(this.perspCamera.near=t.nearPersp),this.updateProjectionMatrix(),this}toCameraState(t=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ja(r,t)}fromCameraState(t){let{orthographic:r,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dn(cs),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,r){let i=new Qi().fromState(r);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(t){let r=super.toJSON(t);return r.object.objectType="EmptyObject",r}};var El=class extends _i(Dn(_u),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new El().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(t,r){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,r),t.size!==void 0&&x1(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),i&&this.update(),this}fromState(t,r){return super.fromState(t),this.fromDirectionalLightState(t,r),this}};var Cl=class extends _i(Dn(Mu),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new yr(s,o),l=new go(a,new Se(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,r,i){let s=new Cl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let r=this._gizmos[t];if(r instanceof go){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(s,o),r.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize??[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(t,r){return super.fromLightState(t,r),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,r){return super.fromState(t),this.fromPointLightState(t,r),this}};var z1=new A,U1=new A,G1=new jt,Dl=class extends _i(Dn(Au),Ah){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=je.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new Dl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),U1.setFromMatrixPosition(this.matrixWorld),G1.setFromRotationMatrix(this.matrixWorld),z1.copy(this.up).applyQuaternion(G1).negate().multiplyScalar(this.distance),this.target.position.copy(U1).add(z1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.decay=t.decay,this.penumbra=t.penumbra,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(t,r){return super.fromLightState(t,r),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,r){return super.fromState(t),this.fromSpotLightState(t,r),this}};var k1=n=>n.tagName==="VIDEO",Po=class{static resize(e,t,r){let i=e/t,s;if(!r.image)return;let o=r.image;k1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/i):r.repeat.set(1,1*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/s*-1,1):r.repeat.set(1*i/s,1)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let i=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let i=r.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];c1(a)&&(Po.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,r,i){let s=e/t,o,a=r.image;k1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Pl=class extends Ct{constructor(t,r=new Ir){super(t,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(t,r){super.resizeGeometry(t,r,0),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh2D",r}clone(){let t=super.clone();return t.updateGeometry({}),t}static fromTexture(t){let r,i;if(t instanceof wu){let a=t.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=t.image;r=a.width*.5,i=a.height*.5}let s=sd.create({parameters:{width:r,height:i}}),o=new Ir;return o.layersList.changeLayer(0,{type:"texture",texture:t}),o.layersList.moveLayer(0,1),o.dispose(),new Pl(s,o)}};var Ll=class extends Ct{constructor(t,r=new Yr){super(t,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}};var Il=class extends Ll{constructor(t,r=new Yr){super(t,r);this.objectType="NonParametric"}toJSON(t){let r=super.toJSON(t);return r.object.objectType="NonParametric",r}};var Id=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},r,i)}parse(e){return new Py(e)}},Py=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let r=[],i=RR(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(r,i[s].toShapes());return r}};function RR(n,e,t){let r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<r.length;c++){let h=r[c];if(h===`
|
|
4491
|
+
`,xR=$e.lights_fragment_begin,bR=$e.shadowmask_pars_fragment,gy=!1,wR=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},yy=(n="medium")=>{if(!gy){gy=!0;let e=wR(n);$e.shadowmap_pars_fragment=vR(e);let t=xR.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let r=bR.slice();r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=r}},m1=n=>{gy=!1,yy(n)};var Xi=n=>"isEntity"in n,zt=n=>"isAbstractMesh"in n,xt=n=>n!==null&&n.isBooleanMesh,g1=n=>n.objectType==="CombinedCamera",y1=n=>Xi(n)&&(n.objectType==="LightDirectional"||n.objectType==="LightSpot"||n.objectType==="LightPoint");var vy=n=>n.objectType==="EmptyObject",Ji=n=>"objectHelper"in n;function xy(n,e){let t=!1;e.position&&(n.position.fromArray(e.position),t=!0),e.rotation&&(n.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,n.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(t=!0,n.hiddenMatrix.fromArray(e.hiddenMatrix??ui.identity)),t&&(n.updateMatrix(),xt(n.parent)&&zt(n)&&n.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=e.isUpVectorFlipped),n.updateUp())}function SR(n,e){xy(n,e),e.name!==void 0&&(n.name=e.name),e.visible!==void 0&&(n.isEntity?n.visibility=e.visible:n.visible=e.visible)}function v1(n,e,t){SR(n,e),e.color!==void 0&&(n.color=Zt(e.color,t)),e.intensity!==void 0&&(n.intensity=e.intensity),e.shadows!==void 0&&!(n instanceof mo)&&(n.castShadow=e.shadows),n.shadow&&!(n instanceof mo)&&e.depth!==void 0&&(n.shadow.camera.far=e.depth,n.shadow.needsUpdate=!0),e.helper!==void 0&&Ji(n)&&(n.enableHelper=e.helper,n.gizmos.shadowmap.visible=e.helper)}function x1(n,e){n.shadow.camera.right=e/2,n.shadow.camera.left=-e/2,n.shadow.camera.top=e/2,n.shadow.camera.bottom=-e/2,n.shadow.needsUpdate=!0}var bl=new yr,wi=new A,Si=new A,wl=new Be,w1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],AR=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],MR=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function _R(n,e,t=0,r=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<r;h++){let u=e.getX(h),f=e.getY(h),d=e.getZ(h);u<i&&(i=u),f<s&&(s=f),d<o&&(o=d),u>a&&(a=u),f>l&&(l=f),d>c&&(c=d)}return n.min.set(i,s,o),n.max.set(a,l,c),n}var b1=(n,e,t,r)=>{if(zt(n)){let i=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?wi.copy(n.originalGeometry.boundingSphere.center):s!==void 0&&(_R(bl,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),bl.getCenter(wi)),n.forceComputeSize?bl.getSize(Si).multiplyScalar(.5):Si.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Ji(n)&&r===!0){let i=n.geometryHelper.getAttribute("position");bl.setFromArray(i.array),bl.getCenter(wi),bl.getSize(Si).multiplyScalar(.5)}else wi.setScalar(0),Si.setScalar(0);wl.copy(e).multiply(n.matrixWorld),Si.x===0&&Si.y===0&&Si.z===0?t.push(new A(wi.x,wi.y,wi.z).applyMatrix4(wl)):w1.forEach(i=>{t.push(i.clone().multiply(Si).add(wi).applyMatrix4(wl))})},xh=class extends yr{constructor(){super(...arguments);this.matrix=new Be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(r=>r.clone()),this.faces=t.faces.map(r=>r.clone()),this.edges=t.edges.map(r=>r.clone()),this.centerEdges=t.centerEdges.map(r=>r.clone()),this}setFromObjectSize(t,r=!1){t.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,r)}expandByObjectSize(t,r,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&b1(o,r,s,t.enableHelper===!0)}):b1(t,r,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(wl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Si).multiplyScalar(.5),this.getCenter(wi),wl.copy(this.matrix).setPosition(wi),this.vertices=w1.map(t=>t.clone().multiply(Si).applyMatrix4(wl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=AR.map(([t,r])=>new Cu(this.vertices[t],this.vertices[r])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=MR.map(([t,r])=>this.vertices[t].clone().add(this.vertices[r]).multiplyScalar(.5))}};function bh(n){let e=[];for(let t in n){let r=n[t];delete r.metadata,e.push(r)}return e}function TR(n){let e=[];for(let t in n)e.push(n[t]);return e}var Md=n=>class extends n{hasEntityChild(){return this.children.some(t=>Xi(t))}isDescendantOf(t){t instanceof lt&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let i=new Be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Xi(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,i={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Xi(o)||o instanceof ws)&&s.children.push(o.toJSON(t).object)}if(r){let o=bh(t.geometries),a=bh(t.materials),l=bh(t.textures),c=bh(t.images),h=bh(t.interactionStates),u=TR(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.interactionStates=h),u.length>0&&(i.nodes=u)}return i.object=s,i}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var Cn=n=>"isEntity"in n,S1=n=>"isAbstractMesh"in n,Dn=n=>class extends Md(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Be;this._singleBBox=new xh;this._recursiveBBox=new xh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Cn(i)&&i.traverseEntity(s=>{Ji(s)&&s.visible&&(s.objectHelper.visible=r)})}get visibility(){return this.visible}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{Cn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Cn(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let r=new Be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let s of this.children)Cn(s)&&s.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),s=i.object;return this.raycastLock===!0&&(s.raycastLock=!0),this.scaleLock===!0&&(s.scaleLock=!0),s.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Be}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){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 ja(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ja(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};var wh=class extends lt{constructor(t,r={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=Af.defaultData(i.toArray(),s),wo(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(t){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let r=0,i=t-this.children.length;r<i;++r){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-t;r<i;++r)this.remove(this.children[0])}_updateRadial(t){let r=t.radial,i=r.start*je.DEG2RAD,s=r.end*je.DEG2RAD,o=i-s,a=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD),l;switch(r.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=r.scale[0],h.scale.y=r.scale[1],h.scale.z=r.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(r.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0],h.position.y+=r.position[1],h.position.z+=r.position[2],r.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let r=t.linear,i=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(r.scale[0]-1)*s,o.scale.y=1+(r.scale[1]-1)*s,o.scale.z=1+(r.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=r.position[0]*s,o.position.y=r.position[1]*s,o.position.z=r.position[2]*s}_updateGrid(t){let r=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[r++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromJSON(t){return this}toJSON(){return{}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),wo(this.parameters,t),this.update(),this}};var Ct=class extends Dn(ir){constructor(t,r){super(t,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Be;this.booleanExclude=null;Array.isArray(r)&&(this.selectedMaterial=0,t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}getSelectedMaterial(t){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t??0),this.material[t??this.selectedMaterial]):this.material}setSelectedMaterial(t,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r??0),r=r??this.selectedMaterial,this.material[r].dispose(),this.material[r]=t):(this.material.dispose(),this.material=t)}updateGeometry(t){let r=this.geometry,i=by[r.userData.type],s=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,o=i.build(i.normalizeInputs(t,s)),a=r.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(t,r,i){ad.resizeGeometry(this.geometry,{width:t,height:r,depth:i})}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Sh(r),s=Array.isArray(this.material)?this.material.map(o=>o.clone()):this.material.clone();return new this.constructor(i,s).copy(this,t)}copy(t,r=!0){return super.copy(t,r),t.cloner&&(this.cloner=new wh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new wh(this)),this.cloner.fromClonerState(t))}fromState(t,r){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Kn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),xt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)zt(t)&&(t.freeBooleanPointer(),xt(t)&&t.invalidateUpstreamBooleanData())}};var ER=new A(0,0,1),A1=new A,M1=new A,_1=new Ht,Vs=class extends Ct{constructor(t=Er.create({}),r=new Ir({side:Wt})){super(t,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Ot;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="VectorObject",r}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),_1.getNormalMatrix(this.matrixWorld),A1.copy(ER).applyMatrix3(_1).normalize(),M1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(A1,M1)}clone(t){let r=this.shape.clone(),i=this.material.clone(),s=this.geometry.userData,o=Er.create(Object.assign({},s,{shape:r})),a=new Vs(o,i).copy(this,t);return a.shape=r,r.update(),a}raycast(t,r){Ct.prototype.raycast.call(this,t,r)}};function _d(n,e){return CR(n)}function CR(n){let e={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=dt.createFromState(n.shape,n.width,n.height);e.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),e.geometry=new Ss().parse(n));let t;try{t=Sh(e)}catch(r){console.error(r)}if(!t){let r=dt.createFromState(Ka.defaultData(),100,100);e.shape=r,t=Sh(e)}return t}var We;ld.then(n=>{We=n});var T1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),E1=new Uint32Array([0,1,2,3]),C1=new Uint8Array([4]),Pn=class{static build(n,e,t,r,i){let s,o,a,l=n?.phongAngle??e?.phongAngle??35;if(r===!1&&(l=-1),n.positionWASM!==void 0){t&&t!==0&&(We.free_bvh(t),We.free_subdivision_surface(t));try{s=Pn.allocate(n,i)}catch(c){console.error(c,n),s=Pn.allocate({positionWASM:T1,indexWASM:E1,verticesPerFaceWASM:C1},i)}We.set_destination_refinement_level(s,0),o=Pn.buildLevel(s,!0,l)}else s=t,n.phongAngle!==void 0&&(o=Pn.buildLevel(s,!0,l));return n.subdivisions!==void 0&&(We.set_destination_refinement_level(s,n.subdivisions),n.subdivisions>0?a=Pn.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(n,e){n.widthSegments>16&&(n.widthSegments=16),n.heightSegments>16&&(n.heightSegments=16),n.depthSegments>16&&(n.depthSegments=16),n.radialSegments>16&&(n.radialSegments=16),n.type==="DodecahedronGeometry"&&(n.detail=0);let t=n.shape!==void 0?e.geometry:_d(n),r,i,s,o;return{positions:r,triIndices:o}=My(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=_y(r,o,t),{positions:r,indices:i,verticesPerFace:s}}static allocate(n,e){let t,r,i,s=[],o=[];n.positionWASM&&n.positionWASM.length>0?(t=n.positionWASM,r=n.indexWASM,i=n.verticesPerFaceWASM):(t=T1,r=E1,i=C1);let a=t.length,l=r.length,c=i.length,h=t.length+s.length+o.length,u=r.length+i.length,f=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=We._malloc(f),g=new Float32Array(We.HEAPF32.buffer,p,h),x=new Uint32Array(We.HEAPU32.buffer,p+d,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(r,0),x.set(i,r.length);let v;n?.scaleBaked?.some(b=>b!==1)&&(v=new Be().makeScale(...n.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?We.alloc_subdivision_surface2(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):We.alloc_subdivision_surface(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return We._free(p),w}static buildLevel(n,e,t,r,i){let s=i?We.get_mesh_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t,i.elements):We.get_mesh_data(n,e?We.Level.CONTROL:We.Level.REFINED,t),o=8,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=We.HEAPU32[a[c]>>2],u=We.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=We.HEAPU32[a[c]>>2],d=We.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=We.HEAPU32[a[c]>>2],p=We.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=We.HEAPU32[a[c]>>2],x=We.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,r===void 0){let v=new Le;if(v.setIndex(new gs(x,1)),v.setAttribute("position",new Ae(u,3)),v.setAttribute("normal",new Ae(d,3)),e){v.setAttribute("faceMap",new gs(p,1));let w=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return We.free_mesh_data(s),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,We.free_mesh_data(s)}static buildControlCageWireframe(n,e,t){let r=We.get_wireframe_data_for_base_level(n),i=4,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(2,2+2),a=0,l=We.HEAPU32[s[a]>>2],c=We.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=We.HEAPU32[s[a]>>2],u=We.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Ae(c,3));let d=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new Xe(d,3)),f.setIndex(new gs(u,1)),We.free_wireframe_data_for_base_level(r),f}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,e,t){e||We.set_destination_refinement_level(n,1);let r=t?We.get_topological_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t.elements):We.get_topological_data(n,e?We.Level.CONTROL:We.Level.REFINED),i=6,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=We.HEAPU32[s[a]>>2],c=new Float32Array(We.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=We.HEAPU32[s[a]>>2],u=new Uint32Array(We.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=We.HEAPU32[s[a]>>2],d=new Uint8Array(We.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return We.free_topological_data(r),{positions:c,indices:u,verticesPerFace:d}}};var D1=["getX","getY","getZ"];function My(n,e){let t={},r=e?e.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let h=e?e.getX(c):c,u="";for(let f=0;f<3;f++)u+=`${~~(n[D1[f]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let f=0;f<3;f++)o.push(n[D1[f]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Td=new A,wy=new A,Sy=new A,Ay=new A;function _y(n,e,t){let r=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);n.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)n.push(s[l],s[l+1],0),r.push(a++);else for(let l=s.length-2;l>=0;l-=2)n.push(s[l],s[l+1],0),r.push(a++);return i.push(a),{indices:r,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){Td.set(n[e[s]*3],n[e[s]*3+1],n[e[s]*3+2]),wy.set(n[e[s+1]*3],n[e[s+1]*3+1],n[e[s+1]*3+2]),Sy.set(n[e[s+4]*3],n[e[s+4]*3+1],n[e[s+4]*3+2]),Ay.set(n[e[s+5]*3],n[e[s+5]*3+1],n[e[s+5]*3+2]),wy.sub(Td).normalize(),Sy.sub(Td).normalize(),Ay.sub(Td).normalize();let a=wy.cross(Sy).dot(Ay);Math.abs(a)>.005?(r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(r.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<n.length;l+=3,c++)n[l+2]===0&&(s.push(c),a++),n[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),r.push(...s,...o),i.push(a,a)}return{indices:r,verticesPerFace:i}}var Kn={};ap(Kn,{calcBoolean:()=>LR,calcBooleanTopological:()=>PR,freeMeshSet:()=>BR,getMeshSet:()=>IR,transformMeshSet:()=>NR});var L1,I1=new Promise(n=>{L1=n}),P1=!1;async function N1(){if(P1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.69/build",[t,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:r});L1(s),P1=!0}var ot,Sl;I1.then(n=>ot=n);function DR(n,e){let t,{positions:r,triIndices:i}=My(n.getAttribute("position"),n.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=_y(r,i,n);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:r,faceIndices:t,nFaces:s}}function B1(n){let e=n.length,t=e*Uint32Array.BYTES_PER_ELEMENT,r=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?t:r,s=ot._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(n,0),s}function O1(n){switch(n){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 "+n)}}function PR(n,e){Sl===void 0&&(Sl=ot.init_csg());let t=B1(n),r=ot.csg_calc_topological(Sl,t,n.length,O1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=ot.HEAPU32[s[a]>>2],d=new Uint8Array(ot.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return ot.free_mesh_data(r),{positions:c,indices:u,verticesPerFace:d}}function LR(n,e,t,r){Sl===void 0&&(Sl=ot.init_csg());let i=B1(n),s=ot.csg_calc(Sl,i,n.length,r,O1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=ot.HEAPU32[a[c]>>2],d=ot.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Ae(u,3)),t.setAttribute("normal",new Ae(d,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Br),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function IR(n,e){if(ot===void 0)return-1;let t,r,i;if(e&&n.userData.positions!==void 0){let p=n.userData;i=p.verticesPerFace.length,t=p.positions,r=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){r[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)r[v++]=p.indices[x++]}}else({positions:t,faceIndices:r,nFaces:i}=DR(n,e));let s=t.length,o=r.length,a=t.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,f=ot._malloc(c),d=new Float32Array(ot.HEAPF32.buffer,f,a),m=new Uint32Array(ot.HEAPU32.buffer,f+h,l);return d.set(t,0),m.set(r,0),ot.get_csg_mesh(f,s,f+h,o,i)}function NR(n,e){ot.transform_csg_mesh(n,e.elements)}function BR(n){ot.free_csg_mesh(n)}var by={ConeGeometry:vS,CubeGeometry:xS,CylinderGeometry:yS,DodecahedronGeometry:bS,EllipseGeometry:VS,HelixGeometry:qS,IcosahedronGeometry:YS,LatheGeometry:XS,NonParametricGeometry:JS,PolygonGeometry:QS,PyramidGeometry:KS,RectangleGeometry:sd,SphereGeometry:ZS,PlaneGeometry:$S,BackdropGeometry:e1,StarGeometry:t1,TextFrameGeometry:od,TorusGeometry:r1,TorusKnotGeometry:n1,TriangleGeometry:i1,VectorGeometry:Er},Sh=n=>by[n.type].create(n);var R1=new Be;function Ty(n){let e=!1;return n.scene.objects.traverse((t,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Ed=class extends Ct{constructor(t=new Le,r=new Yr){super(t,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];xt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(S1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Kn.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else xt(s)&&s.needsTransformForDownstream===!0?(Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(R1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Kn.transformMeshSet(s.booleanMeshSetAddress,R1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Kn.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Le,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Kn.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}updateGeometry(t){let r=t.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=n=>{var e;return e=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Kr(30,30,30),e};var Cd=new so,Ey=new Br,F1=new Be,Mi=(n,e,t,r,i=!1)=>{let s=e,o=n.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ey.copy(s.boundingSphere),Ey.applyMatrix4(o),t.ray.intersectsSphere(Ey)===!1||(F1.copy(o).invert(),Cd.copy(t.ray).applyMatrix4(F1),s.boundingBox!==null&&Cd.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,f=s.attributes.position,d=s.drawRange,m,p;if(i===!1){let x=Math.max(0,d.start),v=Math.min(u.count,d.start+d.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(n,t,Cd,f,l,c,h),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),E=T*T,C=Math.max(0,d.start),I=Math.min(v.count,d.start+d.count);for(let B=C,N=I-1;B<N;B+=_){if(w.fromBufferAttribute(v,B),b.fromBufferAttribute(v,B+1),Cd.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(n.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||r.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,I=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;I.copy(C),I.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(I);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:I.clone(),object:x}}};var Dd=new A,Ln=new Gn,Cy=class extends ys{constructor(t){let r=new Le,i=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Se(15711266),c=new Se(15711266),h=new Se(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(d,m,p){f(d,p),f(m,p)}function f(d,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(s.length/3-1)}r.setAttribute("position",new Ae(s,3)),r.setAttribute("color",new Ae(o,3));super(r,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,r=this.pointMap,i=!0;Ln.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Zn("n1",r,t,Ln,-s,-o,a),Zn("n2",r,t,Ln,s,-o,a),Zn("n3",r,t,Ln,-s,o,a),Zn("n4",r,t,Ln,s,o,a);let l=a;Zn("f1",r,t,Ln,-s,-o,l),Zn("f2",r,t,Ln,s,-o,l),Zn("f3",r,t,Ln,-s,o,l),Zn("f4",r,t,Ln,s,o,l);let c=l,h=.5;Zn("u1",r,t,Ln,s*.7*h,o*1.1,c),Zn("u2",r,t,Ln,-s*.7*h,o*1.1,c),Zn("u3",r,t,Ln,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Zn(n,e,t,r,i,s,o){Dd.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Dd.x,Dd.y,Dd.z)}}var Pd=class extends Ai(Cy){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,r){Mi(this.object,this.geometry,t,r,!0)}};var Al=class extends Ai(Lu){constructor(t,r=15,i=10066329){super(t,r,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Al.geometryHelper,t,r)}};var Ml=class extends Ai(Iu){constructor(t,r=15){super(r);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,r){Mi(this.object,Ml.geometryHelper,t,r)}update(){}};var _l=class extends Ai(Pu){constructor(t,r=15,i=6710886){super(t,r,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,_l.geometryHelper,t,r)}};var Ld=class extends Ai(Du){constructor(t,r=6710886){super(t,r);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Ld.geometryHelper,t,r)}update(){if(this.object!==void 0){let t=Ld._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Ah=Ld;Ah._vector=new A;var _i=(n,e)=>class extends n{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cn(s)&&s.traverseEntity(o=>{Ji(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}copy(i,s=!0){return super.copy(i,s),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let s=super.toJSON(i),o=s.object;return o.enableHelper=this.enableHelper,s}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Zt(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Dy=new A,vn=class extends _i(Dn(Gn),Pd){constructor(t=window.innerWidth,r=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=r,this.orthoCamera=new oa(t*-.5,t*.5,r*.5,r*-.5,s??-5e4,o),this.perspCamera=new Jt(i,t/r,s??50,o),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,r){let i=new vn().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,r){t==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(t,r){r>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Dy),this.getWorldPosition(Tl),Dy.multiplyScalar(this.targetOffset),t.copy(Tl).add(Dy),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new jt),r=new A(0,0,1).applyQuaternion(t),i=new A().copy(lt.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(lt.DefaultUp).projectOnPlane(r),o=new A().crossVectors(s,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let r=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToObject(t){let r=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().sub(s),target:r}}setViewplaneSize(t,r){this.left=-t*.5,this.right=t*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=t/r,this.updateProjectionMatrix()}toOrthographic(t){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,r,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,r,i,s,o,a):this.orthoCamera.setViewOffset(t,r,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,r){return super.copy(t,r),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(t){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(t),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(t){if(super.fromJSON(t),this.cameraType=t.cameraType,t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),i=new A().fromArray(t.orbitControlsTarget);this.targetOffset=i.distanceTo(r)}else t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=t.angleOffsetFromUp??0,t.left!==void 0&&(this.left=t.left),t.right!==void 0&&(this.right=t.right),t.top!==void 0&&(this.top=t.top),t.bottom!==void 0&&(this.bottom=t.bottom),t.view!==void 0&&(this.view=Object.assign({},t.view)),t.zoomOrtho!==void 0&&(this.orthoCamera.zoom=t.zoomOrtho),t.nearOrtho!==void 0&&(this.orthoCamera.near=t.nearOrtho),t.far!==void 0&&(this.far=t.far),t.aspect!==void 0&&(this.aspect=t.aspect),t.fov!==void 0&&(this.fov=t.fov),t.focus!==void 0&&(this.focus=t.focus),t.filmGauge!==void 0&&(this.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(this.filmOffset=t.filmOffset),t.zoomPersp!==void 0&&(this.perspCamera.zoom=t.zoomPersp),t.nearPersp!==void 0&&(this.perspCamera.near=t.nearPersp),this.updateProjectionMatrix(),this}toCameraState(t=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ja(r,t)}fromCameraState(t){let{orthographic:r,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dn(cs),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,r){let i=new Qi().fromState(r);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(t){let r=super.toJSON(t);return r.object.objectType="EmptyObject",r}};var El=class extends _i(Dn(_u),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new El().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(t,r){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,r),t.size!==void 0&&x1(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),i&&this.update(),this}fromState(t,r){return super.fromState(t),this.fromDirectionalLightState(t,r),this}};var Cl=class extends _i(Dn(Mu),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new yr(s,o),l=new go(a,new Se(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,r,i){let s=new Cl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let r=this._gizmos[t];if(r instanceof go){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(s,o),r.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize??[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(t,r){return super.fromLightState(t,r),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,r){return super.fromState(t),this.fromPointLightState(t,r),this}};var z1=new A,U1=new A,G1=new jt,Dl=class extends _i(Dn(Au),Ah){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=je.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new Dl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),U1.setFromMatrixPosition(this.matrixWorld),G1.setFromRotationMatrix(this.matrixWorld),z1.copy(this.up).applyQuaternion(G1).negate().multiplyScalar(this.distance),this.target.position.copy(U1).add(z1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.decay=t.decay,this.penumbra=t.penumbra,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(t,r){return super.fromLightState(t,r),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,r){return super.fromState(t),this.fromSpotLightState(t,r),this}};var k1=n=>n.tagName==="VIDEO",Po=class{static resize(e,t,r){let i=e/t,s;if(!r.image)return;let o=r.image;k1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/i):r.repeat.set(1,1*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/s*-1,1):r.repeat.set(1*i/s,1)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let i=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let i=r.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];c1(a)&&(Po.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,r,i){let s=e/t,o,a=r.image;k1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Pl=class extends Ct{constructor(t,r=new Ir){super(t,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(t,r){super.resizeGeometry(t,r,0),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh2D",r}clone(){let t=super.clone();return t.updateGeometry({}),t}static fromTexture(t){let r,i;if(t instanceof wu){let a=t.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=t.image;r=a.width*.5,i=a.height*.5}let s=sd.create({parameters:{width:r,height:i}}),o=new Ir;return o.layersList.changeLayer(0,{type:"texture",texture:t}),o.layersList.moveLayer(0,1),o.dispose(),new Pl(s,o)}};var Ll=class extends Ct{constructor(t,r=new Yr){super(t,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}};var Il=class extends Ll{constructor(t,r=new Yr){super(t,r);this.objectType="NonParametric"}toJSON(t){let r=super.toJSON(t);return r.object.objectType="NonParametric",r}};var Id=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},r,i)}parse(e){return new Py(e)}},Py=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let r=[],i=RR(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(r,i[s].toShapes());return r}};function RR(n,e,t){let r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<r.length;c++){let h=r[c];if(h===`
|
|
4492
4492
|
`)a=0,l-=s;else{let u=FR(h,i,a,l,t);a+=u.offsetX,o.push(u.path)}}return o}function FR(n,e,t,r,i){let s=i.glyphs[n]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+i.familyName+".");return}let o=new Nu,a,l,c,h,u,f,d,m;if(s.o){let p=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,x=p.length;g<x;)switch(p[g++]){case"m":a=p[g++]*e+t,l=p[g++]*e+r,o.moveTo(a,l);break;case"l":a=p[g++]*e+t,l=p[g++]*e+r,o.lineTo(a,l);break;case"q":c=p[g++]*e+t,h=p[g++]*e+r,u=p[g++]*e+t,f=p[g++]*e+r,o.quadraticCurveTo(u,f,c,h);break;case"b":c=p[g++]*e+t,h=p[g++]*e+r,u=p[g++]*e+t,f=p[g++]*e+r,d=p[g++]*e+t,m=p[g++]*e+r,o.bezierCurveTo(u,f,d,m,c,h);break}}return{offsetX:s.ha*e,path:o}}var $t=class extends ir{constructor({char:t,originalChar:r,fontFamily:i,letterSpacing:s,fontSize:o,LOD:a=16},l=new Un({color:0,opacity:1,visible:!0,transparent:!0,side:Wt})){let c=$t.loadChar(t,i,a);super(c.geometry,l);this.char=t,this.originalChar=r??t,this.fontFamily=i,this.letterSpacing=s,this.fontSize=o,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new O,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return $t._fontPath}static set FONTS_PATH(t){$t._fontPath=t}updatePosition(t,r){this.localPosition.copy(t);let i=new A(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).add(r)}updateFontSize(t){let r=t/this.resolution;this.fontSize=t,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(t){if(this.fontFamily===t)return;this.fontFamily=t;let r=$t.loadChar(this.char,t,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(t){if(this.char===t)return;this.char=t;let r=$t.loadChar(t,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(t){this.letterSpacing!==t&&(this.letterSpacing=t,this.updateFontSize(this.fontSize))}updateLOD(t){if(this.LOD===t)return;this.LOD=t;let r=$t.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let t={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new $t(t).copy(this)}static loadFont(t){return new Promise(function(r,i){$t.fontCache[t]?r($t.fontCache[t]):new Id().load($t.FONTS_PATH+t+".json",o=>{$t.fontCache[t]=o,r(o)},void 0,i)})}static loadChar(t,r,i){if($t.charCache[t]){if($t.charCache[t][i]&&$t.charCache[t][i].fontFamily===r)return $t.charCache[t][i]}else $t.charCache[t]={};let s=$t.fontCache[r],o=s.generateShapes(t,1);return $t.charCache[t][i]={geometry:new pa(o,i),fontFamily:r,resolution:s.data.resolution,glyphsHa:s.data.glyphs[t].ha},$t.charCache[t][i]}},Xr=$t;Xr.charCache={},Xr.fontCache={},Xr._fontPath="/_assets/_fonts/";var Nd=new O,Hs=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new O(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,i=this.message.length;r<i;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,i;for(i=e;i>=0;i-=1)if(this.message[i].char===" "){r=!1,t.length===0&&(i-=1,t.splice(0,0,this.message[i]));break}else t.splice(0,0,this.message[i]);return r?t=[]:this.message.splice(i+1,t.length),t}getWord(e=0,t=1){let r=[],i=e;for(i=e;;i+=t){if(!this.message[i]||this.message[i].char===" "){r.length===0&&this.message[i]&&(r.push(this.message[i]),this.message.splice(i,1));break}t>0?(r.push(this.message[i]),this.message.splice(i,1),i-=t):(r.splice(0,0,this.message[i]),this.message.splice(i,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,i=e;for(;i>=0&&i<this.message.length;){if(this.message[i].char===" "){r===0&&(r=this.message[i].charSize);break}r+=this.message[i].charSize,i+=t}return(i<0||i>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let i=t;i<=r;i+=1)this.message[i].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,i,s){switch(r){case 1:this.leftAlign(e,s);break;case 3:this.centerAlign(this.spaceLeft(t),e,s);break;case 2:this.rightAlign(this.spaceLeft(t),e,s);break;case 4:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){Nd.set(t,r);let i=this.message.length;for(let s=0;s<i;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Nd),e)}leftAlign(e,t){this.align=1,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=3,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=2,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=4,this.endLine){this.offsetCharacters(t,0,r);return}let i=this.countSpaces();if(i===0){this.offsetCharacters(t,0,r);return}let s=e/i,o=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(o+=s),Nd.set(o,r),this.message[a].updatePosition(this.message[a].localPosition.add(Nd),t)}clone(){let e=new Hs(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};var Ly=class extends Ct{constructor(t,r=new Ir({transparent:!0,opacity:1,visible:!1,side:Wt})){super(t,r);this.objectType="TextFrame";this.charContainer=new lt,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=t.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new A(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(t,r,i){let s=od.create({parameters:{width:r.width,height:r.height}}),o=new Ly(s).fromState(r,i);return o.uuid=t,o}async updateText(t){this.clearText();let r=this.userData.textFrame,i=r.fontFamily;await Xr.loadFont(i),r.text=t;let s=r.textOrigin,o=new Un({visible:r.visible,transparent:!0,side:Wt}),a=t.split(`
|
|
4493
4493
|
`),l=0;this.userData.textFrame.textLines=a.map((c,h)=>{let u=new Hs(l,r.lineHeight,r.fontSize);return u.message=c.split("").map(f=>{let d={char:f,fontFamily:i,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=o.clone();m.color=r.hexColor,m.opacity=r.opacity;let p=new Xr(d,m);return u.addChar3D(p,s),this.charContainer.add(p),p}),l+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let t=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;t.length;)t.pop()}raycast(t,r){let i=[];if(super.raycast(t,i),i.length>0){r.push(i[0]);return}let s=[];for(let o=0,a=this.charContainer.children.length;o<a;++o)if(this.charContainer.children[o]instanceof Xr&&(t.intersectObject(this.charContainer.children[o],!1,s),s.length>0)){s[0].object=this,r.push(s[0]);return}}updateGeometry(t){let r=this.userData,i=this.geometry.userData,s=i.parameters.width,o=i.parameters.height,a=t.parameters?.width??s,l=t.parameters?.height??o,c=r.textFrame;super.updateGeometry(t),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==o?(this.checkOverFlow(),this.checkCapacity()):a!==s&&(s<a?this.checkCapacity():s>a&&this.checkOverFlow())}checkOverFlow(t=0){let r=this.userData,i=r.textFrame.textOrigin,s=r.textFrame.textLines;for(let o=t;o<s.length;o++){s[o].updateYLinePos(this.getNewLinePosition(o)),s[o].fullUpdate(i);let a=[];for(;s[o].checkOverFlow(r.textFrame.maxLineSize);)s[o].containSpaceOverFlow()?a.unshift(s[o].getWord(s[o].message.length-1,-1)):a.unshift(s[o].popChar());if(a.length>0){s[o+1]===void 0?(s[o].isEndLine(!1),this.createTextLine()):s[o].endLine&&(this.createTextLine(o+1),s[o].isEndLine(!1),s[o+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let h=0;h<a[c].length;h+=1)s[o+1].addChar3D(a[c][h],i,l),l+=1;s[o+1].fullUpdate(i)}s[o].fullUpdate(i)}this.textFullUpdate(t)}checkCapacity(t=0){let r=this.userData,i=r.textFrame.textOrigin,s=r.textFrame.maxLineSize,o=r.textFrame.textLines;for(let a=t;a<o.length;a+=1)if(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i),!!o[a-1])for(;!o[a-1].endLine;){let l,c=o[a-1].spaceLeft(s);if(o[a].wordSize(0,1)<=c){o[a].containSpace()?l=o[a].getWord(0,1):l=o[a].popChar(0);for(let h=0;h<l.length;h+=1)l[h]&&o[a-1].addChar3D(l[h],i)}else{o[a].isEmpty()?(o[a].endLine&&o[a-1].isEndLine(!0),o.splice(a,1),a-=1):(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i));break}}this.textFullUpdate(t)}createTextLine(t=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(t,0,new Hs(this.getNewLinePosition(t),i.lineHeight,i.fontSize))}textFullUpdate(t=0){let i=this.userData.textFrame,s=i.textLines,o=this.getVerticalAlignmentOffSet();for(let a=t;a<s.length;a++)s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i.textOrigin),s[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,o)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(t){let i=this.userData.textFrame.textLines,s=0;for(let o=0;o<t;o+=1)s+=i[o].maxCharSize*i[o].lineHeight;return s}updateColor(t){let r=this.userData;r.textFrame.hexColor=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.color?.isColor&&(l.color=t)}}}updateOpacity(t){let r=this.userData;r.textFrame.opacity=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.opacity=t}}}updateVisible(t){let r=this.userData;r.textFrame.visible=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.visible=t}}}async updateFontFamily(t){await Xr.loadFont(t);let i=this.userData.textFrame,s=i.textLines;i.fontFamily=t;for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(t){let i=this.userData.textFrame,s=i.textLines,o=i.fontSize;i.fontSize=t;for(let a=0;a<s.length;a++)s[a].updateFontSize(t);this.textFullUpdate(),t>o?this.checkOverFlow():t<o&&this.checkCapacity()}async updateTextTransform(t){let i=this.userData.textFrame;await Xr.loadFont(i.fontFamily);let s=i.textLines;switch(i.textTransform=t,t){case 2:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(t){let r=this.userData,i=r.textFrame.textLines;r.textFrame.letterSpacing=t;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++)o[a].updateLetterSpacing(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(t){let r=this.userData;r.textFrame.LOD=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(t){let r=this.userData,i=r.textFrame.textLines;r.textFrame.lineHeight=t;for(let s=0;s<i.length;s++)i[s].updatelineHeight(t);this.textFullUpdate()}updateVerticalAlignment(t){let r=this.userData;r.textFrame.verticalAlignment=t,this.textFullUpdate()}updateHorizontalAlignment(t){let r=this.userData;r.textFrame.horizontalAlignment=t,this.textFullUpdate()}toJSON(t){let r=super.toJSON(t),i=r.object;i.objectType="TextFrame";let o=this.userData.textFrame.textLines.map(a=>{let l=a.message.map(c=>({char:c.char,originalChar:c.originalChar,fontFamily:c.fontFamily,letterSpacing:c.letterSpacing,fontSize:c.fontSize,LOD:c.LOD}));return{align:a.align,endLine:a.endLine,lineHeight:a.lineHeight,maxCharSize:a.maxCharSize,yLinePos:a.yLinePos,message:l}});return i.userData.textFrame.textLinesData=o,r}async fromJSONasync(t){if(super.fromJSON(t),t.userData!==void 0){let r=t.userData.textFrame;await Xr.loadFont(r.fontFamily),r.textOrigin=new A(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let i=new Un({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:Wt});r.textLinesData&&(r.textLines=r.textLinesData.map((s,o)=>{let a=new Hs(Number(s.yLinePos),Number(s.lineHeight),Number(s.maxCharSize)),l=s.message.map((c,h)=>{if(c.char===void 0){let d=r.textLines[o].message[h];if("geometries"in d){let m=d.geometries[0].userData.parameters;Object.assign(c,{LOD:m.lod,char:m.char,fontFamily:m.fontFamily,fontSize:m.fontSize,letterSpacing:m.letterSpacing,originalChar:m.char})}}let u={char:c.char,fontFamily:c.fontFamily,letterSpacing:Number(c.letterSpacing),fontSize:Number(c.fontSize),LOD:c.LOD},f=new Xr(u,i.clone());return a.addChar3D(f,r.textOrigin),this.charContainer.add(f),f});return a.message=l,a}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(t,r){if(t.color!==void 0){let i=Zt(t.color,r);this.updateColor(i),this.updateOpacity(i.a)}t.alpha!==void 0&&this.updateOpacity(t.alpha),t.font!==void 0&&this.updateFontFamily(t.font),t.horizontalAlign!==void 0&&this.updateHorizontalAlignment(t.horizontalAlign),t.verticalAlign!==void 0&&this.updateVerticalAlignment(t.verticalAlign),t.textTransform!==void 0&&this.updateTextTransform(t.textTransform),t.fontSize!==void 0&&this.updateFontSize(t.fontSize),t.lineHeight!==void 0&&this.updateLineHeight(t.lineHeight),t.letterSpacing!==void 0&&this.updateLetterSpacing(t.letterSpacing),t.text!==void 0&&t.text!==""&&this.updateText(t.text),(t.width!==void 0||t.height!==void 0)&&this.updateGeometry({parameters:{width:t.width,height:t.height}})}fromState(t,r){return super.fromState(t),this.fromTextFrameData(t,r),this}convertToVector(){let{fontFamily:t,hexColor:r}=this.userData.textFrame,i=new Qi;i.name="Text Shape";let s=Xr.fontCache[t];for(let o of this.charContainer.children)o instanceof Xr&&s.generateShapes(o.char,1).forEach(a=>{let l=new dt().fromShape(a);l.applyScale(o.scale.x,o.scale.y);let c=Er.create({shape:l}),h=new Ir({side:Wt});h.color=r;let u=new Vs(c,h);u.name=o.char,u.position.copy(o.position),u.rotation.copy(o.rotation),i.attach(u)});return i}},Lo=Ly;Lo.VerticalAlign=Pg,Lo.HorizontalAlign=Dg,Lo.TextTransform=Lg;var j1=yv(H1());var Iy;ld.then(n=>{Iy=n});var q1=new Be,zR=new Be,UR=new Be,$n=new yr,Ws=new A,GR=new Be,kR=new Be,js=class extends Ct{constructor(t,r,i,s=new Yr){super(i??r,s);this.subdivPointer=t;this.originalGeometry=r;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new Be;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new Be;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(t,r,i){let{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}=Pn.build(r.geometry,void 0,void 0,!r.flatShading),l=vh(r.material,i),c=new js(s,o,a||void 0,l);return r.geometry.phongAngle!==void 0&&(c.phongAngle=r.geometry.phongAngle),c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=t,c.fromState(r),c}shallowClone(t){return new Il(this.geometry,this.material).shallowCopy(this,t)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="SubdivObject",r}buildFromStore(t,r){let{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=Pn.build(t,r,this.subdivPointer,this.smoothShading,this.shearScale);if(t.phongAngle!==void 0&&(this.phongAngle=t.phongAngle),this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry;t.width&&(this.geometry.userData.parameters={width:t.width,height:t.height,depth:t.depth})}updateMesh(t=!1){Pn.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t?this.shearScaleInv:void 0),this.subdividedGeometry&&Pn.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Pn.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Pn.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(t,r){this.geometry=this.originalGeometry,Ct.prototype.raycast.call(this,t,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,r=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:o}=(0,j1.SVD)(r),a=q1.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),l=zR.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),c=UR.copy(l).transpose();this.shearScale=GR.makeScale(o[0],o[1],o[2]).multiply(c).premultiply(l),this.shearScaleInv=kR.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),o.every(h=>Math.abs(o[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Br);let r=t.attributes.position,i=t.boundingSphere.center;$n.setFromBufferAttribute(r),$n.getCenter(i),t.boundingSphere.radius=i.distanceTo($n.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),$n.getSize(Ws);let s={width:Ws.x,height:Ws.y,depth:Ws.z};return this.geometry.userData.parameters=s,s}updateBoundingBox(t){let r=this.originalGeometry;$n.min.set(t[0],t[2],t[4]),$n.max.set(t[1],t[3],t[5]),this.shearScaleInv&&($n.min.applyMatrix4(this.shearScaleInv),$n.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Br);let i=r.boundingSphere.center;$n.getCenter(i),r.boundingSphere.radius=i.distanceTo($n.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),$n.getSize(Ws);let s={width:Ws.x,height:Ws.y,depth:Ws.z};return this.geometry.userData.parameters=s,s}freeSubdivPointer(){this.subdivPointer&&(Iy.free_bvh(this.subdivPointer),Iy.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(t){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:t.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:t.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:t.parameters.depth/this.geometry.userData.parameters.depth,W1(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(W1(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...t.parameters}}};function W1(n,e,t,r){let i=n.position.array,s=n.normal.array,o=q1.makeScale(e,t,r).invert().elements,a,l,c;for(var h=0,u=i.length;h<u;h+=3)i[h]*=e,i[h+1]*=t,i[h+2]*=r,a=s[h],l=s[h+1],c=s[h+2],s[h]=o[0]*a+o[4]*l+o[8]*c,s[h+1]=o[1]*a+o[5]*l+o[9]*c,s[h+2]=o[2]*a+o[6]*l+o[10]*c}function Y1(n,e){e.flatShading!==void 0&&(n.flatShading=e.flatShading,n.needsUpdate=!0),e.wireframe!==void 0&&(n.wireframe=e.wireframe),e.side!==void 0&&(e.side===0?n.side=zn:e.side===1?n.side=gr:n.side=Wt)}function VR(n,e){if(Array.isArray(n.material))for(let t of n.material)Y1(t,e);else{let t=n.material;Y1(t,e)}n.objectType==="SubdivObject"&&e.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!e.flatShading,n.updateMesh())}function X1(n,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=js.createFromState(n,e,t);else{let i=e.geometry.type==="BooleanGeometry"?new Le:_d(e.geometry,t),s="materials"in e?p1(e.materials,t):vh(e.material,t);qf.is2DParametricMesh(i.userData.type)?r=new Pl(i,s):i?.userData.type==="VectorGeometry"?r=new Vs(i,s):e.geometry.type==="NonParametricGeometry"?r=new Il(i,s):e.geometry.type==="BooleanGeometry"?(r=new Ed(void 0,s),r.booleanOp=e.geometry.operation,e.geometry.phongAngle!==void 0&&(r.phongAngle=e.geometry.phongAngle)):r=new Ll(i,s),r.uuid=n,r.fromState(e)}return VR(r,e),r}function J1(n,e,t){return e.type==="Mesh"?X1(n,e,t):e.type==="TextFrame"?Lo.createFromState(n,e,t):e.type==="Empty"?Qi.createFromState(n,e):e.type==="PointLight"?Cl.createFromState(n,e,t):e.type==="SpotLight"?Dl.createFromState(n,e,t):e.type==="DirectionalLight"?El.createFromState(n,e,t):Is.is(e.type)?vn.createFromState(n,e):(console.error(e),new Qi)}function HR(n,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=n.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=n.depthTexture}function Q1(n,e,t){if(!t.userData.layers)return!1;let r=!1,i=t.userData.layers.getLayersOfType("transmission");return i.length>0?(e.layers.set(3),r=!0,n!==void 0&&i.forEach(s=>HR(n,s))):e.layers.set(0),r}function K1(n,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof Ct)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)Q1(n,r,r.material[i])&&(t=!0);else Q1(n,r,r.material)&&(t=!0)}),t}function Z1(n,e){"material"in n&&WR(n.material,e),"geometry"in n&&n.geometry.dispose()}function WR(n,e){Dw(n).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var $1=new A,Ny=class extends Md(un){constructor(t,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new aa(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Se(1,0,0);this.bgColor=new Se(1,1,1);this.entityByUuid={};this.ambientLight=new mo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(t,r)}needsTransmission(t){return this.needsTransmissionDirty&&(this._needsTransmission=K1(t,this),t!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(t){if(t===""||t===void 0)return;let r=this.entityByUuid[t];return r===void 0?this.getObjectByProperty("uuid",t):r}get color(){return this._color}set color(t){this.fogUseBGColor===!0&&this.backupFog.color.copy(t),this._color.copy(t)}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,r){if(this.createChildrenObjects(t.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Zt(t.backgroundColor,r)),this.updateFog(t.fog,r),this.updateAmbientLight(t.environment.ambientLight,r),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof vn&&this.switchActiveCamera(i)}this.traverse(i=>{xt(i)&&i.recomputeBoolean()})}clearScene(t){this.traverseEntity(r=>{Z1(r,t)});for(let r of this.children)Cn(r)&&r.removeFromParent()}resetAfterClear(t,r){this.init(t,r)}createPersonalCamera(){let t=vn.createFromState(Ny.PERSONAL_CAMERA_ID,{...Xf.defaultData,name:"Personal Camera"});return t.enableHelper=!1,t.objectHelper.visible=!1,delete t.isEntity,this.registerObjectCreatedInLegacy(t),t}raycast(t){let r=[],i=s=>{for(let o of s.children)Cn(o)&&!o.raycastLock&&o.visible&&((zt(o)||Ji(o)&&o.enableHelper&&o.objectHelper.parent)&&t.intersectObject(o,!1,r),i(o))};return i(this),r}traverseEntity(t){for(let r of this.children)Cn(r)&&r.traverseEntity(t)}updateFog(t,r){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Zt(t.color,r),this.backupFog.near=t.near,this.backupFog.far=t.far}toJSON(t){return{}}fromJSON(t){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(t,r){v1(this.ambientLight,t,r),t.groundColor!==void 0&&(this.ambientLight.groundColor=Zt(t.groundColor,r)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=t,t.enableHelper=!1}setBackgroundColor(t){this.bgColor=t,this.alpha=t.a}createChildrenObjects(t,r,i){for(let s of t)this.createChildObject(s.id,s.data,s.children,r,i)}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let r of t.children)this.unregisterObject(r)}createChildObject(t,r,i,s,o){let a=J1(t,r,o);return a&&(this.entityByUuid[t]=a,s.add(a),xt(s)&&zt(a)&&(a.prevBooleanObjectParent=s),this.createChildrenObjects(i,a,o)),a}getCenter(t){let r=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],c=this.find(a),h=l?c.recursiveBBox:c.singleBBox;r.push(...h.vertices)}let i=new yr;return i.setFromPoints(r),i.getCenter($1),$1}copyMatrixWorld(t,r){if(t===null){r.identity();return}let i=this.find(t);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(t,r){if(t===null){r.identity();return}let i=this.find(t)?.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(t){this.traverseEntity(r=>{if(r instanceof Ct)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)t(r.material[i]);else t(r.material)})}updateCanvasSize(t,r){this.activeCamera.setViewplaneSize(t,r);let i,s;t>=r?(i=r/t,s=1):(i=1,s=t/r),this.traverseMaterial(o=>{o.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},Mh=Ny;Mh.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var oA={RED:0,GREEN:1,BLUE:2,ALPHA:3};var _h="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var jR=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
4494
4494
|
uniform mediump sampler2D inputBuffer;
|