@splinetool/runtime 0.9.346 → 0.9.347

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.cjs CHANGED
@@ -3137,7 +3137,7 @@ void main() {
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
3138
  }`;function UN(r,t,e){let n=new rh,i=new F,s=new F,o=new $e,a=new ih({depthPacking:O0}),l=new l0,u={},c=e.maxTextureSize,d={[Zr]:Mn,[Mn]:Zr,[wr]:wr},h=new wt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:FN,fragmentShader:kN}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let g=new Te;g.setAttribute("position",new Fe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Xn(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=qp,this.render=function(S,w,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;let E=r.getRenderTarget(),b=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),M=r.state;M.setBlending(Ut),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let I=0,P=S.length;I<P;I++){let C=S[I],D=C.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",C,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;i.copy(D.mapSize);let R=D.getFrameExtents();if(i.multiply(R),s.copy(D.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/R.x),i.x=s.x*R.x,D.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/R.y),i.y=s.y*R.y,D.mapSize.y=s.y)),D.map===null){let Y=this.type!==qd?{minFilter:kt,magFilter:kt}:{};D.map=new Tt(i.x,i.y,Y),D.map.texture.name=C.name+".shadowMap",D.camera.updateProjectionMatrix()}r.setRenderTarget(D.map),r.clear();let U=D.getViewportCount();for(let Y=0;Y<U;Y++){let W=D.getViewport(Y);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),M.viewport(o),D.updateMatrices(C,Y),n=D.getFrustum(),x(w,_,D.camera,C,this.type)}D.isPointLightShadow!==!0&&this.type===qd&&y(D,_),D.needsUpdate=!1}m.needsUpdate=!1,r.setRenderTarget(E,b,T)};function y(S,w){let _=t.update(p);h.defines.VSM_SAMPLES!==S.blurSamples&&(h.defines.VSM_SAMPLES=S.blurSamples,f.defines.VSM_SAMPLES=S.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new Tt(i.x,i.y)),h.uniforms.shadow_pass.value=S.map.texture,h.uniforms.resolution.value=S.mapSize,h.uniforms.radius.value=S.radius,r.setRenderTarget(S.mapPass),r.clear(),r.renderBufferDirect(w,null,_,h,p,null),f.uniforms.shadow_pass.value=S.mapPass.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,r.setRenderTarget(S.map),r.clear(),r.renderBufferDirect(w,null,_,f,p,null)}function v(S,w,_,E,b,T){let M=null,I=_.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(I!==void 0)M=I;else if(M=_.isPointLight===!0?l:a,r.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let P=M.uuid,C=w.uuid,D=u[P];D===void 0&&(D={},u[P]=D);let R=D[C];R===void 0&&(R=M.clone(),D[C]=R),M=R}return M.visible=w.visible,M.wireframe=w.wireframe,T===qd?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:d[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,_.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(_.matrixWorld),M.nearDistance=E,M.farDistance=b),M}function x(S,w,_,E,b){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&b===qd)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,S.matrixWorld);let I=t.update(S),P=S.material;if(Array.isArray(P)){let C=I.groups;for(let D=0,R=C.length;D<R;D++){let U=C[D],Y=P[U.materialIndex];if(Y&&Y.visible){let W=v(S,Y,E,_.near,_.far,b);r.renderBufferDirect(_,null,I,W,S,U)}}}else if(P.visible){let C=v(S,P,E,_.near,_.far,b);r.renderBufferDirect(_,null,I,C,S,null)}}let M=S.children;for(let I=0,P=M.length;I<P;I++)x(M[I],w,_,E,b)}}function GN(r,t,e){let n=e.isWebGL2;function i(){let Q=!1,ie=new $e,me=null,Re=new $e(0,0,0,0);return{setMask:function(Oe){me!==Oe&&!Q&&(r.colorMask(Oe,Oe,Oe,Oe),me=Oe)},setLocked:function(Oe){Q=Oe},setClear:function(Oe,pt,An,dn,Ea){Ea===!0&&(Oe*=dn,pt*=dn,An*=dn),ie.set(Oe,pt,An,dn),Re.equals(ie)===!1&&(r.clearColor(Oe,pt,An,dn),Re.copy(ie))},reset:function(){Q=!1,me=null,Re.set(-1,0,0,0)}}}function s(){let Q=!1,ie=null,me=null,Re=null;return{setTest:function(Oe){Oe?re(2929):K(2929)},setMask:function(Oe){ie!==Oe&&!Q&&(r.depthMask(Oe),ie=Oe)},setFunc:function(Oe){if(me!==Oe){switch(Oe){case mD:r.depthFunc(512);break;case gD:r.depthFunc(519);break;case yD:r.depthFunc(513);break;case Xv:r.depthFunc(515);break;case vD:r.depthFunc(514);break;case xD:r.depthFunc(518);break;case bD:r.depthFunc(516);break;case SD:r.depthFunc(517);break;default:r.depthFunc(515)}me=Oe}},setLocked:function(Oe){Q=Oe},setClear:function(Oe){Re!==Oe&&(r.clearDepth(Oe),Re=Oe)},reset:function(){Q=!1,ie=null,me=null,Re=null}}}function o(){let Q=!1,ie=null,me=null,Re=null,Oe=null,pt=null,An=null,dn=null,Ea=null;return{setTest:function(Xt){Q||(Xt?re(2960):K(2960))},setMask:function(Xt){ie!==Xt&&!Q&&(r.stencilMask(Xt),ie=Xt)},setFunc:function(Xt,ks,ci){(me!==Xt||Re!==ks||Oe!==ci)&&(r.stencilFunc(Xt,ks,ci),me=Xt,Re=ks,Oe=ci)},setOp:function(Xt,ks,ci){(pt!==Xt||An!==ks||dn!==ci)&&(r.stencilOp(Xt,ks,ci),pt=Xt,An=ks,dn=ci)},setLocked:function(Xt){Q=Xt},setClear:function(Xt){Ea!==Xt&&(r.clearStencil(Xt),Ea=Xt)},reset:function(){Q=!1,ie=null,me=null,Re=null,Oe=null,pt=null,An=null,dn=null,Ea=null}}}let a=new i,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},g=new WeakMap,p=[],m=null,y=!1,v=null,x=null,S=null,w=null,_=null,E=null,b=null,T=!1,M=null,I=null,P=null,C=null,D=null,R=r.getParameter(35661),U=!1,Y=0,W=r.getParameter(7938);W.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(W)[1]),U=Y>=1):W.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),U=Y>=2);let q=null,j={},X=r.getParameter(3088),N=r.getParameter(2978),k=new $e().fromArray(X),V=new $e().fromArray(N);function H(Q,ie,me){let Re=new Uint8Array(4),Oe=r.createTexture();r.bindTexture(Q,Oe),r.texParameteri(Q,10241,9728),r.texParameteri(Q,10240,9728);for(let pt=0;pt<me;pt++)r.texImage2D(ie+pt,0,6408,1,1,0,6408,5121,Re);return Oe}let z={};z[3553]=H(3553,3553,1),z[34067]=H(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(Xv),ye(!1),Ee(Ew),re(2884),ge(Ut);function re(Q){h[Q]!==!0&&(r.enable(Q),h[Q]=!0)}function K(Q){h[Q]!==!1&&(r.disable(Q),h[Q]=!1)}function Z(Q,ie){return f[Q]!==ie?(r.bindFramebuffer(Q,ie),f[Q]=ie,n&&(Q===36009&&(f[36160]=ie),Q===36160&&(f[36009]=ie)),!0):!1}function G(Q,ie){let me=p,Re=!1;if(Q)if(me=g.get(ie),me===void 0&&(me=[],g.set(ie,me)),Q.isWebGLMultipleRenderTargets){let Oe=Q.texture;if(me.length!==Oe.length||me[0]!==36064){for(let pt=0,An=Oe.length;pt<An;pt++)me[pt]=36064+pt;me.length=Oe.length,Re=!0}}else me[0]!==36064&&(me[0]=36064,Re=!0);else me[0]!==1029&&(me[0]=1029,Re=!0);Re&&(e.isWebGL2?r.drawBuffers(me):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(me))}function ue(Q){return m!==Q?(r.useProgram(Q),m=Q,!0):!1}let he={[Wl]:32774,[iD]:32778,[sD]:32779};if(n)he[Pw]=32775,he[Iw]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(he[Pw]=Q.MIN_EXT,he[Iw]=Q.MAX_EXT)}let ae={[oD]:0,[aD]:1,[lD]:768,[rA]:770,[pD]:776,[hD]:774,[uD]:772,[cD]:769,[iA]:771,[fD]:775,[dD]:773};function ge(Q,ie,me,Re,Oe,pt,An,dn){if(Q===Ut){y===!0&&(K(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Q!==rD){if(Q!==v||dn!==T){if((x!==Wl||_!==Wl)&&(r.blendEquation(32774),x=Wl,_=Wl),dn)switch(Q){case Xl:r.blendFuncSeparate(1,771,1,771);break;case Tw:r.blendFunc(1,1);break;case Mw:r.blendFuncSeparate(0,769,0,1);break;case Cw:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case Xl:r.blendFuncSeparate(770,771,1,771);break;case Tw:r.blendFunc(770,1);break;case Mw:r.blendFuncSeparate(0,769,0,1);break;case Cw:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}S=null,w=null,E=null,b=null,v=Q,T=dn}return}Oe=Oe||ie,pt=pt||me,An=An||Re,(ie!==x||Oe!==_)&&(r.blendEquationSeparate(he[ie],he[Oe]),x=ie,_=Oe),(me!==S||Re!==w||pt!==E||An!==b)&&(r.blendFuncSeparate(ae[me],ae[Re],ae[pt],ae[An]),S=me,w=Re,E=pt,b=An),v=Q,T=!1}function Se(Q,ie){Q.side===wr?K(2884):re(2884);let me=Q.side===Mn;ie&&(me=!me),ye(me),Q.blending===Xl&&Q.transparent===!1?ge(Ut):ge(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let Re=Q.stencilWrite;u.setTest(Re),Re&&(u.setMask(Q.stencilWriteMask),u.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),u.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),be(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?re(32926):K(32926)}function ye(Q){M!==Q&&(Q?r.frontFace(2304):r.frontFace(2305),M=Q)}function Ee(Q){Q!==tD?(re(2884),Q!==I&&(Q===Ew?r.cullFace(1029):Q===nD?r.cullFace(1028):r.cullFace(1032))):K(2884),I=Q}function Me(Q){Q!==P&&(U&&r.lineWidth(Q),P=Q)}function be(Q,ie,me){Q?(re(32823),(C!==ie||D!==me)&&(r.polygonOffset(ie,me),C=ie,D=me)):K(32823)}function Ge(Q){Q?re(3089):K(3089)}function ht(Q){Q===void 0&&(Q=33984+R-1),q!==Q&&(r.activeTexture(Q),q=Q)}function L(Q,ie,me){me===void 0&&(q===null?me=33984+R-1:me=q);let Re=j[me];Re===void 0&&(Re={type:void 0,texture:void 0},j[me]=Re),(Re.type!==Q||Re.texture!==ie)&&(q!==me&&(r.activeTexture(me),q=me),r.bindTexture(Q,ie||z[Q]),Re.type=Q,Re.texture=ie)}function O(){let Q=j[q];Q!==void 0&&Q.type!==void 0&&(r.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ee(){try{r.compressedTexImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function pe(){try{r.compressedTexImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ve(){try{r.texSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ce(){try{r.texSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ze(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Pe(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ce(){try{r.texStorage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function je(){try{r.texStorage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Le(){try{r.texImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ie(){try{r.texImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Be(Q){k.equals(Q)===!1&&(r.scissor(Q.x,Q.y,Q.z,Q.w),k.copy(Q))}function qe(Q){V.equals(Q)===!1&&(r.viewport(Q.x,Q.y,Q.z,Q.w),V.copy(Q))}function ft(Q,ie){let me=d.get(ie);me===void 0&&(me=new WeakMap,d.set(ie,me));let Re=me.get(Q);Re===void 0&&(Re=r.getUniformBlockIndex(ie,Q.name),me.set(Q,Re))}function Ft(Q,ie){let Re=d.get(ie).get(Q);c.get(ie)!==Re&&(r.uniformBlockBinding(ie,Re,Q.__bindingPointIndex),c.set(ie,Re))}function wn(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},q=null,j={},f={},g=new WeakMap,p=[],m=null,y=!1,v=null,x=null,S=null,w=null,_=null,E=null,b=null,T=!1,M=null,I=null,P=null,C=null,D=null,k.set(0,0,r.canvas.width,r.canvas.height),V.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:re,disable:K,bindFramebuffer:Z,drawBuffers:G,useProgram:ue,setBlending:ge,setMaterial:Se,setFlipSided:ye,setCullFace:Ee,setLineWidth:Me,setPolygonOffset:be,setScissorTest:Ge,activeTexture:ht,bindTexture:L,unbindTexture:O,compressedTexImage2D:ee,compressedTexImage3D:pe,texImage2D:Le,texImage3D:Ie,updateUBOMapping:ft,uniformBlockBinding:Ft,texStorage2D:ce,texStorage3D:je,texSubImage2D:ve,texSubImage3D:Ce,compressedTexSubImage2D:ze,compressedTexSubImage3D:Pe,scissor:Be,viewport:qe,reset:wn}}function zN(r,t,e,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,d=i.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap,p,m=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(L,O){return y?new OffscreenCanvas(L,O):Tp("canvas")}function x(L,O,ee,pe){let ve=1;if((L.width>pe||L.height>pe)&&(ve=pe/Math.max(L.width,L.height)),ve<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let Ce=O?Ep:Math.floor,ze=Ce(ve*L.width),Pe=Ce(ve*L.height);p===void 0&&(p=v(ze,Pe));let ce=ee?v(ze,Pe):p;return ce.width=ze,ce.height=Pe,ce.getContext("2d").drawImage(L,0,0,ze,Pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+ze+"x"+Pe+")."),ce}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function S(L){return $v(L.width)&&$v(L.height)}function w(L){return a?!1:L.wrapS!==Sr||L.wrapT!==Sr||L.minFilter!==kt&&L.minFilter!==it}function _(L,O){return L.generateMipmaps&&O&&L.minFilter!==kt&&L.minFilter!==it}function E(L){r.generateMipmap(L)}function b(L,O,ee,pe,ve=!1){if(a===!1)return O;if(L!==null){if(r[L]!==void 0)return r[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let Ce=O;return O===6403&&(ee===5126&&(Ce=33326),ee===5131&&(Ce=33325),ee===5121&&(Ce=33321)),O===33319&&(ee===5126&&(Ce=33328),ee===5131&&(Ce=33327),ee===5121&&(Ce=33323)),O===6408&&(ee===5126&&(Ce=34836),ee===5131&&(Ce=34842),ee===5121&&(Ce=pe===Ye&&ve===!1?35907:32856),ee===32819&&(Ce=32854),ee===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&t.get("EXT_color_buffer_float"),Ce}function T(L,O,ee){return _(L,ee)===!0||L.isFramebufferTexture&&L.minFilter!==kt&&L.minFilter!==it?Math.log2(Math.max(O.width,O.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?O.mipmaps.length:1}function M(L){return L===kt||L===Dw||L===uv?9728:9729}function I(L){let O=L.target;O.removeEventListener("dispose",I),C(O),O.isVideoTexture&&g.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),R(O)}function C(L){let O=n.get(L);if(O.__webglInit===void 0)return;let ee=L.source,pe=m.get(ee);if(pe){let ve=pe[O.__cacheKey];ve.usedTimes--,ve.usedTimes===0&&D(L),Object.keys(pe).length===0&&m.delete(ee)}n.remove(L)}function D(L){let O=n.get(L);r.deleteTexture(O.__webglTexture);let ee=L.source,pe=m.get(ee);delete pe[O.__cacheKey],o.memory.textures--}function R(L){let O=L.texture,ee=n.get(L),pe=n.get(O);if(pe.__webglTexture!==void 0&&(r.deleteTexture(pe.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++)r.deleteFramebuffer(ee.__webglFramebuffer[ve]),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer[ve]);else{if(r.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let ve=0;ve<ee.__webglColorRenderbuffer.length;ve++)ee.__webglColorRenderbuffer[ve]&&r.deleteRenderbuffer(ee.__webglColorRenderbuffer[ve]);ee.__webglDepthRenderbuffer&&r.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(L.isWebGLMultipleRenderTargets)for(let ve=0,Ce=O.length;ve<Ce;ve++){let ze=n.get(O[ve]);ze.__webglTexture&&(r.deleteTexture(ze.__webglTexture),o.memory.textures--),n.remove(O[ve])}n.remove(O),n.remove(L)}let U=0;function Y(){U=0}function W(){let L=U;return L>=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),U+=1,L}function q(L){let O=[];return O.push(L.wrapS),O.push(L.wrapT),O.push(L.wrapR||0),O.push(L.magFilter),O.push(L.minFilter),O.push(L.anisotropy),O.push(L.internalFormat),O.push(L.format),O.push(L.type),O.push(L.generateMipmaps),O.push(L.premultiplyAlpha),O.push(L.flipY),O.push(L.unpackAlignment),O.push(L.encoding),O.join()}function j(L,O){let ee=n.get(L);if(L.isVideoTexture&&Ge(L),L.isRenderTargetTexture===!1&&L.version>0&&ee.__version!==L.version){let pe=L.image;if(pe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(ee,L,O);return}}e.bindTexture(3553,ee.__webglTexture,33984+O)}function X(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){K(ee,L,O);return}e.bindTexture(35866,ee.__webglTexture,33984+O)}function N(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){K(ee,L,O);return}e.bindTexture(32879,ee.__webglTexture,33984+O)}function k(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){Z(ee,L,O);return}e.bindTexture(34067,ee.__webglTexture,33984+O)}let V={[Ql]:10497,[Sr]:33071,[Kv]:33648},H={[kt]:9728,[Dw]:9984,[uv]:9986,[it]:9729,[PD]:9985,[Ba]:9987};function z(L,O,ee){if(ee?(r.texParameteri(L,10242,V[O.wrapS]),r.texParameteri(L,10243,V[O.wrapT]),(L===32879||L===35866)&&r.texParameteri(L,32882,V[O.wrapR]),r.texParameteri(L,10240,H[O.magFilter]),r.texParameteri(L,10241,H[O.minFilter])):(r.texParameteri(L,10242,33071),r.texParameteri(L,10243,33071),(L===32879||L===35866)&&r.texParameteri(L,32882,33071),(O.wrapS!==Sr||O.wrapT!==Sr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(L,10240,M(O.magFilter)),r.texParameteri(L,10241,M(O.minFilter)),O.minFilter!==kt&&O.minFilter!==it&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let pe=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===kt||O.minFilter!==uv&&O.minFilter!==Ba||O.type===os&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===$d&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(r.texParameterf(L,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy)}}function re(L,O){let ee=!1;L.__webglInit===void 0&&(L.__webglInit=!0,O.addEventListener("dispose",I));let pe=O.source,ve=m.get(pe);ve===void 0&&(ve={},m.set(pe,ve));let Ce=q(O);if(Ce!==L.__cacheKey){ve[Ce]===void 0&&(ve[Ce]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),ve[Ce].usedTimes++;let ze=ve[L.__cacheKey];ze!==void 0&&(ve[L.__cacheKey].usedTimes--,ze.usedTimes===0&&D(O)),L.__cacheKey=Ce,L.__webglTexture=ve[Ce].texture}return ee}function K(L,O,ee){let pe=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(pe=35866),O.isData3DTexture&&(pe=32879);let ve=re(L,O),Ce=O.source;e.bindTexture(pe,L.__webglTexture,33984+ee);let ze=n.get(Ce);if(Ce.version!==ze.__version||ve===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,O.flipY),r.pixelStorei(37441,O.premultiplyAlpha),r.pixelStorei(3317,O.unpackAlignment),r.pixelStorei(37443,0);let Pe=w(O)&&S(O.image)===!1,ce=x(O.image,Pe,!1,c);ce=ht(O,ce);let je=S(ce)||a,Le=s.convert(O.format,O.encoding),Ie=s.convert(O.type),Be=b(O.internalFormat,Le,Ie,O.encoding,O.isVideoTexture);z(pe,O,je);let qe,ft=O.mipmaps,Ft=a&&O.isVideoTexture!==!0,wn=ze.__version===void 0||ve===!0,Q=T(O,ce,je);if(O.isDepthTexture)Be=6402,a?O.type===os?Be=36012:O.type===Xs?Be=33190:O.type===Ro?Be=35056:Be=33189:O.type===os&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Ra&&Be===6402&&O.type!==aA&&O.type!==Xs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Xs,Ie=s.convert(O.type)),O.format===Fo&&Be===6402&&(Be=34041,O.type!==Ro&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Ro,Ie=s.convert(O.type))),wn&&(Ft?e.texStorage2D(3553,1,Be,ce.width,ce.height):e.texImage2D(3553,0,Be,ce.width,ce.height,0,Le,Ie,null));else if(O.isDataTexture)if(ft.length>0&&je){Ft&&wn&&e.texStorage2D(3553,Q,Be,ft[0].width,ft[0].height);for(let ie=0,me=ft.length;ie<me;ie++)qe=ft[ie],Ft?e.texSubImage2D(3553,ie,0,0,qe.width,qe.height,Le,Ie,qe.data):e.texImage2D(3553,ie,Be,qe.width,qe.height,0,Le,Ie,qe.data);O.generateMipmaps=!1}else Ft?(wn&&e.texStorage2D(3553,Q,Be,ce.width,ce.height),e.texSubImage2D(3553,0,0,0,ce.width,ce.height,Le,Ie,ce.data)):e.texImage2D(3553,0,Be,ce.width,ce.height,0,Le,Ie,ce.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ft&&wn&&e.texStorage3D(35866,Q,Be,ft[0].width,ft[0].height,ce.depth);for(let ie=0,me=ft.length;ie<me;ie++)qe=ft[ie],O.format!==di?Le!==null?Ft?e.compressedTexSubImage3D(35866,ie,0,0,0,qe.width,qe.height,ce.depth,Le,qe.data,0,0):e.compressedTexImage3D(35866,ie,Be,qe.width,qe.height,ce.depth,0,qe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?e.texSubImage3D(35866,ie,0,0,0,qe.width,qe.height,ce.depth,Le,Ie,qe.data):e.texImage3D(35866,ie,Be,qe.width,qe.height,ce.depth,0,Le,Ie,qe.data)}else{Ft&&wn&&e.texStorage2D(3553,Q,Be,ft[0].width,ft[0].height);for(let ie=0,me=ft.length;ie<me;ie++)qe=ft[ie],O.format!==di?Le!==null?Ft?e.compressedTexSubImage2D(3553,ie,0,0,qe.width,qe.height,Le,qe.data):e.compressedTexImage2D(3553,ie,Be,qe.width,qe.height,0,qe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?e.texSubImage2D(3553,ie,0,0,qe.width,qe.height,Le,Ie,qe.data):e.texImage2D(3553,ie,Be,qe.width,qe.height,0,Le,Ie,qe.data)}else if(O.isDataArrayTexture)Ft?(wn&&e.texStorage3D(35866,Q,Be,ce.width,ce.height,ce.depth),e.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,Le,Ie,ce.data)):e.texImage3D(35866,0,Be,ce.width,ce.height,ce.depth,0,Le,Ie,ce.data);else if(O.isData3DTexture)Ft?(wn&&e.texStorage3D(32879,Q,Be,ce.width,ce.height,ce.depth),e.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,Le,Ie,ce.data)):e.texImage3D(32879,0,Be,ce.width,ce.height,ce.depth,0,Le,Ie,ce.data);else if(O.isFramebufferTexture){if(wn)if(Ft)e.texStorage2D(3553,Q,Be,ce.width,ce.height);else{let ie=ce.width,me=ce.height;for(let Re=0;Re<Q;Re++)e.texImage2D(3553,Re,Be,ie,me,0,Le,Ie,null),ie>>=1,me>>=1}}else if(ft.length>0&&je){Ft&&wn&&e.texStorage2D(3553,Q,Be,ft[0].width,ft[0].height);for(let ie=0,me=ft.length;ie<me;ie++)qe=ft[ie],Ft?e.texSubImage2D(3553,ie,0,0,Le,Ie,qe):e.texImage2D(3553,ie,Be,Le,Ie,qe);O.generateMipmaps=!1}else Ft?(wn&&e.texStorage2D(3553,Q,Be,ce.width,ce.height),e.texSubImage2D(3553,0,0,0,Le,Ie,ce)):e.texImage2D(3553,0,Be,Le,Ie,ce);_(O,je)&&E(pe),ze.__version=Ce.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function Z(L,O,ee){if(O.image.length!==6)return;let pe=re(L,O),ve=O.source;e.bindTexture(34067,L.__webglTexture,33984+ee);let Ce=n.get(ve);if(ve.version!==Ce.__version||pe===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,O.flipY),r.pixelStorei(37441,O.premultiplyAlpha),r.pixelStorei(3317,O.unpackAlignment),r.pixelStorei(37443,0);let ze=O.isCompressedTexture||O.image[0].isCompressedTexture,Pe=O.image[0]&&O.image[0].isDataTexture,ce=[];for(let ie=0;ie<6;ie++)!ze&&!Pe?ce[ie]=x(O.image[ie],!1,!0,u):ce[ie]=Pe?O.image[ie].image:O.image[ie],ce[ie]=ht(O,ce[ie]);let je=ce[0],Le=S(je)||a,Ie=s.convert(O.format,O.encoding),Be=s.convert(O.type),qe=b(O.internalFormat,Ie,Be,O.encoding),ft=a&&O.isVideoTexture!==!0,Ft=Ce.__version===void 0||pe===!0,wn=T(O,je,Le);z(34067,O,Le);let Q;if(ze){ft&&Ft&&e.texStorage2D(34067,wn,qe,je.width,je.height);for(let ie=0;ie<6;ie++){Q=ce[ie].mipmaps;for(let me=0;me<Q.length;me++){let Re=Q[me];O.format!==di?Ie!==null?ft?e.compressedTexSubImage2D(34069+ie,me,0,0,Re.width,Re.height,Ie,Re.data):e.compressedTexImage2D(34069+ie,me,qe,Re.width,Re.height,0,Re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ft?e.texSubImage2D(34069+ie,me,0,0,Re.width,Re.height,Ie,Be,Re.data):e.texImage2D(34069+ie,me,qe,Re.width,Re.height,0,Ie,Be,Re.data)}}}else{Q=O.mipmaps,ft&&Ft&&(Q.length>0&&wn++,e.texStorage2D(34067,wn,qe,ce[0].width,ce[0].height));for(let ie=0;ie<6;ie++)if(Pe){ft?e.texSubImage2D(34069+ie,0,0,0,ce[ie].width,ce[ie].height,Ie,Be,ce[ie].data):e.texImage2D(34069+ie,0,qe,ce[ie].width,ce[ie].height,0,Ie,Be,ce[ie].data);for(let me=0;me<Q.length;me++){let Oe=Q[me].image[ie].image;ft?e.texSubImage2D(34069+ie,me+1,0,0,Oe.width,Oe.height,Ie,Be,Oe.data):e.texImage2D(34069+ie,me+1,qe,Oe.width,Oe.height,0,Ie,Be,Oe.data)}}else{ft?e.texSubImage2D(34069+ie,0,0,0,Ie,Be,ce[ie]):e.texImage2D(34069+ie,0,qe,Ie,Be,ce[ie]);for(let me=0;me<Q.length;me++){let Re=Q[me];ft?e.texSubImage2D(34069+ie,me+1,0,0,Ie,Be,Re.image[ie]):e.texImage2D(34069+ie,me+1,qe,Ie,Be,Re.image[ie])}}}_(O,Le)&&E(34067),Ce.__version=ve.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function G(L,O,ee,pe,ve){let Ce=s.convert(ee.format,ee.encoding),ze=s.convert(ee.type),Pe=b(ee.internalFormat,Ce,ze,ee.encoding);n.get(O).__hasExternalTextures||(ve===32879||ve===35866?e.texImage3D(ve,0,Pe,O.width,O.height,O.depth,0,Ce,ze,null):e.texImage2D(ve,0,Pe,O.width,O.height,0,Ce,ze,null)),e.bindFramebuffer(36160,L),be(O)?h.framebufferTexture2DMultisampleEXT(36160,pe,ve,n.get(ee).__webglTexture,0,Me(O)):(ve===3553||ve>=34069&&ve<=34074)&&r.framebufferTexture2D(36160,pe,ve,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function ue(L,O,ee){if(r.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let pe=33189;if(ee||be(O)){let ve=O.depthTexture;ve&&ve.isDepthTexture&&(ve.type===os?pe=36012:ve.type===Xs&&(pe=33190));let Ce=Me(O);be(O)?h.renderbufferStorageMultisampleEXT(36161,Ce,pe,O.width,O.height):r.renderbufferStorageMultisample(36161,Ce,pe,O.width,O.height)}else r.renderbufferStorage(36161,pe,O.width,O.height);r.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let pe=Me(O);ee&&be(O)===!1?r.renderbufferStorageMultisample(36161,pe,35056,O.width,O.height):be(O)?h.renderbufferStorageMultisampleEXT(36161,pe,35056,O.width,O.height):r.renderbufferStorage(36161,34041,O.width,O.height),r.framebufferRenderbuffer(36160,33306,36161,L)}else{let pe=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let ve=0;ve<pe.length;ve++){let Ce=pe[ve],ze=s.convert(Ce.format,Ce.encoding),Pe=s.convert(Ce.type),ce=b(Ce.internalFormat,ze,Pe,Ce.encoding),je=Me(O);ee&&be(O)===!1?r.renderbufferStorageMultisample(36161,je,ce,O.width,O.height):be(O)?h.renderbufferStorageMultisampleEXT(36161,je,ce,O.width,O.height):r.renderbufferStorage(36161,ce,O.width,O.height)}}r.bindRenderbuffer(36161,null)}function he(L,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,L),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),j(O.depthTexture,0);let pe=n.get(O.depthTexture).__webglTexture,ve=Me(O);if(O.depthTexture.format===Ra)be(O)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,pe,0,ve):r.framebufferTexture2D(36160,36096,3553,pe,0);else if(O.depthTexture.format===Fo)be(O)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,pe,0,ve):r.framebufferTexture2D(36160,33306,3553,pe,0);else throw new Error("Unknown depthTexture format")}function ae(L){let O=n.get(L),ee=L.isWebGLCubeRenderTarget===!0;if(L.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");he(O.__webglFramebuffer,L)}else if(ee){O.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)e.bindFramebuffer(36160,O.__webglFramebuffer[pe]),O.__webglDepthbuffer[pe]=r.createRenderbuffer(),ue(O.__webglDepthbuffer[pe],L,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=r.createRenderbuffer(),ue(O.__webglDepthbuffer,L,!1);e.bindFramebuffer(36160,null)}function ge(L,O,ee){let pe=n.get(L);O!==void 0&&G(pe.__webglFramebuffer,L,L.texture,36064,3553),ee!==void 0&&ae(L)}function Se(L){let O=L.texture,ee=n.get(L),pe=n.get(O);L.addEventListener("dispose",P),L.isWebGLMultipleRenderTargets!==!0&&(pe.__webglTexture===void 0&&(pe.__webglTexture=r.createTexture()),pe.__version=O.version,o.memory.textures++);let ve=L.isWebGLCubeRenderTarget===!0,Ce=L.isWebGLMultipleRenderTargets===!0,ze=S(L)||a;if(ve){ee.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)ee.__webglFramebuffer[Pe]=r.createFramebuffer()}else{if(ee.__webglFramebuffer=r.createFramebuffer(),Ce)if(i.drawBuffers){let Pe=L.texture;for(let ce=0,je=Pe.length;ce<je;ce++){let Le=n.get(Pe[ce]);Le.__webglTexture===void 0&&(Le.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&L.samples>0&&be(L)===!1){let Pe=Ce?O:[O];ee.__webglMultisampledFramebuffer=r.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let ce=0;ce<Pe.length;ce++){let je=Pe[ce];ee.__webglColorRenderbuffer[ce]=r.createRenderbuffer(),r.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[ce]);let Le=s.convert(je.format,je.encoding),Ie=s.convert(je.type),Be=b(je.internalFormat,Le,Ie,je.encoding,L.isXRRenderTarget===!0),qe=Me(L);r.renderbufferStorageMultisample(36161,qe,Be,L.width,L.height),r.framebufferRenderbuffer(36160,36064+ce,36161,ee.__webglColorRenderbuffer[ce])}r.bindRenderbuffer(36161,null),L.depthBuffer&&(ee.__webglDepthRenderbuffer=r.createRenderbuffer(),ue(ee.__webglDepthRenderbuffer,L,!0)),e.bindFramebuffer(36160,null)}}if(ve){e.bindTexture(34067,pe.__webglTexture),z(34067,O,ze);for(let Pe=0;Pe<6;Pe++)G(ee.__webglFramebuffer[Pe],L,O,36064,34069+Pe);_(O,ze)&&E(34067),e.unbindTexture()}else if(Ce){let Pe=L.texture;for(let ce=0,je=Pe.length;ce<je;ce++){let Le=Pe[ce],Ie=n.get(Le);e.bindTexture(3553,Ie.__webglTexture),z(3553,Le,ze),G(ee.__webglFramebuffer,L,Le,36064+ce,3553),_(Le,ze)&&E(3553)}e.unbindTexture()}else{let Pe=3553;(L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(a?Pe=L.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Pe,pe.__webglTexture),z(Pe,O,ze),G(ee.__webglFramebuffer,L,O,36064,Pe),_(O,ze)&&E(Pe),e.unbindTexture()}L.depthBuffer&&ae(L)}function ye(L){let O=S(L)||a,ee=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let pe=0,ve=ee.length;pe<ve;pe++){let Ce=ee[pe];if(_(Ce,O)){let ze=L.isWebGLCubeRenderTarget?34067:3553,Pe=n.get(Ce).__webglTexture;e.bindTexture(ze,Pe),E(ze),e.unbindTexture()}}}function Ee(L){if(a&&L.samples>0&&be(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],ee=L.width,pe=L.height,ve=16384,Ce=[],ze=L.stencilBuffer?33306:36096,Pe=n.get(L),ce=L.isWebGLMultipleRenderTargets===!0;if(ce)for(let je=0;je<O.length;je++)e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,null),e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,null,0);e.bindFramebuffer(36008,Pe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Pe.__webglFramebuffer);for(let je=0;je<O.length;je++){Ce.push(36064+je),L.depthBuffer&&Ce.push(ze);let Le=Pe.__ignoreDepthValues!==void 0?Pe.__ignoreDepthValues:!1;if(Le===!1&&(L.depthBuffer&&(ve|=256),L.stencilBuffer&&(ve|=1024)),ce&&r.framebufferRenderbuffer(36008,36064,36161,Pe.__webglColorRenderbuffer[je]),Le===!0&&(r.invalidateFramebuffer(36008,[ze]),r.invalidateFramebuffer(36009,[ze])),ce){let Ie=n.get(O[je]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,Ie,0)}r.blitFramebuffer(0,0,ee,pe,0,0,ee,pe,ve,9728),f&&r.invalidateFramebuffer(36008,Ce)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),ce)for(let je=0;je<O.length;je++){e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,Pe.__webglColorRenderbuffer[je]);let Le=n.get(O[je]).__webglTexture;e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,Le,0)}e.bindFramebuffer(36009,Pe.__webglMultisampledFramebuffer)}}function Me(L){return Math.min(d,L.samples)}function be(L){let O=n.get(L);return a&&L.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ge(L){let O=o.render.frame;g.get(L)!==O&&(g.set(L,O),L.update())}function ht(L,O){let ee=L.encoding,pe=L.format,ve=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===Jv||ee!==Jr&&(ee===Ye?a===!1?t.has("EXT_sRGB")===!0&&pe===di?(L.format=Jv,L.minFilter=it,L.generateMipmaps=!1):O=Mp.sRGBToLinear(O):(pe!==di||ve!==jt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ee)),O}this.allocateTextureUnit=W,this.resetTextureUnits=Y,this.setTexture2D=j,this.setTexture2DArray=X,this.setTexture3D=N,this.setTextureCube=k,this.rebindTextures=ge,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=ye,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=G,this.useMultisampledRTT=be}function VN(r,t,e){let n=e.isWebGL2;function i(s,o=null){let a;if(s===jt)return 5121;if(s===LD)return 32819;if(s===RD)return 32820;if(s===ID)return 5120;if(s===DD)return 5122;if(s===aA)return 5123;if(s===OD)return 5124;if(s===Xs)return 5125;if(s===os)return 5126;if(s===$d)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===ND)return 6406;if(s===di)return 6408;if(s===BD)return 6409;if(s===FD)return 6410;if(s===Ra)return 6402;if(s===Fo)return 34041;if(s===Jv)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===kD)return 6403;if(s===UD)return 36244;if(s===GD)return 33319;if(s===zD)return 33320;if(s===VD)return 36249;if(s===dv||s===hv||s===fv||s===pv)if(o===Ye)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===dv)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===hv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===fv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===pv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===dv)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===hv)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===fv)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===pv)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Ow||s===Lw||s===Rw||s===Nw)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Ow)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Lw)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Rw)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Nw)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===HD)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Bw||s===Fw)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Bw)return o===Ye?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Fw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===kw||s===Uw||s===Gw||s===zw||s===Vw||s===Hw||s===Ww||s===jw||s===qw||s===Xw||s===Yw||s===Qw||s===Kw||s===Zw)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===kw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Uw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Gw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===zw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Vw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Hw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Ww)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===jw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===qw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Xw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Yw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Qw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Kw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Zw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===mv)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===mv)return o===Ye?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===WD||s===Jw||s===$w||s===e1)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===mv)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Jw)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===$w)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===e1)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ro?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var c0=class extends fn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},as=class extends ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},HN={type:"move"},Kd=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new as,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 as,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 as,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let p of t.hand.values()){let m=e.getJointPose(p,n),y=this._getHandJoint(u,p);m!==null&&(y.matrix.fromArray(m.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=m.radius),y.visible=m!==null}let c=u.joints["index-finger-tip"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,g=.005;u.inputState.pinching&&h>f+g?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=f-g&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),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(HN)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new as;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},ko=class extends Wt{constructor(t,e,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Ra,c!==Ra&&c!==Fo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Ra&&(n=Xs),n===void 0&&c===Fo&&(n=Ro),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:kt,this.minFilter=l!==void 0?l:kt,this.flipY=!1,this.generateMipmaps=!1}},u0=class extends Gt{constructor(t,e){super();let n=this,i=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,g=null,p=e.getContextAttributes(),m=null,y=null,v=[],x=[],S=new Set,w=new Map,_=new fn;_.layers.enable(1),_.viewport=new $e;let E=new fn;E.layers.enable(2),E.viewport=new $e;let b=[_,E],T=new c0;T.layers.enable(1),T.layers.enable(2);let M=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(N){let k=v[N];return k===void 0&&(k=new Kd,v[N]=k),k.getTargetRaySpace()},this.getControllerGrip=function(N){let k=v[N];return k===void 0&&(k=new Kd,v[N]=k),k.getGripSpace()},this.getHand=function(N){let k=v[N];return k===void 0&&(k=new Kd,v[N]=k),k.getHandSpace()};function P(N){let k=x.indexOf(N.inputSource);if(k===-1)return;let V=v[k];V!==void 0&&V.dispatchEvent({type:N.type,data:N.inputSource})}function C(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",C),i.removeEventListener("inputsourceschange",D);for(let N=0;N<v.length;N++){let k=x[N];k!==null&&(x[N]=null,v[N].disconnect(k))}M=null,I=null,t.setRenderTarget(m),f=null,h=null,d=null,i=null,y=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(N){s=N,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(N){a=N,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(N){u=N},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(N){if(i=N,i!==null){if(m=t.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",C),i.addEventListener("inputsourceschange",D),p.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let k={antialias:i.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,k),i.updateRenderState({baseLayer:f}),y=new Tt(f.framebufferWidth,f.framebufferHeight,{format:di,type:jt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let k=null,V=null,H=null;p.depth&&(H=p.stencil?35056:33190,k=p.stencil?Fo:Ra,V=p.stencil?Ro:Xs);let z={colorFormat:32856,depthFormat:H,scaleFactor:s};d=new XRWebGLBinding(i,e),h=d.createProjectionLayer(z),i.updateRenderState({layers:[h]}),y=new Tt(h.textureWidth,h.textureHeight,{format:di,type:jt,depthTexture:new ko(h.textureWidth,h.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,k),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let re=t.properties.get(y);re.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await i.requestReferenceSpace(a),X.setContext(i),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function D(N){for(let k=0;k<N.removed.length;k++){let V=N.removed[k],H=x.indexOf(V);H>=0&&(x[H]=null,v[H].disconnect(V))}for(let k=0;k<N.added.length;k++){let V=N.added[k],H=x.indexOf(V);if(H===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(V),H=re;break}else if(x[re]===null){x[re]=V,H=re;break}if(H===-1)break}let z=v[H];z&&z.connect(V)}}let R=new A,U=new A;function Y(N,k,V){R.setFromMatrixPosition(k.matrixWorld),U.setFromMatrixPosition(V.matrixWorld);let H=R.distanceTo(U),z=k.projectionMatrix.elements,re=V.projectionMatrix.elements,K=z[14]/(z[10]-1),Z=z[14]/(z[10]+1),G=(z[9]+1)/z[5],ue=(z[9]-1)/z[5],he=(z[8]-1)/z[0],ae=(re[8]+1)/re[0],ge=K*he,Se=K*ae,ye=H/(-he+ae),Ee=ye*-he;k.matrixWorld.decompose(N.position,N.quaternion,N.scale),N.translateX(Ee),N.translateZ(ye),N.matrixWorld.compose(N.position,N.quaternion,N.scale),N.matrixWorldInverse.copy(N.matrixWorld).invert();let Me=K+ye,be=Z+ye,Ge=ge-Ee,ht=Se+(H-Ee),L=G*Z/be*Me,O=ue*Z/be*Me;N.projectionMatrix.makePerspective(Ge,ht,L,O,Me,be)}function W(N,k){k===null?N.matrixWorld.copy(N.matrix):N.matrixWorld.multiplyMatrices(k.matrixWorld,N.matrix),N.matrixWorldInverse.copy(N.matrixWorld).invert()}this.updateCamera=function(N){if(i===null)return;T.near=E.near=_.near=N.near,T.far=E.far=_.far=N.far,(M!==T.near||I!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),M=T.near,I=T.far);let k=N.parent,V=T.cameras;W(T,k);for(let z=0;z<V.length;z++)W(V[z],k);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),N.matrix.copy(T.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);let H=N.children;for(let z=0,re=H.length;z<re;z++)H[z].updateMatrixWorld(!0);V.length===2?Y(T,_,E):T.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(N){l=N,h!==null&&(h.fixedFoveation=N),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=N)},this.getPlanes=function(){return S};let q=null;function j(N,k){if(c=k.getViewerPose(u||o),g=k,c!==null){let V=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let H=!1;V.length!==T.cameras.length&&(T.cameras.length=0,H=!0);for(let z=0;z<V.length;z++){let re=V[z],K=null;if(f!==null)K=f.getViewport(re);else{let G=d.getViewSubImage(h,re);K=G.viewport,z===0&&(t.setRenderTargetTextures(y,G.colorTexture,h.ignoreDepthValues?void 0:G.depthStencilTexture),t.setRenderTarget(y))}let Z=b[z];Z===void 0&&(Z=new fn,Z.layers.enable(z),Z.viewport=new $e,b[z]=Z),Z.matrix.fromArray(re.transform.matrix),Z.projectionMatrix.fromArray(re.projectionMatrix),Z.viewport.set(K.x,K.y,K.width,K.height),z===0&&T.matrix.copy(Z.matrix),H===!0&&T.cameras.push(Z)}}for(let V=0;V<v.length;V++){let H=x[V],z=v[V];H!==null&&z!==void 0&&z.update(H,k,u||o)}if(q&&q(N,k),k.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:k.detectedPlanes});let V=null;for(let H of S)k.detectedPlanes.has(H)||(V===null&&(V=[]),V.push(H));if(V!==null)for(let H of V)S.delete(H),w.delete(H),n.dispatchEvent({type:"planeremoved",data:H});for(let H of k.detectedPlanes)if(!S.has(H))S.add(H),w.set(H,k.lastChangedTime),n.dispatchEvent({type:"planeadded",data:H});else{let z=w.get(H);H.lastChangedTime>z&&(w.set(H,H.lastChangedTime),n.dispatchEvent({type:"planechanged",data:H}))}}g=null}let X=new dA;X.setAnimationLoop(j),this.setAnimationLoop=function(N){q=N},this.dispose=function(){}}};function WN(r,t){function e(p,m){m.color.getRGB(p.fogColor.value,uA(r)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function n(p,m,y,v,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?i(p,m):m.isMeshToonMaterial?(i(p,m),c(p,m)):m.isMeshPhongMaterial?(i(p,m),u(p,m)):m.isMeshStandardMaterial?(i(p,m),d(p,m),m.isMeshPhysicalMaterial&&h(p,m,x)):m.isMeshMatcapMaterial?(i(p,m),f(p,m)):m.isMeshDepthMaterial?i(p,m):m.isMeshDistanceMaterial?(i(p,m),g(p,m)):m.isMeshNormalMaterial?i(p,m):m.isLineBasicMaterial?(s(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?a(p,m,y,v):m.isSpriteMaterial?l(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function i(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===Mn&&(p.bumpScale.value*=-1)),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===Mn&&p.normalScale.value.negate()),m.specularMap&&(p.specularMap.value=m.specularMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y=t.get(m).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap){p.lightMap.value=m.lightMap;let S=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=m.lightMapIntensity*S}m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity);let v;m.map?v=m.map:m.specularMap?v=m.specularMap:m.displacementMap?v=m.displacementMap:m.normalMap?v=m.normalMap:m.bumpMap?v=m.bumpMap:m.roughnessMap?v=m.roughnessMap:m.metalnessMap?v=m.metalnessMap:m.alphaMap?v=m.alphaMap:m.emissiveMap?v=m.emissiveMap:m.clearcoatMap?v=m.clearcoatMap:m.clearcoatNormalMap?v=m.clearcoatNormalMap:m.clearcoatRoughnessMap?v=m.clearcoatRoughnessMap:m.iridescenceMap?v=m.iridescenceMap:m.iridescenceThicknessMap?v=m.iridescenceThicknessMap:m.specularIntensityMap?v=m.specularIntensityMap:m.specularColorMap?v=m.specularColorMap:m.transmissionMap?v=m.transmissionMap:m.thicknessMap?v=m.thicknessMap:m.sheenColorMap?v=m.sheenColorMap:m.sheenRoughnessMap&&(v=m.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uv2Transform.value.copy(x.matrix))}function s(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function a(p,m,y,v){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*y,p.scale.value=v*.5,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y;m.map?y=m.map:m.alphaMap&&(y=m.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function c(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.roughness.value=m.roughness,p.metalness.value=m.metalness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function h(p,m,y){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),p.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===Mn&&p.clearcoatNormalScale.value.negate())),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap)}function f(p,m){m.matcap&&(p.matcap.value=m.matcap)}function g(p,m){p.referencePosition.value.copy(m.referencePosition),p.nearDistance.value=m.nearDistance,p.farDistance.value=m.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function jN(r,t,e,n){let i={},s={},o=[],a=e.isWebGL2?r.getParameter(35375):0;function l(v,x){let S=x.program;n.uniformBlockBinding(v,S)}function u(v,x){let S=i[v.id];S===void 0&&(g(v),S=c(v),i[v.id]=S,v.addEventListener("dispose",m));let w=x.program;n.updateUBOMapping(v,w);let _=t.render.frame;s[v.id]!==_&&(h(v),s[v.id]=_)}function c(v){let x=d();v.__bindingPointIndex=x;let S=r.createBuffer(),w=v.__size,_=v.usage;return r.bindBuffer(35345,S),r.bufferData(35345,w,_),r.bindBuffer(35345,null),r.bindBufferBase(35345,x,S),S}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let x=i[v.id],S=v.uniforms,w=v.__cache;r.bindBuffer(35345,x);for(let _=0,E=S.length;_<E;_++){let b=S[_];if(f(b,_,w)===!0){let T=b.__offset,M=Array.isArray(b.value)?b.value:[b.value],I=0;for(let P=0;P<M.length;P++){let C=M[P],D=p(C);typeof C=="number"?(b.__data[0]=C,r.bufferSubData(35345,T+I,b.__data)):C.isMatrix3?(b.__data[0]=C.elements[0],b.__data[1]=C.elements[1],b.__data[2]=C.elements[2],b.__data[3]=C.elements[0],b.__data[4]=C.elements[3],b.__data[5]=C.elements[4],b.__data[6]=C.elements[5],b.__data[7]=C.elements[0],b.__data[8]=C.elements[6],b.__data[9]=C.elements[7],b.__data[10]=C.elements[8],b.__data[11]=C.elements[0]):(C.toArray(b.__data,I),I+=D.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(35345,T,b.__data)}}r.bindBuffer(35345,null)}function f(v,x,S){let w=v.value;if(S[x]===void 0){if(typeof w=="number")S[x]=w;else{let _=Array.isArray(w)?w:[w],E=[];for(let b=0;b<_.length;b++)E.push(_[b].clone());S[x]=E}return!0}else if(typeof w=="number"){if(S[x]!==w)return S[x]=w,!0}else{let _=Array.isArray(S[x])?S[x]:[S[x]],E=Array.isArray(w)?w:[w];for(let b=0;b<_.length;b++){let T=_[b];if(T.equals(E[b])===!1)return T.copy(E[b]),!0}}return!1}function g(v){let x=v.uniforms,S=0,w=16,_=0;for(let E=0,b=x.length;E<b;E++){let T=x[E],M={boundary:0,storage:0},I=Array.isArray(T.value)?T.value:[T.value];for(let P=0,C=I.length;P<C;P++){let D=I[P],R=p(D);M.boundary+=R.boundary,M.storage+=R.storage}if(T.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=S,E>0){_=S%w;let P=w-_;_!==0&&P-M.boundary<0&&(S+=w-_,T.__offset=S)}S+=M.storage}return _=S%w,_>0&&(S+=w-_),v.__size=S,v.__cache={},this}function p(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function m(v){let x=v.target;x.removeEventListener("dispose",m);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)r.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:u,dispose:y}}function qN(){let r=Tp("canvas");return r.style.display="block",r}function N0(r={}){this.isWebGLRenderer=!0;let t=r.canvas!==void 0?r.canvas:qN(),e=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let d=null,h=null,f=[],g=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Jr,this.physicallyCorrectLights=!1,this.toneMapping=Qs,this.toneMappingExposure=1;let p=this,m=!1,y=0,v=0,x=null,S=-1,w=null,_=new $e,E=new $e,b=null,T=t.width,M=t.height,I=1,P=null,C=null,D=new $e(0,0,T,M),R=new $e(0,0,T,M),U=!1,Y=new rh,W=!1,q=!1,j=null,X=new de,N=new F,k=new A,V={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function H(){return x===null?I:1}let z=e;function re(B,te){for(let se=0;se<B.length;se++){let $=B[se],le=t.getContext($,te);if(le!==null)return le}return null}try{let B={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${$s}`),t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",qe,!1),t.addEventListener("webglcontextcreationerror",ft,!1),z===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),z=re(te,B),z===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let K,Z,G,ue,he,ae,ge,Se,ye,Ee,Me,be,Ge,ht,L,O,ee,pe,ve,Ce,ze,Pe,ce,je;function Le(){K=new f3(z),Z=new a3(z,K,r),K.init(Z),Pe=new VN(z,K,Z),G=new GN(z,K,Z),ue=new g3,he=new CN,ae=new zN(z,K,G,he,Z,Pe,ue),ge=new c3(p),Se=new h3(p),ye=new EO(z,Z),ce=new s3(z,K,ye,Z),Ee=new p3(z,ye,ue,ce),Me=new b3(z,Ee,ye,ue),ve=new x3(z,Z,ae),O=new l3(he),be=new MN(p,ge,Se,K,Z,ce,O),Ge=new WN(p,he),ht=new IN,L=new BN(K,Z),pe=new i3(p,ge,Se,G,Me,c,o),ee=new UN(p,Me,Z),je=new jN(z,ue,Z,G),Ce=new o3(z,K,ue,Z),ze=new m3(z,K,ue,Z),ue.programs=be.programs,p.capabilities=Z,p.extensions=K,p.properties=he,p.renderLists=ht,p.shadowMap=ee,p.state=G,p.info=ue}Le();let Ie=new u0(p,z);this.xr=Ie,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let B=K.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=K.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(B){B!==void 0&&(I=B,this.setSize(T,M,!1))},this.getSize=function(B){return B.set(T,M)},this.setSize=function(B,te,se){if(Ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=B,M=te,t.width=Math.floor(B*I),t.height=Math.floor(te*I),se!==!1&&(t.style.width=B+"px",t.style.height=te+"px"),this.setViewport(0,0,B,te)},this.getDrawingBufferSize=function(B){return B.set(T*I,M*I).floor()},this.setDrawingBufferSize=function(B,te,se){T=B,M=te,I=se,t.width=Math.floor(B*se),t.height=Math.floor(te*se),this.setViewport(0,0,B,te)},this.getCurrentViewport=function(B){return B.copy(_)},this.getViewport=function(B){return B.copy(D)},this.setViewport=function(B,te,se,$){B.isVector4?D.set(B.x,B.y,B.z,B.w):D.set(B,te,se,$),G.viewport(_.copy(D).multiplyScalar(I).floor())},this.getScissor=function(B){return B.copy(R)},this.setScissor=function(B,te,se,$){B.isVector4?R.set(B.x,B.y,B.z,B.w):R.set(B,te,se,$),G.scissor(E.copy(R).multiplyScalar(I).floor())},this.getScissorTest=function(){return U},this.setScissorTest=function(B){G.setScissorTest(U=B)},this.setOpaqueSort=function(B){P=B},this.setTransparentSort=function(B){C=B},this.getClearColor=function(B){return B.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(B=!0,te=!0,se=!0){let $=0;B&&($|=16384),te&&($|=256),se&&($|=1024),z.clear($)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",qe,!1),t.removeEventListener("webglcontextcreationerror",ft,!1),ht.dispose(),L.dispose(),he.dispose(),ge.dispose(),Se.dispose(),Me.dispose(),ce.dispose(),je.dispose(),be.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",Re),Ie.removeEventListener("sessionend",Oe),j&&(j.dispose(),j=null),pt.stop()};function Be(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function qe(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let B=ue.autoReset,te=ee.enabled,se=ee.autoUpdate,$=ee.needsUpdate,le=ee.type;Le(),ue.autoReset=B,ee.enabled=te,ee.autoUpdate=se,ee.needsUpdate=$,ee.type=le}function ft(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function Ft(B){let te=B.target;te.removeEventListener("dispose",Ft),wn(te)}function wn(B){Q(B),he.remove(B)}function Q(B){let te=he.get(B).programs;te!==void 0&&(te.forEach(function(se){be.releaseProgram(se)}),B.isShaderMaterial&&be.releaseShaderCache(B))}this.renderBufferDirect=function(B,te,se,$,le,Je){te===null&&(te=V);let rt=le.isMesh&&le.matrixWorld.determinant()<0,ot=jI(B,te,se,$,le);G.setMaterial($,rt);let lt=se.index,Et=1;$.wireframe===!0&&(lt=Ee.getWireframeAttribute(se),Et=2);let mt=se.drawRange,gt=se.attributes.position,_n=mt.start*Et,Xr=(mt.start+mt.count)*Et;Je!==null&&(_n=Math.max(_n,Je.start*Et),Xr=Math.min(Xr,(Je.start+Je.count)*Et)),lt!==null?(_n=Math.max(_n,0),Xr=Math.min(Xr,lt.count)):gt!=null&&(_n=Math.max(_n,0),Xr=Math.min(Xr,gt.count));let Us=Xr-_n;if(Us<0||Us===1/0)return;ce.setup(le,$,ot,se,lt);let Ta,En=Ce;if(lt!==null&&(Ta=ye.get(lt),En=ze,En.setIndex(Ta)),le.isMesh)$.wireframe===!0?(G.setLineWidth($.wireframeLinewidth*H()),En.setMode(1)):En.setMode(4);else if(le.isLine){let yt=$.linewidth;yt===void 0&&(yt=1),G.setLineWidth(yt*H()),le.isLineSegments?En.setMode(1):le.isLineLoop?En.setMode(2):En.setMode(3)}else le.isPoints?En.setMode(0):le.isSprite&&En.setMode(4);if(le.isInstancedMesh)En.renderInstances(_n,Us,le.count);else if(se.isInstancedBufferGeometry){let yt=se._maxInstanceCount!==void 0?se._maxInstanceCount:1/0,ov=Math.min(se.instanceCount,yt);En.renderInstances(_n,Us,ov)}else En.render(_n,Us)},this.compile=function(B,te){function se($,le,Je){$.transparent===!0&&$.side===wr&&$.forceSinglePass===!1?($.side=Mn,$.needsUpdate=!0,ci($,le,Je),$.side=Zr,$.needsUpdate=!0,ci($,le,Je),$.side=wr):ci($,le,Je)}h=L.get(B),h.init(),g.push(h),B.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),B.traverse(function($){let le=$.material;if(le)if(Array.isArray(le))for(let Je=0;Je<le.length;Je++){let rt=le[Je];se(rt,B,$)}else se(le,B,$)}),g.pop(),h=null};let ie=null;function me(B){ie&&ie(B)}function Re(){pt.stop()}function Oe(){pt.start()}let pt=new dA;pt.setAnimationLoop(me),typeof self<"u"&&pt.setContext(self),this.setAnimationLoop=function(B){ie=B,Ie.setAnimationLoop(B),B===null?pt.stop():pt.start()},Ie.addEventListener("sessionstart",Re),Ie.addEventListener("sessionend",Oe),this.render=function(B,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(te),te=Ie.getCamera()),B.isScene===!0&&B.onBeforeRender(p,B,te,x),h=L.get(B,g.length),h.init(),g.push(h),X.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),Y.setFromProjectionMatrix(X),q=this.localClippingEnabled,W=O.init(this.clippingPlanes,q),d=ht.get(B,f.length),d.init(),f.push(d),An(B,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(P,C),W===!0&&O.beginShadows();let se=h.state.shadowsArray;if(ee.render(se,B,te),W===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),pe.render(d,B),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let le=0,Je=$.length;le<Je;le++){let rt=$[le];dn(d,B,rt,rt.viewport)}}else dn(d,B,te);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(p,B,te),ce.resetDefaultState(),S=-1,w=null,g.pop(),g.length>0?h=g[g.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function An(B,te,se,$){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)se=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)h.pushLight(B),B.castShadow&&h.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||Y.intersectsSprite(B)){$&&k.setFromMatrixPosition(B.matrixWorld).applyMatrix4(X);let rt=Me.update(B),ot=B.material;ot.visible&&d.push(B,rt,ot,se,k.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==ue.render.frame&&(B.skeleton.update(),B.skeleton.frame=ue.render.frame),!B.frustumCulled||Y.intersectsObject(B))){$&&k.setFromMatrixPosition(B.matrixWorld).applyMatrix4(X);let rt=Me.update(B),ot=B.material;if(Array.isArray(ot)){let lt=rt.groups;for(let Et=0,mt=lt.length;Et<mt;Et++){let gt=lt[Et],_n=ot[gt.materialIndex];_n&&_n.visible&&d.push(B,rt,_n,se,k.z,gt)}}else ot.visible&&d.push(B,rt,ot,se,k.z,null)}}let Je=B.children;for(let rt=0,ot=Je.length;rt<ot;rt++)An(Je[rt],te,se,$)}function dn(B,te,se,$){let le=B.opaque,Je=B.transmissive,rt=B.transparent;h.setupLightsView(se),W===!0&&O.setGlobalState(p.clippingPlanes,se),Je.length>0&&Ea(le,te,se),$&&G.viewport(_.copy($)),le.length>0&&Xt(le,te,se),Je.length>0&&Xt(Je,te,se),rt.length>0&&Xt(rt,te,se),G.buffers.depth.setTest(!0),G.buffers.depth.setMask(!0),G.buffers.color.setMask(!0),G.setPolygonOffset(!1)}function Ea(B,te,se){let $=Z.isWebGL2;j===null&&(j=new Tt(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?$d:jt,minFilter:Ba,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(N),$?j.setSize(N.x,N.y):j.setSize(Ep(N.x),Ep(N.y));let le=p.getRenderTarget();p.setRenderTarget(j),p.clear();let Je=p.toneMapping;p.toneMapping=Qs,Xt(B,te,se),p.toneMapping=Je,ae.updateMultisampleRenderTarget(j),ae.updateRenderTargetMipmap(j),p.setRenderTarget(le)}function Xt(B,te,se){let $=te.isScene===!0?te.overrideMaterial:null;for(let le=0,Je=B.length;le<Je;le++){let rt=B[le],ot=rt.object,lt=rt.geometry,Et=$===null?rt.material:$,mt=rt.group;ot.layers.test(se.layers)&&ks(ot,te,se,lt,Et,mt)}}function ks(B,te,se,$,le,Je){B.onBeforeRender(p,te,se,$,le,Je),B.modelViewMatrix.multiplyMatrices(se.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),le.onBeforeRender(p,te,se,$,B,Je),le.transparent===!0&&le.side===wr&&le.forceSinglePass===!1?(le.side=Mn,le.needsUpdate=!0,p.renderBufferDirect(se,te,$,le,B,Je),le.side=Zr,le.needsUpdate=!0,p.renderBufferDirect(se,te,$,le,B,Je),le.side=wr):p.renderBufferDirect(se,te,$,le,B,Je),B.onAfterRender(p,te,se,$,le,Je)}function ci(B,te,se){te.isScene!==!0&&(te=V);let $=he.get(B),le=h.state.lights,Je=h.state.shadowsArray,rt=le.state.version,ot=be.getParameters(B,le.state,Je,te,se),lt=be.getProgramCacheKey(ot),Et=$.programs;$.environment=B.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(B.isMeshStandardMaterial?Se:ge).get(B.envMap||$.environment),Et===void 0&&(B.addEventListener("dispose",Ft),Et=new Map,$.programs=Et);let mt=Et.get(lt);if(mt!==void 0){if($.currentProgram===mt&&$.lightsStateVersion===rt)return bw(B,ot),mt}else ot.uniforms=be.getUniforms(B),B.onBuild(se,ot,p),B.onBeforeCompile(ot,p),mt=be.acquireProgram(ot,lt),Et.set(lt,mt),$.uniforms=ot.uniforms;let gt=$.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(gt.clippingPlanes=O.uniform),bw(B,ot),$.needsLights=XI(B),$.lightsStateVersion=rt,$.needsLights&&(gt.ambientLightColor.value=le.state.ambient,gt.lightProbe.value=le.state.probe,gt.directionalLights.value=le.state.directional,gt.directionalLightShadows.value=le.state.directionalShadow,gt.spotLights.value=le.state.spot,gt.spotLightShadows.value=le.state.spotShadow,gt.rectAreaLights.value=le.state.rectArea,gt.ltc_1.value=le.state.rectAreaLTC1,gt.ltc_2.value=le.state.rectAreaLTC2,gt.pointLights.value=le.state.point,gt.pointLightShadows.value=le.state.pointShadow,gt.hemisphereLights.value=le.state.hemi,gt.directionalShadowMap.value=le.state.directionalShadowMap,gt.directionalShadowMatrix.value=le.state.directionalShadowMatrix,gt.spotShadowMap.value=le.state.spotShadowMap,gt.spotLightMatrix.value=le.state.spotLightMatrix,gt.spotLightMap.value=le.state.spotLightMap,gt.pointShadowMap.value=le.state.pointShadowMap,gt.pointShadowMatrix.value=le.state.pointShadowMatrix);let _n=mt.getUniforms(),Xr=Yl.seqWithValue(_n.seq,gt);return $.currentProgram=mt,$.uniformsList=Xr,mt}function bw(B,te){let se=he.get(B);se.outputEncoding=te.outputEncoding,se.instancing=te.instancing,se.skinning=te.skinning,se.morphTargets=te.morphTargets,se.morphNormals=te.morphNormals,se.morphColors=te.morphColors,se.morphTargetsCount=te.morphTargetsCount,se.numClippingPlanes=te.numClippingPlanes,se.numIntersection=te.numClipIntersection,se.vertexAlphas=te.vertexAlphas,se.vertexTangents=te.vertexTangents,se.toneMapping=te.toneMapping}function jI(B,te,se,$,le){te.isScene!==!0&&(te=V),ae.resetTextureUnits();let Je=te.fog,rt=$.isMeshStandardMaterial?te.environment:null,ot=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Jr,lt=($.isMeshStandardMaterial?Se:ge).get($.envMap||rt),Et=$.vertexColors===!0&&!!se.attributes.color&&se.attributes.color.itemSize===4,mt=!!$.normalMap&&!!se.attributes.tangent,gt=!!se.morphAttributes.position,_n=!!se.morphAttributes.normal,Xr=!!se.morphAttributes.color,Us=$.toneMapped?p.toneMapping:Qs,Ta=se.morphAttributes.position||se.morphAttributes.normal||se.morphAttributes.color,En=Ta!==void 0?Ta.length:0,yt=he.get($),ov=h.state.lights;if(W===!0&&(q===!0||B!==w)){let Yr=B===w&&$.id===S;O.setState($,B,Yr)}let jn=!1;$.version===yt.__version?(yt.needsLights&&yt.lightsStateVersion!==ov.state.version||yt.outputEncoding!==ot||le.isInstancedMesh&&yt.instancing===!1||!le.isInstancedMesh&&yt.instancing===!0||le.isSkinnedMesh&&yt.skinning===!1||!le.isSkinnedMesh&&yt.skinning===!0||yt.envMap!==lt||$.fog===!0&&yt.fog!==Je||yt.numClippingPlanes!==void 0&&(yt.numClippingPlanes!==O.numPlanes||yt.numIntersection!==O.numIntersection)||yt.vertexAlphas!==Et||yt.vertexTangents!==mt||yt.morphTargets!==gt||yt.morphNormals!==_n||yt.morphColors!==Xr||yt.toneMapping!==Us||Z.isWebGL2===!0&&yt.morphTargetsCount!==En)&&(jn=!0):(jn=!0,yt.__version=$.version);let Ma=yt.currentProgram;jn===!0&&(Ma=ci($,te,le));let Sw=!1,Fd=!1,av=!1,yr=Ma.getUniforms(),Ca=yt.uniforms;if(G.useProgram(Ma.program)&&(Sw=!0,Fd=!0,av=!0),$.id!==S&&(S=$.id,Fd=!0),Sw||w!==B){if(yr.setValue(z,"projectionMatrix",B.projectionMatrix),Z.logarithmicDepthBuffer&&yr.setValue(z,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),w!==B&&(w=B,Fd=!0,av=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let Yr=yr.map.cameraPosition;Yr!==void 0&&Yr.setValue(z,k.setFromMatrixPosition(B.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&yr.setValue(z,"isOrthographic",B.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||le.isSkinnedMesh)&&yr.setValue(z,"viewMatrix",B.matrixWorldInverse)}if(le.isSkinnedMesh){yr.setOptional(z,le,"bindMatrix"),yr.setOptional(z,le,"bindMatrixInverse");let Yr=le.skeleton;Yr&&(Z.floatVertexTextures?(Yr.boneTexture===null&&Yr.computeBoneTexture(),yr.setValue(z,"boneTexture",Yr.boneTexture,ae),yr.setValue(z,"boneTextureSize",Yr.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 lv=se.morphAttributes;if((lv.position!==void 0||lv.normal!==void 0||lv.color!==void 0&&Z.isWebGL2===!0)&&ve.update(le,se,$,Ma),(Fd||yt.receiveShadow!==le.receiveShadow)&&(yt.receiveShadow=le.receiveShadow,yr.setValue(z,"receiveShadow",le.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(Ca.envMap.value=lt,Ca.flipEnvMap.value=lt.isCubeTexture&&lt.isRenderTargetTexture===!1?-1:1),Fd&&(yr.setValue(z,"toneMappingExposure",p.toneMappingExposure),yt.needsLights&&qI(Ca,av),Je&&$.fog===!0&&Ge.refreshFogUniforms(Ca,Je),Ge.refreshMaterialUniforms(Ca,$,I,M,j),Yl.upload(z,yt.uniformsList,Ca,ae)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Yl.upload(z,yt.uniformsList,Ca,ae),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&yr.setValue(z,"center",le.center),yr.setValue(z,"modelViewMatrix",le.modelViewMatrix),yr.setValue(z,"normalMatrix",le.normalMatrix),yr.setValue(z,"modelMatrix",le.matrixWorld),$.isShaderMaterial||$.isRawShaderMaterial){let Yr=$.uniformsGroups;for(let cv=0,YI=Yr.length;cv<YI;cv++)if(Z.isWebGL2){let ww=Yr[cv];je.update(ww,Ma),je.bind(ww,Ma)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ma}function qI(B,te){B.ambientLightColor.needsUpdate=te,B.lightProbe.needsUpdate=te,B.directionalLights.needsUpdate=te,B.directionalLightShadows.needsUpdate=te,B.pointLights.needsUpdate=te,B.pointLightShadows.needsUpdate=te,B.spotLights.needsUpdate=te,B.spotLightShadows.needsUpdate=te,B.rectAreaLights.needsUpdate=te,B.hemisphereLights.needsUpdate=te}function XI(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,te,se){he.get(B.texture).__webglTexture=te,he.get(B.depthTexture).__webglTexture=se;let $=he.get(B);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=se===void 0,$.__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"),$.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(B,te){let se=he.get(B);se.__webglFramebuffer=te,se.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(B,te=0,se=0){x=B,y=te,v=se;let $=!0,le=null,Je=!1,rt=!1;if(B){let lt=he.get(B);lt.__useDefaultFramebuffer!==void 0?(G.bindFramebuffer(36160,null),$=!1):lt.__webglFramebuffer===void 0?ae.setupRenderTarget(B):lt.__hasExternalTextures&&ae.rebindTextures(B,he.get(B.texture).__webglTexture,he.get(B.depthTexture).__webglTexture);let Et=B.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(rt=!0);let mt=he.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(le=mt[te],Je=!0):Z.isWebGL2&&B.samples>0&&ae.useMultisampledRTT(B)===!1?le=he.get(B).__webglMultisampledFramebuffer:le=mt,_.copy(B.viewport),E.copy(B.scissor),b=B.scissorTest}else _.copy(D).multiplyScalar(I).floor(),E.copy(R).multiplyScalar(I).floor(),b=U;if(G.bindFramebuffer(36160,le)&&Z.drawBuffers&&$&&G.drawBuffers(B,le),G.viewport(_),G.scissor(E),G.setScissorTest(b),Je){let lt=he.get(B.texture);z.framebufferTexture2D(36160,36064,34069+te,lt.__webglTexture,se)}else if(rt){let lt=he.get(B.texture),Et=te||0;z.framebufferTextureLayer(36160,36064,lt.__webglTexture,se||0,Et)}S=-1},this.readRenderTargetPixels=function(B,te,se,$,le,Je,rt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=he.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&rt!==void 0&&(ot=ot[rt]),ot){G.bindFramebuffer(36160,ot);try{let lt=B.texture,Et=lt.format,mt=lt.type;if(Et!==di&&Pe.convert(Et)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=mt===$d&&(K.has("EXT_color_buffer_half_float")||Z.isWebGL2&&K.has("EXT_color_buffer_float"));if(mt!==jt&&Pe.convert(mt)!==z.getParameter(35738)&&!(mt===os&&(Z.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}te>=0&&te<=B.width-$&&se>=0&&se<=B.height-le&&z.readPixels(te,se,$,le,Pe.convert(Et),Pe.convert(mt),Je)}finally{let lt=x!==null?he.get(x).__webglFramebuffer:null;G.bindFramebuffer(36160,lt)}}},this.copyFramebufferToTexture=function(B,te,se=0){let $=Math.pow(2,-se),le=Math.floor(te.image.width*$),Je=Math.floor(te.image.height*$);ae.setTexture2D(te,0),z.copyTexSubImage2D(3553,se,0,0,B.x,B.y,le,Je),G.unbindTexture()},this.copyTextureToTexture=function(B,te,se,$=0){let le=te.image.width,Je=te.image.height,rt=Pe.convert(se.format),ot=Pe.convert(se.type);ae.setTexture2D(se,0),z.pixelStorei(37440,se.flipY),z.pixelStorei(37441,se.premultiplyAlpha),z.pixelStorei(3317,se.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,$,B.x,B.y,le,Je,rt,ot,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,$,B.x,B.y,te.mipmaps[0].width,te.mipmaps[0].height,rt,te.mipmaps[0].data):z.texSubImage2D(3553,$,B.x,B.y,rt,ot,te.image),$===0&&se.generateMipmaps&&z.generateMipmap(3553),G.unbindTexture()},this.copyTextureToTexture3D=function(B,te,se,$,le=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Je=B.max.x-B.min.x+1,rt=B.max.y-B.min.y+1,ot=B.max.z-B.min.z+1,lt=Pe.convert($.format),Et=Pe.convert($.type),mt;if($.isData3DTexture)ae.setTexture3D($,0),mt=32879;else if($.isDataArrayTexture)ae.setTexture2DArray($,0),mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,$.flipY),z.pixelStorei(37441,$.premultiplyAlpha),z.pixelStorei(3317,$.unpackAlignment);let gt=z.getParameter(3314),_n=z.getParameter(32878),Xr=z.getParameter(3316),Us=z.getParameter(3315),Ta=z.getParameter(32877),En=se.isCompressedTexture?se.mipmaps[0]:se.image;z.pixelStorei(3314,En.width),z.pixelStorei(32878,En.height),z.pixelStorei(3316,B.min.x),z.pixelStorei(3315,B.min.y),z.pixelStorei(32877,B.min.z),se.isDataTexture||se.isData3DTexture?z.texSubImage3D(mt,le,te.x,te.y,te.z,Je,rt,ot,lt,Et,En.data):se.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(mt,le,te.x,te.y,te.z,Je,rt,ot,lt,En.data)):z.texSubImage3D(mt,le,te.x,te.y,te.z,Je,rt,ot,lt,Et,En),z.pixelStorei(3314,gt),z.pixelStorei(32878,_n),z.pixelStorei(3316,Xr),z.pixelStorei(3315,Us),z.pixelStorei(32877,Ta),le===0&&$.generateMipmaps&&z.generateMipmap(mt),G.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?ae.setTextureCube(B,0):B.isData3DTexture?ae.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?ae.setTexture2DArray(B,0):ae.setTexture2D(B,0),G.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,G.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var d0=class extends N0{};d0.prototype.isWebGL1Renderer=!0;var Jl=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ne(t),this.near=e,this.far=n}clone(){return new Jl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Ar=class extends ct{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},Lp=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Zv,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ls()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ls()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ls()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},xr=new A,Ua=class{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)xr.fromBufferAttribute(this,e),xr.applyMatrix4(t),this.setXYZ(e,xr.x,xr.y,xr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)xr.fromBufferAttribute(this,e),xr.applyNormalMatrix(t),this.setXYZ(e,xr.x,xr.y,xr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)xr.fromBufferAttribute(this,e),xr.transformDirection(t),this.setXYZ(e,xr.x,xr.y,xr.z);return this}setX(t,e){return this.normalized&&(e=Nt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Nt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Nt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Nt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ys(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ys(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ys(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ys(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Nt(e,this.array),n=Nt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Nt(e,this.array),n=Nt(n,this.array),i=Nt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Nt(e,this.array),n=Nt(n,this.array),i=Nt(i,this.array),s=Nt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Fe(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ua(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var Rp=class extends Fe{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var hi=class extends Fa{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ne(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},F1=new A,k1=new A,U1=new de,zv=new Ii,pp=new Cn,Ga=class extends ct{constructor(t=new Te,e=new hi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let i=1,s=e.count;i<s;i++)F1.fromBufferAttribute(e,i-1),k1.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=F1.distanceTo(k1);t.setAttribute("lineDistance",new we(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),pp.copy(n.boundingSphere),pp.applyMatrix4(i),pp.radius+=s,t.ray.intersectsSphere(pp)===!1)return;U1.copy(i).invert(),zv.copy(t.ray).applyMatrix4(U1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,f=this.isLineSegments?2:1,g=n.index,m=n.attributes.position;if(g!==null){let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){let w=g.getX(x),_=g.getX(x+1);if(u.fromBufferAttribute(m,w),c.fromBufferAttribute(m,_),zv.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(h);b<t.near||b>t.far||e.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){if(u.fromBufferAttribute(m,x),c.fromBufferAttribute(m,x+1),zv.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let _=t.ray.origin.distanceTo(h);_<t.near||_>t.far||e.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[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}}}}},G1=new A,z1=new A,Uo=class extends Ga{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,s=e.count;i<s;i+=2)G1.fromBufferAttribute(e,i),z1.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+G1.distanceTo(z1);t.setAttribute("lineDistance",new we(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Np=class extends Wt{constructor(t,e,n,i,s,o,a,l,u){super(t,e,n,i,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:it,this.magFilter=s!==void 0?s:it,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var fi=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],h=n[i+1]-c,f=(o-c)/h;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new F:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,i=[],s=[],o=[],a=new A,l=new de;for(let f=0;f<=t;f++){let g=f/t;i[f]=this.getTangentAt(g,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),d=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(Ln(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,g))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(Ln(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let g=1;g<=t;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),o[g].crossVectors(i[g],s[g])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},za=class extends fi{constructor(t=0,e=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new F,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+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},h0=class extends za{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function B0(){let r=0,t=0,e=0,n=0;function i(s,o,a,l){r=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,i(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return r+t*s+e*o+n*a}}}var mp=new A,Vv=new B0,Hv=new B0,Wv=new B0,f0=class extends fi{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new A){let n=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=i[(a-1)%s]:(mp.subVectors(i[0],i[1]).add(i[0]),u=mp);let d=i[a%s],h=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(mp.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=mp),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,g=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(c),f);p<1e-4&&(p=1),g<1e-4&&(g=p),m<1e-4&&(m=p),Vv.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,g,p,m),Hv.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,g,p,m),Wv.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,g,p,m)}else this.curveType==="catmullrom"&&(Vv.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),Hv.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),Wv.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(Vv.calc(l),Hv.calc(l),Wv.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new A().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function V1(r,t,e,n,i){let s=(n-t)*.5,o=(i-e)*.5,a=r*r,l=r*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*r+e}function XN(r,t){let e=1-r;return e*e*t}function YN(r,t){return 2*(1-r)*r*t}function QN(r,t){return r*r*t}function Zd(r,t,e,n){return XN(r,t)+YN(r,e)+QN(r,n)}function KN(r,t){let e=1-r;return e*e*e*t}function ZN(r,t){let e=1-r;return 3*e*e*r*t}function JN(r,t){return 3*(1-r)*r*r*t}function $N(r,t){return r*r*r*t}function Jd(r,t,e,n,i){return KN(r,t)+ZN(r,e)+JN(r,n)+$N(r,i)}var fr=class extends fi{constructor(t=new F,e=new F,n=new F,i=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Jd(t,i.x,s.x,o.x,a.x),Jd(t,i.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Va=class extends fi{constructor(t=new A,e=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Jd(t,i.x,s.x,o.x,a.x),Jd(t,i.y,s.y,o.y,a.y),Jd(t,i.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},pr=class extends fi{constructor(t=new F,e=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new F){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new F;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},sh=class extends fi{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},$r=class extends fi{constructor(t=new F,e=new F,n=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(Zd(t,i.x,s.x,o.x),Zd(t,i.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},p0=class extends fi{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(Zd(t,i.x,s.x,o.x),Zd(t,i.y,s.y,o.y),Zd(t,i.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},$l=class extends fi{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new F){let n=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],d=i[o>i.length-3?i.length-1:o+2];return n.set(V1(a,l.x,u.x,c.x,d.x),V1(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new F().fromArray(i))}return this}},eB=Object.freeze({__proto__:null,ArcCurve:h0,CatmullRomCurve3:f0,CubicBezierCurve:fr,CubicBezierCurve3:Va,EllipseCurve:za,LineCurve:pr,LineCurve3:sh,QuadraticBezierCurve:$r,QuadraticBezierCurve3:p0,SplineCurve:$l}),oh=class extends fi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new pr(e,t))}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(e.push(c),n=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(new eB[i.type]().fromJSON(i))}return this}},Ha=class extends oh{constructor(t){super(),this.type="Path",this.currentPoint=new F,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new pr(this.currentPoint.clone(),new F(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let s=new $r(this.currentPoint.clone(),new F(t,e),new F(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,o){let a=new fr(this.currentPoint.clone(),new F(t,e),new F(n,i),new F(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new $l(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,i,s,o),this}absarc(t,e,n,i,s,o){return this.absellipse(t,e,n,n,i,s,o),this}ellipse(t,e,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,i,s,o,a,l),this}absellipse(t,e,n,i,s,o,a,l){let u=new za(t,e,n,i,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},ec=class extends Te{constructor(t=[new F(0,-.5),new F(.5,0),new F(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=Ln(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new F,f=new A,g=new A,p=new A,m=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:m=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-m,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:m=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-m,f.z=y*0,g.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(g)}for(let v=0;v<=e;v++){let x=n+v*c*i,S=Math.sin(x),w=Math.cos(x);for(let _=0;_<=t.length-1;_++){d.x=t[_].x*S,d.y=t[_].y,d.z=t[_].x*w,o.push(d.x,d.y,d.z),h.x=v/e,h.y=_/(t.length-1),a.push(h.x,h.y);let E=l[3*_+0]*S,b=l[3*_+1],T=l[3*_+0]*w;u.push(E,b,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let S=x+v*t.length,w=S,_=S+t.length,E=S+t.length+1,b=S+1;s.push(w,_,b),s.push(E,b,_)}this.setIndex(s),this.setAttribute("position",new we(o,3)),this.setAttribute("uv",new we(a,2)),this.setAttribute("normal",new we(u,3))}static fromJSON(t){return new ec(t.points,t.segments,t.phiStart,t.phiLength)}};var Wa=class extends Te{constructor(t=1,e=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],d=[],h=[],f=[],g=0,p=[],m=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new we(d,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(f,2));function v(){let S=new A,w=new A,_=0,E=(e-t)/n;for(let b=0;b<=s;b++){let T=[],M=b/s,I=M*(e-t)+t;for(let P=0;P<=i;P++){let C=P/i,D=C*l+a,R=Math.sin(D),U=Math.cos(D);w.x=I*R,w.y=-M*n+m,w.z=I*U,d.push(w.x,w.y,w.z),S.set(R,E,U).normalize(),h.push(S.x,S.y,S.z),f.push(C,1-M),T.push(g++)}p.push(T)}for(let b=0;b<i;b++)for(let T=0;T<s;T++){let M=p[T][b],I=p[T+1][b],P=p[T+1][b+1],C=p[T][b+1];c.push(M,I,C),c.push(I,P,C),_+=6}u.addGroup(y,_,0),y+=_}function x(S){let w=g,_=new F,E=new A,b=0,T=S===!0?t:e,M=S===!0?1:-1;for(let P=1;P<=i;P++)d.push(0,m*M,0),h.push(0,M,0),f.push(.5,.5),g++;let I=g;for(let P=0;P<=i;P++){let D=P/i*l+a,R=Math.cos(D),U=Math.sin(D);E.x=T*U,E.y=m*M,E.z=T*R,d.push(E.x,E.y,E.z),h.push(0,M,0),_.x=R*.5+.5,_.y=U*.5*M+.5,f.push(_.x,_.y),g++}for(let P=0;P<i;P++){let C=w+P,D=I+P;S===!0?c.push(D,D+1,C):c.push(D+1,D,C),b+=3}u.addGroup(y,b,S===!0?1:2),y+=b}}static fromJSON(t){return new Wa(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},tc=class extends Wa{constructor(t=1,e=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new tc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},nc=class extends Te{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new we(s,3)),this.setAttribute("normal",new we(s.slice(),3)),this.setAttribute("uv",new we(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,S=new A,w=new A;for(let _=0;_<e.length;_+=3)f(e[_+0],x),f(e[_+1],S),f(e[_+2],w),l(x,S,w,v)}function l(v,x,S,w){let _=w+1,E=[];for(let b=0;b<=_;b++){E[b]=[];let T=v.clone().lerp(S,b/_),M=x.clone().lerp(S,b/_),I=_-b;for(let P=0;P<=I;P++)P===0&&b===_?E[b][P]=T:E[b][P]=T.clone().lerp(M,P/I)}for(let b=0;b<_;b++)for(let T=0;T<2*(_-b)-1;T++){let M=Math.floor(T/2);T%2===0?(h(E[b][M+1]),h(E[b+1][M]),h(E[b][M])):(h(E[b][M+1]),h(E[b+1][M+1]),h(E[b+1][M]))}}function u(v){let x=new A;for(let S=0;S<s.length;S+=3)x.x=s[S+0],x.y=s[S+1],x.z=s[S+2],x.normalize().multiplyScalar(v),s[S+0]=x.x,s[S+1]=x.y,s[S+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let S=m(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(S,1-w)}g(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],S=o[v+2],w=o[v+4],_=Math.max(x,S,w),E=Math.min(x,S,w);_>.9&&E<.1&&(x<.2&&(o[v+0]+=1),S<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let S=v*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function g(){let v=new A,x=new A,S=new A,w=new A,_=new F,E=new F,b=new F;for(let T=0,M=0;T<s.length;T+=9,M+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),S.set(s[T+6],s[T+7],s[T+8]),_.set(o[M+0],o[M+1]),E.set(o[M+2],o[M+3]),b.set(o[M+4],o[M+5]),w.copy(v).add(x).add(S).divideScalar(3);let I=m(w);p(_,M+0,v,I),p(E,M+2,x,I),p(b,M+4,S,I)}}function p(v,x,S,w){w<0&&v.x===1&&(o[x]=v.x-1),S.x===0&&S.z===0&&(o[x]=w/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new nc(t.vertices,t.indices,t.radius,t.details)}},rc=class extends nc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,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,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new rc(t.radius,t.detail)}};var Js=class extends Ha{constructor(t){super(t),this.uuid=ls(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(new Ha().fromJSON(i))}return this}},tB={triangulate:function(r,t,e=2){let n=t&&t.length,i=n?t[0]*e:r.length,s=gA(r,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=oB(r,t,s,e)),r.length>80*e){a=u=r[0],l=c=r[1];for(let g=e;g<i;g+=e)d=r[g],h=r[g+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return ah(s,o,e,a,l,f,0),o}};function gA(r,t,e,n,i){let s,o;if(i===yB(r,t,e,n)>0)for(s=t;s<e;s+=n)o=H1(s,r[s],r[s+1],o);else for(s=e-n;s>=t;s-=n)o=H1(s,r[s],r[s+1],o);return o&&Yp(o,o.next)&&(ch(o),o=o.next),o}function ja(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Yp(e,e.next)||tn(e.prev,e,e.next)===0)){if(ch(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function ah(r,t,e,n,i,s,o){if(!r)return;!o&&s&&dB(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?rB(r,n,i,s):nB(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),ch(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=iB(ja(r),t,e),ah(r,t,e,n,i,s,2)):o===2&&sB(r,t,e,n,i,s):ah(ja(r),t,e,n,i,s,1);break}}}function nB(r){let t=r.prev,e=r,n=r.next;if(tn(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=i<s?i<o?i:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=i>s?i>o?i:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,g=n.next;for(;g!==t;){if(g.x>=c&&g.x<=h&&g.y>=d&&g.y<=f&&ql(i,a,s,l,o,u,g.x,g.y)&&tn(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function rB(r,t,e,n){let i=r.prev,s=r,o=r.next;if(tn(i,s,o)>=0)return!1;let a=i.x,l=s.x,u=o.x,c=i.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,g=c<d?c<h?c:h:d<h?d:h,p=a>l?a>u?a:u:l>u?l:u,m=c>d?c>h?c:h:d>h?d:h,y=m0(f,g,t,e,n),v=m0(p,m,t,e,n),x=r.prevZ,S=r.nextZ;for(;x&&x.z>=y&&S&&S.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&ql(a,c,l,d,u,h,x.x,x.y)&&tn(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=f&&S.x<=p&&S.y>=g&&S.y<=m&&S!==i&&S!==o&&ql(a,c,l,d,u,h,S.x,S.y)&&tn(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&ql(a,c,l,d,u,h,x.x,x.y)&&tn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=v;){if(S.x>=f&&S.x<=p&&S.y>=g&&S.y<=m&&S!==i&&S!==o&&ql(a,c,l,d,u,h,S.x,S.y)&&tn(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function iB(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Yp(i,s)&&yA(i,n,n.next,s)&&lh(i,s)&&lh(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),ch(n),ch(n.next),n=r=s),n=n.next}while(n!==r);return ja(n)}function sB(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&pB(o,a)){let l=vA(o,a);o=ja(o,o.next),l=ja(l,l.next),ah(o,t,e,n,i,s,0),ah(l,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function oB(r,t,e,n){let i=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:r.length,u=gA(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(fB(u));for(i.sort(aB),s=0;s<i.length;s++)e=lB(i[s],e);return e}function aB(r,t){return r.x-t.x}function lB(r,t){let e=cB(r,t);if(!e)return t;let n=vA(e,r);return ja(n,n.next),ja(e,e.next)}function cB(r,t){let e=t,n=-1/0,i,s=r.x,o=r.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,i=e.x<e.next.x?e:e.next,h===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,u=i.y,c=1/0,d;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&ql(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),lh(e,r)&&(d<c||d===c&&(e.x>i.x||e.x===i.x&&uB(i,e)))&&(i=e,c=d)),e=e.next;while(e!==a);return i}function uB(r,t){return tn(r.prev,r,t.prev)<0&&tn(t.next,r,r.next)<0}function dB(r,t,e,n){let i=r;do i.z===0&&(i.z=m0(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,hB(i)}function hB(r){let t,e,n,i,s,o,a,l,u=1;do{for(e=r,r=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,u*=2}while(o>1);return r}function m0(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function fB(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function ql(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function pB(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!mB(r,t)&&(lh(r,t)&&lh(t,r)&&gB(r,t)&&(tn(r.prev,r,t.prev)||tn(r,t.prev,t))||Yp(r,t)&&tn(r.prev,r,r.next)>0&&tn(t.prev,t,t.next)>0)}function tn(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Yp(r,t){return r.x===t.x&&r.y===t.y}function yA(r,t,e,n){let i=yp(tn(r,t,e)),s=yp(tn(r,t,n)),o=yp(tn(e,n,r)),a=yp(tn(e,n,t));return!!(i!==s&&o!==a||i===0&&gp(r,e,t)||s===0&&gp(r,n,t)||o===0&&gp(e,r,n)||a===0&&gp(e,t,n))}function gp(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function yp(r){return r>0?1:r<0?-1:0}function mB(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&yA(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function lh(r,t){return tn(r.prev,r,r.next)<0?tn(r,t,r.next)>=0&&tn(r,r.prev,t)>=0:tn(r,t,r.prev)<0||tn(r,r.next,t)<0}function gB(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function vA(r,t){let e=new g0(r.i,r.x,r.y),n=new g0(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function H1(r,t,e,n){let i=new g0(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ch(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function g0(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function yB(r,t,e,n){let i=0;for(let s=t,o=e-n;s<e;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var ic=class{static area(t){let e=t.length,n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return ic.area(t)<0}static triangulateShape(t,e){let n=[],i=[],s=[];W1(t),j1(n,t);let o=t.length;e.forEach(W1);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,j1(n,e[l]);let a=tB.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function W1(r){let t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function j1(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}var sc=class extends nc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new sc(t.radius,t.detail)}};var qa=class extends Te{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],d=new A,h=new A,f=[],g=[],p=[],m=[];for(let y=0;y<=n;y++){let v=[],x=y/n,S=0;y==0&&o==0?S=.5/e:y==n&&l==Math.PI&&(S=-.5/e);for(let w=0;w<=e;w++){let _=w/e;d.x=-t*Math.cos(i+_*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(i+_*s)*Math.sin(o+x*a),g.push(d.x,d.y,d.z),h.copy(d).normalize(),p.push(h.x,h.y,h.z),m.push(_+S,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],S=c[y][v],w=c[y+1][v],_=c[y+1][v+1];(y!==0||o>0)&&f.push(x,S,_),(y!==n-1||l<Math.PI)&&f.push(S,w,_)}this.setIndex(f),this.setAttribute("position",new we(g,3)),this.setAttribute("normal",new we(p,3)),this.setAttribute("uv",new we(m,2))}static fromJSON(t){return new qa(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var oc=class extends Te{constructor(t=1,e=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],d=new A,h=new A,f=new A,g=new A,p=new A,m=new A,y=new A;for(let x=0;x<=n;++x){let S=x/n*s*Math.PI*2;v(S,s,o,t,f),v(S+.01,s,o,t,g),m.subVectors(g,f),y.addVectors(g,f),p.crossVectors(m,y),y.crossVectors(p,m),p.normalize(),y.normalize();for(let w=0;w<=i;++w){let _=w/i*Math.PI*2,E=-e*Math.cos(_),b=e*Math.sin(_);d.x=f.x+(E*y.x+b*p.x),d.y=f.y+(E*y.y+b*p.y),d.z=f.z+(E*y.z+b*p.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(w/i)}}for(let x=1;x<=n;x++)for(let S=1;S<=i;S++){let w=(i+1)*(x-1)+(S-1),_=(i+1)*x+(S-1),E=(i+1)*x+S,b=(i+1)*(x-1)+S;a.push(w,_,b),a.push(_,E,b)}this.setIndex(a),this.setAttribute("position",new we(l,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(c,2));function v(x,S,w,_,E){let b=Math.cos(x),T=Math.sin(x),M=w/S*x,I=Math.cos(M);E.x=_*(2+I)*.5*b,E.y=_*(2+I)*T*.5,E.z=_*Math.sin(M)*.5}}static fromJSON(t){return new oc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Lo(r,t,e){return xA(r)?new r.constructor(r.subarray(t,e!==void 0?e:r.length)):r.slice(t,e)}function vp(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function xA(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var ac=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{e:{let o;t:{r:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break e}o=e.length;break t}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=e[--n-1],t>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},y0=class extends ac{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:t1,endingEnd:t1}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case n1:s=t,a=2*e-n;break;case r1:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case n1:o=t,l=2*n-e;break;case r1:o=1,l=n+i[1]-i[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,g=(n-e)/(i-e),p=g*g,m=p*g,y=-h*m+2*h*p-h*g,v=(1+h)*m+(-1.5-2*h)*p+(-.5+h)*g+1,x=(-1-f)*m+(1.5+f)*p+.5*g,S=f*m-f*p;for(let w=0;w!==a;++w)s[w]=y*o[c+w]+v*o[u+w]+x*o[l+w]+S*o[d+w];return s}},v0=class extends ac{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(i-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},x0=class extends ac{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},Oi=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=vp(e,this.TimeBufferType),this.values=vp(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:vp(t.times,Array),values:vp(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new x0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new v0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new y0(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ap:e=this.InterpolantFactoryMethodDiscrete;break;case _p:e=this.InterpolantFactoryMethodLinear;break;case gv:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ap;case this.InterpolantFactoryMethodLinear:return _p;case this.InterpolantFactoryMethodSmooth:return gv}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Lo(n,s,o),this.values=Lo(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&xA(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Lo(this.times),e=Lo(this.values),n=this.getValueSize(),i=this.getInterpolation()===gv,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(i)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let g=0;g!==n;++g){let p=e[d+g];if(p!==e[h+g]||p!==e[f+g]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Lo(t,0,o),this.values=Lo(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=Lo(this.times,0),e=Lo(this.values,0),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};Oi.prototype.TimeBufferType=Float32Array;Oi.prototype.ValueBufferType=Float32Array;Oi.prototype.DefaultInterpolation=_p;var Xa=class extends Oi{};Xa.prototype.ValueTypeName="bool";Xa.prototype.ValueBufferType=Array;Xa.prototype.DefaultInterpolation=Ap;Xa.prototype.InterpolantFactoryMethodLinear=void 0;Xa.prototype.InterpolantFactoryMethodSmooth=void 0;var b0=class extends Oi{};b0.prototype.ValueTypeName="color";var S0=class extends Oi{};S0.prototype.ValueTypeName="number";var w0=class extends ac{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e),u=t*a;for(let c=u+a;u!==c;u+=4)Qe.slerpFlat(s,0,o,u-a,o,u,l);return s}},uh=class extends Oi{InterpolantFactoryMethodLinear(t){return new w0(this.times,this.values,this.getValueSize(),t)}};uh.prototype.ValueTypeName="quaternion";uh.prototype.DefaultInterpolation=_p;uh.prototype.InterpolantFactoryMethodSmooth=void 0;var Ya=class extends Oi{};Ya.prototype.ValueTypeName="string";Ya.prototype.ValueBufferType=Array;Ya.prototype.DefaultInterpolation=Ap;Ya.prototype.InterpolantFactoryMethodLinear=void 0;Ya.prototype.InterpolantFactoryMethodSmooth=void 0;var A0=class extends Oi{};A0.prototype.ValueTypeName="vector";var q1={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(this.files[r]=t)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},dh=class{constructor(t,e,n){let i=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],g=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return g}return null}}},vB=new dh,lc=class{constructor(t){this.manager=t!==void 0?t:vB,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},qs={},_0=class extends Error{constructor(t,e){super(t),this.response=e}},cc=class extends lc{constructor(t){super(t)}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=q1.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(qs[t]!==void 0){qs[t].push({onLoad:e,onProgress:n,onError:i});return}qs[t]=[],qs[t].push({onLoad:e,onProgress:n,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=qs[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,g=f!==0,p=0,m=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:S})=>{if(x)y.close();else{p+=S.byteLength;let w=new ProgressEvent("progress",{lengthComputable:g,loaded:p,total:f});for(let _=0,E=c.length;_<E;_++){let b=c[_];b.onProgress&&b.onProgress(w)}y.enqueue(S),v()}})}}});return new Response(m)}else throw new _0(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(g=>f.decode(g))}}}).then(u=>{q1.add(t,u);let c=qs[t];delete qs[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=qs[t];if(c===void 0)throw this.manager.itemError(t),u;delete qs[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Go=class extends ct{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ne(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Bp=class extends Go{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ne(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},jv=new de,X1=new A,Y1=new A,hh=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new de,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rh,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new $e(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;X1.setFromMatrixPosition(t.matrixWorld),e.position.copy(X1),Y1.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Y1),e.updateMatrixWorld(),jv.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jv),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(jv)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},E0=class extends hh{constructor(){super(new fn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=th*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Fp=class extends Go{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new E0}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},Q1=new de,jd=new A,qv=new A,T0=class extends hh{constructor(){super(new fn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new $e(2,1,1,1),new $e(0,1,1,1),new $e(3,1,1,1),new $e(1,1,1,1),new $e(3,0,1,1),new $e(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),jd.setFromMatrixPosition(t.matrixWorld),n.position.copy(jd),qv.copy(n.position),qv.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(qv),n.updateMatrixWorld(),i.makeTranslation(-jd.x,-jd.y,-jd.z),Q1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Q1)}},kp=class extends Go{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new T0}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},M0=class extends hh{constructor(){super(new ka(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Up=class extends Go{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.shadow=new M0}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var C0=class extends Te{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},uc=class extends lc{constructor(t){super(t)}load(t,e,n,i){let s=this,o=new cc(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){let e={},n={};function i(f,g){if(e[g]!==void 0)return e[g];let m=f.interleavedBuffers[g],y=s(f,m.buffer),v=Qf(m.type,y),x=new Lp(v,m.stride);return x.uuid=m.uuid,e[g]=x,x}function s(f,g){if(n[g]!==void 0)return n[g];let m=f.arrayBuffers[g],y=new Uint32Array(m).buffer;return n[g]=y,y}let o=t.isInstancedBufferGeometry?new C0:new Te,a=t.data.index;if(a!==void 0){let f=Qf(a.type,a.array);o.setIndex(new Fe(f,1))}let l=t.data.attributes;for(let f in l){let g=l[f],p;if(g.isInterleavedBufferAttribute){let m=i(t.data,g.data);p=new Ua(m,g.itemSize,g.offset,g.normalized)}else{let m=Qf(g.type,g.array),y=g.isInstancedBufferAttribute?Rp:Fe;p=new y(m,g.itemSize,g.normalized)}g.name!==void 0&&(p.name=g.name),g.usage!==void 0&&p.setUsage(g.usage),g.updateRange!==void 0&&(p.updateRange.offset=g.updateRange.offset,p.updateRange.count=g.updateRange.count),o.setAttribute(f,p)}let u=t.data.morphAttributes;if(u)for(let f in u){let g=u[f],p=[];for(let m=0,y=g.length;m<y;m++){let v=g[m],x;if(v.isInterleavedBufferAttribute){let S=i(t.data,v.data);x=new Ua(S,v.itemSize,v.offset,v.normalized)}else{let S=Qf(v.type,v.array);x=new Fe(S,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),p.push(x)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,g=d.length;f!==g;++f){let p=d[f];o.addGroup(p.start,p.count,p.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Cn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Gp=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=K1(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=K1();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function K1(){return(typeof performance>"u"?Date:performance).now()}var F0="\\[\\]\\.:\\/",xB=new RegExp("["+F0+"]","g"),k0="[^"+F0+"]",bB="[^"+F0.replace("\\.","")+"]",SB=/((?:WC+[\/:])*)/.source.replace("WC",k0),wB=/(WCOD+)?/.source.replace("WCOD",bB),AB=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",k0),_B=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",k0),EB=new RegExp("^"+SB+wB+AB+_B+"$"),TB=["material","materials","bones","map"],P0=class{constructor(t,e,n){let i=n||It.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},It=class{constructor(t,e,n){this.path=e,this.parsedPath=n||It.parseTrackName(e),this.node=It.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new It.Composite(t,e,n):new It(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(xB,"")}static parseTrackName(t){let e=EB.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);TB.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=It.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[i];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=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}};It.Composite=P0;It.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};It.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};It.prototype.GetterByBindingType=[It.prototype._getValue_direct,It.prototype._getValue_array,It.prototype._getValue_arrayElement,It.prototype._getValue_toArray];It.prototype.SetterByBindingTypeAndVersioning=[[It.prototype._setValue_direct,It.prototype._setValue_direct_setNeedsUpdate,It.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[It.prototype._setValue_array,It.prototype._setValue_array_setNeedsUpdate,It.prototype._setValue_array_setMatrixWorldNeedsUpdate],[It.prototype._setValue_arrayElement,It.prototype._setValue_arrayElement_setNeedsUpdate,It.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[It.prototype._setValue_fromArray,It.prototype._setValue_fromArray_setNeedsUpdate,It.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var w8=new Float32Array(1);var Ae=class{constructor(t){this.value=t}clone(){return new Ae(this.value.clone===void 0?this.value:this.value.clone())}};var dc=class{constructor(t,e,n=0,i=1/0){this.ray=new Ii(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new nh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return I0(t,this,n,e),n.sort(Z1),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)I0(t[i],this,n,e);return n.sort(Z1),n}};function Z1(r,t){return r.distance-t.distance}function I0(r,t,e,n){if(r.layers.test(t.layers)&&r.raycast(t,e),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)I0(i[s],t,e,!0)}}var fh=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Ln(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var J1=new F,zp=class{constructor(t=new F(1/0,1/0),e=new F(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=J1.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return J1.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},$1=new A,xp=new A,Bn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){$1.subVectors(t,this.start),xp.subVectors(this.end,this.start);let n=xp.dot(xp),s=xp.dot($1)/n;return e&&(s=Ln(s,0,1)),s}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},eA=new A,Vp=class extends ct{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Te,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 u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new we(i,3));let s=new hi({fog:!1,toneMapped:!1});this.cone=new Uo(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),eA.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(eA),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Hp=class extends Xn{constructor(t,e,n){let i=new qa(e,4,2),s=new Ks({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var tA=new A,bp=new A,nA=new A,Wp=class extends ct{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Te;i.setAttribute("position",new we([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new hi({fog:!1,toneMapped:!1});this.lightPlane=new Ga(i,s),this.add(this.lightPlane),i=new Te,i.setAttribute("position",new we([0,0,0,0,0,1],3)),this.targetLine=new Ga(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(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),tA.setFromMatrixPosition(this.light.matrixWorld),bp.setFromMatrixPosition(this.light.target.matrixWorld),nA.subVectors(bp,tA),this.lightPlane.lookAt(bp),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(bp),this.targetLine.scale.z=nA.length()}},Sp=new A,sn=new Di,zo=class extends Uo{constructor(t){let e=new Te,n=new hi({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(g,p){l(g),l(p)}function l(g){i.push(0,0,0),s.push(0,0,0),o[g]===void 0&&(o[g]=[]),o[g].push(i.length/3-1)}e.setAttribute("position",new we(i,3)),e.setAttribute("color",new we(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Ne(16755200),c=new Ne(16711680),d=new Ne(43775),h=new Ne(16777215),f=new Ne(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,i=1;sn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),hn("c",e,t,sn,0,0,-1),hn("t",e,t,sn,0,0,1),hn("n1",e,t,sn,-n,-i,-1),hn("n2",e,t,sn,n,-i,-1),hn("n3",e,t,sn,-n,i,-1),hn("n4",e,t,sn,n,i,-1),hn("f1",e,t,sn,-n,-i,1),hn("f2",e,t,sn,n,-i,1),hn("f3",e,t,sn,-n,i,1),hn("f4",e,t,sn,n,i,1),hn("u1",e,t,sn,n*.7,i*1.1,-1),hn("u2",e,t,sn,-n*.7,i*1.1,-1),hn("u3",e,t,sn,0,i*2,-1),hn("cf1",e,t,sn,-n,0,1),hn("cf2",e,t,sn,n,0,1),hn("cf3",e,t,sn,0,-i,1),hn("cf4",e,t,sn,0,i,1),hn("cn1",e,t,sn,-n,0,-1),hn("cn2",e,t,sn,n,0,-1),hn("cn3",e,t,sn,0,-i,-1),hn("cn4",e,t,sn,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function hn(r,t,e,n,i,s,o){Sp.set(i,s,o).unproject(n);let a=t[r];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Sp.x,Sp.y,Sp.z)}}var Vo=class extends Uo{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),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 Te;s.setIndex(new Fe(n,1)),s.setAttribute("position",new we(i,3)),super(s,new hi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var jp=class extends Uo{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Te;i.setAttribute("position",new we(e,3)),i.setAttribute("color",new we(n,3));let s=new hi({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){let i=new Ne,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:$s}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=$s);var pc=".",ph=Symbol("target"),U0=Symbol("unsubscribe");function mh(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function bA(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var ti=Array.isArray;function Qa(r){return typeof r=="symbol"}var MB={after:(r,t)=>ti(r)?r.slice(t.length):t===""?r:r.slice(t.length+1),concat:(r,t)=>ti(r)?(r=[...r],t&&r.push(t),r):t&&t.toString!==void 0?(r!==""&&(r+=pc),Qa(t)?r+t.toString():r+t):r,initial:r=>{if(ti(r))return r.slice(0,-1);if(r==="")return r;let t=r.lastIndexOf(pc);return t===-1?"":r.slice(0,t)},last:r=>{if(ti(r))return r[r.length-1]||"";if(r==="")return r;let t=r.lastIndexOf(pc);return t===-1?r:r.slice(t+1)},walk:(r,t)=>{if(ti(r))for(let e of r)t(e);else if(r!==""){let e=0,n=r.indexOf(pc);if(n===-1)t(r);else for(;e<r.length;)n===-1&&(n=r.length),t(r.slice(e,n)),e=n+1,n=r.indexOf(pc,e)}},get(r,t){return this.walk(t,e=>{r&&(r=r[e])}),r}},_r=MB;function G0(r){return typeof r=="object"&&typeof r.next=="function"}function z0(r,t,e,n,i){let s=r.next;if(t.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],n),o.value[1]=i(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[ph].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,n)),o};return r}function Qp(r,t,e){return r.isUnsubscribed||t.ignoreSymbols&&Qa(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var gh=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),i=n[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),n[e]=i),i}getProxy(t,e,n,i){if(this.isUnsubscribed)return t;let s=t[i],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,n):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,_r.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,i,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,i):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let i=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function mc(r){return toString.call(r)==="[object Object]"}function gc(){return!0}function Ho(r,t){return r.length!==t.length||r.some((e,n)=>t[n]!==e)}var Kp=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var CB=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),V0={push:gc,pop:gc,shift:gc,unshift:gc,copyWithin:Ho,reverse:Ho,sort:Ho,splice:Ho,flat:Ho,fill:Ho},SA=new Set([...Kp,...CB,...Object.keys(V0)]);function yc(r,t){if(r.size!==t.size)return!0;for(let e of r)if(!t.has(e))return!0;return!1}var H0=["keys","values","entries"],W0=new Set(["has","toString"]),j0={add:yc,clear:yc,delete:yc,forEach:yc},wA=new Set([...W0,...Object.keys(j0),...H0]);function vc(r,t){if(r.size!==t.size)return!0;let e;for(let[n,i]of r)if(e=t.get(n),e!==i||e===void 0&&!t.has(n))return!0;return!1}var PB=new Set([...W0,"get"]),q0={set:vc,clear:vc,delete:vc,forEach:vc},AA=new Set([...PB,...Object.keys(q0),...H0]);var Kn=class{constructor(t,e,n,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Kp.has(t)}_shallowClone(t){let e=t;if(mc(t))e={...t};else if(ti(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,i]of t.entries())e.set(n,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,i){return t?(ti(i)?this._onIsChanged=V0[e]:i instanceof Set?this._onIsChanged=j0[e]:i instanceof Map&&(this._onIsChanged=q0[e]),i):n}update(t,e,n){let i=_r.after(t,this._path);if(e!=="length"){let s=this.clone;_r.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:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],_r.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var xc=class extends Kn{static isHandledMethod(t){return SA.has(t)}};var yh=class extends Kn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var bc=class extends Kn{static isHandledMethod(t){return wA.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var Sc=class extends Kn{static isHandledMethod(t){return AA.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var vh=class extends Kn{constructor(t,e,n,i){super(void 0,e,n,i),this._arg1=n[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var xh=class extends Kn{constructor(t,e,n,i){super(void 0,e,n,i),this._weakKey=n[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Ri=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return mc(t)||ti(t)||mh(t)}static isHandledMethod(t,e){return mc(t)?Kn.isHandledMethod(e):ti(t)?xc.isHandledMethod(e):t instanceof Set?bc.isHandledMethod(e):t instanceof Map?Sc.isHandledMethod(e):mh(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let i=Kn;ti(t)?i=xc:t instanceof Date?i=yh:t instanceof Set?i=bc:t instanceof Map?i=Sc:t instanceof WeakSet?i=vh:t instanceof WeakMap&&(i=xh),this._stack.push(new i(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:i}=t,s=Ri.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var IB={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},X0=(r,t,e={})=>{e={...IB,...e};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new gh(i),u=typeof e.onValidate=="function",c=new Ri(u),d=(v,x,S,w,_)=>!u||c.isCloning||e.onValidate(_r.concat(l.getPath(v),x),S,w,_)===!0,h=(v,x,S,w)=>{!Qp(l,e,x)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),x,S,w)},f=(v,x,S,w,_)=>{c.isCloning?c.update(v,x,w):t(_r.concat(v,x),S,w,_)},g=v=>v&&(v[n]||v),p=(v,x,S,w)=>bA(v)||S==="constructor"||s&&!Ri.isHandledMethod(x,S)||Qp(l,e,S)||l.isGetInvariant(x,S)||o&&l.isDetached(x,r)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,_r.concat(w,S),m,n)),m={get(v,x,S){if(Qa(x)){if(x===n||x===ph)return v;if(x===U0&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=mh(v)?Reflect.get(v,x):Reflect.get(v,x,S);return p(w,v,x)},set(v,x,S,w){S=g(S);let _=v[n]||v,E=_[x];if(i(E,S)&&x in v)return!0;let b=d(v,x,S,E);return b&&l.setProperty(_,x,S,w,E)?(h(v,x,v[x],E),!0):!b},defineProperty(v,x,S){if(!l.isSameDescriptor(S,v,x)){let w=v[x];d(v,x,S.value,w)&&l.defineProperty(v,x,S,w)&&h(v,x,S.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let S=Reflect.get(v,x),w=d(v,x,void 0,S);return w&&l.deleteProperty(v,x,S)?(h(v,x,void 0,S),!0):!w},apply(v,x,S){let w=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,S);if((a===!1||a!==!0&&!a.includes(v.name))&&Ri.isHandledType(w)){let _=_r.initial(l.getPath(v)),E=Ri.isHandledMethod(w,v.name);c.start(w,_,S);let b=Reflect.apply(v,c.preferredThisArg(v,x,w),E?S.map(I=>g(I)):S),T=c.isChanged(w,i),M=c.stop();if(Ri.isHandledType(b)&&E&&(x instanceof Map&&v.name==="get"&&(_=_r.concat(_,S[0])),b=l.getProxy(b,_,m)),T){let I={name:v.name,args:S,result:b},P=c.isCloning?_r.initial(_):_,C=c.isCloning?_r.last(_):"";d(_r.get(r,P),C,w,M,I)?f(P,C,w,M,I):c.undo(w)}return(x instanceof Map||x instanceof Set)&&G0(b)?z0(b,v,x,_,p):b}return Reflect.apply(v,x,S)}},y=l.getProxy(r,e.pathAsArray?[]:"",m);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};X0.target=r=>r&&r[ph]||r;X0.unsubscribe=r=>r[U0]||r;var Y0=X0;var DB=typeof global=="object"&&global&&global.Object===Object&&global,Zp=DB;var OB=typeof self=="object"&&self&&self.Object===Object&&self,LB=Zp||OB||Function("return this")(),an=LB;var RB=an.Symbol,Zn=RB;var _A=Object.prototype,NB=_A.hasOwnProperty,BB=_A.toString,bh=Zn?Zn.toStringTag:void 0;function FB(r){var t=NB.call(r,bh),e=r[bh];try{r[bh]=void 0;var n=!0}catch{}var i=BB.call(r);return n&&(t?r[bh]=e:delete r[bh]),i}var EA=FB;var kB=Object.prototype,UB=kB.toString;function GB(r){return UB.call(r)}var TA=GB;var zB="[object Null]",VB="[object Undefined]",MA=Zn?Zn.toStringTag:void 0;function HB(r){return r==null?r===void 0?VB:zB:MA&&MA in Object(r)?EA(r):TA(r)}var ni=HB;function WB(r){return r!=null&&typeof r=="object"}var ar=WB;var jB="[object Symbol]";function qB(r){return typeof r=="symbol"||ar(r)&&ni(r)==jB}var Wo=qB;function XB(r,t){for(var e=-1,n=r==null?0:r.length,i=Array(n);++e<n;)i[e]=t(r[e],e,r);return i}var Jp=XB;var YB=Array.isArray,Fn=YB;var QB=1/0,CA=Zn?Zn.prototype:void 0,PA=CA?CA.toString:void 0;function IA(r){if(typeof r=="string")return r;if(Fn(r))return Jp(r,IA)+"";if(Wo(r))return PA?PA.call(r):"";var t=r+"";return t=="0"&&1/r==-QB?"-0":t}var DA=IA;var KB=/\s/;function ZB(r){for(var t=r.length;t--&&KB.test(r.charAt(t)););return t}var OA=ZB;var JB=/^\s+/;function $B(r){return r&&r.slice(0,OA(r)+1).replace(JB,"")}var LA=$B;function eF(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var Pn=eF;var RA=0/0,tF=/^[-+]0x[0-9a-f]+$/i,nF=/^0b[01]+$/i,rF=/^0o[0-7]+$/i,iF=parseInt;function sF(r){if(typeof r=="number")return r;if(Wo(r))return RA;if(Pn(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=Pn(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=LA(r);var e=nF.test(r);return e||rF.test(r)?iF(r.slice(2),e?2:8):tF.test(r)?RA:+r}var Q0=sF;function oF(r){return r}var NA=oF;var aF="[object AsyncFunction]",lF="[object Function]",cF="[object GeneratorFunction]",uF="[object Proxy]";function dF(r){if(!Pn(r))return!1;var t=ni(r);return t==lF||t==cF||t==aF||t==uF}var $p=dF;var hF=an["__core-js_shared__"],em=hF;var BA=function(){var r=/[^.]+$/.exec(em&&em.keys&&em.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function fF(r){return!!BA&&BA in r}var FA=fF;var pF=Function.prototype,mF=pF.toString;function gF(r){if(r!=null){try{return mF.call(r)}catch{}try{return r+""}catch{}}return""}var eo=gF;var yF=/[\\^$.*+?()[\]{}|]/g,vF=/^\[object .+?Constructor\]$/,xF=Function.prototype,bF=Object.prototype,SF=xF.toString,wF=bF.hasOwnProperty,AF=RegExp("^"+SF.call(wF).replace(yF,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _F(r){if(!Pn(r)||FA(r))return!1;var t=$p(r)?AF:vF;return t.test(eo(r))}var kA=_F;function EF(r,t){return r?.[t]}var UA=EF;function TF(r,t){var e=UA(r,t);return kA(e)?e:void 0}var Lr=TF;var MF=Lr(an,"WeakMap"),tm=MF;var GA=Object.create,CF=function(){function r(){}return function(t){if(!Pn(t))return{};if(GA)return GA(t);r.prototype=t;var e=new r;return r.prototype=void 0,e}}(),zA=CF;function PF(r,t,e){switch(e.length){case 0:return r.call(t);case 1:return r.call(t,e[0]);case 2:return r.call(t,e[0],e[1]);case 3:return r.call(t,e[0],e[1],e[2])}return r.apply(t,e)}var VA=PF;function IF(r,t){var e=-1,n=r.length;for(t||(t=Array(n));++e<n;)t[e]=r[e];return t}var HA=IF;var DF=800,OF=16,LF=Date.now;function RF(r){var t=0,e=0;return function(){var n=LF(),i=OF-(n-e);if(e=n,i>0){if(++t>=DF)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var WA=RF;function NF(r){return function(){return r}}var jA=NF;var BF=function(){try{var r=Lr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),wc=BF;var FF=wc?function(r,t){return wc(r,"toString",{configurable:!0,enumerable:!1,value:jA(t),writable:!0})}:NA,qA=FF;var kF=WA(qA),XA=kF;function UF(r,t){for(var e=-1,n=r==null?0:r.length;++e<n&&t(r[e],e,r)!==!1;);return r}var YA=UF;var GF=9007199254740991,zF=/^(?:0|[1-9]\d*)$/;function VF(r,t){var e=typeof r;return t=t??GF,!!t&&(e=="number"||e!="symbol"&&zF.test(r))&&r>-1&&r%1==0&&r<t}var Ac=VF;function HF(r,t,e){t=="__proto__"&&wc?wc(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e}var nm=HF;function WF(r,t){return r===t||r!==r&&t!==t}var _c=WF;var jF=Object.prototype,qF=jF.hasOwnProperty;function XF(r,t,e){var n=r[t];(!(qF.call(r,t)&&_c(n,e))||e===void 0&&!(t in r))&&nm(r,t,e)}var Ec=XF;function YF(r,t,e,n){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],r[a],a,e,r):void 0;l===void 0&&(l=r[a]),i?nm(e,a,l):Ec(e,a,l)}return e}var us=YF;var QA=Math.max;function QF(r,t,e){return t=QA(t===void 0?r.length-1:t,0),function(){for(var n=arguments,i=-1,s=QA(n.length-t,0),o=Array(s);++i<s;)o[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=e(o),VA(r,this,a)}}var KA=QF;var KF=9007199254740991;function ZF(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=KF}var Tc=ZF;function JF(r){return r!=null&&Tc(r.length)&&!$p(r)}var rm=JF;var $F=Object.prototype;function ek(r){var t=r&&r.constructor,e=typeof t=="function"&&t.prototype||$F;return r===e}var Mc=ek;function tk(r,t){for(var e=-1,n=Array(r);++e<r;)n[e]=t(e);return n}var ZA=tk;var nk="[object Arguments]";function rk(r){return ar(r)&&ni(r)==nk}var K0=rk;var JA=Object.prototype,ik=JA.hasOwnProperty,sk=JA.propertyIsEnumerable,ok=K0(function(){return arguments}())?K0:function(r){return ar(r)&&ik.call(r,"callee")&&!sk.call(r,"callee")},Cc=ok;function ak(){return!1}var $A=ak;var n_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,e_=n_&&typeof module=="object"&&module&&!module.nodeType&&module,lk=e_&&e_.exports===n_,t_=lk?an.Buffer:void 0,ck=t_?t_.isBuffer:void 0,uk=ck||$A,Ka=uk;var dk="[object Arguments]",hk="[object Array]",fk="[object Boolean]",pk="[object Date]",mk="[object Error]",gk="[object Function]",yk="[object Map]",vk="[object Number]",xk="[object Object]",bk="[object RegExp]",Sk="[object Set]",wk="[object String]",Ak="[object WeakMap]",_k="[object ArrayBuffer]",Ek="[object DataView]",Tk="[object Float32Array]",Mk="[object Float64Array]",Ck="[object Int8Array]",Pk="[object Int16Array]",Ik="[object Int32Array]",Dk="[object Uint8Array]",Ok="[object Uint8ClampedArray]",Lk="[object Uint16Array]",Rk="[object Uint32Array]",qt={};qt[Tk]=qt[Mk]=qt[Ck]=qt[Pk]=qt[Ik]=qt[Dk]=qt[Ok]=qt[Lk]=qt[Rk]=!0;qt[dk]=qt[hk]=qt[_k]=qt[fk]=qt[Ek]=qt[pk]=qt[mk]=qt[gk]=qt[yk]=qt[vk]=qt[xk]=qt[bk]=qt[Sk]=qt[wk]=qt[Ak]=!1;function Nk(r){return ar(r)&&Tc(r.length)&&!!qt[ni(r)]}var r_=Nk;function Bk(r){return function(t){return r(t)}}var Pc=Bk;var i_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sh=i_&&typeof module=="object"&&module&&!module.nodeType&&module,Fk=Sh&&Sh.exports===i_,Z0=Fk&&Zp.process,kk=function(){try{var r=Sh&&Sh.require&&Sh.require("util").types;return r||Z0&&Z0.binding&&Z0.binding("util")}catch{}}(),to=kk;var s_=to&&to.isTypedArray,Uk=s_?Pc(s_):r_,im=Uk;var Gk=Object.prototype,zk=Gk.hasOwnProperty;function Vk(r,t){var e=Fn(r),n=!e&&Cc(r),i=!e&&!n&&Ka(r),s=!e&&!n&&!i&&im(r),o=e||n||i||s,a=o?ZA(r.length,String):[],l=a.length;for(var u in r)(t||zk.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Ac(u,l)))&&a.push(u);return a}var sm=Vk;function Hk(r,t){return function(e){return r(t(e))}}var om=Hk;var Wk=om(Object.keys,Object),o_=Wk;var jk=Object.prototype,qk=jk.hasOwnProperty;function Xk(r){if(!Mc(r))return o_(r);var t=[];for(var e in Object(r))qk.call(r,e)&&e!="constructor"&&t.push(e);return t}var a_=Xk;function Yk(r){return rm(r)?sm(r):a_(r)}var Ic=Yk;function Qk(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var l_=Qk;var Kk=Object.prototype,Zk=Kk.hasOwnProperty;function Jk(r){if(!Pn(r))return l_(r);var t=Mc(r),e=[];for(var n in r)n=="constructor"&&(t||!Zk.call(r,n))||e.push(n);return e}var c_=Jk;function $k(r){return rm(r)?sm(r,!0):c_(r)}var Dc=$k;var eU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tU=/^\w*$/;function nU(r,t){if(Fn(r))return!1;var e=typeof r;return e=="number"||e=="symbol"||e=="boolean"||r==null||Wo(r)?!0:tU.test(r)||!eU.test(r)||t!=null&&r in Object(t)}var u_=nU;var rU=Lr(Object,"create"),no=rU;function iU(){this.__data__=no?no(null):{},this.size=0}var d_=iU;function sU(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}var h_=sU;var oU="__lodash_hash_undefined__",aU=Object.prototype,lU=aU.hasOwnProperty;function cU(r){var t=this.__data__;if(no){var e=t[r];return e===oU?void 0:e}return lU.call(t,r)?t[r]:void 0}var f_=cU;var uU=Object.prototype,dU=uU.hasOwnProperty;function hU(r){var t=this.__data__;return no?t[r]!==void 0:dU.call(t,r)}var p_=hU;var fU="__lodash_hash_undefined__";function pU(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=no&&t===void 0?fU:t,this}var m_=pU;function Oc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}Oc.prototype.clear=d_;Oc.prototype.delete=h_;Oc.prototype.get=f_;Oc.prototype.has=p_;Oc.prototype.set=m_;var J0=Oc;function mU(){this.__data__=[],this.size=0}var g_=mU;function gU(r,t){for(var e=r.length;e--;)if(_c(r[e][0],t))return e;return-1}var jo=gU;var yU=Array.prototype,vU=yU.splice;function xU(r){var t=this.__data__,e=jo(t,r);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():vU.call(t,e,1),--this.size,!0}var y_=xU;function bU(r){var t=this.__data__,e=jo(t,r);return e<0?void 0:t[e][1]}var v_=bU;function SU(r){return jo(this.__data__,r)>-1}var x_=SU;function wU(r,t){var e=this.__data__,n=jo(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}var b_=wU;function Lc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}Lc.prototype.clear=g_;Lc.prototype.delete=y_;Lc.prototype.get=v_;Lc.prototype.has=x_;Lc.prototype.set=b_;var qo=Lc;var AU=Lr(an,"Map"),Xo=AU;function _U(){this.size=0,this.__data__={hash:new J0,map:new(Xo||qo),string:new J0}}var S_=_U;function EU(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}var w_=EU;function TU(r,t){var e=r.__data__;return w_(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Yo=TU;function MU(r){var t=Yo(this,r).delete(r);return this.size-=t?1:0,t}var A_=MU;function CU(r){return Yo(this,r).get(r)}var __=CU;function PU(r){return Yo(this,r).has(r)}var E_=PU;function IU(r,t){var e=Yo(this,r),n=e.size;return e.set(r,t),this.size+=e.size==n?0:1,this}var T_=IU;function Rc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}Rc.prototype.clear=S_;Rc.prototype.delete=A_;Rc.prototype.get=__;Rc.prototype.has=E_;Rc.prototype.set=T_;var Za=Rc;var DU="Expected a function";function $0(r,t){if(typeof r!="function"||t!=null&&typeof t!="function")throw new TypeError(DU);var e=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=e.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return e.cache=s.set(i,o)||s,o};return e.cache=new($0.Cache||Za),e}$0.Cache=Za;var M_=$0;var OU=500;function LU(r){var t=M_(r,function(n){return e.size===OU&&e.clear(),n}),e=t.cache;return t}var C_=LU;var RU=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,NU=/\\(\\)?/g,BU=C_(function(r){var t=[];return r.charCodeAt(0)===46&&t.push(""),r.replace(RU,function(e,n,i,s){t.push(i?s.replace(NU,"$1"):n||e)}),t}),P_=BU;function FU(r){return r==null?"":DA(r)}var I_=FU;function kU(r,t){return Fn(r)?r:u_(r,t)?[r]:P_(I_(r))}var pi=kU;var UU=1/0;function GU(r){if(typeof r=="string"||Wo(r))return r;var t=r+"";return t=="0"&&1/r==-UU?"-0":t}var Qo=GU;function zU(r,t){t=pi(t,r);for(var e=0,n=t.length;r!=null&&e<n;)r=r[Qo(t[e++])];return e&&e==n?r:void 0}var am=zU;function VU(r,t){for(var e=-1,n=t.length,i=r.length;++e<n;)r[i+e]=t[e];return r}var Nc=VU;var D_=Zn?Zn.isConcatSpreadable:void 0;function HU(r){return Fn(r)||Cc(r)||!!(D_&&r&&r[D_])}var O_=HU;function L_(r,t,e,n,i){var s=-1,o=r.length;for(e||(e=O_),i||(i=[]);++s<o;){var a=r[s];t>0&&e(a)?t>1?L_(a,t-1,e,n,i):Nc(i,a):n||(i[i.length]=a)}return i}var R_=L_;function WU(r){var t=r==null?0:r.length;return t?R_(r,1):[]}var N_=WU;function jU(r){return XA(KA(r,void 0,N_),r+"")}var lm=jU;var qU=om(Object.getPrototypeOf,Object),Bc=qU;var XU="[object Object]",YU=Function.prototype,QU=Object.prototype,B_=YU.toString,KU=QU.hasOwnProperty,ZU=B_.call(Object);function JU(r){if(!ar(r)||ni(r)!=XU)return!1;var t=Bc(r);if(t===null)return!0;var e=KU.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&B_.call(e)==ZU}var F_=JU;function $U(r,t,e){var n=-1,i=r.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+t];return s}var k_=$U;function eG(){this.__data__=new qo,this.size=0}var U_=eG;function tG(r){var t=this.__data__,e=t.delete(r);return this.size=t.size,e}var G_=tG;function nG(r){return this.__data__.get(r)}var z_=nG;function rG(r){return this.__data__.has(r)}var V_=rG;var iG=200;function sG(r,t){var e=this.__data__;if(e instanceof qo){var n=e.__data__;if(!Xo||n.length<iG-1)return n.push([r,t]),this.size=++e.size,this;e=this.__data__=new Za(n)}return e.set(r,t),this.size=e.size,this}var H_=sG;function Fc(r){var t=this.__data__=new qo(r);this.size=t.size}Fc.prototype.clear=U_;Fc.prototype.delete=G_;Fc.prototype.get=z_;Fc.prototype.has=V_;Fc.prototype.set=H_;var kc=Fc;function oG(r,t){return r&&us(t,Ic(t),r)}var W_=oG;function aG(r,t){return r&&us(t,Dc(t),r)}var j_=aG;var Q_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,q_=Q_&&typeof module=="object"&&module&&!module.nodeType&&module,lG=q_&&q_.exports===Q_,X_=lG?an.Buffer:void 0,Y_=X_?X_.allocUnsafe:void 0;function cG(r,t){if(t)return r.slice();var e=r.length,n=Y_?Y_(e):new r.constructor(e);return r.copy(n),n}var K_=cG;function uG(r,t){for(var e=-1,n=r==null?0:r.length,i=0,s=[];++e<n;){var o=r[e];t(o,e,r)&&(s[i++]=o)}return s}var Z_=uG;function dG(){return[]}var cm=dG;var hG=Object.prototype,fG=hG.propertyIsEnumerable,J_=Object.getOwnPropertySymbols,pG=J_?function(r){return r==null?[]:(r=Object(r),Z_(J_(r),function(t){return fG.call(r,t)}))}:cm,Uc=pG;function mG(r,t){return us(r,Uc(r),t)}var $_=mG;var gG=Object.getOwnPropertySymbols,yG=gG?function(r){for(var t=[];r;)Nc(t,Uc(r)),r=Bc(r);return t}:cm,um=yG;function vG(r,t){return us(r,um(r),t)}var eE=vG;function xG(r,t,e){var n=t(r);return Fn(r)?n:Nc(n,e(r))}var dm=xG;function bG(r){return dm(r,Ic,Uc)}var wh=bG;function SG(r){return dm(r,Dc,um)}var hm=SG;var wG=Lr(an,"DataView"),fm=wG;var AG=Lr(an,"Promise"),pm=AG;var _G=Lr(an,"Set"),mm=_G;var tE="[object Map]",EG="[object Object]",nE="[object Promise]",rE="[object Set]",iE="[object WeakMap]",sE="[object DataView]",TG=eo(fm),MG=eo(Xo),CG=eo(pm),PG=eo(mm),IG=eo(tm),Ja=ni;(fm&&Ja(new fm(new ArrayBuffer(1)))!=sE||Xo&&Ja(new Xo)!=tE||pm&&Ja(pm.resolve())!=nE||mm&&Ja(new mm)!=rE||tm&&Ja(new tm)!=iE)&&(Ja=function(r){var t=ni(r),e=t==EG?r.constructor:void 0,n=e?eo(e):"";if(n)switch(n){case TG:return sE;case MG:return tE;case CG:return nE;case PG:return rE;case IG:return iE}return t});var ro=Ja;var DG=Object.prototype,OG=DG.hasOwnProperty;function LG(r){var t=r.length,e=new r.constructor(t);return t&&typeof r[0]=="string"&&OG.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var oE=LG;var RG=an.Uint8Array,Gc=RG;function NG(r){var t=new r.constructor(r.byteLength);return new Gc(t).set(new Gc(r)),t}var zc=NG;function BG(r,t){var e=t?zc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var aE=BG;var FG=/\w*$/;function kG(r){var t=new r.constructor(r.source,FG.exec(r));return t.lastIndex=r.lastIndex,t}var lE=kG;var cE=Zn?Zn.prototype:void 0,uE=cE?cE.valueOf:void 0;function UG(r){return uE?Object(uE.call(r)):{}}var dE=UG;function GG(r,t){var e=t?zc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var hE=GG;var zG="[object Boolean]",VG="[object Date]",HG="[object Map]",WG="[object Number]",jG="[object RegExp]",qG="[object Set]",XG="[object String]",YG="[object Symbol]",QG="[object ArrayBuffer]",KG="[object DataView]",ZG="[object Float32Array]",JG="[object Float64Array]",$G="[object Int8Array]",ez="[object Int16Array]",tz="[object Int32Array]",nz="[object Uint8Array]",rz="[object Uint8ClampedArray]",iz="[object Uint16Array]",sz="[object Uint32Array]";function oz(r,t,e){var n=r.constructor;switch(t){case QG:return zc(r);case zG:case VG:return new n(+r);case KG:return aE(r,e);case ZG:case JG:case $G:case ez:case tz:case nz:case rz:case iz:case sz:return hE(r,e);case HG:return new n;case WG:case XG:return new n(r);case jG:return lE(r);case qG:return new n;case YG:return dE(r)}}var fE=oz;function az(r){return typeof r.constructor=="function"&&!Mc(r)?zA(Bc(r)):{}}var pE=az;var lz="[object Map]";function cz(r){return ar(r)&&ro(r)==lz}var mE=cz;var gE=to&&to.isMap,uz=gE?Pc(gE):mE,yE=uz;var dz="[object Set]";function hz(r){return ar(r)&&ro(r)==dz}var vE=hz;var xE=to&&to.isSet,fz=xE?Pc(xE):vE,bE=fz;var pz=1,mz=2,gz=4,SE="[object Arguments]",yz="[object Array]",vz="[object Boolean]",xz="[object Date]",bz="[object Error]",wE="[object Function]",Sz="[object GeneratorFunction]",wz="[object Map]",Az="[object Number]",AE="[object Object]",_z="[object RegExp]",Ez="[object Set]",Tz="[object String]",Mz="[object Symbol]",Cz="[object WeakMap]",Pz="[object ArrayBuffer]",Iz="[object DataView]",Dz="[object Float32Array]",Oz="[object Float64Array]",Lz="[object Int8Array]",Rz="[object Int16Array]",Nz="[object Int32Array]",Bz="[object Uint8Array]",Fz="[object Uint8ClampedArray]",kz="[object Uint16Array]",Uz="[object Uint32Array]",Vt={};Vt[SE]=Vt[yz]=Vt[Pz]=Vt[Iz]=Vt[vz]=Vt[xz]=Vt[Dz]=Vt[Oz]=Vt[Lz]=Vt[Rz]=Vt[Nz]=Vt[wz]=Vt[Az]=Vt[AE]=Vt[_z]=Vt[Ez]=Vt[Tz]=Vt[Mz]=Vt[Bz]=Vt[Fz]=Vt[kz]=Vt[Uz]=!0;Vt[bz]=Vt[wE]=Vt[Cz]=!1;function gm(r,t,e,n,i,s){var o,a=t&pz,l=t&mz,u=t&gz;if(e&&(o=i?e(r,n,i,s):e(r)),o!==void 0)return o;if(!Pn(r))return r;var c=Fn(r);if(c){if(o=oE(r),!a)return HA(r,o)}else{var d=ro(r),h=d==wE||d==Sz;if(Ka(r))return K_(r,a);if(d==AE||d==SE||h&&!i){if(o=l||h?{}:pE(r),!a)return l?eE(r,j_(o,r)):$_(r,W_(o,r))}else{if(!Vt[d])return i?r:{};o=fE(r,d,a)}}s||(s=new kc);var f=s.get(r);if(f)return f;s.set(r,o),bE(r)?r.forEach(function(m){o.add(gm(m,t,e,m,r,s))}):yE(r)&&r.forEach(function(m,y){o.set(y,gm(m,t,e,y,r,s))});var g=u?l?hm:wh:l?Dc:Ic,p=c?void 0:g(r);return YA(p||r,function(m,y){p&&(y=m,m=r[y]),Ec(o,y,gm(m,t,e,y,r,s))}),o}var ym=gm;var Gz=1,zz=4;function Vz(r){return ym(r,Gz|zz)}var io=Vz;var Hz="__lodash_hash_undefined__";function Wz(r){return this.__data__.set(r,Hz),this}var _E=Wz;function jz(r){return this.__data__.has(r)}var EE=jz;function vm(r){var t=-1,e=r==null?0:r.length;for(this.__data__=new Za;++t<e;)this.add(r[t])}vm.prototype.add=vm.prototype.push=_E;vm.prototype.has=EE;var TE=vm;function qz(r,t){for(var e=-1,n=r==null?0:r.length;++e<n;)if(t(r[e],e,r))return!0;return!1}var ME=qz;function Xz(r,t){return r.has(t)}var CE=Xz;var Yz=1,Qz=2;function Kz(r,t,e,n,i,s){var o=e&Yz,a=r.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(r),c=s.get(t);if(u&&c)return u==t&&c==r;var d=-1,h=!0,f=e&Qz?new TE:void 0;for(s.set(r,t),s.set(t,r);++d<a;){var g=r[d],p=t[d];if(n)var m=o?n(p,g,d,t,r,s):n(g,p,d,r,t,s);if(m!==void 0){if(m)continue;h=!1;break}if(f){if(!ME(t,function(y,v){if(!CE(f,v)&&(g===y||i(g,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(g===p||i(g,p,e,n,s))){h=!1;break}}return s.delete(r),s.delete(t),h}var xm=Kz;function Zz(r){var t=-1,e=Array(r.size);return r.forEach(function(n,i){e[++t]=[i,n]}),e}var PE=Zz;function Jz(r){var t=-1,e=Array(r.size);return r.forEach(function(n){e[++t]=n}),e}var IE=Jz;var $z=1,eV=2,tV="[object Boolean]",nV="[object Date]",rV="[object Error]",iV="[object Map]",sV="[object Number]",oV="[object RegExp]",aV="[object Set]",lV="[object String]",cV="[object Symbol]",uV="[object ArrayBuffer]",dV="[object DataView]",DE=Zn?Zn.prototype:void 0,ex=DE?DE.valueOf:void 0;function hV(r,t,e,n,i,s,o){switch(e){case dV:if(r.byteLength!=t.byteLength||r.byteOffset!=t.byteOffset)return!1;r=r.buffer,t=t.buffer;case uV:return!(r.byteLength!=t.byteLength||!s(new Gc(r),new Gc(t)));case tV:case nV:case sV:return _c(+r,+t);case rV:return r.name==t.name&&r.message==t.message;case oV:case lV:return r==t+"";case iV:var a=PE;case aV:var l=n&$z;if(a||(a=IE),r.size!=t.size&&!l)return!1;var u=o.get(r);if(u)return u==t;n|=eV,o.set(r,t);var c=xm(a(r),a(t),n,i,s,o);return o.delete(r),c;case cV:if(ex)return ex.call(r)==ex.call(t)}return!1}var OE=hV;var fV=1,pV=Object.prototype,mV=pV.hasOwnProperty;function gV(r,t,e,n,i,s){var o=e&fV,a=wh(r),l=a.length,u=wh(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:mV.call(t,h)))return!1}var f=s.get(r),g=s.get(t);if(f&&g)return f==t&&g==r;var p=!0;s.set(r,t),s.set(t,r);for(var m=o;++d<l;){h=a[d];var y=r[h],v=t[h];if(n)var x=o?n(v,y,h,t,r,s):n(y,v,h,r,t,s);if(!(x===void 0?y===v||i(y,v,e,n,s):x)){p=!1;break}m||(m=h=="constructor")}if(p&&!m){var S=r.constructor,w=t.constructor;S!=w&&"constructor"in r&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof w=="function"&&w instanceof w)&&(p=!1)}return s.delete(r),s.delete(t),p}var LE=gV;var yV=1,RE="[object Arguments]",NE="[object Array]",bm="[object Object]",vV=Object.prototype,BE=vV.hasOwnProperty;function xV(r,t,e,n,i,s){var o=Fn(r),a=Fn(t),l=o?NE:ro(r),u=a?NE:ro(t);l=l==RE?bm:l,u=u==RE?bm:u;var c=l==bm,d=u==bm,h=l==u;if(h&&Ka(r)){if(!Ka(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new kc),o||im(r)?xm(r,t,e,n,i,s):OE(r,t,l,e,n,i,s);if(!(e&yV)){var f=c&&BE.call(r,"__wrapped__"),g=d&&BE.call(t,"__wrapped__");if(f||g){var p=f?r.value():r,m=g?t.value():t;return s||(s=new kc),i(p,m,e,n,s)}}return h?(s||(s=new kc),LE(r,t,e,n,i,s)):!1}var FE=xV;function kE(r,t,e,n,i){return r===t?!0:r==null||t==null||!ar(r)&&!ar(t)?r!==r&&t!==t:FE(r,t,e,n,kE,i)}var UE=kE;function bV(r,t){return r!=null&&t in Object(r)}var GE=bV;function SV(r,t,e){t=pi(t,r);for(var n=-1,i=t.length,s=!1;++n<i;){var o=Qo(t[n]);if(!(s=r!=null&&e(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&Tc(i)&&Ac(o,i)&&(Fn(r)||Cc(r)))}var zE=SV;function wV(r,t){return r!=null&&zE(r,t,GE)}var VE=wV;var AV=function(){return an.Date.now()},Sm=AV;var _V="Expected a function",EV=Math.max,TV=Math.min;function MV(r,t,e){var n,i,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(_V);t=Q0(t)||0,Pn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?EV(Q0(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(_){var E=n,b=i;return n=i=void 0,u=_,o=r.apply(b,E),o}function g(_){return u=_,a=setTimeout(y,t),c?f(_):o}function p(_){var E=_-l,b=_-u,T=t-E;return d?TV(T,s-b):T}function m(_){var E=_-l,b=_-u;return l===void 0||E>=t||E<0||d&&b>=s}function y(){var _=Sm();if(m(_))return v(_);a=setTimeout(y,p(_))}function v(_){return a=void 0,h&&n?f(_):(n=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function S(){return a===void 0?o:v(Sm())}function w(){var _=Sm(),E=m(_);if(n=arguments,i=this,l=_,E){if(a===void 0)return g(l);if(d)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=S,w}var $a=MV;function CV(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}var HE=CV;function PV(r,t){return t.length<2?r:am(r,k_(t,0,-1))}var WE=PV;function IV(r,t){return UE(r,t)}var el=IV;function DV(r,t){return t=pi(t,r),r=WE(r,t),r==null||delete r[Qo(HE(t))]}var jE=DV;function OV(r){return F_(r)?void 0:r}var qE=OV;var LV=1,RV=2,NV=4,BV=lm(function(r,t){var e={};if(r==null)return e;var n=!1;t=Jp(t,function(s){return s=pi(s,r),n||(n=s.length>1),s}),us(r,hm(r),e),n&&(e=ym(e,LV|RV|NV,qE));for(var i=t.length;i--;)jE(e,t[i]);return e}),Vc=BV;function FV(r,t,e,n){if(!Pn(r))return r;t=pi(t,r);for(var i=-1,s=t.length,o=s-1,a=r;a!=null&&++i<s;){var l=Qo(t[i]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Pn(c)?c:Ac(t[i+1])?[]:{})}Ec(a,l,u),a=a[l]}return r}var XE=FV;function kV(r,t,e){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=am(r,o);e(a,o)&&XE(s,pi(o,r),a)}return s}var YE=kV;function UV(r,t){return YE(r,t,function(e,n){return VE(r,n)})}var QE=UV;var GV=lm(function(r,t){return r==null?{}:QE(r,t)}),Ko=GV;var zV="Expected a function";function VV(r,t,e){var n=!0,i=!0;if(typeof r!="function")throw new TypeError(zV);return Pn(e)&&(n="leading"in e?!!e.leading:n,i="trailing"in e?!!e.trailing:i),$a(r,t,{leading:n,maxWait:t,trailing:i})}var tx=VV;var ZE,JE=new Promise(r=>{ZE=r}),KE=!1;async function $E(){if(KE)return;let r=await import("./physics.js");await r.init(),ZE(r),KE=!0}var Lt=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,Lt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let n=e[t.id],i;n===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,Lt.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:n}=t,i=e[n];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Lt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:i}}}}return null}};function Ah(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let t=Object.getOwnPropertyNames(r);for(let e of t){let n=r[e];n&&typeof n=="object"&&Ah(n)}return Object.freeze(r)}function eT(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}var Hc=class extends Error{};function wm(r){let t={...r};return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}function ds(r,t,e){if(r===void 0?t===void 0?(r=0,t=10):r=t-10:t===void 0&&(t=r+10),r>t){let s=r;r=t,t=s}let n=[],i=1/(e+1);for(let s=0;s<e;s++){let o=r+(t-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function Wc(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function tT(){return typeof process<"u"}function nT(r,t){for(let e of r)t(e.id,e.data)!==!0&&nT(e.children,t)}function rT(r,t){if(t(r.id,r.data)!==!0)for(let e of r.children)rT(e,t)}var Qt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Qt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ah(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,n){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}isDescendantOf(e,n){for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,n){if(e===null)this.traverse(n);else{let i=this.get(e);i&&rT(i,n)}}traverse(e){nT(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let i=e,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,Qt.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:n}){if(this.get(e)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:n,fi:i,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:i,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:n,fi:i,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Hc("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,g)=>f.fi-g.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>eT(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(e){var n=e;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(e,n,i){return this.insertAfterHelper(e,this.previous(e,n),i)}insertAfterHelper(e,n,i){let s=this.childrenArray(e);if(n===null){if(s.length===0)return ds(0,i,i);{let o=s[0].fi;return ds(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return ds(l,l+i,i)}else return ds(o.fi,a.fi,i)}}};var jc;(t=>{function r(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let i=n.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=r})(jc||(jc={}));var He=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,He.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ah(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,He.prototype);let n=e;return tT()||n.fillCaches(),n}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:n,id:i,data:s}=e,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:n}=e,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:i}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===e)return n;n=i.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let i=this;if(e===null){if(i.length===0)return ds(0,n,n);{let s=i[0].fi;return ds(s-n,s,n)}}else{let s=this.get(e);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 ds(a,a+n,n)}else return ds(s.fi,o.fi,n)}}};function qc(r){return r&&typeof r=="object"&&r instanceof Kt}var Kt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,i=0,s={};for(;i<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[i]],n!==void 0&&!qc(n))return null;i+=1}n=n?wm(n):new Kt;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;i>0;){if(Object.keys(n).length===0){let l=e[i-1];l&&(n=wm(l),delete n[t.path[i-1]])}else{let l=e[i-1];if(l){let u=wm(l);u[t.path[i-1]]=n,n=u}else{let u=new Kt;u[t.path[i-1]]=n,n=u}}i-=1}let o=Object.setPrototypeOf(n,Kt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},so;(n=>{function r(i,s){return _h(i,s)??i}n.apply=r;function t(i,s){return rx(i,s)}n.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=Er.zoomOnce(l,a[o]),l===void 0)return s;if(!qc(l))return;o+=1}if(l===void 0)return s;if(!!qc(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=nx([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(so||(so={}));function nx(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=_h(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=nx(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return n}function HV(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=_h(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function _h(r,t){if(!qc(t))return t;if(r instanceof Qt){let e=nx(r,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else{if(r instanceof He)return HV(r,t);if(Array.isArray(r)){let e=!1,n=r.map((i,s)=>{let o=_h(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else{if(r instanceof Kt)return rx(r,t);if(r&&typeof r=="object"){let e={},n=!1;for(let[i,s]of Object.entries(r)){let o=_h(s,t[i]);n=n||o!==void 0,o===void 0&&(o=s),e[i]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e):void 0}}}}function rx(r,t){if(r===void 0)return t;if(t===void 0)return r;if(!qc(t))return t;if(!qc(r))return so.apply(r,t);let e=new Set;for(let i of Object.keys(r))e.add(i);for(let i of Object.keys(t))e.add(i);let n=new Kt;for(let i of e){let s=rx(r===void 0?void 0:r[i],t===void 0?void 0:t[i]);n[i]=s}return n}function iT(r,t){let e={cur:[],result:[],len:0};return r=Eh(r,t,e)??r,[r,e.result]}function Am(r,t){return r===null?null:(r.cur[r.len]=t,r.len+=1,r)}function _m(r){r&&(r.len-=1)}function WV(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function sT(r,t,e){let n=!1,i=r.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Eh(s.data,t,Am(e,o));_m(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=sT(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function jV(r,t,e){let n=!1,i=r.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Eh(s.data,t,Am(e,o));return _m(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function Eh(r,t,e){if(r instanceof Qt){let n=sT(r,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof He)return jV(r,t,e);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=Eh(s,t,Am(e,o));return _m(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"&&!Wc(r)){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=Eh(o,t,Am(e,s));_m(e),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=t[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");WV(e)}return n}else return}}var Em;(t=>{function r(e,n){let i=Er.zoom(n,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=r})(Em||(Em={}));var lr;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof Kt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof Qt||l instanceof He||l instanceof Lt?h=l.runOp(u):h=jc.runOp(l,u)),h!==void 0)if(h!==null){let p=h.data;for(let m=d.length-1;m>=0;m--){let y=c[m],v=d[m];if(v instanceof Qt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof He){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Lt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Kt){let x={...v,[y]:p};p=Object.setPrototypeOf(x,Kt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=p;p=[...v],p[y]=x}else p={...v,[y]:p};else return null}return{data:p,actual:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],g;if(l instanceof Qt){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else if(l instanceof He){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else l!==null&&(g=l[f]);if(g!==void 0)d.push(l),l=g;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function i(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(lr||(lr={}));var ix;(l=>{function r(){return[]}l.empty=r;function t(u,c){let d=[];for(let h of u){let[f,...g]=h.path;f===c&&d.push({...h,path:g})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(h=>!c.some(f=>lr.subsumed(h,f))),...c]}l.compress=i;function s(u,c){return u.every(d=>c.every(h=>lr.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],f=[];for(let g of c)try{if(g.type===3){let p=Er.zoom(d,[...g.path,g.id]),m=lr.apply(d,{...g,type:2});if(m!==null){d=m.data;let[y,v]=iT(d,{[g.id]:p});d=y;for(let x of v){let S=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[S]:p}}),f.push({type:0,path:x,props:{[S]:g.id}})}f.push(m.reverse),h.push(m.actual)}}else{let p=lr.apply(d,g);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof Hc)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(ix||(ix={}));var oT=Symbol(),qV=Symbol(),Mm=Symbol(),tl=class{reportOp(t,e,n=[]){let i=this;if(e===null)return;i._current=e.data;let s=n;for(;!(i instanceof Tm);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[Mm];n&&n(),delete this._children[t]}}}},ox=class extends tl{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,jc.runOp(this._current,t),t.path)}},ax=class extends tl{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Lt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},aT={get(r,t){if(t===Mm)return()=>{r._parent=null};if(t===oT)return r._current;if(t===qV)return r;let{_current:e,_children:n}=r;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e[t],o=Cm(r,t,s);return o!==s?(n===void 0&&(n={},r._children=n),n[t]=o,o):s},has(r,t){return t in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,t){let e=r._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},XV={...aT,set(r,t,e){let n={type:0,props:{[t]:Jn(e)??e}};return r.deleteChildren(t),r.runOp(n),!0},deleteProperty(r,t){let e={type:0,props:{[t]:void 0}};return r.deleteChildren(t),r.runOp(e),!0}},YV={...aT,set(r,t,e){return e===void 0?this.deleteProperty(r,t):(r.deleteChildren(t),r.runOp({type:1,id:t,data:e})),!0},deleteProperty(r,t){return r.runOp({type:2,id:t}),!0}},Xc=class extends tl{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Mm]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=Cm(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,i,s){this.runOp({type:7,parent:t,fi:e,id:n,data:i,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}moveBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Yc=class extends tl{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Mm]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),i,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id;if(t(this.data(i),i))return this.get(i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:n}=this,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=Cm(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function sx(r,t,e){if(r.length>0){let n=r[r.length-1];if(n.type===0&&t.type===0&&Er.equal(n.path,e)){Object.assign(n.props,t.props);return}}r.push({...t,path:e})}var Tm=class extends tl{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,n,i){sx(this.ts,e,t),sx(this.actual,n,t),sx(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Cm(r,t,e){return e instanceof Qt?new Xc(r,t,e):e instanceof He?new Yc(r,t,e):e instanceof Lt?new Proxy(new ax(r,t,e),YV):e!==null&&typeof e=="object"?Wc(e)?e:new Proxy(new ox(r,t,e),XV):e}function lx(r){let t=new Tm(r);return[Cm(t,"",r),t]}function Qc(r,t){let[e,n]=lx(r);return t(e),n.result()}function Jn(r){return r instanceof Xc||r instanceof Yc?r._current:r!==null&&typeof r=="object"?r[oT]:r}var Er;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function t(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof Qt||s instanceof Xc)&&typeof o=="string")return s.data(o);if((s instanceof He||s instanceof Yc)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=n})(Er||(Er={}));function lT(r,t){let e=[];if(t.length===r.length)for(var n=0;n<r.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}function Ni(r,t){let e=[];if(t.length<=r.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}var Pm=class{},Th=class extends Pm{constructor(e){super();this.id=e}},Mh=class extends Pm{constructor(e){super();this.data=e}};var ux;try{ux=new TextDecoder}catch{}var De,Jo,J=0;var gT=[],dx=gT,hx=0,Rr={},Mt,Zo,mi=0,hs=0,ri,oo,Tr=[],Dt,cT={useRecords:!1,mapsAsObjects:!0},Ch=class{},px=new Ch;px.name="MessagePack 0xC1";var Kc=!1,fs=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(De)return ST(()=>(Dm(),this?this.unpack(t,e):fs.prototype.unpack.call(cT,t,e)));Jo=e>-1?e:t.length,J=0,hx=0,hs=0,Zo=null,dx=gT,ri=null,De=t;try{Dt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw De=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof fs){if(Rr=this,this.structures)return Mt=this.structures,Im();(!Mt||Mt.length>0)&&(Mt=[])}else Rr=cT,(!Mt||Mt.length>0)&&(Mt=[]);return Im()}unpackMultiple(t,e){let n,i=0;try{Kc=!0;let s=t.length,o=this?this.unpack(t,s):Rm.unpack(t,s);if(e){for(e(o);J<s;)if(i=J,e(Im())===!1)return}else{for(n=[o];J<s;)i=J,n.push(Im());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Kc=!1,Dm()}}_mergeStructures(t,e){t=t||[];for(let n=0,i=t.length;n<i;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let i=t[n],s=e[n];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[n]=i),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Im(){try{if(!Rr.trusted&&!Kc){let t=Mt.sharedLength||0;t<Mt.length&&(Mt.length=t)}let r=ln();if(J==Jo)Mt.restoreStructures&&uT(),Mt=null,De=null,oo&&(oo=null);else if(J>Jo){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Kc)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw Mt.restoreStructures&&uT(),Dm(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function uT(){for(let r in Mt.restoreStructures)Mt[r]=Mt.restoreStructures[r];Mt.restoreStructures=null}function ln(){let r=De[J++];if(r<160)if(r<128){if(r<64)return r;{let t=Mt[r&63]||Rr.getStructures&&yT()[r&63];return t?(t.read||(t.read=mx(t,r&63)),t.read()):r}}else if(r<144)if(r-=128,Rr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[xT()]=ln();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(ln(),ln());return t}else{r-=144;let t=new Array(r);for(let e=0;e<r;e++)t[e]=ln();return t}else if(r<192){let t=r-160;if(hs>=J)return Zo.slice(J-mi,(J+=t)-mi);if(hs==0&&Jo<140){let e=t<16?gx(t):vT(t);if(e!=null)return e}return fx(t)}else{let t;switch(r){case 192:return null;case 193:return ri?(t=ln(),t>0?ri[1].slice(ri.position1,ri.position1+=t):ri[0].slice(ri.position0,ri.position0-=t)):px;case 194:return!1;case 195:return!0;case 196:return cx(De[J++]);case 197:return t=Dt.getUint16(J),J+=2,cx(t);case 198:return t=Dt.getUint32(J),J+=4,cx(t);case 199:return nl(De[J++]);case 200:return t=Dt.getUint16(J),J+=2,nl(t);case 201:return t=Dt.getUint32(J),J+=4,nl(t);case 202:if(t=Dt.getFloat32(J),Rr.useFloat32>2){let e=Lm[(De[J]&127)<<1|De[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=Dt.getFloat64(J),J+=8,t;case 204:return De[J++];case 205:return t=Dt.getUint16(J),J+=2,t;case 206:return t=Dt.getUint32(J),J+=4,t;case 207:return Rr.int64AsNumber?(t=Dt.getUint32(J)*4294967296,t+=Dt.getUint32(J+4)):t=Dt.getBigUint64(J),J+=8,t;case 208:return Dt.getInt8(J++);case 209:return t=Dt.getInt16(J),J+=2,t;case 210:return t=Dt.getInt32(J),J+=4,t;case 211:return Rr.int64AsNumber?(t=Dt.getInt32(J)*4294967296,t+=Dt.getUint32(J+4)):t=Dt.getBigInt64(J),J+=8,t;case 212:if(t=De[J++],t==114)return mT(De[J++]&63);{let e=Tr[t];if(e)return e.read?(J++,e.read(ln())):e.noBuffer?(J++,e()):e(De.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=De[J],t==114?(J++,mT(De[J++]&63,De[J++])):nl(2);case 214:return nl(4);case 215:return nl(8);case 216:return nl(16);case 217:return t=De[J++],hs>=J?Zo.slice(J-mi,(J+=t)-mi):KV(t);case 218:return t=Dt.getUint16(J),J+=2,hs>=J?Zo.slice(J-mi,(J+=t)-mi):ZV(t);case 219:return t=Dt.getUint32(J),J+=4,hs>=J?Zo.slice(J-mi,(J+=t)-mi):JV(t);case 220:return t=Dt.getUint16(J),J+=2,hT(t);case 221:return t=Dt.getUint32(J),J+=4,hT(t);case 222:return t=Dt.getUint16(J),J+=2,fT(t);case 223:return t=Dt.getUint32(J),J+=4,fT(t);default:if(r>=224)return r-256;if(r===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+r)}}}var QV=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function mx(r,t){function e(){if(e.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>QV.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(ln);return r.highByte===0&&(r.read=dT(t,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=ln()}return n}return e.count=0,r.highByte===0?dT(t,e):e}var dT=(r,t)=>function(){let e=De[J++];if(e===0)return t();let n=r<32?-(r+(e<<5)):r+(e<<5),i=Mt[n]||yT()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=mx(i,r)),i.read()};function yT(){let r=ST(()=>(De=null,Rr.getStructures()));return Mt=Rr._mergeStructures(r,Mt)}var fx=Om,KV=Om,ZV=Om,JV=Om;function Om(r){let t;if(r<16&&(t=gx(r)))return t;if(r>64&&ux)return ux.decode(De.subarray(J,J+=r));let e=J+r,n=[];for(t="";J<e;){let i=De[J++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=De[J++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=De[J++]&63,o=De[J++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=De[J++]&63,o=De[J++]&63,a=De[J++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(t+=$n.apply(String,n),n.length=0)}return n.length>0&&(t+=$n.apply(String,n)),t}function hT(r){let t=new Array(r);for(let e=0;e<r;e++)t[e]=ln();return t}function fT(r){if(Rr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[xT()]=ln();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(ln(),ln());return t}}var $n=String.fromCharCode;function vT(r){let t=J,e=new Array(r);for(let n=0;n<r;n++){let i=De[J++];if((i&128)>0){J=t;return}e[n]=i}return $n.apply(String,e)}function gx(r){if(r<4)if(r<2){if(r===0)return"";{let t=De[J++];if((t&128)>1){J-=1;return}return $n(t)}}else{let t=De[J++],e=De[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(r<3)return $n(t,e);let n=De[J++];if((n&128)>0){J-=3;return}return $n(t,e,n)}else{let t=De[J++],e=De[J++],n=De[J++],i=De[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(i&128)>0){J-=4;return}if(r<6){if(r===4)return $n(t,e,n,i);{let s=De[J++];if((s&128)>0){J-=5;return}return $n(t,e,n,i,s)}}else if(r<8){let s=De[J++],o=De[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(r<7)return $n(t,e,n,i,s,o);let a=De[J++];if((a&128)>0){J-=7;return}return $n(t,e,n,i,s,o,a)}else{let s=De[J++],o=De[J++],a=De[J++],l=De[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(r<10){if(r===8)return $n(t,e,n,i,s,o,a,l);{let u=De[J++];if((u&128)>0){J-=9;return}return $n(t,e,n,i,s,o,a,l,u)}}else if(r<12){let u=De[J++],c=De[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(r<11)return $n(t,e,n,i,s,o,a,l,u,c);let d=De[J++];if((d&128)>0){J-=11;return}return $n(t,e,n,i,s,o,a,l,u,c,d)}else{let u=De[J++],c=De[J++],d=De[J++],h=De[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(r<14){if(r===12)return $n(t,e,n,i,s,o,a,l,u,c,d,h);{let f=De[J++];if((f&128)>0){J-=13;return}return $n(t,e,n,i,s,o,a,l,u,c,d,h,f)}}else{let f=De[J++],g=De[J++];if((f&128)>0||(g&128)>0){J-=14;return}if(r<15)return $n(t,e,n,i,s,o,a,l,u,c,d,h,f,g);let p=De[J++];if((p&128)>0){J-=15;return}return $n(t,e,n,i,s,o,a,l,u,c,d,h,f,g,p)}}}}}function cx(r){return Rr.copyBuffers?Uint8Array.prototype.slice.call(De,J,J+=r):De.subarray(J,J+=r)}function nl(r){let t=De[J++];if(Tr[t])return Tr[t](De.subarray(J,J+=r));throw new Error("Unknown extension type "+t)}var pT=new Array(4096);function xT(){let r=De[J++];if(r>=160&&r<192){if(r=r-160,hs>=J)return Zo.slice(J-mi,(J+=r)-mi);if(!(hs==0&&Jo<180))return fx(r)}else return J--,ln();let t=(r<<5^(r>1?Dt.getUint16(J):r>0?De[J]:0))&4095,e=pT[t],n=J,i=J+r-3,s,o=0;if(e&&e.bytes==r){for(;n<i;){if(s=Dt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=De[n++],s!=e[o++]){n=1879048192;break}if(n===i)return J=n,e.string;i-=3,n=J}for(e=[],pT[t]=e,e.bytes=r;n<i;)s=Dt.getUint32(n),e.push(s),n+=4;for(i+=3;n<i;)s=De[n++],e.push(s);let a=r<16?gx(r):vT(r);return a!=null?e.string=a:e.string=fx(r)}var mT=(r,t)=>{var e=ln();let n=r;t!==void 0&&(r=r<32?-((t<<5)+r):(t<<5)+r,e.highByte=t);let i=Mt[r];return i&&i.isShared&&((Mt.restoreStructures||(Mt.restoreStructures=[]))[r]=i),Mt[r]=e,e.read=mx(e,n),e.read()},bT=typeof self=="object"?self:global;Tr[0]=()=>{};Tr[0].noBuffer=!0;Tr[101]=()=>{let r=ln();return(bT[r[0]]||Error)(r[1])};Tr[105]=r=>{let t=Dt.getUint32(J-4);oo||(oo=new Map);let e=De[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let i={target:n};oo.set(t,i);let s=ln();return i.used?Object.assign(n,s):(i.target=s,s)};Tr[112]=r=>{let t=Dt.getUint32(J-4),e=oo.get(t);return e.used=!0,e.target};Tr[115]=()=>new Set(ln());var yx=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");Tr[116]=r=>{let t=r[0],e=yx[t];if(!e)throw new Error("Could not find typed array for code "+t);return new bT[e](Uint8Array.prototype.slice.call(r,1).buffer)};Tr[120]=()=>{let r=ln();return new RegExp(r[0],r[1])};Tr[98]=r=>{let t=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],e=J;J+=t-4,ri=[ln(),ln()],ri.position0=0,ri.position1=0;let n=J;J=e;try{return ln()}finally{J=n}};Tr[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function ST(r){let t=Jo,e=J,n=hx,i=mi,s=hs,o=Zo,a=dx,l=oo,u=ri,c=new Uint8Array(De.slice(0,Jo)),d=Mt,h=Mt.slice(0,Mt.length),f=Rr,g=Kc,p=r();return Jo=t,J=e,hx=n,mi=i,hs=s,Zo=o,dx=a,oo=l,ri=u,De=c,Kc=g,Mt=d,Mt.splice(0,Mt.length,...h),Rr=f,Dt=new DataView(De.buffer,De.byteOffset,De.byteLength),p}function Dm(){De=null,oo=null,Mt=null}function wT(r){r.unpack?Tr[r.type]=r.unpack:Tr[r.type]=r}var Lm=new Array(147);for(let r=0;r<256;r++)Lm[r]=+("1e"+Math.floor(45.15-r*.30103));var Rm=new fs({useRecords:!1}),$V=Rm.unpack,e4=Rm.unpackMultiple,t4=Rm.unpack,Nm={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},n4=new Float32Array(1),Aee=new Uint8Array(n4.buffer,0,4);var Bm;try{Bm=new TextEncoder}catch{}var Fm,xx,km=typeof Buffer<"u",vx=km?Buffer.allocUnsafeSlow:Uint8Array,TT=km?Buffer:Uint8Array,AT=km?4294967296:2144337920,oe,mn,ne=0,ps,ms=null,r4=/[\u0080-\uFFFF]/,Ph=Symbol("record-id"),rl=class extends fs{constructor(t){super(t),this.offset=0;let e,n,i,s,o,a,l=0,u=TT.prototype.utf8Write?function(b,T,M){return oe.utf8Write(b,T,M)}:Bm&&Bm.encodeInto?function(b,T){return Bm.encodeInto(b,oe.subarray(T)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let g=t.maxOwnStructures;g==null&&(g=h?32:64),d&&!t.saveStructures&&(this.structures=[]);let p=f>32||g+f>64,m=f+64,y=f+g+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,S=0;this.pack=this.encode=function(b,T){if(oe||(oe=new vx(8192),mn=new DataView(oe.buffer,0,8192),ne=0),ps=oe.length-10,ps-ne<2048?(oe=new vx(oe.length),mn=new DataView(oe.buffer,0,oe.length),ps=oe.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(ms=["",""],oe[ne++]=214,oe[ne++]=98,ms.position=ne-n,ne+=4):ms=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let M=i.sharedLength||0;if(M>f)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 I=0;I<M;I++){let P=i[I];if(!P)continue;let C,D=i.transitions;for(let R=0,U=P.length;R<U;R++){let Y=P[R];C=D[Y],C||(C=D[Y]=Object.create(null)),D=C}D[Ph]=I+64}l=M}d||(i.nextId=M+64)}s&&(s=!1),o=i||[];try{if(w(b),ms){mn.setUint32(ms.position+n,ne-ms.position-n);let M=ms;ms=null,w(M[0]),w(M[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>ps&&E(ne),c.offset=ne;let M=s4(oe.subarray(n,ne),a.idsToInsert);return a=null,M}return T&CT?(oe.start=n,oe.end=ne,oe):oe.subarray(n,ne)}finally{if(i){if(S<10&&S++,x>1e4)i.transitions=null,S=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,I=v.length;M<I;M++)v[M][Ph]=0;v=[]}if(s&&c.saveStructures){let M=i.sharedLength||f;i.length>M&&(i=i.slice(0,M));let I=oe.subarray(n,ne);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=M,I)}}T&h4&&(ne=n)}};let w=b=>{ne>ps&&(oe=E(ne));var T=typeof b,M;if(T==="string"){let I=b.length;if(ms&&I>=8&&I<4096){let D=r4.test(b);ms[D?0:1]+=b,oe[ne++]=193,w(D?-I:I);return}let P;I<32?P=1:I<256?P=2:I<65536?P=3:P=5;let C=I*3;if(ne+C>ps&&(oe=E(ne+C)),I<64||!u){let D,R,U,Y=ne+P;for(D=0;D<I;D++)R=b.charCodeAt(D),R<128?oe[Y++]=R:R<2048?(oe[Y++]=R>>6|192,oe[Y++]=R&63|128):(R&64512)===55296&&((U=b.charCodeAt(D+1))&64512)===56320?(R=65536+((R&1023)<<10)+(U&1023),D++,oe[Y++]=R>>18|240,oe[Y++]=R>>12&63|128,oe[Y++]=R>>6&63|128,oe[Y++]=R&63|128):(oe[Y++]=R>>12|224,oe[Y++]=R>>6&63|128,oe[Y++]=R&63|128);M=Y-ne-P}else M=u(b,ne+P,C);M<32?oe[ne++]=160|M:M<256?(P<2&&oe.copyWithin(ne+2,ne+1,ne+1+M),oe[ne++]=217,oe[ne++]=M):M<65536?(P<3&&oe.copyWithin(ne+3,ne+2,ne+2+M),oe[ne++]=218,oe[ne++]=M>>8,oe[ne++]=M&255):(P<5&&oe.copyWithin(ne+5,ne+3,ne+3+M),oe[ne++]=219,mn.setUint32(ne,M),ne+=4),ne+=M}else if(T==="number")if(b>>>0===b)b<64?oe[ne++]=b:b<256?(oe[ne++]=204,oe[ne++]=b):b<65536?(oe[ne++]=205,oe[ne++]=b>>8,oe[ne++]=b&255):(oe[ne++]=206,mn.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?oe[ne++]=256+b:b>=-128?(oe[ne++]=208,oe[ne++]=b+256):b>=-32768?(oe[ne++]=209,mn.setInt16(ne,b),ne+=2):(oe[ne++]=210,mn.setInt32(ne,b),ne+=4);else{let I;if((I=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){oe[ne++]=202,mn.setFloat32(ne,b);let P;if(I<4||(P=b*Lm[(oe[ne]&127)<<1|oe[ne+1]>>7])>>0===P){ne+=4;return}else ne--}oe[ne++]=203,mn.setFloat64(ne,b),ne+=8}else if(T==="object")if(!b)oe[ne++]=192;else{if(a){let P=a.get(b);if(P){if(!P.id){let C=a.idsToInsert||(a.idsToInsert=[]);P.id=C.push(P)}oe[ne++]=214,oe[ne++]=112,mn.setUint32(ne,P.id),ne+=4;return}else a.set(b,{offset:ne-n})}let I=b.constructor;if(I===Object)_(b,!0);else if(I===Array){M=b.length,M<16?oe[ne++]=144|M:M<65536?(oe[ne++]=220,oe[ne++]=M>>8,oe[ne++]=M&255):(oe[ne++]=221,mn.setUint32(ne,M),ne+=4);for(let P=0;P<M;P++)w(b[P])}else if(I===Map){M=b.size,M<16?oe[ne++]=128|M:M<65536?(oe[ne++]=222,oe[ne++]=M>>8,oe[ne++]=M&255):(oe[ne++]=223,mn.setUint32(ne,M),ne+=4);for(let[P,C]of b)w(P),w(C)}else{for(let P=0,C=Fm.length;P<C;P++){let D=xx[P];if(b instanceof D){let R=Fm[P];if(R.write){R.type&&(oe[ne++]=212,oe[ne++]=R.type,oe[ne++]=0),w(R.write.call(this,b));return}let U=oe,Y=mn,W=ne;oe=null;let q;try{q=R.pack.call(this,b,j=>(oe=U,U=null,ne+=j,ne>ps&&E(ne),{target:oe,targetView:mn,position:ne-j}),w)}finally{U&&(oe=U,mn=Y,ne=W,ps=oe.length-10)}q&&(q.length+ne>ps&&E(q.length+ne),ne=i4(q,oe,ne,R.type));return}}_(b,!b.hasOwnProperty)}}else if(T==="boolean")oe[ne++]=b?195:194;else if(T==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))oe[ne++]=211,mn.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)oe[ne++]=207,mn.setBigUint64(ne,b);else if(this.largeBigIntToFloat)oe[ne++]=203,mn.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(T==="undefined")this.encodeUndefinedAsNil?oe[ne++]=192:(oe[ne++]=212,oe[ne++]=0,oe[ne++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},_=this.useRecords===!1?this.variableMapSize?b=>{let T=Object.keys(b),M=T.length;M<16?oe[ne++]=128|M:M<65536?(oe[ne++]=222,oe[ne++]=M>>8,oe[ne++]=M&255):(oe[ne++]=223,mn.setUint32(ne,M),ne+=4);let I;for(let P=0;P<M;P++)w(I=T[P]),w(b[I])}:(b,T)=>{oe[ne++]=222;let M=ne-n;ne+=2;let I=0;for(let P in b)(T||b.hasOwnProperty(P))&&(w(P),w(b[P]),I++);oe[M+++n]=I>>8,oe[M+n]=I&255}:b=>{let T=Object.keys(b),M,I=o.transitions||(o.transitions=Object.create(null)),P=0;for(let D=0,R=T.length;D<R;D++){let U=T[D];M=I[U],M||(M=I[U]=Object.create(null),P++),I=M}let C=I[Ph];if(C)C>=96&&p?(oe[ne++]=((C-=96)&31)+96,oe[ne++]=C>>5):oe[ne++]=C;else{C=o.nextId,C||(C=64),C<m&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(C=o.nextOwnId,C<y||(C=m),o.nextOwnId=C+1):(C>=y&&(C=m),o.nextId=C+1);let D=T.highByte=C>=96&&p?C-96>>5:-1;I[Ph]=C,o[C-64]=T,C<m?(T.isShared=!0,o.sharedLength=C-63,s=!0,D>=0?(oe[ne++]=(C&31)+96,oe[ne++]=D):oe[ne++]=C):(D>=0?(oe[ne++]=213,oe[ne++]=114,oe[ne++]=(C&31)+96,oe[ne++]=D):(oe[ne++]=212,oe[ne++]=114,oe[ne++]=C),P&&(x+=S*P),v.length>=g&&(v.shift()[Ph]=0),v.push(I),w(T))}for(let D=0,R=T.length;D<R;D++)w(b[T[D]])},E=b=>{let T;if(b>16777216){if(b-n>AT)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(AT,Math.round(Math.max((b-n)*(b>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(b-n<<2,oe.length-1)>>12)+1<<12;let M=new vx(T);return mn=new DataView(M.buffer,0,T),oe.copy?oe.copy(M,0,n,b):M.set(oe.slice(n,b)),ne-=n,n=0,ps=M.length-10,oe=M}}useBuffer(t){oe=t,mn=new DataView(oe.buffer,oe.byteOffset,oe.byteLength),ne=0}};xx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ch];Fm=[{pack(r,t,e){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,t,e){let n=Array.from(r),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(n)}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),e([r.name,r.message])}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),e([r.source,r.flags])}},{pack(r,t){this.structuredClone?_T(r,16,t):ET(km?Buffer.from(r):new Uint8Array(r),t)}},{pack(r,t){let e=r.constructor;e!==TT&&this.structuredClone?_T(r,yx.indexOf(e.name),t):ET(r,t)}},{pack(r,t){let{target:e,position:n}=t(1);e[n]=193}}];function _T(r,t,e,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function ET(r,t){let e=r.byteLength;var n,i;if(e<256){var{target:n,position:i}=t(e+2);n[i++]=196,n[i++]=e}else if(e<65536){var{target:n,position:i}=t(e+3);n[i++]=197,n[i++]=e>>8,n[i++]=e&255}else{var{target:n,position:i,targetView:s}=t(e+5);n[i++]=198,s.setUint32(i,e),i+=4}n.set(r,i)}function i4(r,t,e,n){let i=r.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=n,t.set(r,e),e+=i,e}function s4(r,t){let e,n=t.length*6,i=r.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function $o(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");xx.unshift(r.Class),Fm.unshift(r)}wT(r)}var MT=new rl({useRecords:!1}),o4=MT.pack,a4=MT.pack;var{NEVER:l4,ALWAYS:c4,DECIMAL_ROUND:u4,DECIMAL_FIT:d4}=Nm,CT=512,h4=1024;var PT=new rl({structuredClone:!0});$o({Class:Lt.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Lt.prototype),r}});$o({Class:He.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,He.prototype),r}});$o({Class:Qt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Qt.prototype),r}});$o({Class:Th.prototype.constructor,type:4,write(r){return r.id},read(r){return new Th(r)}});$o({Class:Mh.prototype.constructor,type:5,write(r){return r.data},read(r){return new Mh(r)}});$o({Class:Kt.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Kt.prototype),r}});function f4(r){var t=0;if(r.length===0)return t;for(let e=0;e<r.length;e++){let n=r[e];t=(t<<5)-t+n,t=t&t}return t}function bx(r){if(Wc(r))return r;if(Array.isArray(r))return r.map(bx);if(typeof r=="object"&&r!==null){let t={};for(let e of Object.keys(r).sort())t[e]=bx(r[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else return r}var Um;(n=>{function r(i){return PT.pack(i)}n.serialize=r;function t(i){return PT.unpack(i)}n.deserialize=t;function e(i){return f4(r(bx(i))).toString()}n.checksum=e})(Um||(Um={}));var ao={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Audio","Create"],["MouseHover"]:["Transition","Create","Destroy","SwitchCamera"],["Scroll"]:["Transition","Create"],["Start"]:["Transition","Audio","Video","Create","Destroy","SwitchCamera"],["Conditional"]:["Transition","Audio","Video","Create","Destroy","SwitchCamera","Reset"],["MouseDown"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["MouseUp"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["MousePress"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],["KeyDown"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["KeyUp"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["KeyPress"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],["GameControl"]:["Transition","Audio","Video","Create"],["Collision"]:["Transition","Audio","Video","Create","Destroy","Reset"]},IT;(e=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=r;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,toggle:!1,actions:new He}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new He}}e.defaultData=t})(IT||(IT={}));var Gm;(e=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=r,e.valueDefaultData={type:"Literal",value:0}})(Gm||(Gm={}));var Sx;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:Gm.propertyDefaultData(i),rOperand:{...Gm.valueDefaultData}}}n.comparisonDefaultData=r;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=e})(Sx||(Sx={}));var DT;(e=>{function r(n){return n.type==="Conditional"}e.is=r;function t(n){return{type:"Conditional",disabled:!1,inActions:new He,outActions:new He,condition:Sx.distanceDefaultData(n)}}e.defaultData=t})(DT||(DT={}));var OT;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new He,drop:new He}})(OT||(OT={}));var zm;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new He})(zm||(zm={}));var Vm;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Vm||(Vm={}));var LT;(e=>{function r(n){return n.type==="MouseHover"}e.is=r;function t(){return{type:"MouseHover",disabled:!1,actions:new He}}e.defaultData=t})(LT||(LT={}));var RT;(e=>{function r(n){return n.type==="Scroll"}e.is=r;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new He}}e.defaultData=t})(RT||(RT={}));var NT;(e=>{function r(n){return n.type==="Start"}e.is=r;function t(){return{type:"Start",disabled:!1,actions:new He}}e.defaultData=t})(NT||(NT={}));var BT;(e=>{function r(n){return n.type==="Collision"}e.is=r;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new He}}e.defaultData=t})(BT||(BT={}));var il;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}e.lerp=t})(il||(il={}));var gs;(a=>{function r(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=r;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function i(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=i;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(gs||(gs={}));var Ih;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}e.lerp=t})(Ih||(Ih={}));var ea;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=t;function e(s){return s??i.identity}i.simplify=e;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}i.applyMatrix4=n})(ea||(ea={}));var er;(u=>{function r(c){return typeof c=="object"&&typeof c.r=="number"&&typeof c.g=="number"&&typeof c.b=="number"}u.isRGB=r,u.white={r:1,g:1,b:1},u.red={r:1,g:0,b:0},u.black={r:0,g:0,b:0};function i(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}u.toRgb255a1=i;function s(c){return{r:c.r,g:c.g,b:c.b}}u.clone=s;function o(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}u.fromHex=o;function a(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}u.equals=a;function l(c,d,h){return{r:c.r+(d.r-c.r)*h,g:c.g+(d.g-c.g)*h,b:c.b+(d.b-c.b)*h}}u.lerp=l})(er||(er={}));var Nr;(a=>{a.white={...er.white,a:1},a.transparent={...er.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...er.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return er.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Nr||(Nr={}));var Hm;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Hm||(Hm={}));var FT;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(FT||(FT={}));var kT;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(kT||(kT={}));var Bi;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(Bi||(Bi={}));var sl;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(sl||(sl={}));var ys;(e=>{function r(n,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*i,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=r;function t(n,i){let s={...n};if(wx.forEach(o=>{Object.assign(s,{[o]:i[o]??n[o]})}),s.radial={...n.radial},i.radial){let o=n.radial,a=i.radial;Ax.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},i.linear){let o=n.linear,a=i.linear;_x.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},i.grid){let o=n.grid,a=i.grid;Ex.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},i.toObject){let o=n.toObject,a=i.toObject;Tx.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},i.randomnessObject){let o=n.randomnessObject,a=i.randomnessObject;Mx.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(ys||(ys={}));var Wm;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(Wm||(Wm={}));var wx=["count"],Ax=["radius","start","end","position","scale","rotation"],_x=["position","scale","rotation"],Ex=["count","size"],Tx=["count","position","scale","rotation"],Mx=["strength","scale","rotation","position","movement","seed","freqScale"];var ol;(e=>{let r={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(ol||(ol={}));var jm;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(jm||(jm={}));var qm;(e=>{function r(n){return t(n)}e.defaultData=r;function t(n){if(n==="PointLight")return{type:n,color:Nr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:Nr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Nr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(qm||(qm={}));var Cx;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}e.equals=t})(Cx||(Cx={}));var Px;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}e.equals=t})(Px||(Px={}));var Xm;(t=>t.defaultData={...Px.defaultData,...Cx.defaultData})(Xm||(Xm={}));var Zc;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Zc||(Zc={}));var UT;(t=>{function r(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=r})(UT||(UT={}));function zT(r){return r.type!=="displace"}var GT;(t=>{function r(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=r})(GT||(GT={}));var Ym=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],VT=["wrapping","image","video"],Mr;(i=>{function r(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}i.patch=r;function t(s,o){return s==="light"&&o?e(o):n(s)}i.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1}}}function n(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Zc.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:er.fromHex(5526619)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...er.fromHex(6710886),a:1},colorB:{...er.fromHex(6710886),a:1},colorC:{...er.fromHex(16777215),a:1},colorD:{...er.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:Nr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Nr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Nr.fromHexAndA(0,1),contourColor:Nr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...er.fromHex(0),a:1},colorB:{...er.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Mr||(Mr={}));var tr;(l=>{function r(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=r;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${f}`,Array.isArray(f)?f.forEach(g=>c+=`${g}`):typeof f=="object"?Object.values(f).forEach(g=>{typeof g=="number"?c+=`${g.toFixed(4)}`:c+=`${g}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new He}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function i(u,c){return{...u,name:c}}l.withName=i;function s(u,c="layer1",d="layer2"){let h=new He;return h.push({fi:0,data:Mr.defaultData("light",u),id:c}),h.push({fi:1,data:Mr.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=Mr.defaultData("texture");Object.assign(f.texture,{image:u});let g=new He;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:Mr.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=Mr.defaultData("video");Object.assign(f.texture,{video:u});let g=new He;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:Mr.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerVideoTextureData=a})(tr||(tr={}));var Jc;(t=>{function r(){return{points:new He,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=r})(Jc||(Jc={}));var $c;(t=>{function r(){return{points:new He,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=r})($c||($c={}));var Ix={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var Qm;(t=>{function r(e,n){let i={...e};return Dx.forEach(s=>{Object.assign(i,{[s]:n[s]??e[s]})}),i}t.merge=r})(Qm||(Qm={}));var Km={shape:Ix,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},Dx=["depth","offset","angle","twist","startScale","endScale"];var Dh;(e=>{function r(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=r;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(Dh||(Dh={}));var Zm;(t=>{function r(e,n){let i={...e};return Object.assign(i,n),i.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Qm.merge(i.extrusion,n.extrusion))),i}t.merge=r})(Zm||(Zm={}));var ta;(t=>{function r(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:$c.defaultData(),extrusion:Km};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Jc.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}t.defaultData=r})(ta||(ta={}));var Ox=["width","height","depth"];function HT(r){for(let t of Object.keys(r))r[t]===void 0&&delete r[t];return r}function ki(r,t){return Object.setPrototypeOf(r,t),r}var p4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),m4=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),g4=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||al&&"ontouchend"in document,y4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,v4=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,x4=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(t)},b4=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},Mte=p4(),al=m4(),Jm=g4(),WT=y4(),kn=v4(),Lx=x4(),Rx=Number(b4());function $m(r){return Array.isArray(r)?r:[r]}function jT(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}function Oh(r){return al?r.metaKey:r.ctrlKey}var Ue=[],tg={},Lh={},eg={};function qT(r){Ue.includes(r)||Ue.push(r)}function eu(r){delete tg[r.pointerId];for(let t=0;t<Ue.length;t++)if(Ue[t].pointerId===r.pointerId){Ue.splice(t,1);break}}function XT(){Ue.splice(0,Ue.length)}function ng(r){if(r.pointerType!=="touch")return;let t=tg[r.pointerId];t===void 0&&(t={x:0,y:0},tg[r.pointerId]=t),t.x=r.pageX,t.y=r.pageY}function rg(r){let t=r.pointerId===Ue[0].pointerId?Ue[1]:Ue[0];return tg[t.pointerId]}function YT(r){Lh[r.key]=!0,eg[r.key]=eg[r.key]===void 0?1:eg[r.key]+1}function QT(r){if(al&&Lh.Meta)for(let t in Lh)Lh[t]=!1;else Lh[r.key]=!1;eg={}}function KT(r){r.addEventListener("pointerdown",qT,!0),r.addEventListener("pointerdown",ng,!0),r.addEventListener("pointermove",ng,!0),r.addEventListener("pointerup",eu,!0),r.addEventListener("pointercancel",eu,!0),r.addEventListener("pointerleave",eu,!0),window.addEventListener("keydown",YT,!0),window.addEventListener("keyup",QT,!0)}function ZT(r){r.removeEventListener("pointerdown",qT,!0),r.removeEventListener("pointerdown",ng,!0),r.removeEventListener("pointermove",ng,!0),r.removeEventListener("pointerup",eu,!0),r.removeEventListener("pointercancel",eu,!0),r.removeEventListener("pointerleave",eu,!0),window.removeEventListener("keydown",YT,!0),window.removeEventListener("keyup",QT,!0)}var JT;(e=>{function r(n){return n==="Component"||n==="Instance"}e.isComponentRelated=r;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(JT||(JT={}));var tu;(i=>{i.identity={...Hm.identity,hiddenMatrix:ea.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function n(s,o){return HT({position:gs.isEqual(s.position,o.position)?void 0:o.position,rotation:gs.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:gs.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:ea.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=n})(tu||(tu={}));var $T;(t=>t.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})($T||($T={}));var ii;(t=>t.defaultData={states:new He,events:new He,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...tu.identity,cloner:null})(ii||(ii={}));var eM;(t=>t.defaultData={type:"Empty",...ii.defaultData})(eM||(eM={}));var tM;(t=>t.defaultData={type:"Component",...ii.defaultData})(tM||(tM={}));var ll;(t=>t.defaultData={type:"Mesh",...ii.defaultData,...Xm.defaultData})(ll||(ll={}));var nu;(t=>t.defaultData={...ii.defaultData,...tu.identity,...sl.defaultData})(nu||(nu={}));var ig;(t=>{function r(e){return{...ii.defaultData,...qm.defaultData(e)}}t.defaultData=r})(ig||(ig={}));var ru;(e=>{function r(n,i,s=0){for(;s<i.length;){let o=n?n[i[s]]:void 0;if(i.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=r;function t(n,i,s=0){let o=r(n,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(ru||(ru={}));var na;(s=>{s.rootOverrideProps=["physics"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...ii.defaultData,...a,component:o,overrides:new Kt,physics:void 0,type:"Instance"}}s.ofComponent=n;function i(o){let a=tu.fromObject(o.data);return n(o.id,a)}s.fromComponentData=i})(na||(na={}));var sg;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:ea.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new He,events:new He,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...sl.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...ii.defaultData,...ll.defaultData,geometry:ta.defaultData("RectangleGeometry"),material:tr.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...ii.defaultData,...ll.defaultData,geometry:ta.defaultData("BooleanGeometry"),material:tr.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...ii.defaultData,...ll.defaultData,geometry:ta.defaultData("TextGeometry"),material:tr.defaultTwoLayerData("phong","layer1","layer2")}))(sg||(sg={}));var lo;(i=>{function r(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Kt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Kt})))):Bi.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=r;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Qc(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&Mr.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Qc(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&Mr.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,g]of Object.entries(h.layers)){let{texture:p,...m}=g;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...d,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(m).length>0){let y={path:[...d,"layers",f],props:m,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...Wm.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,g]of Object.entries(h))c(["materials",f],g);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}i.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,tu.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Bi.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Zm.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:ys.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:ys.merge(a.cloner,o.cloner)});else if(jm.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=er.clone(l.color))}return a}i.patch=n})(lo||(lo={}));var Nh;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:er.white,near:.1,far:2e3})(Nh||(Nh={}));var iu;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(iu||(iu={}));var co;(t=>t.defaultData={orbitControls:iu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null,hdTransmission:!1})(co||(co={}));var Cr;(t=>t.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(Cr||(Cr={}));var og;(o=>{o.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a={withLight:!0,withSquare:!0}){let l=new Qt,u=sg.defaultMeshObject;return a.withLight===!0&&l.push({fi:-1,data:{...ig.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),a.withSquare===!0&&l.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:u,children:[]}),l}o.defaultData={backgroundColor:Nr.fromHexAndA(2960946,1),postprocessing:ol.defaultData,fog:Nh.defaultData,objects:t(),environment:Cr.defaultData,publish:co.defaultData},o.emptyData=function(a){return{backgroundColor:Nr.fromHexAndA(2960946,1),postprocessing:ol.defaultData,fog:Nh.defaultData,objects:a?t(a):new Qt,environment:Cr.defaultData,publish:co.defaultData}};function i(a){return{...o.defaultData,objects:ki(a,Qt.prototype)}}o.withObjs=i;function s(a,l){return i([{id:a,data:l,children:[],fi:0}])}o.withObj=s})(og||(og={}));var su;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(su||(su={}));var ou;(n=>{function r(){let i={};return i["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ki(i,Lt.prototype)}n.defaultColors=r;function t(i){let s={};return i?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...su.emptyImage,name:"AI generated image"}),ki(s,Lt.prototype)}n.defaultImages=t;function e(){return{materials:new Lt,images:new Lt,videos:new Lt,colors:new Lt,audios:new Lt,fonts:new Lt,penumbraSize:[2,2,2]}}n.emptyData=e})(ou||(ou={}));function nM(r){r.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,i=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Ko(Jn(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Jn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Bh(r,t){Object.values(r.shared.materials).forEach(e=>t(e))}function Fh(r,t){r.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&t(i)}):"material"in n&&typeof n.material!="string"&&t(n.material)})}function w4(r){Object.assign(r.scene.publish,{orbitControls:{...iu.defaultData,...Jn(r.scene.publish.orbitControls)}})}function A4(r){Object.assign(r.scene.publish.settings,{video:{...co.defaultData.settings.video,...Jn(r.scene.publish.settings.video)}})}function _4(r){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[i,s]of Object.entries(n))if((Ym.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(VT.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((e,n)=>{n.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function E4(r){r.scene.publish.withBackground=!0}function T4(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function M4(r){r.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function C4(r){r.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function P4(r){r.scene.objects.traverse((t,e)=>{let n=r.scene.objects.unproxy().parent(t);if(n){let i=Jn(r.scene.objects.data(n));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Jn(e).booleanExclude!==!0)}})}function I4(r){r.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function D4(r){function t(n){Object.setPrototypeOf(n,Kt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Kt.prototype)}function e(n){Object.setPrototypeOf(n,Kt.prototype);for(let i in n)t(n[i])}r.scene.objects.traverse((n,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=Jn(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=Jn(l).layers;e(u),l.layers=u}})})}function rM(r){r.layers===void 0&&Object.assign(r,tr.defaultTwoLayerData("lambert"))}function Nx(r){!r.layers||r.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let n=[...t.steps];n.push(t.steps[9]);let i={...Jn(t),colors:e,steps:n};Object.assign(t,i)}})}function O4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function iM(r){r.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&Nx(n)}):"material"in e&&typeof e.material!="string"&&Nx(e.material)}),Object.values(r.shared.materials).forEach(t=>Nx(t))}function L4(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function R4(r){r.shared.audios=ki({},Lt.prototype)}function N4(r){r.shared.videos=ki({},Lt.prototype)}function B4(r){let t=r.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:i})}})}function F4(r){Object.entries(Jn(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(Jn(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function k4(r){r.scene.publish.settings.web.preload=!1}function sM(r){r.layers&&r.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function oM(r){r.layers&&r.layers.forEach(t=>{zT(t)&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle=0,t.highCut=1,t.lowCut=0,t.smoothness=.3,t.seed=0,t.quality=1)})}function U4(r){r.shared.fonts=ki({},Lt.prototype)}function G4(r){return r.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function z4(r){let t=[];r.scene.objects.traverse((e,n)=>{let i=n;if(i.type==="TextFrame"){let s=tr.defaultTwoLayerData("phong"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=G4(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...ii.defaultData,...ll.defaultData,flatShading:!1,wireframe:!1,geometry:{...ta.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Jn(i.states),events:Jn(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=Jn(r.scene.objects).parent(e);r.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{r.scene.objects.delete(e)})}function V4(r){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((e,n)=>{n.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new He,move:new He,jump:new He}});else{let s=new He;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:Ve.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Ko(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new He({fi:0,id:Ve.generateUUID(),data:u},{fi:1,id:Ve.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function H4(r){r.scene.objects.traverse((t,e)=>{function n(i,s){let o=new He,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Ko(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...Ko(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Ve.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function aM(r){let t=r.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Mr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function lM(r){Bh(r,aM),Fh(r,aM)}function W4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function j4(r){r.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function q4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=tr.defaultTwoLayerData("phong"))})}function X4(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function Y4(r){r.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function Q4(r){r.scene.publish.mouseEventTarget===void 0&&(r.scene.publish.mouseEventTarget="canvas"),r.scene.publish.settings.web.hint===void 0&&(r.scene.publish.settings.web.hint=!1)}function K4(r){let{video:t}=r.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function Z4(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function J4(r){let t=r.scene.environment.usePhysics;r.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}var cM=38;function uM(r){let t=r.schema??0;t!==cM&&(console.warn("updating from ",t,"to ",cM),t<1&&(Fh(r,nM),Bh(r,nM),r.schema=1),t<2&&(w4(r),r.schema=2),t<3&&(_4(r),r.schema=3),t<4&&(E4(r),r.schema=4),t<5&&(T4(r),r.schema=5),t<6&&(M4(r),r.schema=6),t<7&&(C4(r),r.schema=7),t<8&&(r.schema=8),t<9&&(iM(r),r.schema=9),t<10&&(O4(r),r.schema=10),t<11&&(L4(r),r.schema=11),t<12&&(iM(r),r.schema=12),t<13&&(R4(r),r.schema=13),t<14&&(B4(r),r.schema=14),t<15&&(F4(r),r.schema=15),t<16&&(k4(r),r.schema=16),t<17&&(Fh(r,sM),Bh(r,sM),r.schema=17),t<18&&(Fh(r,rM),Bh(r,rM),r.schema=18),t<19&&(A4(r),r.schema=19),t<20&&(U4(r),z4(r),r.schema=20),t<21&&(V4(r),H4(r),r.schema=21),t<22&&(lM(r),r.schema=22),t<23&&(W4(r),r.schema=23),t<24&&(j4(r),r.schema=24),(t<25||r.shared.videos===void 0)&&(N4(r),t<25&&(r.schema=25)),t<26&&(P4(r),r.schema=26),t<27&&(I4(r),r.schema=27),t<28&&(lM(r),r.schema=28),t<29&&(D4(r),r.schema=29),t<30&&(q4(r),r.schema=30),t<31&&(X4(r),r.schema=31),t<33&&(Y4(r),r.schema=33),t<34&&(Q4(r),r.schema=34),t<35&&(K4(r),r.schema=35),t<36&&(Z4(r),r.schema=36),t<37&&(J4(r),r.schema=37),t<38&&(Fh(r,oM),Bh(r,oM),r.schema=38))}function uo(r,t=!1){let e=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Te,u=0;for(let c=0;c<r.length;++c){let d=r[c],h=0;if(e!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in d.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(d.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in d.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,d=[];for(let h=0;h<r.length;++h){let f=r[h].index;for(let g=0;g<f.count;++g)d.push(f.getX(g)+c);c+=r[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=dM(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][h]);let g=dM(f);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(g)}}return l}function dM(r){let t,e,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Fe(s,e,n)}var ag;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new He,move:new He,jump:new He}}))(ag||(ag={}));var hM=Math.pow(2,-24);var cl=class{constructor(){}};function gi(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function Bx(r){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>e&&(e=i,t=n)}return t}function Fx(r,t){t.set(r)}function kx(r,t,e){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=t[s],e[s]=n<i?n:i,n=r[o],i=t[o],e[o]=n>i?n:i}}function kh(r,t,e){for(let n=0;n<3;n++){let i=t[r+2*n],s=t[r+2*n+1],o=i-s,a=i+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function lu(r){let t=r[3]-r[0],e=r[4]-r[1],n=r[5]-r[2];return 2*(t*e+e*n+n*t)}function tH(r,t){if(!r.index){let e=r.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new n(4*e)):i=new Uint16Array(new n(2*e)),r.setIndex(new Fe(i,1));for(let s=0;s<e;s++)i[s]=s}}function nH(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let t=[],e=new Set;for(let i of r.groups)e.add(i.start),e.add(i.start+i.count);let n=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function Gx(r,t,e,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,g=-1/0,p=-1/0,m=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let S=r[v+0],w=r[v+1],_=S-w,E=S+w;_<s&&(s=_),E>l&&(l=E),y&&S<d&&(d=S),y&&S>g&&(g=S);let b=r[v+2],T=r[v+3],M=b-T,I=b+T;M<o&&(o=M),I>u&&(u=I),y&&b<h&&(h=b),y&&b>p&&(p=b);let P=r[v+4],C=r[v+5],D=P-C,R=P+C;D<a&&(a=D),R>c&&(c=R),y&&P<f&&(f=P),y&&P>m&&(m=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(i[0]=d,i[1]=h,i[2]=f,i[3]=g,i[4]=p,i[5]=m)}function rH(r,t,e,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=r[c+0];h<i&&(i=h),h>a&&(a=h);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let g=r[c+4];g<o&&(o=g),g>u&&(u=g)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function iH(r,t,e,n,i){let s=e,o=e+n-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var ho=32,sH=(r,t)=>r.candidate-t.candidate,ra=new Array(ho).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),lg=new Float32Array(6);function oH(r,t,e,n,i,s){let o=-1,a=0;if(s===0)o=Bx(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=Bx(r),o!==-1&&(a=aH(e,n,i,o));else if(s===2){let l=lu(r),u=1.25*i,c=n*6,d=(n+i)*6;for(let h=0;h<3;h++){let f=t[h],m=(t[h+3]-f)/ho;if(i<ho/4){let y=[...ra];y.length=i;let v=0;for(let S=c;S<d;S+=6,v++){let w=y[v];w.candidate=e[S+2*h],w.count=0;let{bounds:_,leftCacheBounds:E,rightCacheBounds:b}=w;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0,E[T]=1/0,E[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0;kh(S,e,_)}y.sort(sH);let x=i;for(let S=0;S<x;S++){let w=y[S];for(;S+1<x&&y[S+1].candidate===w.candidate;)y.splice(S+1,1),x--}for(let S=c;S<d;S+=6){let w=e[S+2*h];for(let _=0;_<x;_++){let E=y[_];w>=E.candidate?kh(S,e,E.rightCacheBounds):(kh(S,e,E.leftCacheBounds),E.count++)}}for(let S=0;S<x;S++){let w=y[S],_=w.count,E=i-w.count,b=w.leftCacheBounds,T=w.rightCacheBounds,M=0;_!==0&&(M=lu(b)/l);let I=0;E!==0&&(I=lu(T)/l);let P=1+1.25*(M*_+I*E);P<u&&(o=h,u=P,a=w.candidate)}}else{for(let x=0;x<ho;x++){let S=ra[x];S.count=0,S.candidate=f+m+x*m;let w=S.bounds;for(let _=0;_<3;_++)w[_]=1/0,w[_+3]=-1/0}for(let x=c;x<d;x+=6){let _=~~((e[x+2*h]-f)/m);_>=ho&&(_=ho-1);let E=ra[_];E.count++,kh(x,e,E.bounds)}let y=ra[ho-1];Fx(y.bounds,y.rightCacheBounds);for(let x=ho-2;x>=0;x--){let S=ra[x],w=ra[x+1];kx(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let x=0;x<ho-1;x++){let S=ra[x],w=S.count,_=S.bounds,b=ra[x+1].rightCacheBounds;w!==0&&(v===0?Fx(_,lg):kx(_,lg,lg)),v+=w;let T=0,M=0;v!==0&&(T=lu(lg)/l);let I=i-v;I!==0&&(M=lu(b)/l);let P=1+1.25*(T*v+M*I);P<u&&(o=h,u=P,a=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function aH(r,t,e,n){let i=0;for(let s=t,o=t+e;s<o;s++)i+=r[s*6+n*2];return i/e}function lH(r,t){let e=r.attributes.position,n=e.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=e.offset||0,l=3;e.isInterleavedBufferAttribute&&(l=e.data.stride);for(let u=0;u<s;u++){let c=u*3,d=u*6,h=i[c+0]*l+a,f=i[c+1]*l+a,g=i[c+2]*l+a;for(let p=0;p<3;p++){let m=n[h+p],y=n[f+p],v=n[g+p],x=m;y<x&&(x=y),v<x&&(x=v);let S=m;y>S&&(S=y),v>S&&(S=v);let w=(S-x)/2,_=p*2;o[d+_+0]=x+w,o[d+_+1]=w+(Math.abs(x)+w)*hM,x<t[p]&&(t[p]=x),S>t[p+3]&&(t[p+3]=S)}}return o}function cH(r,t){function e(y){h&&h(y/f)}function n(y,v,x,S=null,w=0){if(!g&&w>=l&&(g=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),x<=c||w>=l)return e(v+x),y.offset=v,y.count=x,y;let _=oH(y.boundingData,S,o,v,x,d);if(_.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let E=iH(a,o,v,x,_);if(E===v||E===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=_.axis;let b=new cl,T=v,M=E-v;y.left=b,b.boundingData=new Float32Array(6),Gx(o,T,M,b.boundingData,s),n(b,T,M,s,w+1);let I=new cl,P=E,C=x-M;y.right=I,I.boundingData=new Float32Array(6),Gx(o,P,C,I.boundingData,s),n(I,P,C,s,w+1)}return y}tH(r,t);let i=new Float32Array(6),s=new Float32Array(6),o=lH(r,i),a=r.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=r.index.count/3,g=!1,p=[],m=nH(r);if(m.length===1){let y=m[0],v=new cl;v.boundingData=i,rH(o,y.offset,y.count,s),n(v,y.offset,y.count,s),p.push(v)}else for(let y of m){let v=new cl;v.boundingData=new Float32Array(6),Gx(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function mM(r,t){let e=cH(r,t),n,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,g=!!d.count,p=d.boundingData;for(let m=0;m<6;m++)n[h+m]=p[m];if(g){let m=d.offset,y=d.count;return i[h+6]=m,s[f+14]=y,s[f+15]=65535,c+32}else{let m=d.left,y=d.right,v=d.splitAxis,x;if(x=u(c+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[h+6]=x/4,x=u(x,y),i[h+7]=v,x}}}var Br=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Br.prototype.setFromBox=function(){let r=new A;return function(e,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let d=e.dot(r);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var _re=function(){let r=new Br;return function(e,n){let i=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let d=o[c],h=s[c];if(r.setFromPoints(h,a),d.isSeparated(r))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(r.setFromPoints(h,i),d.isSeparated(r))return!1}}}();var uH=function(){let r=new A,t=new A,e=new A;return function(i,s,o){let a=i.start,l=r,u=s.start,c=t;e.subVectors(a,u),r.subVectors(i.end,s.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),g=e.dot(l),m=l.dot(l)*f-h*h,y,v;m!==0?y=(d*h-g*f)/m:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),Uh=function(){let r=new F,t=new A,e=new A;return function(i,s,o,a){uH(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(i.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),gM=function(){let r=new A,t=new A,e=new pn,n=new Bn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var dH=1e-15;function cu(r){return Math.abs(r)<dH}var Fr=class extends on{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Br),this.points=[this.a,this.b,this.c],this.sphere=new Cn,this.plane=new pn,this.needsUpdate=!0}intersectsSphere(t){return gM(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,i);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,i);let f=s[3],g=o[3];f.subVectors(n,t),g.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Fr.prototype.closestPointToSegment=function(){let r=new A,t=new A,e=new Bn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),Uh(e,i,r,t),c=r.distanceToSquared(t),c<d&&(d=c,s&&s.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(d)}}();Fr.prototype.intersectsTriangle=function(){let r=new Fr,t=new Array(3),e=new Array(3),n=new Br,i=new Br,s=new A,o=new A,a=new A,l=new A,u=new Bn,c=new Bn,d=new Bn;return function(f,g=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,m=f.plane;if(Math.abs(p.normal.dot(m.normal))>1-1e-10){let y=this.satBounds,v=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let w=0;w<4;w++){let _=y[w],E=v[w];if(n.setFromPoints(E,e),_.isSeparated(n))return!1}let x=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let _=x[w],E=S[w];if(n.setFromPoints(E,t),_.isSeparated(n))return!1}for(let w=0;w<4;w++){let _=v[w];for(let E=0;E<4;E++){let b=S[E];if(s.crossVectors(_,b),n.setFromPoints(s,t),i.setFromPoints(s,e),n.isSeparated(i))return!1}}return g&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let y=this.points,v=!1,x=0;for(let C=0;C<3;C++){let D=y[C],R=y[(C+1)%3];u.start.copy(D),u.end.copy(R),u.delta(o);let U=v?c.start:c.end,Y=cu(m.distanceToPoint(D));if(cu(m.normal.dot(o))&&Y){c.copy(u),x=2;break}if((m.intersectLine(u,U)||Y)&&!cu(U.distanceTo(R))){if(x++,v)break;v=!0}}if(x===1&&this.containsPoint(c.start))return g&&(g.start.copy(c.start),g.end.copy(c.start)),!0;if(x!==2)return!1;let S=f.points,w=!1,_=0;for(let C=0;C<3;C++){let D=S[C],R=S[(C+1)%3];u.start.copy(D),u.end.copy(R),u.delta(a);let U=w?d.start:d.end,Y=cu(p.distanceToPoint(D));if(cu(p.normal.dot(a))&&Y){d.copy(u),_=2;break}if((p.intersectLine(u,U)||Y)&&!cu(U.distanceTo(R))){if(_++,w)break;w=!0}}if(_===1&&this.containsPoint(d.start))return g&&(g.start.copy(d.start),g.end.copy(d.start)),!0;if(_!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let C=d.start;d.start=d.end,d.end=C}let E=c.start.dot(o),b=c.end.dot(o),T=d.start.dot(o),M=d.end.dot(o),I=b<T,P=E<M;return E!==M&&T!==b&&I===P?!1:(g&&(l.subVectors(c.start,d.start),l.dot(o)>0?g.start.copy(c.start):g.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?g.end.copy(c.end):g.end.copy(d.end)),!0)}}}();Fr.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();Fr.prototype.distanceToTriangle=function(){let r=new A,t=new A,e=["a","b","c"],n=new Bn,i=new Bn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],g=o[f];this.closestPointToPoint(g,r),h=g.distanceToSquared(r),h<c&&(c=h,a&&a.copy(r),l&&l.copy(g));let p=this[f];o.closestPointToPoint(p,r),h=p.distanceToSquared(r),h<c&&(c=h,a&&a.copy(p),l&&l.copy(r))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let g=0;g<3;g++){let p=e[g],m=e[(g+1)%3];i.set(o[p],o[m]),Uh(n,i,r,t);let y=r.distanceToSquared(t);y<c&&(c=y,a&&a.copy(r),l&&l.copy(t))}}return Math.sqrt(c)}}();var kr=class extends St{constructor(...t){super(...t),this.isOrientedBox=!0,this.matrix=new de,this.invMatrix=new de,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Br),this.alignedSatBounds=new Array(3).fill().map(()=>new Br),this.needsUpdate=!1}set(t,e,n){super.set(t,e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){super.copy(t),this.matrix.copy(t.matrix),this.needsUpdate=!0}};kr.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=i[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=i[h];c.subVectors(a,f),d.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();kr.prototype.intersectsBox=function(){let r=new Br;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,e),c.isSeparated(r))return!1}return!0}}();kr.prototype.intersectsTriangle=function(){let r=new Fr,t=new Array(3),e=new Br,n=new Br,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let h=0;h<3;h++){let f=a[h],g=l[h];if(e.setFromPoints(g,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],g=c[h];if(e.setFromPoints(g,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let g=0;g<4;g++){let p=c[g];if(i.crossVectors(f,p),e.setFromPoints(i,t),n.setFromPoints(i,d),e.isSeparated(n))return!1}}return!0}}();kr.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();kr.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();kr.prototype.distanceToBox=function(){let r=["x","y","z"],t=new Array(12).fill().map(()=>new Bn),e=new Array(12).fill().map(()=>new Bn),n=new A,i=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,d=o.min,h=o.max,f=this.points,g=1/0;for(let m=0;m<8;m++){let y=f[m];i.copy(y).clamp(d,h);let v=y.distanceToSquared(i);if(v<g&&(g=v,l&&l.copy(y),u&&u.copy(i),v<c))return Math.sqrt(v)}let p=0;for(let m=0;m<3;m++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(m+1)%3,S=(m+2)%3,w=y<<x|v<<S,_=1<<m|y<<x|v<<S,E=f[w],b=f[_];t[p].set(E,b);let M=r[m],I=r[x],P=r[S],C=e[p],D=C.start,R=C.end;D[M]=d[M],D[I]=y?d[I]:h[I],D[P]=v?d[P]:h[I],R[M]=h[M],R[I]=y?d[I]:h[I],R[P]=v?d[P]:h[I],p++}for(let m=0;m<=1;m++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=m?h.x:d.x,i.y=y?h.y:d.y,i.z=v?h.z:d.z,this.closestPointToPoint(i,n);let x=i.distanceToSquared(n);if(x<g&&(g=x,l&&l.copy(n),u&&u.copy(i),x<c))return Math.sqrt(x)}for(let m=0;m<12;m++){let y=t[m];for(let v=0;v<12;v++){let x=e[v];Uh(y,x,n,i);let S=n.distanceToSquared(i);if(S<g&&(g=S,l&&l.copy(n),u&&u.copy(i),S<c))return Math.sqrt(S)}}return Math.sqrt(g)}}();var ug=new A,dg=new A,hg=new A,yM=new F,vM=new F,xM=new F,bM=new A;function hH(r,t,e,n,i,s){let o;return s===Mn?o=r.intersectTriangle(n,e,t,!0,i):o=r.intersectTriangle(t,e,n,s!==wr,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function fH(r,t,e,n,i,s,o){ug.fromBufferAttribute(t,n),dg.fromBufferAttribute(t,i),hg.fromBufferAttribute(t,s);let a=hH(r,ug,dg,hg,bM,o);if(a){e&&(yM.fromBufferAttribute(e,n),vM.fromBufferAttribute(e,i),xM.fromBufferAttribute(e,s),a.uv=on.getUV(bM,ug,dg,hg,yM,vM,xM,new F));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};on.getNormal(ug,dg,hg,l.normal),a.face=l,a.faceIndex=n}return a}function Vx(r,t,e,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=fH(e,r.attributes.position,r.attributes.uv,o,a,l,t);return u?(u.faceIndex=n,i&&i.push(u),u):null}function SM(r,t,e,n,i,s){for(let o=n,a=n+i;o<a;o++)Vx(r,t,e,o,s)}function wM(r,t,e,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Vx(r,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Hx(r,t,e){return r===null||(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r.distance<e.near||r.distance>e.far)?null:r}function yi(r,t,e,n){let i=r.a,s=r.b,o=r.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function Wx(r,t,e,n,i,s,o){let a=e.index,l=e.attributes.position;for(let u=r,c=t+r;u<c;u++)if(yi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var uu=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function fo(r,t){return t[r+15]===65535}function ul(r,t){return t[r+6]}function du(r,t){return t[r+14]}function hu(r){return r+8}function fu(r,t){return t[r+6]}function AM(r,t){return t[r+7]}var pu=new St,pg=new A,mH=["x","y","z"];function mg(r,t,e,n,i){let s=r*2,o=mu,a=ia,l=sa;if(fo(s,a)){let c=ul(r,l),d=du(s,a);SM(t,e,n,c,d,i)}else{let c=hu(r);yg(c,o,n,pg)&&mg(c,t,e,n,i);let d=fu(r,l);yg(d,o,n,pg)&&mg(d,t,e,n,i)}}function gg(r,t,e,n){let i=r*2,s=mu,o=ia,a=sa;if(fo(i,o)){let u=ul(r,a),c=du(i,o);return wM(t,e,n,u,c)}else{let u=AM(r,a),c=mH[u],h=n.direction[c]>=0,f,g;h?(f=hu(r),g=fu(r,a)):(f=fu(r,a),g=hu(r));let m=yg(f,s,n,pg)?gg(f,t,e,n):null;if(m){let x=m.point[c];if(h?x<=s[g+u]:x>=s[g+u+3])return m}let v=yg(g,s,n,pg)?gg(g,t,e,n):null;return m&&v?m.distance<=v.distance?m:v:m||v||null}}var _M=function(){let r,t,e=[],n=new uu(()=>new St);return function(...o){r=n.getPrimitive(),t=n.getPrimitive(),e.push(r,t);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],r=e[l-2]),a};function i(s,o,a,l,u=null,c=0,d=0){function h(x){let S=x*2,w=ia,_=sa;for(;!fo(S,w);)x=hu(x),S=x*2;return ul(x,_)}function f(x){let S=x*2,w=ia,_=sa;for(;!fo(S,w);)x=fu(x,_),S=x*2;return ul(x,_)+du(S,w)}let g=s*2,p=mu,m=ia,y=sa;if(fo(g,m)){let x=ul(s,y),S=du(g,m);return gi(s,p,r),l(x,S,!1,d,c+s,r)}else{let x=hu(s),S=fu(s,y),w=x,_=S,E,b,T,M;if(u&&(T=r,M=t,gi(w,p,T),gi(_,p,M),E=u(T),b=u(M),b<E)){w=S,_=x;let Y=E;E=b,b=Y,T=M}T||(T=r,gi(w,p,T));let I=fo(w*2,m),P=a(T,I,E,d+1,c+w),C;if(P===2){let Y=h(w),q=f(w)-Y;C=l(Y,q,!0,d+1,c+w,T)}else C=P&&i(w,o,a,l,u,c,d+1);if(C)return!0;M=t,gi(_,p,M);let D=fo(_*2,m),R=a(M,D,b,d+1,c+_),U;if(R===2){let Y=h(_),q=f(_)-Y;U=l(Y,q,!0,d+1,c+_,M)}else U=R&&i(_,o,a,l,u,c,d+1);return!!U}}}(),EM=function(){let r=new Fr,t=new Fr,e=new de,n=new kr,i=new kr;return function s(o,a,l,u,c=null){let d=o*2,h=mu,f=ia,g=sa;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),fo(d,f)){let m=a,y=m.index,v=m.attributes.position,x=l.index,S=l.attributes.position,w=ul(o,g),_=du(d,f);if(e.copy(u).invert(),l.boundsTree)return gi(o,h,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>i.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let T=w*3,M=(_+w)*3;T<M;T+=3)if(yi(t,T,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let E=w*3,b=_+w*3;E<b;E+=3){yi(r,E,y,v),r.a.applyMatrix4(e),r.b.applyMatrix4(e),r.c.applyMatrix4(e),r.needsUpdate=!0;for(let T=0,M=x.count;T<M;T+=3)if(yi(t,T,x,S),t.needsUpdate=!0,r.intersectsTriangle(t))return!0}}else{let m=o+8,y=g[o+6];return gi(m,h,pu),!!(c.intersectsBox(pu)&&s(m,a,l,u,c)||(gi(y,h,pu),c.intersectsBox(pu)&&s(y,a,l,u,c)))}}}();function yg(r,t,e,n){return gi(r,t,pu),e.intersectBox(pu,n)}var jx=[],fg,mu,ia,sa;function gu(r){fg&&jx.push(fg),fg=r,mu=new Float32Array(r),ia=new Uint16Array(r),sa=new Uint32Array(r)}function Gh(){fg=null,mu=null,ia=null,sa=null,jx.length&&gu(jx.pop())}var qx=Symbol("skip tree generation"),Xx=new St,Yx=new St,yu=new de,dl=new kr,zh=new kr,Vh=new A,vg=new A,gH=new A,yH=new A,vH=new A,TM=new St,vs=new uu(()=>new Fr),cn=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),cn.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),cn.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=t,o=new cn(e,{...n,[qx]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Fe(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[qx]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[qx]||(this._roots=mM(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new St))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,i=e.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,d,h=0,f=this._roots;for(let p=0,m=f.length;p<m;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),d=new Float32Array(l),g(0,h),h+=l.byteLength;function g(p,m,y=!1){let v=p*2;if(c[v+15]===65535){let S=u[p+6],w=c[v+14],_=1/0,E=1/0,b=1/0,T=-1/0,M=-1/0,I=-1/0;for(let P=3*S,C=3*(S+w);P<C;P++){let D=n[P]*a+o,R=s[D+0],U=s[D+1],Y=s[D+2];R<_&&(_=R),R>T&&(T=R),U<E&&(E=U),U>M&&(M=U),Y<b&&(b=Y),Y>I&&(I=Y)}return d[p+0]!==_||d[p+1]!==E||d[p+2]!==b||d[p+3]!==T||d[p+4]!==M||d[p+5]!==I?(d[p+0]=_,d[p+1]=E,d[p+2]=b,d[p+3]=T,d[p+4]=M,d[p+5]=I,!0):!1}else{let S=p+8,w=u[p+6],_=S+m,E=w+m,b=y,T=!1,M=!1;t?b||(T=t.has(_),M=t.has(E),b=!T&&!M):(T=!0,M=!0);let I=b||T,P=b||M,C=!1;I&&(C=g(S,m,b));let D=!1;P&&(D=g(w,m,b));let R=C||D;if(R)for(let U=0;U<3;U++){let Y=S+U,W=w+U,q=d[Y],j=d[Y+3],X=d[W],N=d[W+3];d[p+U]=q<X?q:X,d[p+U+3]=j>N?j:N}return R}}}traverse(t,e=0){let n=this._roots[e],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=i[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=i[a+6],f=i[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=Zr){let n=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(gu(n[c]),mg(0,i,h,t,s),Gh(),a){let g=l[c].materialIndex;for(let p=f,m=s.length;p<m;p++)s[p].face.materialIndex=g}}return s}raycastFirst(t,e=Zr){let n=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;gu(n[c]);let f=gg(0,i,h,t);Gh(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,i=!1;for(let s of this._roots)if(gu(s),i=EM(0,n,t,e),Gh(),i)break;return i}shapecast(t,e,n){let i=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,g,p,m)=>{let y=g*3;return h(f,y,y+1,y+2,p,m)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=vs.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,g,p,m,y)=>h(f,g,p,m,y)?!0:Wx(f,g,i,u,p,m,s)}else l||(u?l=(h,f,g,p)=>Wx(h,f,i,u,g,p,s):l=(h,f,g)=>g);let c=!1,d=0;for(let h of this._roots){if(gu(h),c=_M(0,i,a,l,o,d),Gh(),c)break;d+=h.byteLength}return vs.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;yu.copy(e).invert();let c=vs.getPrimitive(),d=vs.getPrimitive();if(s){let f=function(g,p,m,y,v,x,S,w){for(let _=m,E=m+y;_<E;_++){yi(d,_*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let b=g,T=g+p;b<T;b++)if(yi(c,b*3,o,a),c.needsUpdate=!0,s(c,d,b,_,v,x,S,w))return!0}return!1};if(i){let g=i;i=function(p,m,y,v,x,S,w,_){return g(p,m,y,v,x,S,w,_)?!0:f(p,m,y,v,x,S,w,_)}}else i=f}t.getBoundingBox(Yx),Yx.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>Yx.intersectsBox(f),intersectsRange:(f,g,p,m,y,v)=>(Xx.copy(v),Xx.applyMatrix4(yu),t.shapecast({intersectsBounds:x=>Xx.intersectsBox(x),intersectsRange:(x,S,w,_,E)=>i(f,g,x,S,m,y,_,E)}))});return vs.releasePrimitive(c),vs.releasePrimitive(d),h}intersectsBox(t,e){return dl.set(t.min,t.max,e),dl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>dl.intersectsBox(n),intersectsTriangle:n=>dl.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),dl.set(t.boundingBox.min,t.boundingBox.max,e),dl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=vs.getPrimitive(),f=vs.getPrimitive(),g=vg,p=gH,m=null,y=null;i&&(m=yH,y=vH);let v=1/0,x=null,S=null;return yu.copy(e).invert(),zh.matrix.copy(yu),this.shapecast({boundsTraverseOrder:w=>dl.distanceToBox(w),intersectsBounds:(w,_,E)=>E<v&&E<o?(_&&(zh.min.copy(w.min),zh.max.copy(w.max),zh.needsUpdate=!0),!0):!1,intersectsRange:(w,_)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>zh.distanceToBox(E),intersectsBounds:(E,b,T)=>T<v&&T<o,intersectsRange:(E,b)=>{for(let T=E*3,M=(E+b)*3;T<M;T+=3){yi(f,T,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let I=w*3,P=(w+_)*3;I<P;I+=3){yi(h,I,u,l),h.needsUpdate=!0;let C=h.distanceToTriangle(f,g,m);if(C<v&&(p.copy(g),y&&y.copy(m),v=C,x=I/3,S=T/3),C<s)return!0}}}});{let E=d?d.count:c.count;for(let b=0,T=E;b<T;b+=3){yi(f,b,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,I=(w+_)*3;M<I;M+=3){yi(h,M,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,g,m);if(P<v&&(p.copy(g),y&&y.copy(m),v=P,x=M/3,S=b/3),P<s)return!0}}}}}),vs.releasePrimitive(h),vs.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(yu),p.applyMatrix4(yu),i.distance=p.sub(i.point).length(),i.faceIndex=S),n)}closestPointToPoint(t,e={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(Vh.copy(t).clamp(c.min,c.max),Vh.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,Vh);let h=t.distanceToSquared(Vh);return h<a&&(vg.copy(Vh),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(vg):e.point=vg.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{gi(0,new Float32Array(n),TM),t.union(TM)}),t}},MM=cn.prototype.raycast;cn.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,e,n,i]=r;return MM.call(this,n,t.material).forEach(o=>{o=Hx(o,t,e),o&&i.push(o)}),i}else return MM.apply(this,r)};var CM=cn.prototype.raycastFirst;cn.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,e,n]=r;return Hx(CM.call(this,n,t.material),t,e)}else return CM.apply(this,r)};var PM=cn.prototype.closestPointToPoint;cn.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let t=r[1],e={};return r[1]=e,PM.apply(this,r),t&&t.copy(e.point),e.distance}else return PM.apply(this,r)};var IM=cn.prototype.closestPointToGeometry;cn.prototype.closestPointToGeometry=function(...r){let t=r[2],e=r[3];if(t&&t.isVector3||e&&e.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,IM.apply(this,r),t&&t.copy(n.point),e&&e.copy(i.point).applyMatrix4(s),n.distance}else return IM.apply(this,r)};var DM=cn.prototype.refit;cn.prototype.refit=function(...r){let t=r[0],e=r[1];if(e&&(e instanceof Set||Array.isArray(e))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;e.forEach(i=>n.add(i)),t&&t.forEach(i=>n.add(i)),DM.call(this,n)}else DM.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let t=cn.prototype[r];cn.prototype[r]=function(...e){return(e[0]===null||e[0].isMesh)&&(e.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,e)}});var ld=Gs(LM());var xH=.5*(Math.sqrt(3)-1),Hh=(3-Math.sqrt(3))/6,bH=1/3,xs=1/6,vie=(Math.sqrt(5)-1)/4,xie=(5-Math.sqrt(5))/20,Wh=r=>Math.floor(r)|0,RM=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),Kx=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function xg(r=Math.random){let t=BM(r),e=new Float64Array(t).map(i=>RM[i%12*2]),n=new Float64Array(t).map(i=>RM[i%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*xH,d=Wh(s+c),h=Wh(o+c),f=(d+h)*Hh,g=d-f,p=h-f,m=s-g,y=o-p,v,x;m>y?(v=1,x=0):(v=0,x=1);let S=m-v+Hh,w=y-x+Hh,_=m-1+2*Hh,E=y-1+2*Hh,b=d&255,T=h&255,M=.5-m*m-y*y;if(M>=0){let C=b+t[T],D=e[C],R=n[C];M*=M,a=M*M*(D*m+R*y)}let I=.5-S*S-w*w;if(I>=0){let C=b+v+t[T+x],D=e[C],R=n[C];I*=I,l=I*I*(D*S+R*w)}let P=.5-_*_-E*E;if(P>=0){let C=b+1+t[T+1],D=e[C],R=n[C];P*=P,u=P*P*(D*_+R*E)}return 70*(a+l+u)}}function NM(r=Math.random){let t=BM(r),e=new Float64Array(t).map(s=>Kx[s%12*3]),n=new Float64Array(t).map(s=>Kx[s%12*3+1]),i=new Float64Array(t).map(s=>Kx[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*bH,g=Wh(o+f),p=Wh(a+f),m=Wh(l+f),y=(g+p+m)*xs,v=g-y,x=p-y,S=m-y,w=o-v,_=a-x,E=l-S,b,T,M,I,P,C;w>=_?_>=E?(b=1,T=0,M=0,I=1,P=1,C=0):w>=E?(b=1,T=0,M=0,I=1,P=0,C=1):(b=0,T=0,M=1,I=1,P=0,C=1):_<E?(b=0,T=0,M=1,I=0,P=1,C=1):w<E?(b=0,T=1,M=0,I=0,P=1,C=1):(b=0,T=1,M=0,I=1,P=1,C=0);let D=w-b+xs,R=_-T+xs,U=E-M+xs,Y=w-I+2*xs,W=_-P+2*xs,q=E-C+2*xs,j=w-1+3*xs,X=_-1+3*xs,N=E-1+3*xs,k=g&255,V=p&255,H=m&255,z=.6-w*w-_*_-E*E;if(z<0)u=0;else{let G=k+t[V+t[H]];z*=z,u=z*z*(e[G]*w+n[G]*_+i[G]*E)}let re=.6-D*D-R*R-U*U;if(re<0)c=0;else{let G=k+b+t[V+T+t[H+M]];re*=re,c=re*re*(e[G]*D+n[G]*R+i[G]*U)}let K=.6-Y*Y-W*W-q*q;if(K<0)d=0;else{let G=k+I+t[V+P+t[H+C]];K*=K,d=K*K*(e[G]*Y+n[G]*W+i[G]*q)}let Z=.6-j*j-X*X-N*N;if(Z<0)h=0;else{let G=k+1+t[V+1+t[H+1]];Z*=Z,h=Z*Z*(e[G]*j+n[G]*X+i[G]*N)}return 32*(u+c+d+h)}}function BM(r){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let i=n+~~(r()*(256-n)),s=e[n];e[n]=e[i],e[i]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var Ui=new on,bg=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let s=1;Ui.a.fromBufferAttribute(t,i),Ui.b.fromBufferAttribute(t,i+1),Ui.c.fromBufferAttribute(t,i+2),s*=Ui.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let i=0;i<e.length;i++)n+=e[i],this.distribution[i]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*n);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,i=e.length-1,s=-1;for(;n<=i;){let o=Math.ceil((n+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:n=o+1}return s}sampleFace(t,e,n){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),Ui.a.fromBufferAttribute(this.positionAttribute,t*3),Ui.b.fromBufferAttribute(this.positionAttribute,t*3+1),Ui.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Ui.a,i).addScaledVector(Ui.b,s).addScaledVector(Ui.c,1-(i+s)),Ui.getNormal(n),this}};var kM=Gs(Zx()),SH=new de,wH=new de,AH=new de,jh;(t=>{function r(e){return e&&e.__isSPEObject}t.is=r})(jh||(jh={}));var vu=r=>class extends r{constructor(){super(...arguments);this.hiddenMatrix=new de;this.matrixWorldRigid=new de;this.shearScale=new de;this.shearScaleInv=new de}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof ct&&(n=n.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===n)return!0;i=i.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseObject(n,i=0){if(n(this,i)!==!0)for(let o of this.children)jh.is(o)&&o.traverseObject(n,i+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,i=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,kM.SVD)(i),l=SH.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=wH.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=AH.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,i){this.updateWorldMatrix(!0,!1);let s=new de().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof de?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),i!==void 0&&(this.children.pop(),this.children.splice(i,0,n)),this}copy(n,i=!1){return super.copy(n,i),this.hasNonUniformScale=n.hasNonUniformScale,this}};var Jx=class extends vu(ct){},_H=r=>r.type==="Mesh",cr=class extends Jx{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let i=this.children[e];i?.object!==n&&(i&&this.remove(i),i=new cr(n),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=n.matrix,i.hiddenMatrix=n.hiddenMatrix),i.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return _H(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var hl=new A,fl=new A,xu=new de,GM=[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)],EH=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],TH=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],UM=(r,t,e)=>{r.updateEntityBoxSize(hl,fl),xu.copy(t).multiply(r.matrixWorld),fl.x===0&&fl.y===0&&fl.z===0?e.push(new A(hl.x,hl.y,hl.z).applyMatrix4(xu)):GM.forEach(n=>{e.push(n.clone().multiply(fl).add(hl).applyMatrix4(xu))})},qh=class extends St{constructor(){super(...arguments);this.matrix=new de;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new de().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,n)}expandByObjectSize(e,n,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}UM(o,n,s)}}):UM(e,n,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xu.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(fl).multiplyScalar(.5),this.getCenter(hl),xu.copy(this.matrix).setPosition(hl),this.vertices=GM.map(e=>e.clone().multiply(fl).applyMatrix4(xu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=EH.map(([e,n])=>new Bn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=TH.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Gi={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var eb=class extends oh{constructor(){super()}getPoints(t=12){let e=[],n,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?i[a]:i[a]-i[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let g=h[f];n&&n.equals(g)||(e.push(g),n=g)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var tb=.001;function nb(r,t,e){return t.clone().sub(r).cross(t.clone().sub(e)).length()<=tb}function $x(r,t){let e=new A(...r.position),n=new A(...r.controlNext.position),i=new A(...t.controlPrevious.position),s=new A(...t.position);return nb(e,n,s)&&nb(e,i,s)}function wg(r){let t=r.points.map(c=>new A(...c.data.position)),e=[r.points[0]],n=new A(...e[0].data.position);for(let c=0;c<r.points.length-1;c++)nb(n,t[c],t[c+1])||(e.push(r.points[c]),n=t[c]);e.push(r.points[r.points.length-1]);let i=r.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new A(...d.position),f=new A(...d.controlPrevious.position),g=new A(...d.controlNext.position),p={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:g};if(d.roundness===0||!r.isClosed&&(c===0||c===o-1)){a[c]={...p,removedLength:0};continue}let m=i&&c==0?o-1:c-1,y=i&&c==o-1?0:c+1,v=e[m].data,x=e[y].data,S=new A(...v.position),w=new A(...x.position),_=S.clone().sub(h).normalize(),E=w.clone().sub(h).normalize();Object.assign(p,{prevDir:_,nextDir:E});let b=$x(v,d),T=$x(d,x);if(!b||!T)a[c]={...p,removedLength:0};else{let M=_.clone().add(E).normalize(),I=M.clone().cross(_).length()/_.dot(M);a[c]={...p,tan:I,removedLength:d.roundness/I}}}for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],g=a[h];if(f.removedLength!==0||g.removedLength!==0){let p=f.position.distanceTo(g.position);f.removedLength=Math.min(f.removedLength,p/2),g.removedLength=Math.min(g.removedLength,p/2)}}let l=[];for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],g=a[h],p=null;if(!$x(e[d].data,e[h].data))f.position.distanceTo(g.position)>tb&&(p=new Va(f.position,f.controlNext,g.controlPrevious,g.position));else{let m=f.position.clone(),y=g.position.clone();(f.removedLength!==0||g.removedLength!==0)&&(f.nextDir&&m.add(f.nextDir.clone().setLength(f.removedLength)),g.prevDir&&y.add(g.prevDir.clone().setLength(g.removedLength))),m.distanceTo(y)>tb&&(p=new Va(m,m.clone().lerp(y,.3),y.clone().lerp(m,.3),y))}l[2*c+1]=p}for(let c=0;c<o;c++){let d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),g=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),p=d.tan*d.removedLength,m=d.prevDir.clone().add(d.nextDir).normalize(),y=f.clone().lerp(g,.5),v=f.distanceTo(g)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(v,2))).add(y),S=m.clone().multiplyScalar(-p).add(x),w=h.distanceTo(S)/h.distanceTo(y),_=d.prevDir.clone().multiplyScalar(w*h.distanceTo(f)).add(h),E=_.clone().lerp(S,2),b=f.clone().lerp(_,4/3),T=g.clone().lerp(E,4/3);l[2*c]=new Va(f,b,T,g)}let u=new eb;return l.forEach(c=>{c&&u.add(c)}),u}var vt;(t=>{function r(e){return e&&e.__isEntity}t.is=r})(vt||(vt={}));var po=r=>vt.is(r),MH={type:"completeState",isfromEntity:!0},Ag=r=>class extends vu(r){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new qh;this._recursiveBBox=new qh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let i=this.children[n];if(vt.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let n=this;for(;n.data.type!=="Instance";){let i=n.parent;if(vt.is(i))n=i;else return}return n}forInstancesRec(n){this.instances.forEach(i=>{i.disposed||n(i),i.forInstancesRec(n)})}super_Entity(n,i){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)lo.toOps(this.data,o.data).forEach(l=>{let u=Em.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,i)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=lo.patch(this.data,o),lo.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched),this.stateSelection=n,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(n,i){n.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{po(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let i;return this.traverseEntity(s=>{s.uuid===n&&(i=s)}),i}traverseSortNextHelper(){let n=this.parent;if(n){let i=n.children,s=i.indexOf(this)+1;if(vt.is(i[s]))return i[s];if(vt.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&vt.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let i=this;for(;n>0&&i!==null;)i=i.parent,n-=1;return i}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let i=this.parent;for(;i;){if(n===i)return!0;i=i.parent}return!1}countToAccestor(n){let i=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(n){for(let i of this.children)po(i)&&n(i)}traverseEntityAncestors(n){this.traverseAncestors(i=>{vt.is(i)&&n(i)})}traverseEntity(n,i=0){if(n(this,i)!==!0)for(let o of this.children)po(o)&&o.traverseEntity(n,i+1)}traverseVisibleEntity(n){n(this);for(let i of this.children)po(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,i=!1){return super.copy(n,i),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>po(n))}isAncestorOf(n){if(this.uuid===n)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===n&&(i=!0)}),i}toObjectTransformState(n=[]){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 Vc(i,n)}updateTransformState(n){let i=!1;return n.position&&(this.position.fromArray(n.position),i=!0),n.rotation&&(this.rotation.fromArray(n.rotation),i=!0),n.scale&&(i=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??ea.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)vt.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{vt.is(n)&&n.disposeRecursively()})}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Vc(i,n)}updateByOp(n,i,s,o){let a=this.data;this.data=i;let l=n,u=Ni(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=Er.zoom(h,n.path.slice(2));if(f)for(let g in n.props)n.props[g]===void 0&&g in f&&(d[g]=f[g])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=Er.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,lo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Ni(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(so.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=Er.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let g=n.props;if(f)for(let[p,m]of Object.entries(n.props))m===void 0&&(g===n.props&&(g={...n.props}),g[p]=f[p]);n={...n,props:g}}h.overrideData=ru.resolve(i.overrides,c),h.updateByOp(n,lr.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of na.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of na.rootOverrideProps)if(Ni(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=so.filterOp(d.overrideData,c);h&&d.updateByOp(h,lr.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=so.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=i:f=lr.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,i,s){if(this.dataPatched=i,n.path.length===0&&n.type===0)n.props.type!==void 0&&!Bi.is(n.props.type)&&Gi.changeEntityProptotype(this,i,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){Gi.changeEntityProptotype(this,i,s);for(let o of this.children)vt.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,i,s)}updateByPatchedOp(n,i,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Ni(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Ni(n.path,["cloner"])!==null){let o=lr.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=n.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data,c=wg(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new de;l.updateMatrixWorld();let g=new de().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(g);let p={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let m=new de().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(m).add(h),v=new de().lookAt(h,y,new A(0,1,0)),x=new zt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(m=>{m._cameraType&&m.dispatchEvent(MH)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,i){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,i),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof Gi.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,i){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Gi.Cloner(this,n),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,i.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var VM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},r.parameters),n=e.width/2,i=e.radiusTop??n,s=e.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=r.parameters,g;return d||f?g=new Xh(u,c,n,i,s,o,a,l*Math.PI/180,d,d,h,f):g=new Wa(u,c,n,i,s,o,a,l*Math.PI/180),g.scale(1,1,e/t),Object.assign(g,{userData:{...r,type:"CylinderGeometry"}})}};function oa(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function zM(r){return new F(r.y,-r.x)}var Xh=class extends Te{constructor(t,e,n,i,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,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&&(u=0,c=0);let g=[],p=[],m=[],y=[],v=0,x=n/2,S=new A,w=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let _=new F(t,x),E=new F(e,-x),b=null,T=null,M=null,I=null,P=_.clone().sub(E),C=0,D=0,R=0;h>0&&(C=Math.min(t,e)*(1-h),D=t-C,R=e-C);let U=_.clone();U.x-=C;let Y=Math.PI-P.angle(),W=P.angle(),q=Math.tan(W/2),j=Math.tan(Y/2),X=q+j,N=h?X:j,k=h?X:q;if(u=Math.min(u,(t-D)/N,P.length()/X),c=Math.min(c,(e-R)/k,P.length()/X),u>0){let Z=u/q;b=_.clone().sub(new F(Z,u)),h&&(M=b.clone(),M.x-=C-X*u),_.sub(P.clone().setLength(Z))}if(c>0){let Z=c/j;T=E.clone().sub(new F(Z,-c)),E.add(P.clone().setLength(Z)),h&&(I=T.clone(),I.x-=C-X*c,U.sub(P.clone().setLength(Z)))}P=_.clone().sub(E);let V=P.length()<.5,H=[];for(let Z=0;Z<=i;Z++){let G=[],ue=Z/i,he=ue*l+a,ae=new F(Math.sin(he),Math.cos(he));I&&T?(z(G,ue,ae,Y,c,I,-1,!0),z(G,ue,ae,W,c,T,-1,!1)):T?(re(G,ae,T.x,0,-1),z(G,ue,ae,W,c,T,-1,!1)):o||re(G,ae,e,R,-1);let ge=zM(P).normalize();if(oa(ge,ae,S),!V)for(let Se=0;Se<=s;Se++){let ye=Se/s,Ee=P.clone().multiplyScalar(ye).add(E);oa(Ee,ae,w),p.push(w.x,w.y,w.z),m.push(S.x,S.y,S.z),y.push(ue,.5+w.y/n),G.push(v++)}if(M&&b?(z(G,ue,ae,Y,u,b,1,!1),z(G,ue,ae,W,u,M,1,!0)):b?(z(G,ue,ae,Y,u,b,1,!1),re(G,ae,b.x,0,1)):o||re(G,ae,t,D,1),h&&!V){let Se=zM(P).multiplyScalar(-1).normalize();oa(Se,ae,S);for(let ye=0;ye<=s;ye++){let Ee=ye/s,Me=P.clone().multiplyScalar(-Ee).add(U);oa(Me,ae,w),p.push(w.x,w.y,w.z),m.push(S.x,S.y,S.z),y.push(ue,.5+w.y/n),G.push(v++)}}h&&!o&&G.push(G[0]),H.push(G)}for(let Z=0;Z<H.length-1;Z++)for(let G=0;G<H[0].length-1;G++){if(o&&h&&G==s)continue;let ue=H[Z][G],he=H[Z+1][G],ae=H[Z+1][G+1],ge=H[Z][G+1],Se=p[ae*3+0],ye=p[ae*3+2];g.push(ue,he,ge),(Se!=0||ye!=0)&&g.push(he,ae,ge)}l<Math.PI*2&&(K(-1,H[0],a),K(1,H[H.length-1],a+l)),this.setIndex(g),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(m,3)),this.setAttribute("uv",new we(y,2));function z(Z,G,ue,he,ae,ge,Se,ye){for(let Ee=0;Ee<d+1;Ee++){let Me=Ee/d,be=Se<0?Me:1-Me;ye&&(be-=1),be*=he;let Ge=new F(Math.sin(be),Math.cos(be)*Se),ht=Ge.clone().multiplyScalar(ae).add(ge);oa(ht,ue,w),p.push(w.x,w.y,w.z),oa(Ge,ue,S),m.push(S.x,S.y,S.z),y.push(G,.5+w.y/n),Z.push(v++)}}function re(Z,G,ue,he,ae){let ge=new A,Se=new F,ye=[ue,he];ae<0&&ye.reverse();for(let Ee of ye)Se.set(Ee,x*ae),oa(Se,G,ge),p.push(ge.x,ge.y,ge.z),m.push(0,ae,0),y.push(.5,.5),Z.push(v++)}function K(Z,G,ue){let he=new F(Math.sin(ue),Math.cos(ue)),ae=new F(-Math.cos(ue),Math.sin(ue)),ge=new A,Se=Z<0?(Me,be,Ge)=>g.push(Me,be,Ge):(Me,be,Ge)=>g.push(Me,Ge,be),ye=new F((t+e+D+R)/4,0);oa(ye,he,ge),p.push(ge.x,ge.y,ge.z),m.push(ae.x,0,ae.y),y.push(.5,.5);let Ee=v++;for(let Me of G){let be=p.slice(Me*3,Me*3+3);p.push(...be),m.push(ae.x,0,ae.y);let Ge=y.slice(Me*2,Me*2+2);y.push(...Ge),v++}for(let Me=Ee+1;Me<v-1;Me++)Se(Ee,Me,Me+1);Se(Ee,v-1,Ee+1)}}};var HM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=r.parameters,h;return u>0||c>0||l<360?h=new Xh(0,t/2,n,i,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new tc(t/2,n,i,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...r,type:"ConeGeometry"}})}};var WM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new Yn(t,e,n,i,s,o):u=new ib(t,e,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},rb=Math.PI/2,ib=class extends Te{constructor(t=1,e=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],g=0,p=0;m("z","y","x",-1,-1,n,e,t,o,s,0),m("z","y","x",1,-1,n,e,-t,o,s,1),m("x","z","y",1,1,t,n,e,i,o,2),m("x","z","y",1,-1,t,n,-e,i,o,3),m("x","y","z",1,-1,t,e,n,i,s,4),m("x","y","z",-1,-1,t,e,-n,i,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,i,0),y("x","y","z",1,-1,1,t,e,n,i,1),y("x","y","z",-1,1,1,t,e,n,i,0),y("x","y","z",1,1,-1,t,e,n,i,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new we(d,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(f,2));function m(x,S,w,_,E,b,T,M,I,P,C){let D=(b-2*a)/I,R=(T-2*a)/P,U=b/2-a,Y=T/2-a,W=M/2,q=I+1,j=P+1,X=0,N=0,k=new A;for(let V=0;V<j;V++){let H=V*R-Y;for(let z=0;z<q;z++){let re=z*D-U;k[x]=re*_,k[S]=H*E,k[w]=W,d.push(k.x,k.y,k.z),k[x]=0,k[S]=0,k[w]=M>0?1:-1,h.push(k.x,k.y,k.z),f.push(z/I),f.push(1-V/P),X+=1}}for(let V=0;V<P;V++)for(let H=0;H<I;H++){let z=g+H+q*V,re=g+H+q*(V+1),K=g+(H+1)+q*(V+1),Z=g+(H+1)+q*V;c.push(z,re,Z),c.push(re,K,Z),N+=6}u.addGroup(p,N,C),p+=N,g+=X}function y(x,S,w,_,E,b,T,M,I,P,C){let D=(T-2*a)/P,R=T/2-a,U=M/2-a,Y=I/2,W=P+1,q=0,j=0,X=new A,N=new A;for(let k=0;k<l+1;k++){let V=k/l*rb,H=Math.sin(V)*a,z=(1-Math.cos(V))*a,re=Math.sin(V),K=Math.cos(V);X[S]=(U+H)*E,X[w]=(Y-z)*b,N[x]=0,N[S]=re*Math.sign(X[S]),N[w]=K*Math.sign(X[w]);for(let Z=0;Z<W;Z++){let G=Z*D-R;X[x]=G*_,d.push(X.x,X.y,X.z),h.push(N.x,N.y,N.z),f.push(Z/P),f.push(0),q+=1}}for(let k=0;k<l;k++)for(let V=0;V<P;V++){let H=g+V+W*k,z=g+V+W*(k+1),re=g+(V+1)+W*(k+1),K=g+(V+1)+W*k;c.push(H,z,K),c.push(z,re,K),j+=6}u.addGroup(p,j,C),p+=j,g+=q}function v(x,S,w){let _=new A,E=new A(t/2,e/2,n/2);E.subScalar(a);let b=[],T=x*S*w>0?(I,P,C)=>c.push(I,P,C):(I,P,C)=>c.push(I,C,P);for(let I=0;I<=l;I++){let P=[],C=rb*(1-I/l),D=Math.cos(C),R=Math.sin(C),U=0;for(let Y=0;Y<=I;Y++){let W=Math.cos(U),q=Math.sin(U);_.x=D*W,_.y=R,_.z=D*q;let j=E.clone().addScaledVector(_,a);d.push(x*j.x,S*j.y,w*j.z),h.push(x*_.x,S*_.y,w*_.z),f.push(0,0),P.push(g++),U+=rb/I}b.push(P)}let M=b.length-1;for(let I=0;I<M;I++){let P=b[I],C=b[I+1],D=P.length-1;T(P[0],C[1],C[0]);for(let R=1;R<=D;R++)T(P[R-1],P[R],C[R]),T(P[R],C[R+1],C[R])}}}};var aa=class extends Te{constructor(t=[],e=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new we(a,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],g=new A,p=g.clone(),m=new on,y=s*i,v=i-y,x=o+1,S=new A,w=(q,j)=>S.subVectors(q,j).normalize(),_=(q,j)=>Array(q).fill(void 0).map(j),E=_(t.length/3,(q,j)=>new A().fromArray(t,j*3).setLength(i)),b=[],T=1e6;for(let q=0;q<E.length;q++){let j=E[q],X=[],N,k,V,H=1e10,z=-1;for(;(z=e.indexOf(q,z+1))!=-1;){let G=z-z%3;N=e[G+(z+1)%3],k=e[G+(z+2)%3],V=j.distanceToSquared(E[N]),H=Math.min(H,V),X.push([N,k,V])}H+=1e-6;let re=[],K=0,Z=X.length;for(let G=0;G<Z;G++){[N,k,V]=X[K];let ue=b[N]?.includes(q)==!0;V<=H&&re.push(N+ +ue*T),K=X.findIndex(he=>he[0]==k)}b.push(re)}let M=[];{let q=0,j=0,X,N,k=f==3;for(let V=0;V<=o;V++){X=V*(V+1)/2,N=(V+1)*(V+2)/2;for(let H=0;H<o-V;H++)[q,j]=[X+H+V+2,N+H+V+3],M.push(X,N,...k?[j,X]:[q,N],j,q),[X,N]=[q,j];M.push(X,N,X+o+2)}}let I=g.clone(),P=g.clone(),C=g.clone(),D=g.clone(),R=g.clone(),U=[],Y=_(E.length,()=>_(f,()=>g.clone()));for(let q=0;q<E.length;q++){g.copy(E[q]).normalize(),I.copy(g).multiplyScalar(v);let j=b[q];for(let re=0;re<j.length;re++){let K=j[re],Z=j[(re+1)%f];m.setFromPointsAndIndices(E,q,K%T,Z%T),m.b.sub(m.a).setLength(1e10).add(m.a),m.c.sub(m.a).setLength(1e10).add(m.a),m.closestPointToPoint(I,Y[q][re])}let X=[],N=[],k=[],V=new A;o==0&&[...Y[q]].reduce((re,K)=>re.add(K),V).multiplyScalar(1/f);for(let re=0;re<f;re++){let K=[],Z=(re-1+f)%f,G=Y[q][Z],ue=Y[q][re];g.copy(G).sub(I),p.copy(ue).sub(I);let he=I.angleTo(g),ae=g.angleTo(p),ge=Math.cos(he)*y;o==0?P.copy(V):P.copy(I).setLength(v+ge),N.push(ge);let Se=[P,G,ue];for(let ye=0;ye<2;ye++){let Ee=Se[ye],Me=Se[ye+1];D.subVectors(Ee,I),R.subVectors(Me,I),C.crossVectors(D,R).normalize();for(let be=0;be<x;be++){let Ge=[he,ae][ye]*be/x;g.copy(D).applyAxisAngle(C,Ge).add(I),X.push(g.clone()),ye&&(w(g,I),K.push([be==0?Ee:g.clone(),S.clone()]))}ye&&(w(Me,I),K.push([Me,S.clone()]))}k.push(K)}U.push(k);let H=2*x,z=2;for(let re=0;re<f;re++){let K=H*re,Z=H*((re+1)%f),G=[X[K]];for(let he=1;he<x;he++){D=X[K+he],R=X[Z+he],G.push(D);for(let ae=1,ge=he-z+1;ae<=ge;ae++)g.lerpVectors(D,R,ae/(ge+1)),g.sub(I).setLength(N[re]).add(I),G.push(g.clone());G.push(R)}for(let he=0;he<x;he++)G.push(X[he+x+K]);G.push(X[Z+x]);let ue=M.map(he=>G[he]);a.push(...ue.map(he=>[he.x,he.y,he.z]).flat()),u.push(...ue.map(he=>(w(he,I),[S.x,S.y,S.z])).flat())}}let W=[];for(let q=0;q<b.length;q++)for(let j=0;j<f;j++){let X=b[q][j];if(X<T){let N=b[X].findIndex(H=>H%T==q),k=U[q][j],V=U[X][N];for(let H=0;H<x;H++){let z=k[H],re=V[x-H],K=k[H+1],Z=V[x-(H+1)];[z,re,K,K,re,Z].forEach(G=>{a.push(G[0].x,G[0].y,G[0].z),u.push(G[1].x,G[1].y,G[1].z)})}W.push(k[0][0],V[x][0],k[x][0],V[0][0])}}for(;W.length;){let q,j,X,N;[q,j]=W.splice(0,2);let k=[q];for(;q!=j;)k.push(j),X=W.indexOf(j),N=X%2,j=W.splice(X-N,2)[1-N];S.subVectors(k[0],k[1]).cross(g.subVectors(k[0],k[2])).normalize();let V=S.dot(k[0])<0;V&&S.negate();for(let H=1;H<=k.length-2;H++)[k[H+ +V],k[H+1-+V],k[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(S.x,S.y,S.z)})}}function d(){let h=new A;for(let E=0;E<a.length;E+=3){h.x=a[E+0],h.y=a[E+1],h.z=a[E+2];let b=w(h)/2/Math.PI+.5,T=_(h)/Math.PI+.5;l.push(b,1-T)}let f=new A,g=new A,p=new A,m=new A,y=new F,v=new F,x=new F,S=(E,b,T,M)=>{M<0&&E.x===1&&(l[b]=E.x-1),T.x===0&&T.z===0&&(l[b]=M/2/Math.PI+.5)};for(let E=0,b=0;E<a.length;E+=9,b+=6){f.set(a[E+0],a[E+1],a[E+2]),g.set(a[E+3],a[E+4],a[E+5]),p.set(a[E+6],a[E+7],a[E+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),m.copy(f).add(g).add(p).divideScalar(3);let T=w(m);S(y,b+0,f,T),S(v,b+2,g,T),S(x,b+4,p,T)}for(let E=0;E<l.length;E+=6){let b=l[E+0],T=l[E+2],M=l[E+4],I=Math.max(b,T,M),P=Math.min(b,T,M);I>.9&&P<.1&&(b<.2&&(l[E+0]+=1),T<.2&&(l[E+2]+=1),M<.2&&(l[E+4]+=1))}function w(E){return Math.atan2(E.z,-E.x)}function _(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(t){return new aa(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var jM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Yh(t*.5,s,o):new rc(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},Yh=class extends aa{constructor(t=1,e=.2,n=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,t,e,n),this.type=l}static fromJSON(t){return new Yh(t.radius,t.corner,t.cornerSides)}};var Qh=1e-12,bu=class{constructor(t){this.position=new F;this.startPosition=new F;this.uuid=Ve.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new bu(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Su=class extends bu{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Su(this.parent).copy(this)}},zi=class extends bu{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Su(this),new Su(this))}static create(e,n){let i=new zi(e,new F(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new zi(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new F,n=new F){let[i,s]=this.computeTangents();return i&&s&&(qM(i,e),qM(s,n)),[e,n]}computeTangent(e=new F){let[n,i]=this.computeTangents();return n&&i&&e.copy(n).add(i).normalize(),e}computeNormal(e=new F){let[n,i]=this.computeNormals();return e.copy(n).add(i).normalize(),e}};function qM(r,t=new F){let e=r.length();return t.set(-r.y/e,r.x/e)}var ob=r=>r,wu=new F,_g=new F,CH=new F,PH=new F,IH=new F,DH=new F,YM=new A,QM=new A;function KM(r){let t=new F;t.addVectors(r.v0,wu.subVectors(r.v1,r.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(r.v2,_g.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new fr(r.v0,t,e,r.v2)}function Kh(r,t,e=Number.EPSILON){return Math.abs(r-t)<e}function OH(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function LH(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function ab(r,t,e){let n=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function ZM(r,t,e){return XM(r,t)&&XM(t,e)&&sb(r.position,t.position,e.position)}function sb(r,t,e){return wu.copy(t).sub(r).cross(_g.copy(e).sub(r))===0}function JM(r,t,e,n,i){let s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),o=(r.y+t.y)/2,a=(r.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(r.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function $M(r,t,e){let n=r.distanceTo(e),i=t.distanceTo(e);return n<i?t:r}function eC(r,t,e,n,i,s){let o=t.x-r.x,a=t.y-r.y,l=e.x-r.x,u=e.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return ab(t,r,e)>Math.PI&&(c*=-1),Kh(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),i.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[i,s]}function lb(r,t){return r.position.equals(r.controls[1].position)&&t.position.equals(t.controls[0].position)}function XM(r,t){return sb(r.position,r.controls[1].position,t.position)&&sb(r.position,t.controls[0].position,t.position)}function tC(r,t,e,n,i=.5){let s=wu.subVectors(t,r).multiplyScalar(i).add(r),o=_g.subVectors(e,t).multiplyScalar(i).add(t),a=CH.subVectors(n,e).multiplyScalar(i).add(e),l=s,u=PH.subVectors(o,s).multiplyScalar(i).add(s),c=IH.subVectors(a,o).multiplyScalar(i).add(o),d=a,h=DH.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function nC(r,t,e=12,n=!0){let i=QM.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=ob(t[l]),c=wu,d=la(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof fr||u instanceof $r||u instanceof pr){if(u.getPoint(h/d,c),i.set(c.x,c.y,0),s!==void 0&&LH(s,i))continue;s===void 0&&(s=YM),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function rC(r,t,e,n=12,i=!0){let s=QM.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=ob(t[l]),d=wu,h=la(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof fr||c instanceof $r||c instanceof pr){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=YM:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function cb(r,t=12,e=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=la(o.roundedCurveCorner,t)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=la(o.curveAfter,t)),n.push(a)}return r.length>0&&e&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=la(r[0].roundedCurveCorner,t)*.5),n}function la(r,t=12){return r&&r instanceof za?t*2:r&&(r instanceof pr||r instanceof sh)?1:r&&r instanceof $l?t*r.points.length:t}function iC(r,t,e=12,n=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=ob(t[o]),l=la(a,e),u=wu;for(let c=0;c<=l;c++)if(a instanceof fr||a instanceof $r||a instanceof pr){if(a.getPoint(c/l,u),i!==void 0&&OH(i,u,Qh))continue;i===void 0&&(i=_g),i.copy(u),r.push(u.x,u.y),s++}}return Kh(r[0],r[r.length-2],Qh)&&Kh(r[1],r[r.length-1],Qh)&&(r.pop(),r.pop()),n&&s>1&&!(Kh(r[s-1],r[1],Qh)&&Kh(r[s-2],r[0],Qh))&&(r.push(r[0],r[1]),s++),r}var ub=new F,RH=new F,NH=new F,BH=new F,FH=new F,kH=new F,At=class extends Js{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new pn(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=Ve.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,i){let s=new At;return s.isClosed=e.isClosed,s.points=e.points.map(o=>zi.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>At.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let i=ub.set(e,n);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(e,n);this._update()}createPoint(e,n=0,i=Ve.generateUUID()){let s;e instanceof F?s=e:s=new F(e,n);let o=new zi(i,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(i=>i.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return nC(e,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=cb(this.points,e,!1),this.roundedCurveDivisions=cb(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,i=12){return rC(e,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),iC(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=la(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(e,n,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(lb(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(ub.set(i.x,i.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){lb(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,n.curveAfter=i;let s=i.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(n,i)}if(this.points.length>2){let n=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],u=o.roundness,c=a&&l&&ZM(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,g=o.roundedCurveAfter,p=d.getLength(),m=h.getLength(),y=Math.min(u,p*.499),v=Math.min(u,m*.499),x=Math.min(y,v),S=1-x/p,w=x/m,_=d.getPointAt(S,ub),E=h.getPointAt(w,RH);this._subSplitCurve(d,f,S,_,void 0),this._subSplitCurve(h,g,w,void 0,E);let b;if(this.useCubicForRoundedCorners){let T=ab(_,o.position,E)/2,M=Math.tan(T)*_.distanceTo(o.position),[I,P]=JM(_,E,M,NH,BH),C=$M(I,P,o.position),[D,R]=eC(C,_,E,M,FH,kH);b=new fr(_.clone(),D.clone(),R.clone(),E.clone())}else b=new $r(_.clone(),o.position.clone(),E.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+n,0,b),n++}}}}_subSplitCurve(e,n,i,s,o){if(e instanceof pr)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(i,0),c=tC(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let e=new At(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],d=e.points[s+5],h=e.points[s+6],f=new zi(Ve.generateUUID(),new F(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new At;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof fr&&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 $r&&(s[a]=KM(s[a]));for(a=0,l=s.length;a<l;a++){let d=s[a],h=a>0?s[a-1]:null,f;d instanceof fr?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof pr&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&n(f,h),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof fr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof pr&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(e.curves),e instanceof Js&&(this.shapeHoles=e.holes.map(s=>{let o=new At;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let i=this.getPointByUuid(e);i&&(n.position!==void 0&&i.position.fromArray(n.position),n.roundness!==void 0&&(i.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var hb=Math.PI*2;function db({x:r,y:t},e,n,i,s){return{x:r*e+i,y:t*n+s}}function UH(r,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-i*e,y:i+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function sC(r,t,e,n){let i=r*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,r*e+t*n));return i*Math.acos(s)}function GH(r,t,e,n,i,s,o,a,l,u){let c=Math.pow(i,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),g=c*d-c*f-d*h;g<0&&(g=0),g/=c*f+d*h,g=Math.sqrt(g)*(l===u?-1:1);let p=g*i/s*a,m=g*-s/i*o,y=p+(r+e)/2,v=m+(t+n)/2,x=(o-p)/i,S=(a-m)/s,w=(-o-p)/i,_=(-a-m)/s,E=sC(1,0,x,S),b=sC(x,S,w,_);return!u&&b>0&&(b-=hb),u&&b<0&&(b+=hb),{centerx:y,centery:v,ang1:E,ang2:b}}function oC({px:r,py:t,cx:e,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(i*=Math.sqrt(d),s*=Math.sqrt(d));let h=GH(r,t,e,n,i,s,u,c,o,a),{ang1:f,ang2:g}=h,{centerx:p,centery:m}=h,y=Math.abs(g)/(hb/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);g/=v;for(let x=0;x<v;x++)l.push(UH(f,g)),f+=g;return l.map(x=>{let{x:S,y:w}=db(x[0],i,s,p,m),{x:_,y:E}=db(x[1],i,s,p,m),{x:b,y:T}=db(x[2],i,s,p,m);return{x1:S,y1:w,x2:_,y2:E,x:b,y:T}})}var dt;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(dt||(dt={}));var nn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(nn||(nn={}));function Ke(r,t){if(!r)throw t||"Assertion Failed!"}var We=function(){function r(){}return r.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},r.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},r.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},r.edgeGoesLeft=function(t){return r.vertLeq(t.Dst,t.Org)},r.edgeGoesRight=function(t){return r.vertLeq(t.Org,t.Dst)},r.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},r.edgeEval=function(t,e,n){Ke(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-n.t)*(i/(i+s)):e.t-n.t+(n.t-t.t)*(s/(i+s)):0},r.edgeSign=function(t,e,n){Ke(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?(e.t-n.t)*i+(e.t-t.t)*s:0},r.transEval=function(t,e,n){Ke(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-n.s)*(i/(i+s)):e.s-n.s+(n.s-t.s)*(s/(i+s)):0},r.transSign=function(t,e,n){Ke(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?(e.s-n.s)*i+(e.s-t.s)*s:0},r.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},r.interpolate=function(t,e,n,i){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+i)/2:e+(i-e)*(t/(t+n)):i+(e-i)*(n/(t+n))},r.intersect=function(t,e,n,i,s){var o,a,l;r.vertLeq(t,e)||(l=t,t=e,e=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.vertLeq(n,e)?r.vertLeq(e,i)?(o=r.edgeEval(t,n,e),a=r.edgeEval(n,e,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,e.s)):(o=r.edgeSign(t,n,e),a=-r.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+e.s)/2,r.transLeq(t,e)||(l=t,t=e,e=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.transLeq(n,e)?r.transLeq(e,i)?(o=r.transEval(t,n,e),a=r.transEval(n,e,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,e.t)):(o=r.transSign(t,n,e),a=-r.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+e.t)/2},r}(),Zh=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Eg=function(){function r(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),r}(),Au=function(){function r(){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 r}(),aC=function(){function r(){var t=new Au,e=new Zh,n=new Eg(0),i=new Eg(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(t){var e=new Eg(0),n=new Eg(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return n.next=i,i.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},r.prototype.splice_=function(t,e){var n=t.Onext,i=e.Onext;n.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=n},r.prototype.makeVertex_=function(t,e,n){var i=t;Ke(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},r.prototype.makeFace_=function(t,e,n){var i=t;Ke(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=n.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},r.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},r.prototype.killVertex_=function(t,e){var n=t.anEdge,i=n;do i.Org=e,i=i.Onext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.killFace_=function(t,e){var n=t.anEdge,i=n;do i.Lface=e,i=i.Lnext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var t=new Au,e=new Au,n=new Zh,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(t,e){var n=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new Au;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Zh;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},r.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!n){var i=new Zh;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},r.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Au;return this.makeVertex_(i,n,e.Org),e.Lface=n.Lface=t.Lface,e},r.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},r.prototype.connect=function(t,e){var n=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Zh;this.makeFace_(o,i,t.Lface)}return i},r.prototype.zapFace=function(t){var e=t.anEdge,n,i,s,o,a;i=e.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},r.prototype.mergeConvexFaces=function(t){var e,n,i,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&We.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&We.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=t,s=t;(i=s.next)!==t;s=i){Ke(i.prev===s),l=i.anEdge;do Ke(l.Sym!==l),Ke(l.Sym.Sym===l),Ke(l.Lnext.Onext.Sym===l),Ke(l.Onext.Sym.Lnext===l),Ke(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(Ke(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){Ke(o.prev===a),l=o.anEdge;do Ke(l.Sym!==l),Ke(l.Sym.Sym===l),Ke(l.Lnext.Onext.Sym===l),Ke(l.Onext.Sym.Lnext===l),Ke(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(Ke(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)Ke(l.Sym.next===u.Sym),Ke(l.Sym!==l),Ke(l.Sym.Sym===l),Ke(l.Org!==null),Ke(l.Dst!==null),Ke(l.Lnext.Onext.Sym===l),Ke(l.Onext.Sym.Lnext===l);Ke(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),lC=function(){function r(){this.handle=null}return r}(),cC=function(){function r(){this.key=null,this.node=0}return r}(),zH=function(){function r(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var n=0;n<t+1;n++)this.nodes[n]=new lC,this.handles[n]=new cC;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,Ke(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[i].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(t){var e,n;if(e=++this.size,e*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 lC;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new cC}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},r.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,i=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(t){var e=this.nodes,n=this.handles,i;Ke(t>=1&&t<=this.max&&n[t].key!==null),i=n[t].node,e[i].handle=e[this.size].handle,n[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[e[i>>1].handle].key,n[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},r}(),fb=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),uC=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),VH=function(){function r(t,e){this.frame=t,this.leq=e,this.head=new uC,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(t){return this.insertBefore(this.head,t)},r.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},r.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new uC;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},r.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},r}(),HH=function(){function r(){}return r.regionBelow=function(t){return t.nodeUp.prev.key},r.regionAbove=function(t){return t.nodeUp.next.key},r.debugEvent=function(t){},r.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.edgeLeq=function(t,e,n){var i=t.event,s=e.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?We.vertLeq(s.Org,o.Org)?We.edgeSign(o.Dst,s.Org,o.Org)<=0:We.edgeSign(s.Dst,o.Org,s.Org)>=0:We.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return We.edgeSign(s.Dst,i,s.Org)>=0;var a=We.edgeEval(s.Dst,i,s.Org),l=We.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(t,e){e.fixUpperEdge&&Ke(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},r.fixUpperEdge=function(t,e,n){Ke(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},r.topLeftRegion=function(t,e){var n=e.eUp.Org,i;do e=r.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(i=t.mesh.connect(r.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;r.fixUpperEdge(t,e,i),e=r.regionAbove(e)}return e},r.topRightRegion=function(t){var e=t.eUp.Dst;do t=r.regionAbove(t);while(t.eUp.Dst===e);return t},r.addRegionBelow=function(t,e,n){var i=new fb;return i.eUp=n,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(t,e){switch(t.windingRule){case dt.ODD:return(e&1)!==0;case dt.NONZERO:return e!==0;case dt.POSITIVE:return e>0;case dt.NEGATIVE:return e<0;case dt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(t,e){e.windingNumber=r.regionAbove(e).windingNumber+e.eUp.winding,e.inside=r.isWindingInside(t,e.windingNumber)},r.finishRegion=function(t,e){var n=e.eUp,i=n.Lface;i.inside=e.inside,i.anEdge=n,r.deleteRegion(t,e)},r.finishLeftRegions=function(t,e,n){for(var i,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),r.finishRegion(t,o),a=s.eUp,o=s}return a},r.addRightEdges=function(t,e,n,i,s,o){var a,l,u,c,d=!0;u=n;do Ke(We.vertLeq(u.Org,u.Dst)),r.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(e).eUp.Rprev),l=e,c=s;a=r.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=r.isWindingInside(t,a.windingNumber),l.dirty=!0,!d&&r.checkForRightSplice(t,l)&&(r.addWinding(u,c),r.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,Ke(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(t,l)},r.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},r.vertexWeights=function(t,e,n){var i=We.vertL1dist(e,t),s=We.vertL1dist(n,t),o=.5*s/(i+s),a=.5*i/(i+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},r.getIntersectData=function(t,e,n,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,r.vertexWeights(e,n,i),r.vertexWeights(e,s,o)},r.checkForRightSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp;if(We.vertLeq(i.Org,s.Org)){if(We.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;We.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=n.dirty=!0)}else{if(We.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o;if(Ke(!We.vertEq(i.Dst,s.Dst)),We.vertLeq(i.Dst,s.Dst)){if(We.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(We.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},r.checkForIntersect=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,d,h=new Au,f,g;if(Ke(!We.vertEq(u,l)),Ke(We.edgeSign(l,t.event,o)<=0),Ke(We.edgeSign(u,t.event,a)>=0),Ke(o!==t.event&&a!==t.event),Ke(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(We.vertLeq(o,a)){if(We.edgeSign(u,o,a)>0)return!1}else if(We.edgeSign(l,a,o)<0)return!1;return r.debugEvent(t),We.intersect(l,o,u,a,h),Ke(Math.min(o.t,l.t)<=h.t),Ke(h.t<=Math.max(a.t,u.t)),Ke(Math.min(u.s,l.s)<=h.s),Ke(h.s<=Math.max(a.s,o.s)),We.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=We.vertLeq(o,a)?o:a,We.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),We.vertEq(h,o)||We.vertEq(h,a)?(r.checkForRightSplice(t,e),!1):!We.vertEq(l,t.event)&&We.edgeSign(l,t.event,h)>=0||!We.vertEq(u,t.event)&&We.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=r.topLeftRegion(t,e),i=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),n),r.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),n=e,e=r.topRightRegion(e),g=r.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(t,n,null),r.addRightEdges(t,e,s.Onext,i.Rprev,g,!0),!0):(We.edgeSign(l,t.event,h)>=0&&(r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),We.edgeSign(u,t.event,h)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=h.s,i.Org.t=h.t,i.Org.pqHandle=t.pq.insert(i.Org),r.getIntersectData(t,i.Org,o,l,a,u),r.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(t,e){for(var n=r.regionBelow(e),i,s;;){for(;n.dirty;)e=n,n=r.regionBelow(n);if(!e.dirty&&(n=e,e=r.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(r.deleteRegion(t,n),t.mesh.delete(s),n=r.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(r.checkForIntersect(t,e))return}else r.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n))}},r.connectRightVertex=function(t,e,n){var i,s=n.Onext,o=r.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(t,e),We.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=r.topLeftRegion(t,e),s=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),o),u=!0),We.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(t,o,null),u=!0),u){r.addRightEdges(t,e,n.Onext,s,s,!0);return}We.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(n.Lprev,i),r.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(t,e)},r.connectLeftDegenerate=function(t,e,n){var i,s,o,a,l;if(i=e.eUp,We.vertEq(i.Org,n)){Ke(!1),r.spliceMergeVertices(t,i,n.anEdge);return}if(!We.vertEq(i.Dst,n)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,i),r.sweepEvent(t,n);return}Ke(!1),e=r.topRightRegion(e),l=r.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ke(s!==o),r.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),We.edgeGoesLeft(s)||(s=null),r.addRightEdges(t,e,o.Onext,a,s,!0)},r.connectLeftVertex=function(t,e){var n,i,s,o,a,l,u=new fb;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,We.edgeSign(o.Dst,e,o.Org)===0){r.connectLeftDegenerate(t,n,e);return}if(s=We.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?r.fixUpperEdge(t,s,l):r.computeWinding(t,r.addRegionBelow(t,n,l)),r.sweepEvent(t,e)}else r.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},r.sweepEvent=function(t,e){t.event=e,r.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){r.connectLeftVertex(t,e);return}var i=r.topLeftRegion(t,n.activeRegion);Ke(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(t,s,null);a.Onext===o?r.connectRightVertex(t,i,a):r.addRightEdges(t,i,a.Onext,o,o,!0)},r.addSentinel=function(t,e,n,i){var s=new fb,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},r.initEdgeDict=function(t){t.dict=new VH(t,r.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;r.addSentinel(t,i,s,o),r.addSentinel(t,i,s,a)},r.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ke(e.fixUpperEdge),Ke(++n===1)),Ke(e.windingNumber===0),r.deleteRegion(t,e)},r.removeDegenerateEdges=function(t){var e,n,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,i=e.Lnext,We.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(r.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===n||i===n.Sym)&&(n=n.next),t.mesh.delete(i)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},r.initPriorityQ=function(t){var e,n,i,s=0;for(i=t.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,e=t.pq=new zH(s,We.vertLeq),i=t.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=e.insert(n);return n!==i?!1:(e.init(),!0)},r.donePriorityQ=function(t){t.pq=null},r.removeDegenerateFaces=function(t,e){var n,i,s;for(n=e.fHead.next;n!==e.fHead;n=i)i=n.next,s=n.anEdge,Ke(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),t.mesh.delete(s));return!0},r.computeInterior=function(t,e){e===void 0&&(e=!0);var n,i;if(r.removeDegenerateEdges(t),!r.initPriorityQ(t))return!1;for(r.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!We.vertEq(i,n));)i=t.pq.extractMin(),r.spliceMergeVertices(t,n.anEdge,i.anEdge);r.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,r.debugEvent(t),r.doneEdgeDict(t),r.donePriorityQ(t),r.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},r}(),WH=function(){function r(){this.mesh=new aC,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=dt.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 r.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},r.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},r.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},r.prototype.computeNormal_=function(t){var e,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],f=[null,null,null],g=[null,null,null],p=this.mesh.vHead;e=p.next;for(var m=0;m<3;++m)s=e.coords[m],u[m]=s,g[m]=e,l[m]=s,f[m]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,g[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,n=g[v],i=f[v],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],e=p.next;e!==p;e=e.next)d[0]=e.coords[0]-i.coords[0],d[1]=e.coords[1]-i.coords[1],d[2]=e.coords[2]-i.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,i,s=0,o=t.next;o!==t;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(e=n.next;e!==n;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,i,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},r.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.prototype.tessellateMonoRegion_=function(t,e){var n,i;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;We.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;We.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(We.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(We.edgeGoesLeft(i.Lnext)||We.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(We.edgeGoesRight(n.Lprev)||We.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},r.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},r.prototype.setWindingNumber_=function(t,e,n){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},r.prototype.outputPolymesh_=function(t,e,n,i){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===nn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*i;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],i>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===nn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var g=l;g<n;++g)this.elements[h++]=-1}}},r.prototype.outputContours_=function(t,e){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new aC),t<2&&(t=2),t>3&&(t=3);for(var n=null,i=0;i<e.length;i+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[i+0],n.Org.coords[1]=e[i+1],t>2?n.Org.coords[2]=e[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(t,e,n,i,s,o){if(t===void 0&&(t=dt.ODD),e===void 0&&(e=nn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),HH.computeInterior(this,o);var a=this.mesh;return e===nn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===nn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,n,i),!0},r}();function Vi(r){var t=r.windingRule,e=t===void 0?dt.ODD:t,n=r.elementType,i=n===void 0?nn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,d=r.contours,h=d===void 0?[]:d,f=r.strict,g=f===void 0?!0:f,p=r.debug,m=p===void 0?!1:p;if(!h&&g)throw new Error("Contours can't be empty");if(!!h){var y=new WH;r.edgeCreateCallback&&(y.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(y.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,i,o,l,c,g),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:m?y.mesh:void 0}}}var Gse=dt.ODD,zse=dt.NONZERO,Vse=dt.POSITIVE,Hse=dt.NEGATIVE,Wse=dt.ABS_GEQ_TWO,jse=nn.POLYGONS,qse=nn.CONNECTED_POLYGONS,Xse=nn.BOUNDARY_CONTOURS;var Tg=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*Tg.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let n=t*Tg.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let u=new Float32Array(i,o*s,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=e,n}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Jh=Tg;Jh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var $h={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},mb={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},gb={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},pb=(r,t)=>([e,n])=>(n<e&&(n+=t),(r>=e?r:r+t)<=n),_u=class extends Te{constructor(e,n,i=0,s=12,o=3,a=dt.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(E=>{let b=E.extractShapePointsToFlatArray([],s),T=[];for(let M=b.length-1;M>=1;M-=2){let I=b[M-1],P=b[M-0];T.push(I,P)}return T}),c;try{c=Vi({windingRule:a,elementType:nn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=$h}let d;try{d=Vi({windingRule:dt.ODD,elementType:nn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=mb}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let E=0;E<d.elements.length;E++){let b=d.elements[E],T=E%2===0?c.vertexCount:0;c.elements.push(b+T)}for(let E=0;E<d.vertexIndices.length;E++){let b=d.vertexIndices[E],T=c.vertexCount;c.vertexIndices.push(b+T)}for(let E=0;E<d.vertices.length;E++){let b=d.vertices[E];c.vertices.push(b)}}let f=1/0,g=-1/0,p=1/0,m=-1/0;for(let E=0,b=c.vertexCount;E<b;E++){let T=E*2,M=c.vertices[T+0],I=c.vertices[T+1];M<f&&(f=M),M>g&&(g=M),I<p&&(p=I),I>m&&(m=I)}this._minX=f,this._minY=p,this._width=g-f,this._height=m-p,this._buffer=new Jh(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let E=c.elementCount-1;E>=0;E--){let b=E>=h,T=E*2,M=c.elements[T+0],I=c.elements[T+1],P=M+I,C={start:M,count:I,normals:[],continuous:[],concave:[]},D=M,R=P-1,U=M+1,Y=this._shape.roundedCurves.length;do{let X=D-M,N=c.vertices[R*2+0],k=c.vertices[R*2+1],V=c.vertices[D*2+0],H=c.vertices[D*2+1],z=c.vertices[U*2+0],re=c.vertices[U*2+1],K=V-N,Z=H-k,G=Math.sqrt(K*K+Z*Z);K/=G,Z/=G;let ue=V-z,he=H-re,ae=Math.sqrt(ue*ue+he*he);ue/=ae,he/=ae,C.normals[X*2+0]=-he,C.normals[X*2+1]=ue,C.concave[X]=K*he-Z*ue>0;let ge=c.vertexIndices[D];if(Array.isArray(ge))C.continuous[X]=!1;else{let[Se,ye]=this._shape.getCurveIndexFromVertexId(ge-1,!0);if(ye>0&&ye<1)C.continuous[X]=!0;else{let Ee=ye===1?Se+1:Se-1;Ee=(Ee+Y)%Y;let Me=ye===1?0:1,be=this._shape.roundedCurves[Se].getTangent(ye),Ge=this._shape.roundedCurves[Ee].getTangent(Me);C.continuous[X]=be.dot(Ge)>.95}}b&&(C.normals[X*2+0]*=-1,C.normals[X*2+1]*=-1),[R,D,U]=[D,U,U+1],U>=P&&(U-=I)}while(U!==M+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(M*2,P*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((X,N)=>[N,N]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(M*2,P*2)});for(let X=1;X<=this._bevelSegments;X++){let N=X/this._bevelSegments*Math.PI/2,k=(1-Math.cos(N))*this._bevelSize,V=[],H=[],z=[],re=[],K=0;for(let G=0;G<I;G++){let ue=G*2,he=(G-1+I)%I*2,ae=c.vertices[C.start*2+ue+0],ge=c.vertices[C.start*2+ue+1],Se=-C.normals[he+0]*k,ye=-C.normals[he+1]*k,Ee=-C.normals[ue+0]*k,Me=-C.normals[ue+1]*k;if(C.concave[G]||!C.concave[G]&&b){let be=Math.atan2(ye,Se),Ge=Math.atan2(Me,Ee);Ge>be&&(Ge-=Math.PI*2);let ht=Ge-be;if(C.continuous[G]||b){let L=be+ht/2,O=Math.cos(L)*k,ee=Math.sin(L)*k;V[2*K+0]=ae+O*(b?-1:1),V[2*K+1]=ge+ee*(b?-1:1),re[K]=G,K++}else{let L=Math.max(1,Math.floor(s/4*Math.abs(ht)/Math.PI));for(let O=0;O<=L;O++){let ee=be+ht*(O/L),pe=Math.cos(ee)*k,ve=Math.sin(ee)*k;V[2*K+0]=ae+pe,V[2*K+1]=ge+ve,re[K]=G,K++}}}else V[2*K+0]=ae+Se,V[2*K+1]=ge+ye,re[K]=G,H[G]=K,K++,V[2*K+0]=ae,V[2*K+1]=ge,re[K]=G,K++,V[2*K+0]=ae+Ee,V[2*K+1]=ge+Me,re[K]=G,z[G]=K,K++}let Z=Vi({windingRule:dt.POSITIVE,elementType:nn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[V],edgeCreateCallback:G=>{let he=G.Org.idx,ae=re[he],ge=re[(he+1)%re.length];G.idx=[ae,ge],G.Sym.idx=[ge,ae]},vertexIdCallback:G=>{let ue=G.Lprev.idx;return[ue?ue[1]:0,G.idx?G.idx[0]:0]}});if(!Z)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!Z.vertexCount)break;for(let G=0;G<Z.vertexIndices.length;G++){let[ue,he]=Z.vertexIndices[G];if(ue===he)continue;let ae=he;he<ue&&(ae+=I);for(let ge=ue;ge<ae;ge++){let Se=ge%I,ye=(ge+1)%I;if(!C.continuous[Se]||!C.continuous[ye]){Z.vertexIndices[G]=[ue,Se],Z.vertexIndices.splice(G+1,0,[ye,he]),Z.vertices.splice((G+1)*2,0,Z.vertices[G*2],Z.vertices[G*2+1]);break}}}W.push({bevelI:X,angle:N,size:k,boundary:Z,reverseMap:re,insetPoints:V})}let q=(X,N,k)=>{let V=0,H=X.boundary.vertexIndices.length;for(;V<H&&k(X.boundary.vertexIndices[N]);)N=(N+1)%H,V++;return V},j=y.length;for(let X=1;X<W.length;X++){let N=W[X-1],k=W[X],V=N.boundary.vertexIndices.length,H=k.boundary.vertexIndices.length;if(!V||!H)break;let z=C.concave.length,re=0,K=pb(re,I);for(;!N.boundary.vertexIndices.filter(K).length||!k.boundary.vertexIndices.filter(K).length;)re++,K=pb(re,I);let Z=N.boundary.vertexIndices.findIndex(K),G=k.boundary.vertexIndices.findIndex(K);do Z=(Z+1)%V;while(K(N.boundary.vertexIndices[Z]));do G=(G+1)%H;while(K(k.boundary.vertexIndices[G]));re=(re+1)%I;let ue=re,he=this._buildBevelVert(C,N,(Z-1+V)%V),ae=this._buildBevelVert(C,k,(G-1+H)%H),ge=he,Se=ae,ye,Ee,Me=!1;do{K=pb(re,I);let be=q(N,Z,K),Ge=q(k,G,K),ht=Me;if(Me=!1,be&&!Ge){for(let L=0;L<be;L++)ye=this._buildBevelVert(C,N,(Z+L)%V,L/(be-1)),y.push(ge.topN,ye.topP,Se.topN),y.push(ye.bottomP,ge.bottomN,Se.bottomN),ge=ye;Me=!0}else if(!be&&Ge)for(let L=0;L<Ge;L++)Ee=this._buildBevelVert(C,k,(G+L)%H,L/(Ge-1)),y.push(Se.topN,ge.topP,Ee.topP),y.push(ge.bottomP,Se.bottomN,Ee.bottomP),Se=Ee;else if(be&&Ge)if(ye=this._buildBevelVert(C,N,Z,0),Ee=this._buildBevelVert(C,k,G,0),ht?(y.push(ge.topN,Ee.topP,Se.topN),y.push(ge.topN,ye.topP,Ee.topP),y.push(Ee.bottomP,ge.bottomN,Se.bottomN),y.push(Ee.bottomP,ye.bottomP,ge.bottomN)):(y.push(Se.topN,ge.topN,ye.topP),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,ge.bottomN,Se.bottomN),y.push(ye.bottomP,Se.bottomN,Ee.bottomP)),ge=ye,Se=Ee,be===Ge)for(let L=1;L<be;L++)ye=this._buildBevelVert(C,N,(Z+L)%V,L/(be-1)),Ee=this._buildBevelVert(C,k,(G+L)%H,L/(Ge-1)),y.push(ge.topN,ye.topP,Se.topN),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,ge.bottomN,Se.bottomN),y.push(ye.bottomP,Se.bottomN,Ee.bottomP),ge=ye,Se=Ee;else if(be>Ge){let L=be/Ge,O=0;for(let ee=1;ee<be;ee++)ye=this._buildBevelVert(C,N,(Z+ee)%V,ee/(be-1)),y.push(ge.topN,ye.topP,Se.topN),y.push(ye.bottomP,ge.bottomN,Se.bottomN),ge=ye,ee>(O+1)*L&&(O++,Ee=this._buildBevelVert(C,k,(G+O)%H,O/(Ge-1)),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,Se.bottomN,Ee.bottomP),Se=Ee)}else{let L=Ge/be,O=0;for(let ee=1;ee<Ge;ee++)Ee=this._buildBevelVert(C,k,(G+ee)%H,ee/(Ge-1)),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,Se.bottomN,Ee.bottomP),Se=Ee,ee>(O+1)*L&&(O++,ye=this._buildBevelVert(C,N,(Z+O)%V,O/(be-1)),y.push(ge.topN,ye.topP,Se.topN),y.push(ye.bottomP,ge.bottomN,Se.bottomN),ge=ye)}Z=(Z+be)%V,G=(G+Ge)%H,re=(re+1)%z}while(re!==ue)}if(this._buildWall(W,C,y),b){let X=[];for(let N=y.length-1;N>=j+2;N-=3){let k=y[N-2],V=y[N-1],H=y[N-0];X.push(H,V,k)}y.splice(j,y.length-j,...X)}if(b){let X=[];for(let N=W[W.length-1].boundary.vertices.length-1;N>=1;N-=2){let k=W[W.length-1].boundary.vertices[N-1],V=W[W.length-1].boundary.vertices[N-0];X.push(k,V)}v.push(X)}if(!b){let X=W[W.length-1],N;try{N=Vi({windingRule:W.length>1?dt.POSITIVE:dt.ODD,elementType:nn.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,...v]})}catch{N=gb}if(!N)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let k=0;k<N.elementCount*3;k+=3){let V=this._buildSurfaceVert(N,N.elements[k+0]),H=this._buildSurfaceVert(N,N.elements[k+1]),z=this._buildSurfaceVert(N,N.elements[k+2]);y.push(V.top,H.top,z.top),y.push(z.bottom,H.bottom,V.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Fe(Uint32Array.from(y),1),S=new Fe(this._buffer.positions,3),w=new Fe(this._buffer.normals,3),_=new Fe(this._buffer.uvs,2);S.needsUpdate=!0,w.needsUpdate=!0,_.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",w),this.setAttribute("uv",_),this.setIndex(x)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=e.vertices[n*2+0],o=e.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=l,this.vertexCache[i]=h,h}_buildBevelVert(e,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=e.continuous[c]&&e.continuous[u]):(u=a,c=(u-1+e.count)%e.count,h=e.concave[u]&&n.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(n.angle),g=Math.sin(n.angle),p=i*2,m=u*2,y=c*2,v=n.boundary.vertices[p+0],x=n.boundary.vertices[p+1],S=(1-g)*this._bevelSize,w=(v-this._minX)/this._width,_=(x-this._minY)/this._height,E=e.normals[m+0],b=e.normals[m+1],T=e.normals[y+0],M=e.normals[y+1];if(h){let R=T-E,U=M-b;E=E+R*(1-s),b=b+U*(1-s);let Y=Math.sqrt(E*E+b*b);E/=Y,b/=Y}let I=this._buffer.get(d?2:4),P=I*3,C=I*2,D={i,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-S,this._buffer.normals[P+0]=E*f,this._buffer.normals[P+1]=b*f,this._buffer.normals[P+2]=g,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=_,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=S,this._buffer.normals[P+3]=E*f,this._buffer.normals[P+4]=b*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=_,this._buffer.uvs[C+3]=w,d||(I+=2,P+=6,C+=4,D.topP=I+0,D.bottomP=I+1,this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-S,this._buffer.normals[P+0]=T*f,this._buffer.normals[P+1]=M*f,this._buffer.normals[P+2]=g,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=_,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=S,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=M*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=_,this._buffer.uvs[C+3]=w),this.vertexCache[o]=D,D}clone(){let e=new _u(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=io(this.userData),e}};var Eu=class extends Te{constructor(e,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=dt.ODD;this.elementType=nn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:dt.ODD,elementType:nn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(g=>g.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;for(let g=0,p=s.length/2;g<p;g++){let m=g*2,y=s[m+0],v=s[m+1];if(c!==void 0&&y!==c&&(l=!1),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=Vi({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=$h}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Fe(new Float32Array(h*3),3),this._normalAttribute=new Fe(new Float32Array(h*3),3),this._uvAttribute=new Fe(new Float32Array(h*2),2),this._indexAttribute=new Fe(new Uint32Array(f*3),1),a){let g=1/0,p=-1/0,m=1/0,y=-1/0;for(let S=0,w=h;S<w;S++){let _=S*2,E=a.vertices[_+0],b=a.vertices[_+1];E<g&&(g=E),E>p&&(p=E),b<m&&(m=b),b>y&&(y=b)}let v=p-g,x=y-m;for(let S=0,w=h;S<w;S++){let _=S*2,E=a.vertices[_+0],b=a.vertices[_+1],T=(E-g)/v,M=(b-m)/x;this._positionAttribute.setXYZ(S,E,b,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,T,M)}for(let S=0,w=f;S<w;S++){let _=S*3,E=a.elements[_+0],b=a.elements[_+1],T=a.elements[_+2];this._indexAttribute.setX(_+0,E),this._indexAttribute.setX(_+1,b),this._indexAttribute.setX(_+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new Eu(this._shape,this._curveSegments);return e.userData=io(this.userData),e}};var Tu=class extends _u{constructor(e,n,i=0,s=12,o=3,a=dt.ODD){super(e,n,i,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Tu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=io(this.userData),e}};var Ur=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:dt.ODD},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=r.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof At?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new At(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update());let l=o??new At(n,i);return{parameters:Object.assign(e,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return t<=0?a=new Eu(r.shape,i,{windingRule:o}):a=new Tu(r.shape,t,e,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var hC=Math.PI*2,Cu=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=t*.5,d=e*.5,h=jH(u,c,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Ur.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function jH(r,t,e,n,i,s){if(n>=hC)return i>30||i%4===0?(XH(r,t,e,s),Math.round(i/4)):dC(r,n,i,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=oC({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?qH(r,o.x,o.y,u,i,t,e,s):dC(r,n,i,t,e,s)}function qH(r,t,e,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(Mu(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=r.points[u],f=Mu(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),r.addPoint(f)}return a>0?fC(r,s,o,a):r.addPoint(Mu(0,0)),l}function dC(r,t,e,n,i,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*i;r.addPoint(Mu(u,c))}return t<hC?s>0?fC(r,n,i,s):r.addPoint(Mu(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&pC(r,n,i,s)),1}function XH(r,t,e,n=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;r.addPoint(Mg(i-t,s,i-t,s-l,i-t,s+l)),r.addPoint(Mg(i,s+e,i-a,s+e,i+a,s+e)),r.addPoint(Mg(i+t,s,i+t,s+l,i+t,s-l)),r.addPoint(Mg(i,s-e,i+a,s-e,i-a,s-e)),n>0&&pC(r,t,e,n)}function Mu(r,t){return new zi(Ve.generateUUID(),new F(r,t))}function Mg(r,t,e,n,i,s){let o=Mu(r,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(i,s),o}function fC(r,t,e,n){mC(r,t,e,n).forEach(s=>r.addPoint(s))}function pC(r,t,e,n){let i=mC(r,t,e,n),s=new At;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function mC(r,t,e,n){let i=n*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new F(i/t,s/e),a=r.points.map(l=>{let u=l.clone();return u.uuid=Ve.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var gC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(r){let{width:t,height:e,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=r.parameters,h=new ef(!1,t,e,n,i,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...r,type:"HelixGeometry"}})}},yb=new cs([0,0,0],1),ef=class extends Te{constructor(t=!0,e=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let g=()=>new A,p=new A,m=g(),y=g(),v=g(),x,S,w,_,E,b,T,M,I=g(),P=g(),C=g(),D=g(),R=g(),U=g(),Y=g(),W=g(),q=n-2*l+.001,j=q/o,X=Math.ceil(a*o),N=X+1,k=q/X,V=-q/2,H=c+1,z=2*Math.PI/c,re=Math.PI/2/h,K=.01,Z=Math.min((1-d/100)*l,l-K),G=l-Z,ue=0,he=2,ae=h*he+he,ge=H*ae/he,Se=ge+H*N,ye=H*(N+ae),[Ee,Me,be]=[3,3,2].map(Le=>Array(ye*Le).fill(0)),Ge=[],ht=s-l;function L(Le,Ie){let Be=Math.PI/2;b=Ie*k,M=2*Math.PI*(b%j)/j+Be,b+=V,T=Math.sin(M)*ht,E=Math.cos(M)*ht,t?Le.set(E,T,b):Le.set(E,b,T)}L(p,-1e-10),L(m,0),I.copy(p),L(p,1);let O=p.distanceTo(m),ee=f?0:G+Z,pe=O*X+2*ee,ve=Z,Ce=pe-ee;for(let Le=0;Le<=X;Le++){L(y,Le),W.subVectors(y,I).normalize(),I.copy(y),U.copy(y).setComponent(+t+1,0).normalize(),Y.crossVectors(W,U).normalize();let Ie=Le===0,Be=Le===X,qe=Ie?3*Math.PI/2:re,ft=Ie?ve:Ce,Ft=Ie?H:Se,wn=Ie?0:ye-H,Q=W.clone().multiplyScalar(Ie?-G:G).add(y),ie=W.clone().multiplyScalar(Ie?-1:1).normalize();for(let me=0;me<H;me++){let Re=me*z;if(P.addVectors(p.copy(U).multiplyScalar(l*Math.cos(Re)),m.copy(Y).multiplyScalar(l*Math.sin(Re))),C.copy(P).normalize(),Ie||Be){f||(ue=wn+me,[0,1,2].forEach(Oe=>{Ee[ue*3+Oe]=Q.getComponent(Oe),Me[ue*3+Oe]=ie.getComponent(Oe)}),be[ue*2]=+Be,be[ue*2+1]=me/c),m.copy(C).multiplyScalar(Z),v.addVectors(y,m);for(let Oe=0;Oe<h;Oe++){let pt=Oe*re+qe;D.addVectors(p.copy(W).multiplyScalar(G*Math.sin(pt)),m.copy(C).multiplyScalar(G*Math.cos(pt))),R.copy(D).normalize(),m.addVectors(v,D),D.normalize(),ue=Ft+Oe*H+me,[0,1,2].forEach(dn=>{Ee[ue*3+dn]=m.getComponent(dn),Me[ue*3+dn]=R.getComponent(dn)});let An=+Ie+Math.sin(pt);be[ue*2]=(ft+G*An)/pe,be[ue*2+1]=me/c}}m.addVectors(y,P),ue=ge+Le*H+me,[0,1,2].forEach(Oe=>{Ee[ue*3+Oe]=m.getComponent(Oe),Me[ue*3+Oe]=C.getComponent(Oe)}),be[ue*2]=(ee+Le*O)/pe,be[ue*2+1]=me/c}}let ze=N+2*h+he,Pe=1,[ce,je]=[+f,ze-1];for(let Le=ce;Le<=je-1;Le++){let Ie=f&&Le===je-1;for(let Be=0;Be<H-1;Be++)x=Le*H+Be,S=x+1,w=(Ie?Be:x)+H,_=(Ie?Be+1:S)+H,Le===0?Ge.push(S,_,w):Le===ze-2?Ge.push(x,S,w):Ge.push(x,S,w,S,_,w)}this.setIndex(Ge),this.setAttribute("position",new we(Ee,3)),this.setAttribute("normal",new we(Me,3)),this.setAttribute("uv",new we(be,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,i=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let h=0;h<t.radialSegments;h++)s=c*n+h,o=s+1,a=(d?h:s)+n,l=(d?h+1:o)+n,i[u++]=s,i[u++]=o,i[u++]=a,i[u++]=o,i[u++]=l,i[u++]=a;return i.length=u,yb.array=i,yb.count=i.length,yb}};var yC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new tf(t*.5,s,o):new sc(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},tf=class extends aa{constructor(t=1,e=.2,n=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,t,e,n),this.type=a}static fromJSON(t){return new tf(t.radius,t.corner,t.cornerSides)}};var vC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{points:t,segments:e,verticalSegments:n}=r.parameters,i=new Js;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new ec(i.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var bs=new de,vb=new ct,Cg=new A,ca=class extends Gt{constructor(){super(),this.uuid=Ve.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new Yt().getNormalMatrix(t);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(t);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return bs.makeRotationX(t),this.applyMatrix4(bs),this}rotateY(t){return bs.makeRotationY(t),this.applyMatrix4(bs),this}rotateZ(t){return bs.makeRotationZ(t),this.applyMatrix4(bs),this}translate(t,e,n){return bs.makeTranslation(t,e,n),this.applyMatrix4(bs),this}scale(t,e,n){return bs.makeScale(t,e,n),this.applyMatrix4(bs),this}lookAt(t){return vb.lookAt(t),vb.updateMatrix(),this.applyMatrix4(vb.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,i=t.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,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Ne().fromBufferAttribute(a,h));function c(h,f,g,p){let m=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[g].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,g)],v=new Pu(h,f,g,y,m,p);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new F().fromBufferAttribute(l,h),new F().fromBufferAttribute(l,f),new F().fromBufferAttribute(l,g)]),u!==void 0&&e.faceVertexUvs[1].push([new F().fromBufferAttribute(u,h),new F().fromBufferAttribute(u,f),new F().fromBufferAttribute(u,g)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],g=f.start,p=f.count;for(let m=g,y=g+p;m<y;m+=3)n!==void 0?c(n.getX(m),n.getX(m+1),n.getX(m+2),f.materialIndex):c(m,m+1,m+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cg).negate(),this.translate(Cg.x,Cg.y,Cg.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,i=new de;return i.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)e[n]=new A;if(t){let n=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],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)e[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];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 t=new ca;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let i=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new St),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Cn),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let i,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(i=new Yt().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let g=u[h],p,m,y=g.vertexNormals,v=g.vertexColors,x=new Pu(g.a+s,g.b+s,g.c+s);x.normal.copy(g.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let S=0,w=y.length;S<w;S++)p=y[S].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),x.vertexNormals.push(p);x.color.copy(g.color);for(let S=0,w=v.length;S<w;S++)m=v[S],x.vertexColors.push(m.clone());x.materialIndex=g.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let g=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,m=g.length;p<m;p++){let y=g[p],v=[];for(let x=0,S=y.length;x<S;x++)v.push(y[x].clone());this.faceVertexUvs[h].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},n=[],i=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let i=t[e];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(i[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let g=this.parameters;for(let p in g)g[p]!==void 0&&(t[p]=g[p]);return t}let e=[];for(let g=0;g<this.vertices.length;g++){let p=this.vertices[g];e.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let g=0;g<this.faces.length;g++){let p=this.faces[g],m=!0,y=!1,v=this.faceVertexUvs[0][g]!==void 0,x=p.normal.length()>0,S=p.vertexNormals.length>0,w=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,E=0;if(E=c(E,0,0),E=c(E,1,m),E=c(E,2,y),E=c(E,3,v),E=c(E,4,x),E=c(E,5,S),E=c(E,6,w),E=c(E,7,_),n.push(E),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let b=this.faceVertexUvs[0][g];n.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&n.push(d(p.normal)),S){let b=p.vertexNormals;n.push(d(b[0]),d(b[1]),d(b[2]))}if(w&&n.push(h(p.color)),_){let b=p.vertexColors;n.push(h(b[0]),h(b[1]),h(b[2]))}}function c(g,p,m){return m?g|1<<p:g&~(1<<p)}function d(g){let p=g.x.toString()+g.y.toString()+g.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(g.x,g.y,g.z)),s[p]}function h(g){let p=g.r.toString()+g.g.toString()+g.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(g.getHex())),a[p]}function f(g){let p=g.x.toString()+g.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(g.x,g.y)),u[p]}return t.data={},t.data.vertices=e,t.data.normals=i,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new ca().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let i=t.faces;for(let h=0,f=i.length;h<f;h++)this.faces.push(i[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let g=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,m=g.length;p<m;p++){let y=g[p],v=[];for(let x=0,S=y.length;x<S;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let g={};if(g.name=s[h].name,s[h].vertices!==void 0){g.vertices=[];for(let p=0,m=s[h].vertices.length;p<m;p++)g.vertices.push(s[h].vertices[p].clone())}if(s[h].normals!==void 0){g.normals=[];for(let p=0,m=s[h].normals.length;p<m;p++)g.normals.push(s[h].normals[p].clone())}this.morphTargets.push(g)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let g={};if(o[h].vertexNormals!==void 0){g.vertexNormals=[];for(let p=0,m=o[h].vertexNormals.length;p<m;p++){let y=o[h].vertexNormals[p],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),g.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){g.faceNormals=[];for(let p=0,m=o[h].faceNormals.length;p<m;p++)g.faceNormals.push(o[h].faceNormals[p].clone())}this.morphNormals.push(g)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new xb().fromGeometry(this),e=new Te,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Pg.call(new Fe(n,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",Pg.call(new Fe(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",xC.call(new Fe(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",bC.call(new Fe(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",bC.call(new Fe(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new we(u.data.length*3,3);c.name=u.name,s.push(Pg.call(c,u.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new we(t.skinIndices.length*4,4);e.setAttribute("skinIndex",SC.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new we(t.skinWeights.length*4,4);e.setAttribute("skinWeight",SC.call(i,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Te,n=t.geometry;if(t.isPoints||t.isLine){let i=new we(n.vertices.length*3,3),s=new we(n.colors.length*3,3);if(e.setAttribute("position",Pg.call(i,n.vertices)),e.setAttribute("color",xC.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new we(n.lineDistances.length,1);e.setAttribute("lineDistance",YH.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};ca.prototype.isGeometry=!0;var xb=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],n,i,s,o=t.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,e.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,i=t.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,g=t.skinWeights,p=f.length===n.length,m=g.length===n.length;n.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=i[0][y];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new F,new F,new F))}if(o===!0){let w=i[1][y];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new F,new F,new F))}for(let w=0;w<l;w++){let _=a[w].vertices;u[w].data.push(_[v.a],_[v.b],_[v.c])}for(let w=0;w<d;w++){let _=c[w].vertexNormals[y];h[w].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),m&&this.skinWeights.push(g[v.a],g[v.b],g[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Pu=class{constructor(t,e,n,i,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Ne,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function YH(r){return this.array.set(r),this}function xC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Ne),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function bC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new F),t[e++]=s.x,t[e++]=s.y}return this}function Pg(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function SC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new $e),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var QH=["a","b","c"];function KH(r,t){switch(t){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function bb(r,t,e){let n=Math.min(r,t),i=Math.max(r,t),s=n+"_"+i;return e.get(s)}function Sb(r,t,e,n,i,s){let o=Math.min(r,t),a=Math.max(r,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[t].edges.push(u)}function ZH(r,t,e,n){let i,s,o;for(i=0,s=r.length;i<s;i++)e[i]={edges:[]};for(i=0,s=t.length;i<s;i++)o=t[i],Sb(o.a,o.b,r,n,o,e),Sb(o.b,o.c,r,n,o,e),Sb(o.c,o.a,r,n,o,e)}function Ig(r,t,e,n,i){r.push(new Pu(t,e,n,void 0,void 0,i))}function Iu(r,t){return Math.abs(t-r)/2+Math.min(r,t)}function Dg(r,t,e,n){r.push([t.clone(),e.clone(),n.clone()])}var Og=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Te?t=new ca().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,i,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;ZH(l,u,h,f);let g=[],p,m,y,v,x,S,w;for(let K of Array.from(f.keys())){for(m=f.get(K),y=new A,x=3/8,S=1/8,w=m.faces.length,w!=2&&(x=.5,S=0,w!=1),y.addVectors(m.a,m.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=m.faces[o],a=0;a<3&&(p=l[KH(v,QH[a])],!(p!==m.a&&p!==m.b));a++);p&&e.add(p)}e.multiplyScalar(S),y.add(e),m.newEdge=g.length,g.push(y)}let _,E,b,T,M,I,P,C=[];for(i=0,s=l.length;i<s;i++){for(I=l[i],M=h[i].edges,n=M.length,n==3?_=3/16:n>3&&(_=3/(8*n)),E=1-n*Number(_),b=_,n<=2&&(n==2?(E=3/4,b=1/8):n==1||n==0),P=I.clone().multiplyScalar(E),e.set(0,0,0),o=0;o<n;o++)T=M[o],p=T.a!==I?T.a:T.b,e.add(p);e.multiplyScalar(Number(b)),P.add(e),C.push(P)}let D=C.concat(g),R=C.length,U,Y,W,q=[],j=[],X,N,k,V,H=new F,z=new F,re=new F;for(i=0,s=u.length;i<s;i++)v=u[i],U=Number(bb(v.a,v.b,f).newEdge)+R,Y=Number(bb(v.b,v.c,f).newEdge)+R,W=Number(bb(v.c,v.a,f).newEdge)+R,Ig(q,U,Y,W,v.materialIndex),Ig(q,v.a,U,W,v.materialIndex),Ig(q,v.b,Y,U,v.materialIndex),Ig(q,v.c,W,Y,v.materialIndex),d&&(X=c[i],N=X[0],k=X[1],V=X[2],H.set(Iu(N.x,k.x),Iu(N.y,k.y)),z.set(Iu(k.x,V.x),Iu(k.y,V.y)),re.set(Iu(N.x,V.x),Iu(N.y,V.y)),Dg(j,H,z,re),Dg(j,N,H,re),Dg(j,k,z,H),Dg(j,V,re,z));t.vertices=D,t.faces=q,d&&(t.faceVertexUvs[0]=j)}};var Un=new A,wC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=r.geometry??t?.geometry??new Te().copy(new Yn(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Un),n={width:Un.x,height:Un.y,depth:Un.z,subdivisions:0}):n=t.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(r){let{width:t,height:e,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Te().copy(new Yn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Un)):Un.set(o.width,o.height,o.depth),(t!==Un.x||e!==Un.y||n!==Un.z)&&s.scale(Un.x===0?1:t/Un.x,Un.y===0?1:e/Un.y,Un.z===0?1:n/Un.z);let a=s.originalGeometry;try{i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Og(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,t,e){new uc(e).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Un);let o=100/Un.x;Object.assign(s.parameters,{width:100,height:Un.y*o,depth:Un.z*o}),t(this.build(s))})}};var Lg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let m=f*p,y=d+Math.sin(m)*u,v=h+Math.cos(m)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let p=0,m=l.points.length;p<m;p++)l.points[p].roundness=i;l.roundness=i,l.update();let g=Ur.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(g,{userData:{...r,type:"PolygonGeometry"}})}};var AC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new Ab(t*.5,e,i,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function nf(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function wb(r,t,e,n,i,s){let o=t.clone().sub(r),a=e.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function JH(r,t,e){let n=r.clone().sub(t),i=e.clone().sub(t);return n.projectOnVector(i),n.add(t)}var Ab=class extends Te{constructor(t=.5,e=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,g=Math.PI/n,p=t*Math.cos(Math.PI/n),m=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),S=new A(0,f,0),w=new F(t,-f),_=new F(p,-f),E=new F(0,S.y).sub(_),b=new F(0,S.y).sub(w),T=new F(E.y,-E.x).normalize(),M=new F(b.y,-b.x).normalize(),P=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-E.angle())/2)-1e-8;o=Math.min(o,P);let C;{let j=new A(T.x,T.y,0),X=new A(Math.cos(m)*j.x,j.y,Math.sin(m)*j.x);C=j.angleTo(X)}let D=o/Math.tan((Math.PI-E.angle())/2),R=o/Math.tan((Math.PI-C)/2),U=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let j=h++,X=[],N=w.clone(),k=D/Math.cos(Math.PI/n);N.x-=k;for(let V=0;V<n;V++){let H=V/n*Math.PI*2+g,z=new F(Math.sin(H),Math.cos(H));nf(N,z,U),u.push(U.x,U.y,U.z),c.push(0,-1,0),d.push(0,0),X.push(h++)}for(let V=0;V<X.length;V++)l.push(X[V],j,X[(V+1)%X.length])}let Y=[];{let j=new A,X=new A,N=new A,k=new A,V=new A,H=new A;for(let z=0;z<n;z++){let re=z/n*Math.PI*2+g,K=(z+.5)/n*Math.PI*2+g,Z=(z+1)/n*Math.PI*2+g,G=new F(Math.sin(re),Math.cos(re)),ue=new F(Math.sin(K),Math.cos(K)),he=new F(Math.sin(Z),Math.cos(Z));nf(w,G,X),nf(w,he,N),nf(T,ue,j),wb(S,X,N,R,R,k),u.push(k.x,k.y,k.z),wb(X,S,N,R,D,V),u.push(V.x,V.y,V.z),wb(N,X,S,D,R,H),u.push(H.x,H.y,H.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),d.push(0,0),d.push(0,0),d.push(0,0);let ae=h++,ge=h++,Se=h++;if(l.push(ae,ge,Se),o>0){{let Me=X.clone().add(N).multiplyScalar(.5),be=S.clone().sub(Me).normalize(),ht=x.clone().sub(Me).normalize().add(be).normalize().multiplyScalar(-1),L=H.clone().sub(V);W(Me,L,ht,E.angle())}let ye,Ee;{let Me=new A;nf(M,he,Me);let be=H.clone().add(k).multiplyScalar(.5);be=JH(be,N,S);let Ge=H.clone().sub(k);[ye,Ee]=W(be,Ge,Me,C,k.y)}{let Me=ye,be=Me.clone().setY(0).normalize(),Ge=new A(0,-1,0),ht=be.clone().cross(Ge);q(Me,be,Ge,ht)}Y.concat(Ee);{let Me=E.angle(),be=Math.PI-Me,Ge=S.clone();Ge.y-=o/Math.sin(Me-Math.PI/2);let ht=new A,L=[];for(let ee=0;ee<a;ee++){let pe=[],ve=Math.PI/2-be*ee/a,Ce=Math.cos(ve),ze=Math.sin(ve),Pe=K;for(let ce=0;ce<=ee;ce++){let je=Math.cos(Pe),Le=Math.sin(Pe);j.x=Ce*Le,j.y=ze,j.z=Ce*je,ht.copy(Ge).addScaledVector(j,o),u.push(ht.x,ht.y,ht.z),c.push(j.x,j.y,j.z),d.push(0,0),pe.push(h++),Pe+=Math.PI*2/ee/n}L.push(pe)}Ee.reverse(),L.push(Ee);let O=L.length-1;for(let ee=0;ee<O;ee++){let pe=L[ee],ve=L[ee+1],Ce=pe.length-1;l.push(ve[1],pe[0],ve[0]);for(let ze=1;ze<=Ce;ze++)l.push(pe[ze],pe[ze-1],ve[ze]),l.push(ve[ze+1],pe[ze],ve[ze])}}}}}this.setIndex(l),this.setAttribute("position",new we(u,3)),this.setAttribute("normal",new we(c,3)),this.setAttribute("uv",new we(d,2));function W(j,X,N,k,V){let H=-k/2,z=(Math.PI-k)/2,re=X.clone().normalize().cross(N);j.addScaledVector(N,-o/Math.sin(z));let K=new A,Z=new A,G=1,ue=h,he=[];for(let ae=0;ae<=a;ae++){let ge=H+ae/a*k;Z.set(0,0,0),Z.addScaledVector(re,Math.sin(ge)),Z.addScaledVector(N,Math.cos(ge));for(let Se=0;Se<=G;Se++){let ye=Se/G-.5;if(K.copy(j),K.addScaledVector(X,ye),K.addScaledVector(Z,o),V!=null){let Ee=Math.max(0,K.y-V);K.addScaledVector(X,-Ee/X.y)}u.push(K.x,K.y,K.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),Se===0&&he.push(h),h++}}for(let ae=0;ae<a;ae++)for(let ge=0;ge<G;ge++){let Se=ue+ge+(G+1)*ae,ye=Se+(G+1),Ee=ye+1,Me=Se+1;l.push(Se,ye,Me),l.push(ye,Ee,Me)}return[j.clone().addScaledVector(X,.5),he]}function q(j,X,N,k){let V=Math.PI/2,H=b.angle()-V,z=[],re=new A,K=new A;for(let G=0;G<=a;G++){let ue=[],he=G/a;for(let ae=0;ae<=G;ae++){let Se=((G?ae/G:0)-.5)*v,ye=Math.cos(Se),Ee=Math.sin(Se),Me=Math.atan(Math.tan(H)*ye),be=(V+Me)*he,Ge=Math.cos(be),ht=Math.sin(be);re.set(0,0,0),re.addScaledVector(X,ht*ye),re.addScaledVector(N,Ge),re.addScaledVector(k,ht*Ee),K.copy(j).addScaledVector(re,o),u.push(K.x,K.y,K.z),c.push(re.x,re.y,re.z),d.push(0,0),ue.push(h++)}z.push(ue)}let Z=z.length-1;for(let G=0;G<Z;G++){let ue=z[G],he=z[G+1],ae=ue.length-1;l.push(ue[0],he[1],he[0]);for(let ge=1;ge<=ae;ge++)l.push(ue[ge-1],ue[ge],he[ge]),l.push(ue[ge],he[ge+1],he[ge])}}}};var Rg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(r){let t=r.shape,{width:e,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(S,w,_){return w>e&&_>n?Math.min(S*e/w,S*n/_):w>e?S*e/w:_>n?S*n/_:S}let f=[];f[0]=i[0]===0?0:h(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:h(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:h(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:h(i[3],i[3]+i[0],i[3]+i[2]);let g=c.x,p=d.x,m=d.y,y=c.y;t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(p,m)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(g,y)),t.isClosed=!0;let v=!0;for(let S=0,w=t.points.length;S<w;S++)t.points[S].roundness=f[S],S>0&&f[S]!==f[S-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Ur.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...r,type:"RectangleGeometry"}})}};var _C=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t=100,height:e=t,depth:n=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new qa(.5*t,i,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var EC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(r){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new Zs(t,e,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var TC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new _b(t,e,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},_b=class extends Te{constructor(t=1,e=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let d=[],h=Math.PI/2,f=(K=0,Z=0,G=0)=>new A(K,Z,G),g=f(),p=f(),[m,y,v]=[e/2,t/2,n/2],x=-y,S=+y,[w,_,E]=[f(x,-m,+v),f(x,-m,-v),f(x,+m,-v)],b=(K,Z=!1)=>Math.sin(K-Math.PI/(1+ +Z)),T=(K,Z=!1)=>Math.cos(K-Math.PI/(1+ +Z));E.y=Math.sin(i)*e-m;let M=Math.cos(i)*e-v,I=w.z-c;i<=h?(E.z=Math.min(M,I),E.z==I&&(E.y-=(M-I)/Math.tan(h-i))):_.z=Math.min(_.z-M-v,w.z-c),g.subVectors(w,_),p.subVectors(E,_);let P=Math.min(g.length(),p.length())*s/100,C=P*Math.tan(i/2),D=P/Math.cos(i/2),R=g.clone().normalize().add(p.normalize()).setLength(D).add(_);g.set(0,b(i,!0),T(i,!0)),d.push([E,g.clone()]);let U=(Math.PI-i)/o;for(let K=0;K<=o;K++){let Z=h+i+K*U;g.set(0,Math.sin(Z)*C,Math.cos(Z)*C),g.add(R),p.set(0,b(Z),T(Z)),d.push([g.clone(),p.clone()])}d.push([w,f(0,1,0)]);let Y=Math.sin(U/2)*C*2,W=d.length-1,q=d[0][0].distanceTo(d[1][0]),j=d[W-1][0].distanceTo(d[W][0]),X=q+Y*o+j;d[0].push(1);for(let K=0;K<=o;K++)d[K+1].push(1-(q+K*Y)/X);d[W].push(0);let[N,k,V]=d[0],H,z,re;for(let K=1;K<d.length;K++)[H,z,re]=d[K],a.push(x,N.y,N.z,x,H.y,H.z,S,N.y,N.z,S,N.y,N.z,x,H.y,H.z,S,H.y,H.z),l.push(0,k.y,k.z,0,z.y,z.z,0,k.y,k.z,0,k.y,k.z,0,z.y,z.z,0,z.y,z.z),u.push(0,V,0,re,1,V,1,V,0,re,1,re),[N,k,V]=[H,z,re];this.setAttribute("position",new we(a,3)),this.setAttribute("normal",new we(l,3)),this.setAttribute("uv",new we(u,2))}};var Ng=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,d=t*.5,h=e*.5,f=0,g=0,p=o*Math.PI/360/i,m=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let S=0;S<i;S++){let w=p*S,_=f+Math.sin(w)*d,E=g+Math.cos(w)*h;c.addPoint(c.createPoint(_,E))}}else for(let S=0;S<i;S++){let w=f+Math.cos(m)*d,_=g+Math.sin(m)*h;c.addPoint(c.createPoint(w,_)),m+=p,w=f+Math.cos(m)*y,_=g+Math.sin(m)*v,S<=i,c.addPoint(c.createPoint(w,_)),m+=p}c.isClosed=!0;for(let S=0,w=c.points.length;S<w;S++)c.points[S].roundness=s;c.roundness=s,c.update();let x=Ur.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...r,type:"StarGeometry"}})}};var MC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e}=r.parameters,n=new Zs(t,e);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var CC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:i,depth:s})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=$H(t,e,n,t*.5,o,s,0,0,i,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function $H(r,t,e,n,i,s,o,a,l,u,c){return[t,e]=[e,t],o=t/2,i/=2*Math.PI,i==1&&(u=0),new ef(!0,r,t,e,n,i,s,o,a,l,u,c)}var PC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(r){let{width:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=t*.5;a!==e&&(a-=e);let l=new oc(a,e,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var IC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t=100,height:e,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=Ur.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...r,type:"TriangleGeometry"}})}};function DC(r,t){let e=2*Math.PI;return(r%e+e)%e===(t%e+e)%e}function e5(r,t,e){let n=[new A,new A,new A],i=[new A,new A,new A];return r.extractBasis(n[0],n[1],n[2]),t.extractBasis(i[0],i[1],i[2]),n.forEach((s,o)=>{let a=i[o],l=Ve.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new de().makeBasis(n[0],n[1],n[2])}var OC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Cu.create({parameters:Ix}).userData.shape;return{path:r.path??$c.defaultData(),parameters:Object.assign(e,{width:n,height:i,depth:s,extrusion:{...Km,...e.extrusion}}),shapeData:o}}static build(r){if(r.path.points.length>=2){let e=new Eb(r);return Object.assign(e,{userData:{...r,type:"PathGeometry"}})}else return Object.assign(new Te,{userData:{...r,type:"PathGeometry"}})}},Eb=class extends Te{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!DC(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:i,offset:s}=this.inputs.parameters.extrusion,o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((i+s)*o):Math.ceil(Math.min(1,i+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let P=0;P<u;P++){let C=this.inputs.path.isClosed?(P+a)%e.length:Math.min(P+a,e.length-1);c.push(e[C].clone()),d.push(n[C].clone())}let h=(P,C,D)=>{c[P]=c[P].clone().lerp(c[C],D),d[P]=e5(d[P],d[C],D)},f=0,g=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(g||s===0)&&(f=g,h(0,1,f));let p=0,m=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&m&&(p=m,h(c.length-1,c.length-2,1-p)),i===0){let P=c.length-1;c[P].copy(c[0]),d[P].copy(d[0])}this._applyPathModifiers(d,f,p);let{regions:y,infos:v,vertices:x}=this._computeShapePoints(5),S=0,w=0;v.sort((P,C)=>P.start-C.start),v.forEach(P=>{P.verticesStart=S,P.verticesCount=P.continuous.reduce((C,D,R)=>C+(R===0||!D?2:1),0),w+=P.verticesCount,S=w});let _=w*u,E,b=0;if(this._isOpenEnded()){try{E=Vi({windingRule:dt.ODD,elementType:nn.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{E=gb}b=E.vertexCount}let T=_+2*b,M={positions:new Float32Array(T*3),normals:new Float32Array(T*3),uvs:new Float32Array(T*2)},I=[];v.forEach(P=>{this._extrudeRegion(P,x,d,c,M,I,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,_,I,M,d[0],c[0],!1),this._closeEnd(E,_+b,I,M,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Fe(M.positions,3)),this.setAttribute("normal",new Fe(M.normals,3)),this.setAttribute("uv",new Fe(M.uvs,2)),this.setIndex(I)}_extractPathPoints(){let n=wg(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let i=[n[0]];return n.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let n=[],i=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let m=0;m<i;m++){let y=e[m],v;m===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[m-1];let x;m===i-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[m-1]):x=e[m+1];let S=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),_=S.clone().add(w).normalize();l.copy(_),m===0&&(_.equals(c)||_.clone().negate().equals(c))&&c.set(0,0,1);let E=c.clone().cross(_).normalize(),b=_.clone().cross(E).normalize();c.copy(b),u.copy(E),m===0&&(o.copy(b),a.copy(_));let T=new de().makeBasis(E,b,_);n.push(T)}let d=s?a:l,h=s?o:new A(0,1,0),f=d.clone().cross(u).normalize(),g=Math.acos(h.dot(f));if(isNaN(g))return n;let p=h.clone().cross(f);d.dot(p)>0&&(g*=-1);for(let m=1;m<n.length;m++){let y=new de().makeRotationZ(g*m/n.length);n[m].multiply(y)}return n}_applyPathModifiers(e,n,i){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new de,d=new de;return e.forEach((h,f)=>{let g=f===0?0:f===s-1?1:(f-n)/(s-(i===0?0:1)-(n+(1-i)));c.makeRotationZ(Ve.lerp(o,o+a,g));let p=Ve.lerp(l,u,g);d.makeScale(p,p,p),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=dt.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(p=>{let m=p.extractShapePointsToFlatArray([],e),y=[];for(let v=m.length-1;v>=1;v-=2){let x=m[v-1],S=m[v-0];y.push(x,S)}return y}),a;try{a=Vi({windingRule:n,elementType:nn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=$h}let l;try{l=Vi({windingRule:dt.ODD,elementType:nn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=mb}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let m=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(m+y)}for(let p=0;p<l.vertexIndices.length;p++){let m=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(m+y)}for(let p=0;p<l.vertices.length;p++){let m=l.vertices[p];a.vertices.push(m)}}let c=1/0,d=-1/0,h=1/0,f=-1/0;for(let p=0,m=a.vertexCount;p<m;p++){let y=p*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>d&&(d=v),x<h&&(h=x),x>f&&(f=x)}let g=[];for(let p=a.elementCount-1;p>=0;p--){let m=p>=u,y=p*2,v=a.elements[y+0],x=a.elements[y+1],S=v+x,w={start:v,count:x,normals:[],isHole:m,continuous:[],verticesStart:0,verticesCount:0};g.push(w);let _=v,E=S-1,b=v+1,T=i.roundedCurves.length;do{let M=_-v,I=a.vertices[E*2+0],P=a.vertices[E*2+1],C=a.vertices[_*2+0],D=a.vertices[_*2+1],R=a.vertices[b*2+0],U=a.vertices[b*2+1],Y=C-I,W=D-P,q=Math.sqrt(Y*Y+W*W);Y/=q,W/=q;let j=C-R,X=D-U,N=Math.sqrt(j*j+X*X);j/=N,X/=N,w.normals[M*2+0]=-X,w.normals[M*2+1]=j;let k=a.vertexIndices[_];if(Array.isArray(k))w.continuous[M]=!1;else{let[V,H]=i.getCurveIndexFromVertexId(k-1,!0);if(H>0&&H<1)w.continuous[M]=!0;else{let z=H===1?V+1:V-1;z=(z+T)%T;let re=H===1?0:1,K=i.roundedCurves[V].getTangent(H),Z=i.roundedCurves[z].getTangent(re);w.continuous[M]=K.dot(Z)>.95}}m&&(w.normals[M*2+0]*=-1,w.normals[M*2+1]*=-1),[E,_,b]=[_,b,b+1],b>=S&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:g,vertices:a.vertices}}_insertVertex(e,n,i,s,o){let a=n*2,l=n*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,n,i,s,o,a,l){let u=new A,c=new A,d=new A,h=new A,f=new F;i.forEach((p,m)=>{let y=s[m],v=e.verticesStart*i.length+e.verticesCount*m;for(let x=0;x<e.count;x++){let S=(e.start+x)*2;if(u.set(n[S+0],n[S+1],0),d.copy(u).applyMatrix4(p).add(y),e.continuous[x])h.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let w=x==0?(e.start+e.count-1)*2:S-2;c.set(n[w+0],n[w+1],0),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(p).normalize(),f.set(x===0?1:x/e.count,m/(i.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,m/(i.length-1));else{let w=x===e.count-1?e.start*2:S+2;c.set(n[w+0],n[w+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(p).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let g=i.length-1;for(let p=0;p<g;p++){let m=e.verticesStart*i.length+e.verticesCount*p,y=e.verticesStart*i.length+e.verticesCount*(p+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let S=x===e.count-1?0:v+1,w=m+v,_=m+S,E=y+S,b=y+v;e.isHole?a.push(w,E,_,w,b,E):a.push(w,_,E,w,E,b),v++}}}_closeEnd(e,n,i,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),d=new A,h=new F;for(let g=0;g<u;g++){let p=2*g;d.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+g,d,c,h)}let f=e.elements;for(let g=0;g<e.elementCount;g++){let p=3*g,m=f[p+0]+n,y=f[p+(l?1:2)]+n,v=f[p+(l?2:1)]+n;i.push(m,y,v)}}};function LC(){let r=new Te;return r.setAttribute("position",new Fe(new Float32Array([]),3)),r.setIndex(new Fe(new Uint16Array([]),1)),r}var t5=LC().attributes,n5=12,r5=1,Du=class extends Te{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,t5),this.userData={parameters:e,type:"TextGeometry"};let i=n.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let i=n.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=i5(e,n,d),{shapes:f,charWidths:g,charCoords:p}=n.generateShapes(h,e),m=i*.5,y=s*.5,v=f.map(w=>new At().fromShape(w));this.vectorShapes=v;let x=v.map(w=>Ur.create({shape:w,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?dt.NONZERO:dt.ODD,subdivisions:this.isLowResolution&&o>0?r5:n5}})),S=x.length?uo(x):LC();S.translate(-m,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=g,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([w,_])=>{this.setAttribute(w,_)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=ki(new Te,Du.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function i5(r,t,e){e=e??r.text;let n=[""],i="";for(let s of e)i+=s,s===" "||s===`
3139
3139
  `?(n[n.length-1]+=i,i="",s===`
3140
- `&&n.push("")):t.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var NC,Ou=new Promise(r=>{NC=r}),RC=!1;async function BC(){if(RC)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.346/build",[e,n]=await Promise.all([import("./process.js"),fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});NC(s),RC=!0}function pl(r,t,e){let n={parameters:r,type:r.type};if(r.type==="PathGeometry")n.path=r.path;else if(r.type==="VectorGeometry"){let s=At.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new uc().parse(r);else{if(r.type==="SubdivGeometry")return new gn(r,e);if(r.type==="TextGeometry")return new Du(r,t)}let i;try{i=Tb(n)}catch(s){console.error(s)}if(!i){let s=At.createFromState(Jc.defaultData(),100,100);n.shape=s,i=Tb(n)}return i}var s5=new de;function rf(r,t,e,n){let i=r.position.array,s=r.normal.array,o=s5.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=t,i[c+1]*=e,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var Bg=new St,Lu=new A,Xe;Ou.then(r=>{Xe=r});var FC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),kC=new Uint32Array([0,1,2,3]),UC=new Uint8Array([4]),gn=class extends Te{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=gs.div(n,i);this.subdividedGeometry&&rf(this.subdividedGeometry.attributes,...s),this.originalGeometry&&rf(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Lu.fromArray(s));let a=Lu.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,i;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:i}=gn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Yn(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(gn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Cn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;Bg.setFromBufferAttribute(n),Bg.getCenter(i),e.boundingSphere.radius=i.distanceTo(Bg.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Bg.getSize(Lu);let s={width:Lu.x,height:Lu.y,depth:Lu.z};return this.userData.parameters=s,s}static build(e,n,i,s){let o,a,l,u=e?.phongAngle??35;i===!1&&(u=-1),n&&(Xe.free_bvh(n),Xe.free_subdivision_surface(n));try{o=gn.allocate(e,s)}catch(c){console.error(c,e),o=gn.allocate({positionWASM:FC,indexWASM:kC,verticesPerFaceWASM:UC},s)}if(Xe.set_destination_refinement_level(o,0),a=gn.buildLevel(o,!0,u),e.subdivisions>0)try{Xe.set_destination_refinement_level(o,e.subdivisions),l=gn.buildLevel(o,!1,u)}catch{try{Xe.set_destination_refinement_level(o,e.subdivisions-1),l=gn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0?n.geometry:pl(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=sf(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=Ib(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=FC,s=kC,o=UC);let u=i.length,c=s.length,d=o.length,h=i.length+a.length+l.length,f=s.length+o.length,g=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,m=f*Uint32Array.BYTES_PER_ELEMENT,y=Xe._malloc(g),v=new Float32Array(Xe.HEAPF32.buffer,y,h),x=new Uint32Array(Xe.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let S;e?.scaleBaked?.some(_=>_!==1)&&(S=new de().makeScale(...e.scaleBaked)),n&&(S?S.premultiply(n):S=n);let w=S?Xe.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,S.elements):Xe.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Xe._free(y),w}static buildLevel(e,n,i,s,o){let a=o?Xe.get_mesh_data2(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i,o.elements):Xe.get_mesh_data(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i),l=8,u=Xe.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Xe.HEAPU32[u[d]>>2],f=Xe.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let g=Xe.HEAPU32[u[d]>>2],p=Xe.HEAPF32.subarray(g>>2,(g>>2)+c[d]);d++;let m=Xe.HEAPU32[u[d]>>2],y=Xe.HEAPU32.subarray(m>>2,(m>>2)+c[d]);d++;let v=Xe.HEAPU32[u[d]>>2],x=Xe.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let S=new Te;if(S.setIndex(new cs(x,1)),S.setAttribute("position",new we(f,3)),S.setAttribute("normal",new we(p,3)),n){S.setAttribute("faceMap",new cs(y,1));let w=new Float32Array(p.length/3*4).fill(0);S.setAttribute("color",new Fe(w,4))}return Xe.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Xe.free_mesh_data(a)}static freeSubdivPointer(e){Xe.free_bvh(e),Xe.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=Xe.get_wireframe_data_for_base_level(e),o=4,a=Xe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Xe.HEAPU32[a[u]>>2],d=Xe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Xe.HEAPU32[a[u]>>2],f=Xe.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let g=new Te;g.setAttribute("position",new we(d,3));let p=new Float32Array(d.length);for(let m=0,y=d.length;m<y;)p[m++]=i.r,p[m++]=i.g,p[m++]=i.b;return g.setAttribute("color",new Fe(p,3)),g.setIndex(new cs(f,1)),Xe.free_wireframe_data_for_base_level(s),g}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Xe.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||Xe.set_destination_refinement_level(e,n);let o=i?Xe.get_topological_data2(e,s?Xe.Level.CONTROL:Xe.Level.REFINED,i.elements):Xe.get_topological_data(e,s?Xe.Level.CONTROL:Xe.Level.REFINED),a=6,l=Xe.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Xe.HEAPU32[l[c]>>2],h=new Float32Array(Xe.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Xe.HEAPU32[l[c]>>2],g=new Uint32Array(Xe.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Xe.HEAPU32[l[c]>>2],m=new Uint8Array(Xe.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Xe.free_topological_data(o),{positions:h,indices:g,verticesPerFace:m}}};var GC=["getX","getY","getZ"];function sf(r,t){let e={},n=t?t.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[GC[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[GC[h]](c));e[d]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Fg=new A,Mb=new A,Cb=new A,Pb=new A;function Ib(r,t,e,n){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Fg.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),Mb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),Cb.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),Pb.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),Mb.sub(Fg).normalize(),Cb.sub(Fg).normalize(),Pb.sub(Fg).normalize();let l=Mb.cross(Cb).dot(Pb);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(i.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Hi={};Aw(Hi,{calcBoolean:()=>l5,calcBooleanTopological:()=>a5,freeMeshSet:()=>d5,getMeshSet:()=>c5,transformMeshSet:()=>u5});var VC,HC=new Promise(r=>{VC=r}),zC=!1;async function WC(){if(zC)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.346/build",[e,n]=await Promise.all([import("./boolean.js"),fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});VC(s),zC=!0}var at,Ru;HC.then(r=>at=r);function o5(r,t,e){let n,i;r.userData.parameters.type==="TorusGeometry"&&r.userData.parameters.arc===Math.PI*2?i=r.getClosedTorusIndicesForBooleanOrSubdiv():i=r.getIndex();let{positions:s,triIndices:o}=sf(r.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:u}=Ib(s,o,r);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function jC(r){let t=r.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?e:n,s=at._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(at.HEAPU32.buffer,s,t):new Float32Array(at.HEAPF32.buffer,s,t)).set(r,0),s}function qC(r){switch(r){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function a5(r,t){Ru===void 0&&(Ru=at.init_csg());let e=jC(r),n=at.csg_calc_topological(Ru,e,r.length,qC(t));at._free(e);let i=6,s=at.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=at.HEAPU32[s[a]>>2],u=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=at.HEAPU32[s[a]>>2],d=new Uint32Array(at.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=at.HEAPU32[s[a]>>2],f=new Uint8Array(at.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return at.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function l5(r,t,e,n){Ru===void 0&&(Ru=at.init_csg());let i=jC(r),s=at.csg_calc(Ru,i,r.length,n,qC(t));at._free(i);let o=5,a=at.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=at.HEAPU32[a[u]>>2],d=at.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=at.HEAPU32[a[u]>>2],f=at.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let g=l[u];e.setAttribute("position",new we(d,3)),e.setAttribute("normal",new we(f,3));let p=at.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Cn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},at.free_mesh_data(s),g}function c5(r,t,e){if(at===void 0)return-1;let n,i,s;if(t&&r.userData.positions!==void 0){let m=r.userData;s=m.verticesPerFace.length,n=m.positions,i=Array(m.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<m.verticesPerFace.length;y++){i[x++]=m.verticesPerFace[y];for(let S=0;S<m.verticesPerFace[y];S++)i[x++]=m.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=o5(r,t,e));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=at._malloc(c),g=new Float32Array(at.HEAPF32.buffer,f,l),p=new Uint32Array(at.HEAPU32.buffer,f+d,u);return g.set(n,0),p.set(i,0),at.get_csg_mesh(f,o,f+d,a,s)}function u5(r,t){at.transform_csg_mesh(r,t.elements)}function d5(r){at.free_csg_mesh(r)}var h5={ConeGeometry:HM,CubeGeometry:WM,CylinderGeometry:VM,DodecahedronGeometry:jM,EllipseGeometry:Cu,HelixGeometry:gC,IcosahedronGeometry:yC,LatheGeometry:vC,NonParametricGeometry:wC,PolygonGeometry:Lg,PyramidGeometry:AC,RectangleGeometry:Rg,SphereGeometry:_C,PlaneGeometry:EC,BackdropGeometry:TC,StarGeometry:Ng,TextFrameGeometry:MC,TorusGeometry:CC,TorusKnotGeometry:PC,TriangleGeometry:IC,PathGeometry:OC,VectorGeometry:Ur},Tb=r=>h5[r.type].create(r);function of(r){return r!==null&&"booleanOp"in r}var Nu=class extends Ag(Xn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new de}updateVisible(){super.updateVisible(),this.visible=!of(this.parent)&&this.visible,of(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),of(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Nu&&(e.freeBooleanPointer(),of(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&of(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var kg=new St;function af(r,t=0,e=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=r.getX(d),f=r.getY(d),g=r.getZ(d);h<s&&(s=h),f<o&&(o=f),g<a&&(a=g),h>l&&(l=h),f>u&&(u=f),g>c&&(c=g)}kg.min.set(s,o,a),kg.max.set(l,u,c),kg.getCenter(n),kg.getSize(i).multiplyScalar(.5)}var f5=new Te,p5=new Ks,Bt=class extends Nu{constructor(t,e){super(f5,p5),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?af(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var lf=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var nr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ve.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,n){e=e??this.getType(t,e);let i=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,i,s,o){return""}generate(t,e,n,i,s){return""}parse(t,e,n,i){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let i=t.getTypeLength(n);(i>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=i,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof nr&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Db=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Gn=new Db;var ke=class extends nr{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,i,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Ve.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,i)):super.build(e,n,i);if(o)return a.name=a.name||super.build(e,n,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,i);i=this.getUUID(!1);let u=this.getTemp(e,i);if(u)return e.format(u,l,n);{u=super.generate(e,n,i,a.output,s);let c=this.generate(e,l,i);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,i)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let i=e.getVars()[n];return i?i.name:void 0}generate(e,n,i,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var Rt=class extends ke{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var un=class extends Rt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(e,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,n,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var ur=class extends Rt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var Zt=class extends Ne{constructor(e,n,i,s){super(e,n,i);this.isColorA=!0;this.a=s}setRGBA(e,n,i,s){super.setRGB(e,n,i),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Gr=class extends Rt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Zt?e:new Zt(e.r,e.g,e.b,e.a)}generateReadonly(e,n,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var m5=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,XC=/[a-z_0-9]+/gi,fe=class extends ke{constructor(e,n,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(e,n,i,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=XC.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],g=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&g&&Gn.containsKeyword(f)){let m=this.keywords[f];if(!m){let y=Gn.getKeywordData(f);y.cache&&(m=e.keywords[f]),m=m||Gn.getKeyword(f,e),y.cache&&(e.keywords[f]=m)}p=m.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Gn.contains(p)&&e.include(Gn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,i,s){if(this.src=e||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=m5.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(XC);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var g5=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ob=class extends ke{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Ob.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,i,s,o){this.src=e||"";let a,l,u="",c=g5.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),n)}generate(e,n,i,s,o){return e.format(this.name,this.getType(e),n)}},xt=Ob;xt.PI="PI",xt.PI2="PI2",xt.RECIPROCAL_PI="RECIPROCAL_PI",xt.RECIPROCAL_PI2="RECIPROCAL_PI2",xt.LOG2="LOG2",xt.EPSILON="EPSILON";var y5=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3140
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var NC,Ou=new Promise(r=>{NC=r}),RC=!1;async function BC(){if(RC)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.347/build",[e,n]=await Promise.all([import("./process.js"),fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});NC(s),RC=!0}function pl(r,t,e){let n={parameters:r,type:r.type};if(r.type==="PathGeometry")n.path=r.path;else if(r.type==="VectorGeometry"){let s=At.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new uc().parse(r);else{if(r.type==="SubdivGeometry")return new gn(r,e);if(r.type==="TextGeometry")return new Du(r,t)}let i;try{i=Tb(n)}catch(s){console.error(s)}if(!i){let s=At.createFromState(Jc.defaultData(),100,100);n.shape=s,i=Tb(n)}return i}var s5=new de;function rf(r,t,e,n){let i=r.position.array,s=r.normal.array,o=s5.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=t,i[c+1]*=e,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var Bg=new St,Lu=new A,Xe;Ou.then(r=>{Xe=r});var FC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),kC=new Uint32Array([0,1,2,3]),UC=new Uint8Array([4]),gn=class extends Te{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=gs.div(n,i);this.subdividedGeometry&&rf(this.subdividedGeometry.attributes,...s),this.originalGeometry&&rf(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Lu.fromArray(s));let a=Lu.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,i;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:i}=gn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Yn(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(gn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Cn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;Bg.setFromBufferAttribute(n),Bg.getCenter(i),e.boundingSphere.radius=i.distanceTo(Bg.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Bg.getSize(Lu);let s={width:Lu.x,height:Lu.y,depth:Lu.z};return this.userData.parameters=s,s}static build(e,n,i,s){let o,a,l,u=e?.phongAngle??35;i===!1&&(u=-1),n&&(Xe.free_bvh(n),Xe.free_subdivision_surface(n));try{o=gn.allocate(e,s)}catch(c){console.error(c,e),o=gn.allocate({positionWASM:FC,indexWASM:kC,verticesPerFaceWASM:UC},s)}if(Xe.set_destination_refinement_level(o,0),a=gn.buildLevel(o,!0,u),e.subdivisions>0)try{Xe.set_destination_refinement_level(o,e.subdivisions),l=gn.buildLevel(o,!1,u)}catch{try{Xe.set_destination_refinement_level(o,e.subdivisions-1),l=gn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0?n.geometry:pl(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=sf(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=Ib(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=FC,s=kC,o=UC);let u=i.length,c=s.length,d=o.length,h=i.length+a.length+l.length,f=s.length+o.length,g=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,m=f*Uint32Array.BYTES_PER_ELEMENT,y=Xe._malloc(g),v=new Float32Array(Xe.HEAPF32.buffer,y,h),x=new Uint32Array(Xe.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let S;e?.scaleBaked?.some(_=>_!==1)&&(S=new de().makeScale(...e.scaleBaked)),n&&(S?S.premultiply(n):S=n);let w=S?Xe.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,S.elements):Xe.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Xe._free(y),w}static buildLevel(e,n,i,s,o){let a=o?Xe.get_mesh_data2(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i,o.elements):Xe.get_mesh_data(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i),l=8,u=Xe.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Xe.HEAPU32[u[d]>>2],f=Xe.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let g=Xe.HEAPU32[u[d]>>2],p=Xe.HEAPF32.subarray(g>>2,(g>>2)+c[d]);d++;let m=Xe.HEAPU32[u[d]>>2],y=Xe.HEAPU32.subarray(m>>2,(m>>2)+c[d]);d++;let v=Xe.HEAPU32[u[d]>>2],x=Xe.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let S=new Te;if(S.setIndex(new cs(x,1)),S.setAttribute("position",new we(f,3)),S.setAttribute("normal",new we(p,3)),n){S.setAttribute("faceMap",new cs(y,1));let w=new Float32Array(p.length/3*4).fill(0);S.setAttribute("color",new Fe(w,4))}return Xe.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Xe.free_mesh_data(a)}static freeSubdivPointer(e){Xe.free_bvh(e),Xe.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=Xe.get_wireframe_data_for_base_level(e),o=4,a=Xe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Xe.HEAPU32[a[u]>>2],d=Xe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Xe.HEAPU32[a[u]>>2],f=Xe.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let g=new Te;g.setAttribute("position",new we(d,3));let p=new Float32Array(d.length);for(let m=0,y=d.length;m<y;)p[m++]=i.r,p[m++]=i.g,p[m++]=i.b;return g.setAttribute("color",new Fe(p,3)),g.setIndex(new cs(f,1)),Xe.free_wireframe_data_for_base_level(s),g}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Xe.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||Xe.set_destination_refinement_level(e,n);let o=i?Xe.get_topological_data2(e,s?Xe.Level.CONTROL:Xe.Level.REFINED,i.elements):Xe.get_topological_data(e,s?Xe.Level.CONTROL:Xe.Level.REFINED),a=6,l=Xe.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Xe.HEAPU32[l[c]>>2],h=new Float32Array(Xe.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Xe.HEAPU32[l[c]>>2],g=new Uint32Array(Xe.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Xe.HEAPU32[l[c]>>2],m=new Uint8Array(Xe.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Xe.free_topological_data(o),{positions:h,indices:g,verticesPerFace:m}}};var GC=["getX","getY","getZ"];function sf(r,t){let e={},n=t?t.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[GC[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[GC[h]](c));e[d]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Fg=new A,Mb=new A,Cb=new A,Pb=new A;function Ib(r,t,e,n){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Fg.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),Mb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),Cb.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),Pb.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),Mb.sub(Fg).normalize(),Cb.sub(Fg).normalize(),Pb.sub(Fg).normalize();let l=Mb.cross(Cb).dot(Pb);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(i.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Hi={};Aw(Hi,{calcBoolean:()=>l5,calcBooleanTopological:()=>a5,freeMeshSet:()=>d5,getMeshSet:()=>c5,transformMeshSet:()=>u5});var VC,HC=new Promise(r=>{VC=r}),zC=!1;async function WC(){if(zC)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.347/build",[e,n]=await Promise.all([import("./boolean.js"),fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});VC(s),zC=!0}var at,Ru;HC.then(r=>at=r);function o5(r,t,e){let n,i;r.userData.parameters.type==="TorusGeometry"&&r.userData.parameters.arc===Math.PI*2?i=r.getClosedTorusIndicesForBooleanOrSubdiv():i=r.getIndex();let{positions:s,triIndices:o}=sf(r.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:u}=Ib(s,o,r);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function jC(r){let t=r.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?e:n,s=at._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(at.HEAPU32.buffer,s,t):new Float32Array(at.HEAPF32.buffer,s,t)).set(r,0),s}function qC(r){switch(r){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function a5(r,t){Ru===void 0&&(Ru=at.init_csg());let e=jC(r),n=at.csg_calc_topological(Ru,e,r.length,qC(t));at._free(e);let i=6,s=at.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=at.HEAPU32[s[a]>>2],u=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=at.HEAPU32[s[a]>>2],d=new Uint32Array(at.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=at.HEAPU32[s[a]>>2],f=new Uint8Array(at.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return at.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function l5(r,t,e,n){Ru===void 0&&(Ru=at.init_csg());let i=jC(r),s=at.csg_calc(Ru,i,r.length,n,qC(t));at._free(i);let o=5,a=at.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=at.HEAPU32[a[u]>>2],d=at.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=at.HEAPU32[a[u]>>2],f=at.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let g=l[u];e.setAttribute("position",new we(d,3)),e.setAttribute("normal",new we(f,3));let p=at.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Cn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},at.free_mesh_data(s),g}function c5(r,t,e){if(at===void 0)return-1;let n,i,s;if(t&&r.userData.positions!==void 0){let m=r.userData;s=m.verticesPerFace.length,n=m.positions,i=Array(m.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<m.verticesPerFace.length;y++){i[x++]=m.verticesPerFace[y];for(let S=0;S<m.verticesPerFace[y];S++)i[x++]=m.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=o5(r,t,e));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=at._malloc(c),g=new Float32Array(at.HEAPF32.buffer,f,l),p=new Uint32Array(at.HEAPU32.buffer,f+d,u);return g.set(n,0),p.set(i,0),at.get_csg_mesh(f,o,f+d,a,s)}function u5(r,t){at.transform_csg_mesh(r,t.elements)}function d5(r){at.free_csg_mesh(r)}var h5={ConeGeometry:HM,CubeGeometry:WM,CylinderGeometry:VM,DodecahedronGeometry:jM,EllipseGeometry:Cu,HelixGeometry:gC,IcosahedronGeometry:yC,LatheGeometry:vC,NonParametricGeometry:wC,PolygonGeometry:Lg,PyramidGeometry:AC,RectangleGeometry:Rg,SphereGeometry:_C,PlaneGeometry:EC,BackdropGeometry:TC,StarGeometry:Ng,TextFrameGeometry:MC,TorusGeometry:CC,TorusKnotGeometry:PC,TriangleGeometry:IC,PathGeometry:OC,VectorGeometry:Ur},Tb=r=>h5[r.type].create(r);function of(r){return r!==null&&"booleanOp"in r}var Nu=class extends Ag(Xn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new de}updateVisible(){super.updateVisible(),this.visible=!of(this.parent)&&this.visible,of(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),of(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Nu&&(e.freeBooleanPointer(),of(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&of(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var kg=new St;function af(r,t=0,e=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=r.getX(d),f=r.getY(d),g=r.getZ(d);h<s&&(s=h),f<o&&(o=f),g<a&&(a=g),h>l&&(l=h),f>u&&(u=f),g>c&&(c=g)}kg.min.set(s,o,a),kg.max.set(l,u,c),kg.getCenter(n),kg.getSize(i).multiplyScalar(.5)}var f5=new Te,p5=new Ks,Bt=class extends Nu{constructor(t,e){super(f5,p5),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?af(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var lf=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var nr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ve.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,n){e=e??this.getType(t,e);let i=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,i,s,o){return""}generate(t,e,n,i,s){return""}parse(t,e,n,i){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let i=t.getTypeLength(n);(i>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=i,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof nr&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Db=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Gn=new Db;var ke=class extends nr{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,i,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Ve.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,i)):super.build(e,n,i);if(o)return a.name=a.name||super.build(e,n,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,i);i=this.getUUID(!1);let u=this.getTemp(e,i);if(u)return e.format(u,l,n);{u=super.generate(e,n,i,a.output,s);let c=this.generate(e,l,i);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,i)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let i=e.getVars()[n];return i?i.name:void 0}generate(e,n,i,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var Rt=class extends ke{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var un=class extends Rt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(e,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,n,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var ur=class extends Rt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var Zt=class extends Ne{constructor(e,n,i,s){super(e,n,i);this.isColorA=!0;this.a=s}setRGBA(e,n,i,s){super.setRGB(e,n,i),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Gr=class extends Rt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Zt?e:new Zt(e.r,e.g,e.b,e.a)}generateReadonly(e,n,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var m5=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,XC=/[a-z_0-9]+/gi,fe=class extends ke{constructor(e,n,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(e,n,i,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=XC.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],g=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&g&&Gn.containsKeyword(f)){let m=this.keywords[f];if(!m){let y=Gn.getKeywordData(f);y.cache&&(m=e.keywords[f]),m=m||Gn.getKeyword(f,e),y.cache&&(e.keywords[f]=m)}p=m.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Gn.contains(p)&&e.include(Gn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,i,s){if(this.src=e||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=m5.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(XC);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var g5=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ob=class extends ke{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Ob.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,i,s,o){this.src=e||"";let a,l,u="",c=g5.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),n)}generate(e,n,i,s,o){return e.format(this.name,this.getType(e),n)}},xt=Ob;xt.PI="PI",xt.PI2="PI2",xt.RECIPROCAL_PI="RECIPROCAL_PI",xt.RECIPROCAL_PI2="RECIPROCAL_PI2",xt.LOG2="LOG2",xt.EPSILON="EPSILON";var y5=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
3141
  )*?)}`,"gim"),v5=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Bu=class extends ke{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}generate(e,n,i,s,o){return n==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),n)}parse(e=""){this.src=e,this.inputs=[];let n=y5.exec(e);if(n){let i=n[2],s;for(;s=v5.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Fu=class extends ke{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,n){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(s,this.getType(e),n)}};Gn.addKeyword("uv",function(){return new Fu});Gn.addKeyword("uv2",function(){return new Fu(1)});var ml=class extends ke{constructor(e,n){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=n??ml.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Jr:return["Linear"];case Ye:return["sRGB"];default:return[]}}generate(e,n){let i=this.input.build(e,"v4"),s=this.getType(e),o=ml.Nodes[this.method],a=e.include(o);if(a===ml.LINEAR_TO_LINEAR)return e.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+i+", "+l+" )",s,n)}else return e.format(a+"( "+i+" )",s,n)}fromEncoding(e){let n=ml.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(e){let n=ml.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}},Pr=ml;Pr.Nodes={LinearToLinear:new fe(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3142
3142
  `)),sRGBToLinear:new fe(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
3143
3143
  `)),LinearTosRGB:new fe(["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(`
@@ -5758,4 +5758,4 @@ outputColor=vec4(color,inputColor.a);}`,$y={DEFAULT:0,ESKIL:1},FI=class extends
5758
5758
  void main() {
5759
5759
  gl_FragColor = vec4(0.0);
5760
5760
  }
5761
- `}),Bd=class extends qr{constructor(e,n){super("OpaquePass",e??kI,n);this.hasTransmissionPass=!1;this.clear=!0;this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??kI}getScene(){return this.scene}render(e,n){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(s=>{s.layers.isEnabled(3)&&s instanceof Bt&&(this.originalMaterials.set(s.id,s.material),s.material=f8)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:n;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((s,o)=>{let a=this.scene.getObjectById(o);a&&(a.material=s)})}};function UI(r,t){return t&&t.enabled&&r.push(t.effect),r}var p8=r=>Object.values(st).includes(r)?r:st.NORMAL,jf=class extends Gt{constructor(e){super();this.postprocessingState=ol.defaultData;this._scene=new Ar;this._camera=new Ht;this.effects=new Map;this._renderToScreen=!0;this.clock=new Gp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new Md),this.effects.set("chromaticAberration",new Pd),this.effects.set("vignette",new Ld),this.effects.set("noise",new Od),this.effects.set("colorAverage",new Id),this.effects.set("hueSaturation",new Dd),this.effects.set("brightnessContrast",new Cd),this.effects.set("depthOfField",new Rd),this.effects.set("pixelation",new Nd),this.effectComposer=new MI(this.renderer),this.opaquePass=new Bd(this.scene,this.camera),this.transmissionPass=new nv(this.scene,this.camera,this.renderer),this.helperPass=new Bd(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Wf(!1,!0,!1),this.helperPassOnTop=new Bd(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new BI({preset:Pl.ULTRA,edgeDetectionMode:ev.COLOR}),n=()=>{e.removeEventListener("load",n),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",n),e.edgeDetectionMaterial.predicationMode=gw.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new tv(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(UI,[]);e.length>0&&(this.uvEffectPass=new tv(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(UI,[]);n.length>0&&(this.effectPass=new tv(this.camera,...n),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new Tt(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Ql,wrapT:Ql}),this._rt.samples=0,this._savePass=new Td(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?(n.removePass(this._savePass),n.passes[n.passes.length-1].renderToScreen=!0,n.autoRenderToScreen=!0):(n.autoRenderToScreen=!1,n.passes[n.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),n.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...i}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(i)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=p8(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,i,s),this.effectComposer.outputBuffer.scissor.set(e,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,i,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,i,s){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,i,s),this.effectComposer.outputBuffer.viewport.set(e,n,i,s))}resize(e,n,i){if(this.effectComposer.setSize(e,n,i),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var GI=new Wt,rv=class extends N0{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new jf(this);this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let n=this.setPixelRatio.bind(this),i=this.setSize.bind(this),s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio=o,n(o)},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,i(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2))}get hdTransmission(){return bt.transmissionLod.value===1}set hdTransmission(e){bt.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new Tt(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Ba,magFilter:it,wrapS:Sr,wrapT:Sr,depthBuffer:!1}),this.transmissionDepthTarget=new Tt(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:kt,magFilter:kt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Tt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:kt,magFilter:kt,type:os,depthTexture:new ko(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof Ht?dy.uniforms.depthContrast.value=(n.far-n.near)/1e4:dy.uniforms.depthContrast.value=1,e.overrideMaterial=dy,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?fy:null,n.layers.enable(0),n.layers.enable(3))}renderSplineScene(e,n,i,s,o){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((l,u)=>{bt.penumbraSize.value[u]=l}),bt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?bt.resolution.value.set(this.resolution.x,this.resolution.y):bt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(bt.normalRenderTarget.value=this.overrideNormal,bt.normalRenderTargetDepth.value=GI):e.needsNormal()&&(this.createNormalRenderTarget(),bt.normalRenderTarget.value=this.normalRenderTarget.texture,bt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n));let a=!1;if(this.overrideTransmission!==void 0)bt.transmissionRenderTarget.value=this.overrideTransmission,bt.transmissionRenderTargetDepth.value=GI,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),bt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,bt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(l)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=s,this.pipeline.sceneHelpersOnTop=o,this.pipeline.scene=e,this.pipeline.camera=n,a&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?fy:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var iv=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new go(t.shared,e),this.scene=new rn(t.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof $t&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var sv=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function m8(r){let t;if(!!r.index)for(let e=0;e<r.index.array.length;e+=3)t=r.index.array[e],r.index.array[e]=r.index.array[e+2],r.index.array[e+2]=t}function qf(r){return r instanceof Qi?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function g8(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof Bt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof Bt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!tr.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!tr.isMergable(u.material))return;s=tr.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][qf(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][qf(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][qf(n)].push(u)}),e}function y8(r){let t=0;return Object.values(r).forEach(e=>{Object.values(e).forEach(n=>{let i=n.length;i>t&&(t=i)})}),t}function zI(r,t){let e=g8(t,r),n=y8(e),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let g of Object.values(f)){if(a=0,u=0,g.forEach(m=>{m instanceof Bt&&(o[a++]=m.geometry.clone(),l[u++]=m)}),u<2)continue;for(let m=0;m<u;m++)l[m].updateWorldMatrix(!0,!1),o[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&m8(o[m]);let p=uo(o.slice(0,a),!1);if(p){let m;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new Xn(p,l[0].material);break}default:{m=new Xn(p,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Bt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][qf(x)]&&e[x.material.uuid][qf(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let h=0;h<s;h++)i[h].removeFromParent()}var WI=Gs(HI(),1);var v8=new F;function x8(r){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(t)}var xw=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._lastTime=performance.now();this._isStopped=!1;this._renderRequested=!1;this.time=performance.now();this.dt=0;this._skipRender=!1;this.disposed=!1;this._requestRenderInner=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0,this._requestRenderInner()};this.render=t=>{!this._renderer||(this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._isStopped||(this._rafId=requestAnimationFrame(this.render)),this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(!this._isStopped&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender))&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end(),this._renderRequested=!1,this.canvas.dispatchEvent(this._renderedEvent)))};this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=v8.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderInner())};this._debouncedResize=$a(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new sv({x:10,y:10})),KT(t)}async load(t,e){x8(t),this.disposed=!1;let i=await(await fetch(t,e)).arrayBuffer();await this.start(i)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await gI(t);this._data=n,n.version&&(0,WI.default)(n.version,"0.9.346")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([hS(n)&&WC(),aP(n)&&BC(),n.scene.environment.usePhysics&&$E(),rS(n)&&sP()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let i=new iv(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();zI(n,i.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}hS(n)&&this._scene.traverse(o=>{Dr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderInner(),this._scene?.traverse(o=>{o instanceof oi&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{i.scene.markNeedsUpdateRendererDirty(),this._requestRenderInner()}),rS(n)&&sI(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),_y(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new rv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderInner),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=n.scene.environment.ambientLight.softShadows?qp:D0,kP(n.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Zy(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}e&&(this._scene.updateMatrixWorld(!0),this._controls=new jy(n,this._scene,this._renderer,this._requestRenderInner,this._sharedAssetsManager,!0),this._eventManager=new Ky(this._renderer,this._scene,this._camera,n.scene.publish,this._sharedAssetsManager,this._requestRenderInner,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),this._rafId===void 0?this.render(performance.now()):this._requestRenderInner(),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==rn.PERSONAL_CAMERA_ID){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Ad&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:i,a:s}={r:0,g:0,b:0,a:1},o=new Zt(e,n,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.setBackgroundColor(o),this._requestRenderInner()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0),this._proxyObjectCache.forEach(t=>{Y0.unsubscribe(t)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),ZT(this.canvas)}get isStopped(){return this._isStopped}stop(){this._isStopped||(this._rafId&&cancelAnimationFrame(this._rafId),this._rafId=void 0,this._isStopped=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isStopped||(this._isStopped=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._rafId===void 0&&(this._rafId=requestAnimationFrame(this.render)),this._rafId=void 0)}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,emitEvent(i){t.dispatchEvent({type:"userEvent",eventName:i})},emitEventReverse(i){t.dispatchEvent({type:"userEvent",eventName:i,reverse:!0})}},n=Y0(e,(i,s)=>{typeof t[i]!="object"&&Object.getOwnPropertyDescriptor(t,i)?.writable&&(t[i]=s),this._requestRenderInner(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};
5761
+ `}),Bd=class extends qr{constructor(e,n){super("OpaquePass",e??kI,n);this.hasTransmissionPass=!1;this.clear=!0;this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??kI}getScene(){return this.scene}render(e,n){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(s=>{s.layers.isEnabled(3)&&s instanceof Bt&&(this.originalMaterials.set(s.id,s.material),s.material=f8)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:n;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((s,o)=>{let a=this.scene.getObjectById(o);a&&(a.material=s)})}};function UI(r,t){return t&&t.enabled&&r.push(t.effect),r}var p8=r=>Object.values(st).includes(r)?r:st.NORMAL,jf=class extends Gt{constructor(e){super();this.postprocessingState=ol.defaultData;this._scene=new Ar;this._camera=new Ht;this.effects=new Map;this._renderToScreen=!0;this.clock=new Gp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new Md),this.effects.set("chromaticAberration",new Pd),this.effects.set("vignette",new Ld),this.effects.set("noise",new Od),this.effects.set("colorAverage",new Id),this.effects.set("hueSaturation",new Dd),this.effects.set("brightnessContrast",new Cd),this.effects.set("depthOfField",new Rd),this.effects.set("pixelation",new Nd),this.effectComposer=new MI(this.renderer),this.opaquePass=new Bd(this.scene,this.camera),this.transmissionPass=new nv(this.scene,this.camera,this.renderer),this.helperPass=new Bd(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Wf(!1,!0,!1),this.helperPassOnTop=new Bd(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new BI({preset:Pl.ULTRA,edgeDetectionMode:ev.COLOR}),n=()=>{e.removeEventListener("load",n),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",n),e.edgeDetectionMaterial.predicationMode=gw.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new tv(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(UI,[]);e.length>0&&(this.uvEffectPass=new tv(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(UI,[]);n.length>0&&(this.effectPass=new tv(this.camera,...n),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new Tt(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Ql,wrapT:Ql}),this._rt.samples=0,this._savePass=new Td(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?(n.removePass(this._savePass),n.passes[n.passes.length-1].renderToScreen=!0,n.autoRenderToScreen=!0):(n.autoRenderToScreen=!1,n.passes[n.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),n.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...i}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(i)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=p8(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,i,s),this.effectComposer.outputBuffer.scissor.set(e,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,i,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,i,s){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,i,s),this.effectComposer.outputBuffer.viewport.set(e,n,i,s))}resize(e,n,i){if(this.effectComposer.setSize(e,n,i),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var GI=new Wt,rv=class extends N0{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new jf(this);this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let n=this.setPixelRatio.bind(this),i=this.setSize.bind(this),s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio=o,n(o)},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,i(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2))}get hdTransmission(){return bt.transmissionLod.value===1}set hdTransmission(e){bt.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new Tt(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Ba,magFilter:it,wrapS:Sr,wrapT:Sr,depthBuffer:!1}),this.transmissionDepthTarget=new Tt(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:kt,magFilter:kt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Tt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:kt,magFilter:kt,type:os,depthTexture:new ko(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof Ht?dy.uniforms.depthContrast.value=(n.far-n.near)/1e4:dy.uniforms.depthContrast.value=1,e.overrideMaterial=dy,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?fy:null,n.layers.enable(0),n.layers.enable(3))}renderSplineScene(e,n,i,s,o){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((l,u)=>{bt.penumbraSize.value[u]=l}),bt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?bt.resolution.value.set(this.resolution.x,this.resolution.y):bt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(bt.normalRenderTarget.value=this.overrideNormal,bt.normalRenderTargetDepth.value=GI):e.needsNormal()&&(this.createNormalRenderTarget(),bt.normalRenderTarget.value=this.normalRenderTarget.texture,bt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n));let a=!1;if(this.overrideTransmission!==void 0)bt.transmissionRenderTarget.value=this.overrideTransmission,bt.transmissionRenderTargetDepth.value=GI,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),bt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,bt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(l)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=s,this.pipeline.sceneHelpersOnTop=o,this.pipeline.scene=e,this.pipeline.camera=n,a&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?fy:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var iv=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new go(t.shared,e),this.scene=new rn(t.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof $t&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var sv=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function m8(r){let t;if(!!r.index)for(let e=0;e<r.index.array.length;e+=3)t=r.index.array[e],r.index.array[e]=r.index.array[e+2],r.index.array[e+2]=t}function qf(r){return r instanceof Qi?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function g8(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof Bt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof Bt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!tr.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!tr.isMergable(u.material))return;s=tr.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][qf(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][qf(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][qf(n)].push(u)}),e}function y8(r){let t=0;return Object.values(r).forEach(e=>{Object.values(e).forEach(n=>{let i=n.length;i>t&&(t=i)})}),t}function zI(r,t){let e=g8(t,r),n=y8(e),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let g of Object.values(f)){if(a=0,u=0,g.forEach(m=>{m instanceof Bt&&(o[a++]=m.geometry.clone(),l[u++]=m)}),u<2)continue;for(let m=0;m<u;m++)l[m].updateWorldMatrix(!0,!1),o[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&m8(o[m]);let p=uo(o.slice(0,a),!1);if(p){let m;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new Xn(p,l[0].material);break}default:{m=new Xn(p,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Bt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][qf(x)]&&e[x.material.uuid][qf(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let h=0;h<s;h++)i[h].removeFromParent()}var WI=Gs(HI(),1);var v8=new F;function x8(r){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(t)}var xw=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._lastTime=performance.now();this._isStopped=!1;this._renderRequested=!1;this.time=performance.now();this.dt=0;this._skipRender=!1;this.disposed=!1;this._requestRenderInner=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0,this._requestRenderInner()};this.render=t=>{!this._renderer||(this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._isStopped||(this._rafId=requestAnimationFrame(this.render)),this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(!this._isStopped&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender))&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end(),this._renderRequested=!1,this.canvas.dispatchEvent(this._renderedEvent)))};this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=v8.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderInner())};this._debouncedResize=$a(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new sv({x:10,y:10})),KT(t)}async load(t,e){x8(t),this.disposed=!1;let i=await(await fetch(t,e)).arrayBuffer();await this.start(i)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await gI(t);this._data=n,n.version&&(0,WI.default)(n.version,"0.9.347")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([hS(n)&&WC(),aP(n)&&BC(),n.scene.environment.usePhysics&&$E(),rS(n)&&sP()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let i=new iv(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();zI(n,i.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}hS(n)&&this._scene.traverse(o=>{Dr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderInner(),this._scene?.traverse(o=>{o instanceof oi&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{i.scene.markNeedsUpdateRendererDirty(),this._requestRenderInner()}),rS(n)&&sI(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),_y(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new rv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderInner),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=n.scene.environment.ambientLight.softShadows?qp:D0,kP(n.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Zy(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}e&&(this._scene.updateMatrixWorld(!0),this._controls=new jy(n,this._scene,this._renderer,this._requestRenderInner,this._sharedAssetsManager,!0),this._eventManager=new Ky(this._renderer,this._scene,this._camera,n.scene.publish,this._sharedAssetsManager,this._requestRenderInner,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),this._rafId===void 0?this.render(performance.now()):this._requestRenderInner(),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==rn.PERSONAL_CAMERA_ID){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Ad&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:i,a:s}={r:0,g:0,b:0,a:1},o=new Zt(e,n,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.setBackgroundColor(o),this._requestRenderInner()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0),this._proxyObjectCache.forEach(t=>{Y0.unsubscribe(t)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),ZT(this.canvas)}get isStopped(){return this._isStopped}stop(){this._isStopped||(this._rafId&&cancelAnimationFrame(this._rafId),this._rafId=void 0,this._isStopped=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isStopped||(this._isStopped=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._rafId===void 0&&(this._rafId=requestAnimationFrame(this.render)),this._rafId=void 0)}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,emitEvent(i){t.dispatchEvent({type:"userEvent",eventName:i})},emitEventReverse(i){t.dispatchEvent({type:"userEvent",eventName:i,reverse:!0})}},n=Y0(e,(i,s)=>{typeof t[i]!="object"&&Object.getOwnPropertyDescriptor(t,i)?.writable&&(t[i]=s),this._requestRenderInner(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};