@splinetool/viewer 0.9.332 → 0.9.333
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/spline-viewer.cjs
CHANGED
|
@@ -3137,7 +3137,7 @@ void main() {
|
|
|
3137
3137
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3138
3138
|
}`;function _D(e,t,i){let r=new _g,s=new G,n=new G,a=new $e,o=new Yb({depthPacking:Bb}),l=new xD,h={},u=i.maxTextureSize,c={[Zr]:ui,[ui]:Zr,[sr]:sr},d=new ai({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new G},radius:{value:4}},vertexShader:wD,fragmentShader:bD}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new He;f.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new nr(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yg,this.render=function(w,_,S){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let A=e.getRenderTarget(),b=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(xi),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=w.length;T<D;T++){let L=w[T],P=L.shadow;if(P===void 0){console.warn("THREE.WebGLShadowMap:",L,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;s.copy(P.mapSize);let N=P.getFrameExtents();if(s.multiply(N),n.copy(P.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(n.x=Math.floor(u/N.x),s.x=n.x*N.x,P.mapSize.x=n.x),s.y>u&&(n.y=Math.floor(u/N.y),s.y=n.y*N.y,P.mapSize.y=n.y)),P.map===null){let q=this.type!==Zl?{minFilter:Rt,magFilter:Rt}:{};P.map=new ni(s.x,s.y,q),P.map.texture.name=L.name+".shadowMap",P.camera.updateProjectionMatrix()}e.setRenderTarget(P.map),e.clear();let W=P.getViewportCount();for(let q=0;q<W;q++){let z=P.getViewport(q);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),P.updateMatrices(L,q),r=P.getFrustum(),x(_,S,P.camera,L,this.type)}P.isPointLightShadow!==!0&&this.type===Zl&&v(P,S),P.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(A,b,M)};function v(w,_){let S=t.update(g);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ni(s.x,s.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,e.setRenderTarget(w.mapPass),e.clear(),e.renderBufferDirect(_,null,S,d,g,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,e.setRenderTarget(w.map),e.clear(),e.renderBufferDirect(_,null,S,p,g,null)}function y(w,_,S,A,b,M){let C=null,T=S.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(T!==void 0)C=T;else if(C=S.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let D=C.uuid,L=_.uuid,P=h[D];P===void 0&&(P={},h[D]=P);let N=P[L];N===void 0&&(N=C.clone(),P[L]=N),C=N}return C.visible=_.visible,C.wireframe=_.wireframe,M===Zl?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:c[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,S.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(S.matrixWorld),C.nearDistance=A,C.farDistance=b),C}function x(w,_,S,A,b){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===Zl)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,w.matrixWorld);let C=t.update(w),T=w.material;if(Array.isArray(T)){let D=C.groups;for(let L=0,P=D.length;L<P;L++){let N=D[L],W=T[N.materialIndex];if(W&&W.visible){let q=y(w,W,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,q,w,N)}}}else if(T.visible){let D=y(w,T,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,D,w,null)}}let M=w.children;for(let C=0,T=M.length;C<T;C++)x(M[C],_,S,A,b)}}function SD(e,t,i){let r=i.isWebGL2;function s(){let X=!1,ne=new $e,de=null,Se=new $e(0,0,0,0);return{setMask:function(De){de!==De&&!X&&(e.colorMask(De,De,De,De),de=De)},setLocked:function(De){X=De},setClear:function(De,lt,Xt,kt,Yn){Yn===!0&&(De*=kt,lt*=kt,Xt*=kt),ne.set(De,lt,Xt,kt),Se.equals(ne)===!1&&(e.clearColor(De,lt,Xt,kt),Se.copy(ne))},reset:function(){X=!1,de=null,Se.set(-1,0,0,0)}}}function n(){let X=!1,ne=null,de=null,Se=null;return{setTest:function(De){De?se(2929):H(2929)},setMask:function(De){ne!==De&&!X&&(e.depthMask(De),ne=De)},setFunc:function(De){if(de!==De){switch(De){case GM:e.depthFunc(512);break;case VM:e.depthFunc(519);break;case HM:e.depthFunc(513);break;case Qf:e.depthFunc(515);break;case WM:e.depthFunc(514);break;case qM:e.depthFunc(518);break;case XM:e.depthFunc(516);break;case YM:e.depthFunc(517);break;default:e.depthFunc(515)}de=De}},setLocked:function(De){X=De},setClear:function(De){Se!==De&&(e.clearDepth(De),Se=De)},reset:function(){X=!1,ne=null,de=null,Se=null}}}function a(){let X=!1,ne=null,de=null,Se=null,De=null,lt=null,Xt=null,kt=null,Yn=null;return{setTest:function(Lt){X||(Lt?se(2960):H(2960))},setMask:function(Lt){ne!==Lt&&!X&&(e.stencilMask(Lt),ne=Lt)},setFunc:function(Lt,Rs,dr){(de!==Lt||Se!==Rs||De!==dr)&&(e.stencilFunc(Lt,Rs,dr),de=Lt,Se=Rs,De=dr)},setOp:function(Lt,Rs,dr){(lt!==Lt||Xt!==Rs||kt!==dr)&&(e.stencilOp(Lt,Rs,dr),lt=Lt,Xt=Rs,kt=dr)},setLocked:function(Lt){X=Lt},setClear:function(Lt){Yn!==Lt&&(e.clearStencil(Lt),Yn=Lt)},reset:function(){X=!1,ne=null,de=null,Se=null,De=null,lt=null,Xt=null,kt=null,Yn=null}}}let o=new s,l=new n,h=new a,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,M=!1,C=null,T=null,D=null,L=null,P=null,N=e.getParameter(35661),W=!1,q=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(z)[1]),W=q>=1):z.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),W=q>=2);let j=null,k={},F=e.getParameter(3088),R=e.getParameter(2978),V=new $e().fromArray(F),Q=new $e().fromArray(R);function Y(X,ne,de){let Se=new Uint8Array(4),De=e.createTexture();e.bindTexture(X,De),e.texParameteri(X,10241,9728),e.texParameteri(X,10240,9728);for(let lt=0;lt<de;lt++)e.texImage2D(ne+lt,0,6408,1,1,0,6408,5121,Se);return De}let U={};U[3553]=Y(3553,3553,1),U[34067]=Y(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),se(2929),l.setFunc(Qf),Te(!1),xe(p0),se(2884),pe(xi);function se(X){d[X]!==!0&&(e.enable(X),d[X]=!0)}function H(X){d[X]!==!1&&(e.disable(X),d[X]=!1)}function $(X,ne){return p[X]!==ne?(e.bindFramebuffer(X,ne),p[X]=ne,r&&(X===36009&&(p[36160]=ne),X===36160&&(p[36009]=ne)),!0):!1}function J(X,ne){let de=g,Se=!1;if(X)if(de=f.get(ne),de===void 0&&(de=[],f.set(ne,de)),X.isWebGLMultipleRenderTargets){let De=X.texture;if(de.length!==De.length||de[0]!==36064){for(let lt=0,Xt=De.length;lt<Xt;lt++)de[lt]=36064+lt;de.length=De.length,Se=!0}}else de[0]!==36064&&(de[0]=36064,Se=!0);else de[0]!==1029&&(de[0]=1029,Se=!0);Se&&(i.isWebGL2?e.drawBuffers(de):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(de))}function ue(X){return m!==X?(e.useProgram(X),m=X,!0):!1}let re={[vo]:32774,[LM]:32778,[OM]:32779};if(r)re[v0]=32775,re[y0]=32776;else{let X=t.get("EXT_blend_minmax");X!==null&&(re[v0]=X.MIN_EXT,re[y0]=X.MAX_EXT)}let oe={[IM]:0,[RM]:1,[BM]:768,[Db]:770,[jM]:776,[UM]:774,[zM]:772,[NM]:769,[Lb]:771,[kM]:775,[FM]:773};function pe(X,ne,de,Se,De,lt,Xt,kt){if(X===xi){v===!0&&(H(3042),v=!1);return}if(v===!1&&(se(3042),v=!0),X!==DM){if(X!==y||kt!==M){if((x!==vo||S!==vo)&&(e.blendEquation(32774),x=vo,S=vo),kt)switch(X){case Oo:e.blendFuncSeparate(1,771,1,771);break;case f0:e.blendFunc(1,1);break;case m0:e.blendFuncSeparate(0,769,0,1);break;case g0:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}else switch(X){case Oo:e.blendFuncSeparate(770,771,1,771);break;case f0:e.blendFunc(770,1);break;case m0:e.blendFuncSeparate(0,769,0,1);break;case g0:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}w=null,_=null,A=null,b=null,y=X,M=kt}return}De=De||ne,lt=lt||de,Xt=Xt||Se,(ne!==x||De!==S)&&(e.blendEquationSeparate(re[ne],re[De]),x=ne,S=De),(de!==w||Se!==_||lt!==A||Xt!==b)&&(e.blendFuncSeparate(oe[de],oe[Se],oe[lt],oe[Xt]),w=de,_=Se,A=lt,b=Xt),y=X,M=!1}function ye(X,ne){X.side===sr?H(2884):se(2884);let de=X.side===ui;ne&&(de=!de),Te(de),X.blending===Oo&&X.transparent===!1?pe(xi):pe(X.blending,X.blendEquation,X.blendSrc,X.blendDst,X.blendEquationAlpha,X.blendSrcAlpha,X.blendDstAlpha,X.premultipliedAlpha),l.setFunc(X.depthFunc),l.setTest(X.depthTest),l.setMask(X.depthWrite),o.setMask(X.colorWrite);let Se=X.stencilWrite;h.setTest(Se),Se&&(h.setMask(X.stencilWriteMask),h.setFunc(X.stencilFunc,X.stencilRef,X.stencilFuncMask),h.setOp(X.stencilFail,X.stencilZFail,X.stencilZPass)),Ie(X.polygonOffset,X.polygonOffsetFactor,X.polygonOffsetUnits),X.alphaToCoverage===!0?se(32926):H(32926)}function Te(X){C!==X&&(X?e.frontFace(2304):e.frontFace(2305),C=X)}function xe(X){X!==TM?(se(2884),X!==T&&(X===p0?e.cullFace(1029):X===PM?e.cullFace(1028):e.cullFace(1032))):H(2884),T=X}function be(X){X!==D&&(W&&e.lineWidth(X),D=X)}function Ie(X,ne,de){X?(se(32823),(L!==ne||P!==de)&&(e.polygonOffset(ne,de),L=ne,P=de)):H(32823)}function We(X){X?se(3089):H(3089)}function dt(X){X===void 0&&(X=33984+N-1),j!==X&&(e.activeTexture(X),j=X)}function I(X,ne,de){de===void 0&&(j===null?de=33984+N-1:de=j);let Se=k[de];Se===void 0&&(Se={type:void 0,texture:void 0},k[de]=Se),(Se.type!==X||Se.texture!==ne)&&(j!==de&&(e.activeTexture(de),j=de),e.bindTexture(X,ne||U[X]),Se.type=X,Se.texture=ne)}function O(){let X=k[j];X!==void 0&&X.type!==void 0&&(e.bindTexture(X.type,null),X.type=void 0,X.texture=void 0)}function ie(){try{e.compressedTexImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function fe(){try{e.compressedTexImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function me(){try{e.texSubImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function we(){try{e.texSubImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function qe(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Me(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ce(){try{e.texStorage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ue(){try{e.texStorage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ee(){try{e.texImage2D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function _e(){try{e.texImage3D.apply(e,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Le(X){V.equals(X)===!1&&(e.scissor(X.x,X.y,X.z,X.w),V.copy(X))}function ze(X){Q.equals(X)===!1&&(e.viewport(X.x,X.y,X.z,X.w),Q.copy(X))}function ot(X,ne){let de=c.get(ne);de===void 0&&(de=new WeakMap,c.set(ne,de));let Se=de.get(X);Se===void 0&&(Se=e.getUniformBlockIndex(ne,X.name),de.set(X,Se))}function Ct(X,ne){let de=c.get(ne).get(X);u.get(ne)!==de&&(e.uniformBlockBinding(ne,de,X.__bindingPointIndex),u.set(ne,de))}function qt(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),d={},j=null,k={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,M=!1,C=null,T=null,D=null,L=null,P=null,V.set(0,0,e.canvas.width,e.canvas.height),Q.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:se,disable:H,bindFramebuffer:$,drawBuffers:J,useProgram:ue,setBlending:pe,setMaterial:ye,setFlipSided:Te,setCullFace:xe,setLineWidth:be,setPolygonOffset:Ie,setScissorTest:We,activeTexture:dt,bindTexture:I,unbindTexture:O,compressedTexImage2D:ie,compressedTexImage3D:fe,texImage2D:Ee,texImage3D:_e,updateUBOMapping:ot,uniformBlockBinding:Ct,texStorage2D:ce,texStorage3D:Ue,texSubImage2D:me,texSubImage3D:we,compressedTexSubImage2D:qe,compressedTexSubImage3D:Me,scissor:Le,viewport:ze,reset:qt}}function AD(e,t,i,r,s,n,a){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,u=s.maxTextureSize,c=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(I,O){return v?new OffscreenCanvas(I,O):Td("canvas")}function x(I,O,ie,fe){let me=1;if((I.width>fe||I.height>fe)&&(me=fe/Math.max(I.width,I.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){let we=O?Cd:Math.floor,qe=we(me*I.width),Me=we(me*I.height);g===void 0&&(g=y(qe,Me));let ce=ie?y(qe,Me):g;return ce.width=qe,ce.height=Me,ce.getContext("2d").drawImage(I,0,0,qe,Me),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+qe+"x"+Me+")."),ce}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function w(I){return tm(I.width)&&tm(I.height)}function _(I){return o?!1:I.wrapS!==ir||I.wrapT!==ir||I.minFilter!==Rt&&I.minFilter!==gt}function S(I,O){return I.generateMipmaps&&O&&I.minFilter!==Rt&&I.minFilter!==gt}function A(I){e.generateMipmap(I)}function b(I,O,ie,fe,me=!1){if(o===!1)return O;if(I!==null){if(e[I]!==void 0)return e[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let we=O;return O===6403&&(ie===5126&&(we=33326),ie===5131&&(we=33325),ie===5121&&(we=33321)),O===33319&&(ie===5126&&(we=33328),ie===5131&&(we=33327),ie===5121&&(we=33323)),O===6408&&(ie===5126&&(we=34836),ie===5131&&(we=34842),ie===5121&&(we=fe===Ke&&me===!1?35907:32856),ie===32819&&(we=32854),ie===32820&&(we=32855)),(we===33325||we===33326||we===33327||we===33328||we===34842||we===34836)&&t.get("EXT_color_buffer_float"),we}function M(I,O,ie){return S(I,ie)===!0||I.isFramebufferTexture&&I.minFilter!==Rt&&I.minFilter!==gt?Math.log2(Math.max(O.width,O.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?O.mipmaps.length:1}function C(I){return I===Rt||I===x0||I===rp?9728:9729}function T(I){let O=I.target;O.removeEventListener("dispose",T),L(O),O.isVideoTexture&&f.delete(O)}function D(I){let O=I.target;O.removeEventListener("dispose",D),N(O)}function L(I){let O=r.get(I);if(O.__webglInit===void 0)return;let ie=I.source,fe=m.get(ie);if(fe){let me=fe[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&P(I),Object.keys(fe).length===0&&m.delete(ie)}r.remove(I)}function P(I){let O=r.get(I);e.deleteTexture(O.__webglTexture);let ie=I.source,fe=m.get(ie);delete fe[O.__cacheKey],a.memory.textures--}function N(I){let O=I.texture,ie=r.get(I),fe=r.get(O);if(fe.__webglTexture!==void 0&&(e.deleteTexture(fe.__webglTexture),a.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)e.deleteFramebuffer(ie.__webglFramebuffer[me]),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer[me]);else{if(e.deleteFramebuffer(ie.__webglFramebuffer),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let me=0;me<ie.__webglColorRenderbuffer.length;me++)ie.__webglColorRenderbuffer[me]&&e.deleteRenderbuffer(ie.__webglColorRenderbuffer[me]);ie.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ie.__webglDepthRenderbuffer)}if(I.isWebGLMultipleRenderTargets)for(let me=0,we=O.length;me<we;me++){let qe=r.get(O[me]);qe.__webglTexture&&(e.deleteTexture(qe.__webglTexture),a.memory.textures--),r.remove(O[me])}r.remove(O),r.remove(I)}let W=0;function q(){W=0}function z(){let I=W;return I>=l&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l),W+=1,I}function j(I){let O=[];return O.push(I.wrapS),O.push(I.wrapT),O.push(I.wrapR||0),O.push(I.magFilter),O.push(I.minFilter),O.push(I.anisotropy),O.push(I.internalFormat),O.push(I.format),O.push(I.type),O.push(I.generateMipmaps),O.push(I.premultiplyAlpha),O.push(I.flipY),O.push(I.unpackAlignment),O.push(I.encoding),O.join()}function k(I,O){let ie=r.get(I);if(I.isVideoTexture&&We(I),I.isRenderTargetTexture===!1&&I.version>0&&ie.__version!==I.version){let fe=I.image;if(fe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(fe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{H(ie,I,O);return}}i.bindTexture(3553,ie.__webglTexture,33984+O)}function F(I,O){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){H(ie,I,O);return}i.bindTexture(35866,ie.__webglTexture,33984+O)}function R(I,O){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){H(ie,I,O);return}i.bindTexture(32879,ie.__webglTexture,33984+O)}function V(I,O){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){$(ie,I,O);return}i.bindTexture(34067,ie.__webglTexture,33984+O)}let Q={[xh]:10497,[ir]:33071,[Jf]:33648},Y={[Rt]:9728,[x0]:9984,[rp]:9986,[gt]:9729,[iE]:9985,[Ho]:9987};function U(I,O,ie){if(ie?(e.texParameteri(I,10242,Q[O.wrapS]),e.texParameteri(I,10243,Q[O.wrapT]),(I===32879||I===35866)&&e.texParameteri(I,32882,Q[O.wrapR]),e.texParameteri(I,10240,Y[O.magFilter]),e.texParameteri(I,10241,Y[O.minFilter])):(e.texParameteri(I,10242,33071),e.texParameteri(I,10243,33071),(I===32879||I===35866)&&e.texParameteri(I,32882,33071),(O.wrapS!==ir||O.wrapT!==ir)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(I,10240,C(O.magFilter)),e.texParameteri(I,10241,C(O.minFilter)),O.minFilter!==Rt&&O.minFilter!==gt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let fe=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Rt||O.minFilter!==rp&&O.minFilter!==Ho||O.type===Pn&&t.has("OES_texture_float_linear")===!1||o===!1&&O.type===wh&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(e.texParameterf(I,fe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function se(I,O){let ie=!1;I.__webglInit===void 0&&(I.__webglInit=!0,O.addEventListener("dispose",T));let fe=O.source,me=m.get(fe);me===void 0&&(me={},m.set(fe,me));let we=j(O);if(we!==I.__cacheKey){me[we]===void 0&&(me[we]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),me[we].usedTimes++;let qe=me[I.__cacheKey];qe!==void 0&&(me[I.__cacheKey].usedTimes--,qe.usedTimes===0&&P(O)),I.__cacheKey=we,I.__webglTexture=me[we].texture}return ie}function H(I,O,ie){let fe=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(fe=35866),O.isData3DTexture&&(fe=32879);let me=se(I,O),we=O.source;i.bindTexture(fe,I.__webglTexture,33984+ie);let qe=r.get(we);if(we.version!==qe.__version||me===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let Me=_(O)&&w(O.image)===!1,ce=x(O.image,Me,!1,u);ce=dt(O,ce);let Ue=w(ce)||o,Ee=n.convert(O.format,O.encoding),_e=n.convert(O.type),Le=b(O.internalFormat,Ee,_e,O.encoding,O.isVideoTexture);U(fe,O,Ue);let ze,ot=O.mipmaps,Ct=o&&O.isVideoTexture!==!0,qt=qe.__version===void 0||me===!0,X=M(O,ce,Ue);if(O.isDepthTexture)Le=6402,o?O.type===Pn?Le=36012:O.type===Tn?Le=33190:O.type===xa?Le=35056:Le=33189:O.type===Pn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===wa&&Le===6402&&O.type!==Rb&&O.type!==Tn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Tn,_e=n.convert(O.type)),O.format===Pa&&Le===6402&&(Le=34041,O.type!==xa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=xa,_e=n.convert(O.type))),qt&&(Ct?i.texStorage2D(3553,1,Le,ce.width,ce.height):i.texImage2D(3553,0,Le,ce.width,ce.height,0,Ee,_e,null));else if(O.isDataTexture)if(ot.length>0&&Ue){Ct&&qt&&i.texStorage2D(3553,X,Le,ot[0].width,ot[0].height);for(let ne=0,de=ot.length;ne<de;ne++)ze=ot[ne],Ct?i.texSubImage2D(3553,ne,0,0,ze.width,ze.height,Ee,_e,ze.data):i.texImage2D(3553,ne,Le,ze.width,ze.height,0,Ee,_e,ze.data);O.generateMipmaps=!1}else Ct?(qt&&i.texStorage2D(3553,X,Le,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,ce.width,ce.height,Ee,_e,ce.data)):i.texImage2D(3553,0,Le,ce.width,ce.height,0,Ee,_e,ce.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ct&&qt&&i.texStorage3D(35866,X,Le,ot[0].width,ot[0].height,ce.depth);for(let ne=0,de=ot.length;ne<de;ne++)ze=ot[ne],O.format!==Vr?Ee!==null?Ct?i.compressedTexSubImage3D(35866,ne,0,0,0,ze.width,ze.height,ce.depth,Ee,ze.data,0,0):i.compressedTexImage3D(35866,ne,Le,ze.width,ze.height,ce.depth,0,ze.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ct?i.texSubImage3D(35866,ne,0,0,0,ze.width,ze.height,ce.depth,Ee,_e,ze.data):i.texImage3D(35866,ne,Le,ze.width,ze.height,ce.depth,0,Ee,_e,ze.data)}else{Ct&&qt&&i.texStorage2D(3553,X,Le,ot[0].width,ot[0].height);for(let ne=0,de=ot.length;ne<de;ne++)ze=ot[ne],O.format!==Vr?Ee!==null?Ct?i.compressedTexSubImage2D(3553,ne,0,0,ze.width,ze.height,Ee,ze.data):i.compressedTexImage2D(3553,ne,Le,ze.width,ze.height,0,ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ct?i.texSubImage2D(3553,ne,0,0,ze.width,ze.height,Ee,_e,ze.data):i.texImage2D(3553,ne,Le,ze.width,ze.height,0,Ee,_e,ze.data)}else if(O.isDataArrayTexture)Ct?(qt&&i.texStorage3D(35866,X,Le,ce.width,ce.height,ce.depth),i.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,Ee,_e,ce.data)):i.texImage3D(35866,0,Le,ce.width,ce.height,ce.depth,0,Ee,_e,ce.data);else if(O.isData3DTexture)Ct?(qt&&i.texStorage3D(32879,X,Le,ce.width,ce.height,ce.depth),i.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,Ee,_e,ce.data)):i.texImage3D(32879,0,Le,ce.width,ce.height,ce.depth,0,Ee,_e,ce.data);else if(O.isFramebufferTexture){if(qt)if(Ct)i.texStorage2D(3553,X,Le,ce.width,ce.height);else{let ne=ce.width,de=ce.height;for(let Se=0;Se<X;Se++)i.texImage2D(3553,Se,Le,ne,de,0,Ee,_e,null),ne>>=1,de>>=1}}else if(ot.length>0&&Ue){Ct&&qt&&i.texStorage2D(3553,X,Le,ot[0].width,ot[0].height);for(let ne=0,de=ot.length;ne<de;ne++)ze=ot[ne],Ct?i.texSubImage2D(3553,ne,0,0,Ee,_e,ze):i.texImage2D(3553,ne,Le,Ee,_e,ze);O.generateMipmaps=!1}else Ct?(qt&&i.texStorage2D(3553,X,Le,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,Ee,_e,ce)):i.texImage2D(3553,0,Le,Ee,_e,ce);S(O,Ue)&&A(fe),qe.__version=we.version,O.onUpdate&&O.onUpdate(O)}I.__version=O.version}function $(I,O,ie){if(O.image.length!==6)return;let fe=se(I,O),me=O.source;i.bindTexture(34067,I.__webglTexture,33984+ie);let we=r.get(me);if(me.version!==we.__version||fe===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,O.flipY),e.pixelStorei(37441,O.premultiplyAlpha),e.pixelStorei(3317,O.unpackAlignment),e.pixelStorei(37443,0);let qe=O.isCompressedTexture||O.image[0].isCompressedTexture,Me=O.image[0]&&O.image[0].isDataTexture,ce=[];for(let ne=0;ne<6;ne++)!qe&&!Me?ce[ne]=x(O.image[ne],!1,!0,h):ce[ne]=Me?O.image[ne].image:O.image[ne],ce[ne]=dt(O,ce[ne]);let Ue=ce[0],Ee=w(Ue)||o,_e=n.convert(O.format,O.encoding),Le=n.convert(O.type),ze=b(O.internalFormat,_e,Le,O.encoding),ot=o&&O.isVideoTexture!==!0,Ct=we.__version===void 0||fe===!0,qt=M(O,Ue,Ee);U(34067,O,Ee);let X;if(qe){ot&&Ct&&i.texStorage2D(34067,qt,ze,Ue.width,Ue.height);for(let ne=0;ne<6;ne++){X=ce[ne].mipmaps;for(let de=0;de<X.length;de++){let Se=X[de];O.format!==Vr?_e!==null?ot?i.compressedTexSubImage2D(34069+ne,de,0,0,Se.width,Se.height,_e,Se.data):i.compressedTexImage2D(34069+ne,de,ze,Se.width,Se.height,0,Se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ot?i.texSubImage2D(34069+ne,de,0,0,Se.width,Se.height,_e,Le,Se.data):i.texImage2D(34069+ne,de,ze,Se.width,Se.height,0,_e,Le,Se.data)}}}else{X=O.mipmaps,ot&&Ct&&(X.length>0&&qt++,i.texStorage2D(34067,qt,ze,ce[0].width,ce[0].height));for(let ne=0;ne<6;ne++)if(Me){ot?i.texSubImage2D(34069+ne,0,0,0,ce[ne].width,ce[ne].height,_e,Le,ce[ne].data):i.texImage2D(34069+ne,0,ze,ce[ne].width,ce[ne].height,0,_e,Le,ce[ne].data);for(let de=0;de<X.length;de++){let Se=X[de].image[ne].image;ot?i.texSubImage2D(34069+ne,de+1,0,0,Se.width,Se.height,_e,Le,Se.data):i.texImage2D(34069+ne,de+1,ze,Se.width,Se.height,0,_e,Le,Se.data)}}else{ot?i.texSubImage2D(34069+ne,0,0,0,_e,Le,ce[ne]):i.texImage2D(34069+ne,0,ze,_e,Le,ce[ne]);for(let de=0;de<X.length;de++){let Se=X[de];ot?i.texSubImage2D(34069+ne,de+1,0,0,_e,Le,Se.image[ne]):i.texImage2D(34069+ne,de+1,ze,_e,Le,Se.image[ne])}}}S(O,Ee)&&A(34067),we.__version=me.version,O.onUpdate&&O.onUpdate(O)}I.__version=O.version}function J(I,O,ie,fe,me){let we=n.convert(ie.format,ie.encoding),qe=n.convert(ie.type),Me=b(ie.internalFormat,we,qe,ie.encoding);r.get(O).__hasExternalTextures||(me===32879||me===35866?i.texImage3D(me,0,Me,O.width,O.height,O.depth,0,we,qe,null):i.texImage2D(me,0,Me,O.width,O.height,0,we,qe,null)),i.bindFramebuffer(36160,I),Ie(O)?d.framebufferTexture2DMultisampleEXT(36160,fe,me,r.get(ie).__webglTexture,0,be(O)):(me===3553||me>=34069&&me<=34074)&&e.framebufferTexture2D(36160,fe,me,r.get(ie).__webglTexture,0),i.bindFramebuffer(36160,null)}function ue(I,O,ie){if(e.bindRenderbuffer(36161,I),O.depthBuffer&&!O.stencilBuffer){let fe=33189;if(ie||Ie(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===Pn?fe=36012:me.type===Tn&&(fe=33190));let we=be(O);Ie(O)?d.renderbufferStorageMultisampleEXT(36161,we,fe,O.width,O.height):e.renderbufferStorageMultisample(36161,we,fe,O.width,O.height)}else e.renderbufferStorage(36161,fe,O.width,O.height);e.framebufferRenderbuffer(36160,36096,36161,I)}else if(O.depthBuffer&&O.stencilBuffer){let fe=be(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,fe,35056,O.width,O.height):Ie(O)?d.renderbufferStorageMultisampleEXT(36161,fe,35056,O.width,O.height):e.renderbufferStorage(36161,34041,O.width,O.height),e.framebufferRenderbuffer(36160,33306,36161,I)}else{let fe=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<fe.length;me++){let we=fe[me],qe=n.convert(we.format,we.encoding),Me=n.convert(we.type),ce=b(we.internalFormat,qe,Me,we.encoding),Ue=be(O);ie&&Ie(O)===!1?e.renderbufferStorageMultisample(36161,Ue,ce,O.width,O.height):Ie(O)?d.renderbufferStorageMultisampleEXT(36161,Ue,ce,O.width,O.height):e.renderbufferStorage(36161,ce,O.width,O.height)}}e.bindRenderbuffer(36161,null)}function re(I,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,I),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),k(O.depthTexture,0);let ie=r.get(O.depthTexture).__webglTexture,fe=be(O);if(O.depthTexture.format===wa)Ie(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ie,0,fe):e.framebufferTexture2D(36160,36096,3553,ie,0);else if(O.depthTexture.format===Pa)Ie(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ie,0,fe):e.framebufferTexture2D(36160,33306,3553,ie,0);else throw new Error("Unknown depthTexture format")}function oe(I){let O=r.get(I),ie=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!O.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");re(O.__webglFramebuffer,I)}else if(ie){O.__webglDepthbuffer=[];for(let fe=0;fe<6;fe++)i.bindFramebuffer(36160,O.__webglFramebuffer[fe]),O.__webglDepthbuffer[fe]=e.createRenderbuffer(),ue(O.__webglDepthbuffer[fe],I,!1)}else i.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=e.createRenderbuffer(),ue(O.__webglDepthbuffer,I,!1);i.bindFramebuffer(36160,null)}function pe(I,O,ie){let fe=r.get(I);O!==void 0&&J(fe.__webglFramebuffer,I,I.texture,36064,3553),ie!==void 0&&oe(I)}function ye(I){let O=I.texture,ie=r.get(I),fe=r.get(O);I.addEventListener("dispose",D),I.isWebGLMultipleRenderTargets!==!0&&(fe.__webglTexture===void 0&&(fe.__webglTexture=e.createTexture()),fe.__version=O.version,a.memory.textures++);let me=I.isWebGLCubeRenderTarget===!0,we=I.isWebGLMultipleRenderTargets===!0,qe=w(I)||o;if(me){ie.__webglFramebuffer=[];for(let Me=0;Me<6;Me++)ie.__webglFramebuffer[Me]=e.createFramebuffer()}else{if(ie.__webglFramebuffer=e.createFramebuffer(),we)if(s.drawBuffers){let Me=I.texture;for(let ce=0,Ue=Me.length;ce<Ue;ce++){let Ee=r.get(Me[ce]);Ee.__webglTexture===void 0&&(Ee.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&I.samples>0&&Ie(I)===!1){let Me=we?O:[O];ie.__webglMultisampledFramebuffer=e.createFramebuffer(),ie.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ie.__webglMultisampledFramebuffer);for(let ce=0;ce<Me.length;ce++){let Ue=Me[ce];ie.__webglColorRenderbuffer[ce]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ie.__webglColorRenderbuffer[ce]);let Ee=n.convert(Ue.format,Ue.encoding),_e=n.convert(Ue.type),Le=b(Ue.internalFormat,Ee,_e,Ue.encoding,I.isXRRenderTarget===!0),ze=be(I);e.renderbufferStorageMultisample(36161,ze,Le,I.width,I.height),e.framebufferRenderbuffer(36160,36064+ce,36161,ie.__webglColorRenderbuffer[ce])}e.bindRenderbuffer(36161,null),I.depthBuffer&&(ie.__webglDepthRenderbuffer=e.createRenderbuffer(),ue(ie.__webglDepthRenderbuffer,I,!0)),i.bindFramebuffer(36160,null)}}if(me){i.bindTexture(34067,fe.__webglTexture),U(34067,O,qe);for(let Me=0;Me<6;Me++)J(ie.__webglFramebuffer[Me],I,O,36064,34069+Me);S(O,qe)&&A(34067),i.unbindTexture()}else if(we){let Me=I.texture;for(let ce=0,Ue=Me.length;ce<Ue;ce++){let Ee=Me[ce],_e=r.get(Ee);i.bindTexture(3553,_e.__webglTexture),U(3553,Ee,qe),J(ie.__webglFramebuffer,I,Ee,36064+ce,3553),S(Ee,qe)&&A(3553)}i.unbindTexture()}else{let Me=3553;(I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(o?Me=I.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Me,fe.__webglTexture),U(Me,O,qe),J(ie.__webglFramebuffer,I,O,36064,Me),S(O,qe)&&A(Me),i.unbindTexture()}I.depthBuffer&&oe(I)}function Te(I){let O=w(I)||o,ie=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let fe=0,me=ie.length;fe<me;fe++){let we=ie[fe];if(S(we,O)){let qe=I.isWebGLCubeRenderTarget?34067:3553,Me=r.get(we).__webglTexture;i.bindTexture(qe,Me),A(qe),i.unbindTexture()}}}function xe(I){if(o&&I.samples>0&&Ie(I)===!1){let O=I.isWebGLMultipleRenderTargets?I.texture:[I.texture],ie=I.width,fe=I.height,me=16384,we=[],qe=I.stencilBuffer?33306:36096,Me=r.get(I),ce=I.isWebGLMultipleRenderTargets===!0;if(ce)for(let Ue=0;Ue<O.length;Ue++)i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Ue,36161,null),i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Ue,3553,null,0);i.bindFramebuffer(36008,Me.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Me.__webglFramebuffer);for(let Ue=0;Ue<O.length;Ue++){we.push(36064+Ue),I.depthBuffer&&we.push(qe);let Ee=Me.__ignoreDepthValues!==void 0?Me.__ignoreDepthValues:!1;if(Ee===!1&&(I.depthBuffer&&(me|=256),I.stencilBuffer&&(me|=1024)),ce&&e.framebufferRenderbuffer(36008,36064,36161,Me.__webglColorRenderbuffer[Ue]),Ee===!0&&(e.invalidateFramebuffer(36008,[qe]),e.invalidateFramebuffer(36009,[qe])),ce){let _e=r.get(O[Ue]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,_e,0)}e.blitFramebuffer(0,0,ie,fe,0,0,ie,fe,me,9728),p&&e.invalidateFramebuffer(36008,we)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ce)for(let Ue=0;Ue<O.length;Ue++){i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Ue,36161,Me.__webglColorRenderbuffer[Ue]);let Ee=r.get(O[Ue]).__webglTexture;i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Ue,3553,Ee,0)}i.bindFramebuffer(36009,Me.__webglMultisampledFramebuffer)}}function be(I){return Math.min(c,I.samples)}function Ie(I){let O=r.get(I);return o&&I.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function We(I){let O=a.render.frame;f.get(I)!==O&&(f.set(I,O),I.update())}function dt(I,O){let ie=I.encoding,fe=I.format,me=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===em||ie!==Es&&(ie===Ke?o===!1?t.has("EXT_sRGB")===!0&&fe===Vr?(I.format=em,I.minFilter=gt,I.generateMipmaps=!1):O=Fb.sRGBToLinear(O):(fe!==Vr||me!==Ti)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ie)),O}this.allocateTextureUnit=z,this.resetTextureUnits=q,this.setTexture2D=k,this.setTexture2DArray=F,this.setTexture3D=R,this.setTextureCube=V,this.rebindTextures=pe,this.setupRenderTarget=ye,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Ie}function MD(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Ti)return 5121;if(n===aE)return 32819;if(n===oE)return 32820;if(n===rE)return 5120;if(n===sE)return 5122;if(n===Rb)return 5123;if(n===nE)return 5124;if(n===Tn)return 5125;if(n===Pn)return 5126;if(n===wh)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===lE)return 6406;if(n===Vr)return 6408;if(n===hE)return 6409;if(n===cE)return 6410;if(n===wa)return 6402;if(n===Pa)return 34041;if(n===em)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===dE)return 6403;if(n===uE)return 36244;if(n===pE)return 33319;if(n===fE)return 33320;if(n===mE)return 36249;if(n===sp||n===np||n===ap||n===op)if(a===Ke)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===sp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===np)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ap)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===op)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===sp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===np)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ap)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===op)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===w0||n===b0||n===_0||n===S0)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===w0)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===b0)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===_0)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===S0)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===gE)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===A0||n===M0)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===A0)return a===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===M0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===E0||n===C0||n===T0||n===P0||n===D0||n===L0||n===O0||n===I0||n===R0||n===B0||n===N0||n===z0||n===F0||n===U0)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===E0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===C0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===T0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===P0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===D0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===L0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===O0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===I0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===R0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===B0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===N0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===z0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===F0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===U0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===lp)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===lp)return a===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===vE||n===k0||n===j0||n===G0)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===lp)return o.COMPRESSED_RED_RGTC1_EXT;if(n===k0)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===j0)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===G0)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===xa?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[n]!==void 0?e[n]:null}return{convert:s}}var ED=class extends Ei{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ao=class extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}},CD={type:"move"},Rp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ao,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 Ao,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ao,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],c=h.position.distanceTo(u.position),d=.02,p=.005;l.inputState.pinching&&c>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(CD)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Ao;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ag=class extends pi{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:wa,h!==wa&&h!==Pa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===wa&&(i=Tn),i===void 0&&h===Pa&&(i=xa),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Rt,this.minFilter=o!==void 0?o:Rt,this.flipY=!1,this.generateMipmaps=!1}},TD=class extends Fi{constructor(e,t){super();let i=this,r=null,s=1,n=null,a="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),g=null,m=null,v=[],y=[],x=new Set,w=new Map,_=new Ei;_.layers.enable(1),_.viewport=new $e;let S=new Ei;S.layers.enable(2),S.viewport=new $e;let A=[_,S],b=new ED;b.layers.enable(1),b.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let R=v[F];return R===void 0&&(R=new Rp,v[F]=R),R.getTargetRaySpace()},this.getControllerGrip=function(F){let R=v[F];return R===void 0&&(R=new Rp,v[F]=R),R.getGripSpace()},this.getHand=function(F){let R=v[F];return R===void 0&&(R=new Rp,v[F]=R),R.getHandSpace()};function T(F){let R=y.indexOf(F.inputSource);if(R===-1)return;let V=v[R];V!==void 0&&V.dispatchEvent({type:F.type,data:F.inputSource})}function D(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",L);for(let F=0;F<v.length;F++){let R=y[F];R!==null&&(y[F]=null,v[F].disconnect(R))}M=null,C=null,e.setRenderTarget(g),d=null,c=null,u=null,r=null,m=null,k.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(F){l=F},this.getBaseLayer=function(){return c!==null?c:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(F){if(r=F,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",D),r.addEventListener("inputsourceschange",L),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let R={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,R),r.updateRenderState({baseLayer:d}),m=new ni(d.framebufferWidth,d.framebufferHeight,{format:Vr,type:Ti,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let R=null,V=null,Q=null;f.depth&&(Q=f.stencil?35056:33190,R=f.stencil?Pa:wa,V=f.stencil?xa:Tn);let Y={colorFormat:32856,depthFormat:Q,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(Y),r.updateRenderState({layers:[c]}),m=new ni(c.textureWidth,c.textureHeight,{format:Vr,type:Ti,depthTexture:new Ag(c.textureWidth,c.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,R),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let U=e.properties.get(m);U.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),k.setContext(r),k.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function L(F){for(let R=0;R<F.removed.length;R++){let V=F.removed[R],Q=y.indexOf(V);Q>=0&&(y[Q]=null,v[Q].disconnect(V))}for(let R=0;R<F.added.length;R++){let V=F.added[R],Q=y.indexOf(V);if(Q===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(V),Q=U;break}else if(y[U]===null){y[U]=V,Q=U;break}if(Q===-1)break}let Y=v[Q];Y&&Y.connect(V)}}let P=new E,N=new E;function W(F,R,V){P.setFromMatrixPosition(R.matrixWorld),N.setFromMatrixPosition(V.matrixWorld);let Q=P.distanceTo(N),Y=R.projectionMatrix.elements,U=V.projectionMatrix.elements,se=Y[14]/(Y[10]-1),H=Y[14]/(Y[10]+1),$=(Y[9]+1)/Y[5],J=(Y[9]-1)/Y[5],ue=(Y[8]-1)/Y[0],re=(U[8]+1)/U[0],oe=se*ue,pe=se*re,ye=Q/(-ue+re),Te=ye*-ue;R.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(Te),F.translateZ(ye),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let xe=se+ye,be=H+ye,Ie=oe-Te,We=pe+(Q-Te),dt=$*H/be*xe,I=J*H/be*xe;F.projectionMatrix.makePerspective(Ie,We,dt,I,xe,be)}function q(F,R){R===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(R.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(r===null)return;b.near=S.near=_.near=F.near,b.far=S.far=_.far=F.far,(M!==b.near||C!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),M=b.near,C=b.far);let R=F.parent,V=b.cameras;q(b,R);for(let Y=0;Y<V.length;Y++)q(V[Y],R);b.matrixWorld.decompose(b.position,b.quaternion,b.scale),F.matrix.copy(b.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);let Q=F.children;for(let Y=0,U=Q.length;Y<U;Y++)Q[Y].updateMatrixWorld(!0);V.length===2?W(b,_,S):b.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return b},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(F){o=F,c!==null&&(c.fixedFoveation=F),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=F)},this.getPlanes=function(){return x};let z=null;function j(F,R){if(h=R.getViewerPose(l||n),p=R,h!==null){let V=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let Q=!1;V.length!==b.cameras.length&&(b.cameras.length=0,Q=!0);for(let Y=0;Y<V.length;Y++){let U=V[Y],se=null;if(d!==null)se=d.getViewport(U);else{let $=u.getViewSubImage(c,U);se=$.viewport,Y===0&&(e.setRenderTargetTextures(m,$.colorTexture,c.ignoreDepthValues?void 0:$.depthStencilTexture),e.setRenderTarget(m))}let H=A[Y];H===void 0&&(H=new Ei,H.layers.enable(Y),H.viewport=new $e,A[Y]=H),H.matrix.fromArray(U.transform.matrix),H.projectionMatrix.fromArray(U.projectionMatrix),H.viewport.set(se.x,se.y,se.width,se.height),Y===0&&b.matrix.copy(H.matrix),Q===!0&&b.cameras.push(H)}}for(let V=0;V<v.length;V++){let Q=y[V],Y=v[V];Q!==null&&Y!==void 0&&Y.update(Q,R,l||n)}if(z&&z(F,R),R.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:R.detectedPlanes});let V=null;for(let Q of x)R.detectedPlanes.has(Q)||(V===null&&(V=[]),V.push(Q));if(V!==null)for(let Q of V)x.delete(Q),w.delete(Q),i.dispatchEvent({type:"planeremoved",data:Q});for(let Q of R.detectedPlanes)if(!x.has(Q))x.add(Q),w.set(Q,R.lastChangedTime),i.dispatchEvent({type:"planeadded",data:Q});else{let Y=w.get(Q);Q.lastChangedTime>Y&&(w.set(Q,Q.lastChangedTime),i.dispatchEvent({type:"planechanged",data:Q}))}}p=null}let k=new Vb;k.setAnimationLoop(j),this.setAnimationLoop=function(F){z=F},this.dispose=function(){}}};function PD(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,Gb(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),c(g,m),m.isMeshPhysicalMaterial&&d(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(n(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===ui&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===ui&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let w=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*w}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uv2Transform.value.copy(x.matrix))}function n(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function c(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===ui&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function DD(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let w=x.program;r.uniformBlockBinding(y,w)}function h(y,x){let w=s[y.id];w===void 0&&(f(y),w=u(y),s[y.id]=w,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let S=t.render.frame;n[y.id]!==S&&(d(y),n[y.id]=S)}function u(y){let x=c();y.__bindingPointIndex=x;let w=e.createBuffer(),_=y.__size,S=y.usage;return e.bindBuffer(35345,w),e.bufferData(35345,_,S),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,w),w}function c(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let x=s[y.id],w=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let S=0,A=w.length;S<A;S++){let b=w[S];if(p(b,S,_)===!0){let M=b.__offset,C=Array.isArray(b.value)?b.value:[b.value],T=0;for(let D=0;D<C.length;D++){let L=C[D],P=g(L);typeof L=="number"?(b.__data[0]=L,e.bufferSubData(35345,M+T,b.__data)):L.isMatrix3?(b.__data[0]=L.elements[0],b.__data[1]=L.elements[1],b.__data[2]=L.elements[2],b.__data[3]=L.elements[0],b.__data[4]=L.elements[3],b.__data[5]=L.elements[4],b.__data[6]=L.elements[5],b.__data[7]=L.elements[0],b.__data[8]=L.elements[6],b.__data[9]=L.elements[7],b.__data[10]=L.elements[8],b.__data[11]=L.elements[0]):(L.toArray(b.__data,T),T+=P.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,b.__data)}}e.bindBuffer(35345,null)}function p(y,x,w){let _=y.value;if(w[x]===void 0){if(typeof _=="number")w[x]=_;else{let S=Array.isArray(_)?_:[_],A=[];for(let b=0;b<S.length;b++)A.push(S[b].clone());w[x]=A}return!0}else if(typeof _=="number"){if(w[x]!==_)return w[x]=_,!0}else{let S=Array.isArray(w[x])?w[x]:[w[x]],A=Array.isArray(_)?_:[_];for(let b=0;b<S.length;b++){let M=S[b];if(M.equals(A[b])===!1)return M.copy(A[b]),!0}}return!1}function f(y){let x=y.uniforms,w=0,_=16,S=0;for(let A=0,b=x.length;A<b;A++){let M=x[A],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let D=0,L=T.length;D<L;D++){let P=T[D],N=g(P);C.boundary+=N.boundary,C.storage+=N.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=w,A>0){S=w%_;let D=_-S;S!==0&&D-C.boundary<0&&(w+=_-S,M.__offset=w)}w+=C.storage}return S=w%_,S>0&&(w+=_-S),y.__size=w,y.__cache={},this}function g(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){let x=y.target;x.removeEventListener("dispose",m);let w=a.indexOf(x.__bindingPointIndex);a.splice(w,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete n[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function LD(){let e=Td("canvas");return e.style.display="block",e}function Qb(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:LD(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,n=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,u;i!==null?u=i.getContextAttributes().alpha:u=e.alpha!==void 0?e.alpha:!1;let c=null,d=null,p=[],f=[];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=Es,this.physicallyCorrectLights=!1,this.toneMapping=Ks,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,x=null,w=-1,_=null,S=new $e,A=new $e,b=null,M=t.width,C=t.height,T=1,D=null,L=null,P=new $e(0,0,M,C),N=new $e(0,0,M,C),W=!1,q=new _g,z=!1,j=!1,k=null,F=new ge,R=new G,V=new E,Q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return x===null?T:1}let U=i;function se(B,ee){for(let ae=0;ae<B.length;ae++){let K=B[ae],he=t.getContext(K,ee);if(he!==null)return he}return null}try{let B={alpha:!0,depth:r,stencil:s,antialias:n,premultipliedAlpha:a,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${el}`),t.addEventListener("webglcontextlost",Le,!1),t.addEventListener("webglcontextrestored",ze,!1),t.addEventListener("webglcontextcreationerror",ot,!1),U===null){let ee=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&ee.shift(),U=se(ee,B),U===null)throw se(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}U.getShaderPrecisionFormat===void 0&&(U.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let H,$,J,ue,re,oe,pe,ye,Te,xe,be,Ie,We,dt,I,O,ie,fe,me,we,qe,Me,ce,Ue;function Ee(){H=new H3(U),$=new F3(U,H,e),H.init($),Me=new MD(U,H,$),J=new SD(U,H,$),ue=new X3,re=new cD,oe=new AD(U,H,J,re,$,Me,ue),pe=new k3(g),ye=new V3(g),Te=new iC(U,$),ce=new N3(U,H,Te,$),xe=new W3(U,Te,ue,ce),be=new K3(U,xe,Te,ue),me=new Z3(U,$,oe),O=new U3(re),Ie=new hD(g,pe,ye,H,$,ce,O),We=new PD(g,re),dt=new uD,I=new yD(H,$),fe=new B3(g,pe,ye,J,be,u,a),ie=new _D(g,be,$),Ue=new DD(U,ue,$,J),we=new z3(U,H,ue,$),qe=new q3(U,H,ue,$),ue.programs=Ie.programs,g.capabilities=$,g.extensions=H,g.properties=re,g.renderLists=dt,g.shadowMap=ie,g.state=J,g.info=ue}Ee();let _e=new TD(g,U);this.xr=_e,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let B=H.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=H.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(B){B!==void 0&&(T=B,this.setSize(M,C,!1))},this.getSize=function(B){return B.set(M,C)},this.setSize=function(B,ee,ae){if(_e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=B,C=ee,t.width=Math.floor(B*T),t.height=Math.floor(ee*T),ae!==!1&&(t.style.width=B+"px",t.style.height=ee+"px"),this.setViewport(0,0,B,ee)},this.getDrawingBufferSize=function(B){return B.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(B,ee,ae){M=B,C=ee,T=ae,t.width=Math.floor(B*ae),t.height=Math.floor(ee*ae),this.setViewport(0,0,B,ee)},this.getCurrentViewport=function(B){return B.copy(S)},this.getViewport=function(B){return B.copy(P)},this.setViewport=function(B,ee,ae,K){B.isVector4?P.set(B.x,B.y,B.z,B.w):P.set(B,ee,ae,K),J.viewport(S.copy(P).multiplyScalar(T).floor())},this.getScissor=function(B){return B.copy(N)},this.setScissor=function(B,ee,ae,K){B.isVector4?N.set(B.x,B.y,B.z,B.w):N.set(B,ee,ae,K),J.scissor(A.copy(N).multiplyScalar(T).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(B){J.setScissorTest(W=B)},this.setOpaqueSort=function(B){D=B},this.setTransparentSort=function(B){L=B},this.getClearColor=function(B){return B.copy(fe.getClearColor())},this.setClearColor=function(){fe.setClearColor.apply(fe,arguments)},this.getClearAlpha=function(){return fe.getClearAlpha()},this.setClearAlpha=function(){fe.setClearAlpha.apply(fe,arguments)},this.clear=function(B=!0,ee=!0,ae=!0){let K=0;B&&(K|=16384),ee&&(K|=256),ae&&(K|=1024),U.clear(K)},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",Le,!1),t.removeEventListener("webglcontextrestored",ze,!1),t.removeEventListener("webglcontextcreationerror",ot,!1),dt.dispose(),I.dispose(),re.dispose(),pe.dispose(),ye.dispose(),be.dispose(),ce.dispose(),Ue.dispose(),Ie.dispose(),_e.dispose(),_e.removeEventListener("sessionstart",Se),_e.removeEventListener("sessionend",De),k&&(k.dispose(),k=null),lt.stop()};function Le(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function ze(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let B=ue.autoReset,ee=ie.enabled,ae=ie.autoUpdate,K=ie.needsUpdate,he=ie.type;Ee(),ue.autoReset=B,ie.enabled=ee,ie.autoUpdate=ae,ie.needsUpdate=K,ie.type=he}function ot(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function Ct(B){let ee=B.target;ee.removeEventListener("dispose",Ct),qt(ee)}function qt(B){X(B),re.remove(B)}function X(B){let ee=re.get(B).programs;ee!==void 0&&(ee.forEach(function(ae){Ie.releaseProgram(ae)}),B.isShaderMaterial&&Ie.releaseShaderCache(B))}this.renderBufferDirect=function(B,ee,ae,K,he,Be){ee===null&&(ee=Q);let Je=he.isMesh&&he.matrixWorld.determinant()<0,rt=lM(B,ee,ae,K,he);J.setMaterial(K,Je);let nt=ae.index,St=1;K.wireframe===!0&&(nt=xe.getWireframeAttribute(ae),St=2);let ut=ae.drawRange,ht=ae.attributes.position,_i=ut.start*St,Yi=(ut.start+ut.count)*St;Be!==null&&(_i=Math.max(_i,Be.start*St),Yi=Math.min(Yi,(Be.start+Be.count)*St)),nt!==null?(_i=Math.max(_i,0),Yi=Math.min(Yi,nt.count)):ht!=null&&(_i=Math.max(_i,0),Yi=Math.min(Yi,ht.count));let Bs=Yi-_i;if(Bs<0||Bs===1/0)return;ce.setup(he,K,rt,ae,nt);let Qn,Yt=we;if(nt!==null&&(Qn=Te.get(nt),Yt=qe,Yt.setIndex(Qn)),he.isMesh)K.wireframe===!0?(J.setLineWidth(K.wireframeLinewidth*Y()),Yt.setMode(1)):Yt.setMode(4);else if(he.isLine){let ct=K.linewidth;ct===void 0&&(ct=1),J.setLineWidth(ct*Y()),he.isLineSegments?Yt.setMode(1):he.isLineLoop?Yt.setMode(2):Yt.setMode(3)}else he.isPoints?Yt.setMode(0):he.isSprite&&Yt.setMode(4);if(he.isInstancedMesh)Yt.renderInstances(_i,Bs,he.count);else if(ae.isInstancedBufferGeometry){let ct=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,Ju=Math.min(ae.instanceCount,ct);Yt.renderInstances(_i,Bs,Ju)}else Yt.render(_i,Bs)},this.compile=function(B,ee){function ae(K,he,Be){K.transparent===!0&&K.side===sr&&K.forceSinglePass===!1?(K.side=ui,K.needsUpdate=!0,dr(K,he,Be),K.side=Zr,K.needsUpdate=!0,dr(K,he,Be),K.side=sr):dr(K,he,Be)}d=I.get(B),d.init(),f.push(d),B.traverseVisible(function(K){K.isLight&&K.layers.test(ee.layers)&&(d.pushLight(K),K.castShadow&&d.pushShadow(K))}),d.setupLights(g.physicallyCorrectLights),B.traverse(function(K){let he=K.material;if(he)if(Array.isArray(he))for(let Be=0;Be<he.length;Be++){let Je=he[Be];ae(Je,B,K)}else ae(he,B,K)}),f.pop(),d=null};let ne=null;function de(B){ne&&ne(B)}function Se(){lt.stop()}function De(){lt.start()}let lt=new Vb;lt.setAnimationLoop(de),typeof self<"u"&<.setContext(self),this.setAnimationLoop=function(B){ne=B,_e.setAnimationLoop(B),B===null?lt.stop():lt.start()},_e.addEventListener("sessionstart",Se),_e.addEventListener("sessionend",De),this.render=function(B,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),_e.enabled===!0&&_e.isPresenting===!0&&(_e.cameraAutoUpdate===!0&&_e.updateCamera(ee),ee=_e.getCamera()),B.isScene===!0&&B.onBeforeRender(g,B,ee,x),d=I.get(B,f.length),d.init(),f.push(d),F.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),q.setFromProjectionMatrix(F),j=this.localClippingEnabled,z=O.init(this.clippingPlanes,j),c=dt.get(B,p.length),c.init(),p.push(c),Xt(B,ee,0,g.sortObjects),c.finish(),g.sortObjects===!0&&c.sort(D,L),z===!0&&O.beginShadows();let ae=d.state.shadowsArray;if(ie.render(ae,B,ee),z===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),fe.render(c,B),d.setupLights(g.physicallyCorrectLights),ee.isArrayCamera){let K=ee.cameras;for(let he=0,Be=K.length;he<Be;he++){let Je=K[he];kt(c,B,Je,Je.viewport)}}else kt(c,B,ee);x!==null&&(oe.updateMultisampleRenderTarget(x),oe.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(g,B,ee),ce.resetDefaultState(),w=-1,_=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function Xt(B,ee,ae,K){if(B.visible===!1)return;if(B.layers.test(ee.layers)){if(B.isGroup)ae=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(ee);else if(B.isLight)d.pushLight(B),B.castShadow&&d.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||q.intersectsSprite(B)){K&&V.setFromMatrixPosition(B.matrixWorld).applyMatrix4(F);let Be=be.update(B),Je=B.material;Je.visible&&c.push(B,Be,Je,ae,V.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||q.intersectsObject(B))){K&&V.setFromMatrixPosition(B.matrixWorld).applyMatrix4(F);let Be=be.update(B),Je=B.material;if(Array.isArray(Je)){let rt=Be.groups;for(let nt=0,St=rt.length;nt<St;nt++){let ut=rt[nt],ht=Je[ut.materialIndex];ht&&ht.visible&&c.push(B,Be,ht,ae,V.z,ut)}}else Je.visible&&c.push(B,Be,Je,ae,V.z,null)}}let he=B.children;for(let Be=0,Je=he.length;Be<Je;Be++)Xt(he[Be],ee,ae,K)}function kt(B,ee,ae,K){let he=B.opaque,Be=B.transmissive,Je=B.transparent;d.setupLightsView(ae),z===!0&&O.setGlobalState(g.clippingPlanes,ae),Be.length>0&&Yn(he,ee,ae),K&&J.viewport(S.copy(K)),he.length>0&&Lt(he,ee,ae),Be.length>0&&Lt(Be,ee,ae),Je.length>0&&Lt(Je,ee,ae),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Yn(B,ee,ae){let K=$.isWebGL2;k===null&&(k=new ni(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?wh:Ti,minFilter:Ho,samples:K&&n===!0?4:0})),g.getDrawingBufferSize(R),K?k.setSize(R.x,R.y):k.setSize(Cd(R.x),Cd(R.y));let he=g.getRenderTarget();g.setRenderTarget(k),g.clear();let Be=g.toneMapping;g.toneMapping=Ks,Lt(B,ee,ae),g.toneMapping=Be,oe.updateMultisampleRenderTarget(k),oe.updateRenderTargetMipmap(k),g.setRenderTarget(he)}function Lt(B,ee,ae){let K=ee.isScene===!0?ee.overrideMaterial:null;for(let he=0,Be=B.length;he<Be;he++){let Je=B[he],rt=Je.object,nt=Je.geometry,St=K===null?Je.material:K,ut=Je.group;rt.layers.test(ae.layers)&&Rs(rt,ee,ae,nt,St,ut)}}function Rs(B,ee,ae,K,he,Be){B.onBeforeRender(g,ee,ae,K,he,Be),B.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),he.onBeforeRender(g,ee,ae,K,B,Be),he.transparent===!0&&he.side===sr&&he.forceSinglePass===!1?(he.side=ui,he.needsUpdate=!0,g.renderBufferDirect(ae,ee,K,he,B,Be),he.side=Zr,he.needsUpdate=!0,g.renderBufferDirect(ae,ee,K,he,B,Be),he.side=sr):g.renderBufferDirect(ae,ee,K,he,B,Be),B.onAfterRender(g,ee,ae,K,he,Be)}function dr(B,ee,ae){ee.isScene!==!0&&(ee=Q);let K=re.get(B),he=d.state.lights,Be=d.state.shadowsArray,Je=he.state.version,rt=Ie.getParameters(B,he.state,Be,ee,ae),nt=Ie.getProgramCacheKey(rt),St=K.programs;K.environment=B.isMeshStandardMaterial?ee.environment:null,K.fog=ee.fog,K.envMap=(B.isMeshStandardMaterial?ye:pe).get(B.envMap||K.environment),St===void 0&&(B.addEventListener("dispose",Ct),St=new Map,K.programs=St);let ut=St.get(nt);if(ut!==void 0){if(K.currentProgram===ut&&K.lightsStateVersion===Je)return l0(B,rt),ut}else rt.uniforms=Ie.getUniforms(B),B.onBuild(ae,rt,g),B.onBeforeCompile(rt,g),ut=Ie.acquireProgram(rt,nt),St.set(nt,ut),K.uniforms=rt.uniforms;let ht=K.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(ht.clippingPlanes=O.uniform),l0(B,rt),K.needsLights=cM(B),K.lightsStateVersion=Je,K.needsLights&&(ht.ambientLightColor.value=he.state.ambient,ht.lightProbe.value=he.state.probe,ht.directionalLights.value=he.state.directional,ht.directionalLightShadows.value=he.state.directionalShadow,ht.spotLights.value=he.state.spot,ht.spotLightShadows.value=he.state.spotShadow,ht.rectAreaLights.value=he.state.rectArea,ht.ltc_1.value=he.state.rectAreaLTC1,ht.ltc_2.value=he.state.rectAreaLTC2,ht.pointLights.value=he.state.point,ht.pointLightShadows.value=he.state.pointShadow,ht.hemisphereLights.value=he.state.hemi,ht.directionalShadowMap.value=he.state.directionalShadowMap,ht.directionalShadowMatrix.value=he.state.directionalShadowMatrix,ht.spotShadowMap.value=he.state.spotShadowMap,ht.spotLightMatrix.value=he.state.spotLightMatrix,ht.spotLightMap.value=he.state.spotLightMap,ht.pointShadowMap.value=he.state.pointShadowMap,ht.pointShadowMatrix.value=he.state.pointShadowMatrix);let _i=ut.getUniforms(),Yi=dd.seqWithValue(_i.seq,ht);return K.currentProgram=ut,K.uniformsList=Yi,ut}function l0(B,ee){let ae=re.get(B);ae.outputEncoding=ee.outputEncoding,ae.instancing=ee.instancing,ae.skinning=ee.skinning,ae.morphTargets=ee.morphTargets,ae.morphNormals=ee.morphNormals,ae.morphColors=ee.morphColors,ae.morphTargetsCount=ee.morphTargetsCount,ae.numClippingPlanes=ee.numClippingPlanes,ae.numIntersection=ee.numClipIntersection,ae.vertexAlphas=ee.vertexAlphas,ae.vertexTangents=ee.vertexTangents,ae.toneMapping=ee.toneMapping}function lM(B,ee,ae,K,he){ee.isScene!==!0&&(ee=Q),oe.resetTextureUnits();let Be=ee.fog,Je=K.isMeshStandardMaterial?ee.environment:null,rt=x===null?g.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Es,nt=(K.isMeshStandardMaterial?ye:pe).get(K.envMap||Je),St=K.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,ut=!!K.normalMap&&!!ae.attributes.tangent,ht=!!ae.morphAttributes.position,_i=!!ae.morphAttributes.normal,Yi=!!ae.morphAttributes.color,Bs=K.toneMapped?g.toneMapping:Ks,Qn=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Yt=Qn!==void 0?Qn.length:0,ct=re.get(K),Ju=d.state.lights;if(z===!0&&(j===!0||B!==_)){let Qi=B===_&&K.id===w;O.setState(K,B,Qi)}let $u=!1;K.version===ct.__version?(ct.needsLights&&ct.lightsStateVersion!==Ju.state.version||ct.outputEncoding!==rt||he.isInstancedMesh&&ct.instancing===!1||!he.isInstancedMesh&&ct.instancing===!0||he.isSkinnedMesh&&ct.skinning===!1||!he.isSkinnedMesh&&ct.skinning===!0||ct.envMap!==nt||K.fog===!0&&ct.fog!==Be||ct.numClippingPlanes!==void 0&&(ct.numClippingPlanes!==O.numPlanes||ct.numIntersection!==O.numIntersection)||ct.vertexAlphas!==St||ct.vertexTangents!==ut||ct.morphTargets!==ht||ct.morphNormals!==_i||ct.morphColors!==Yi||ct.toneMapping!==Bs||$.isWebGL2===!0&&ct.morphTargetsCount!==Yt)&&($u=!0):($u=!0,ct.__version=K.version);let Zn=ct.currentProgram;$u===!0&&(Zn=dr(K,ee,he));let h0=!1,yl=!1,ep=!1,Pi=Zn.getUniforms(),Kn=ct.uniforms;if(J.useProgram(Zn.program)&&(h0=!0,yl=!0,ep=!0),K.id!==w&&(w=K.id,yl=!0),h0||_!==B){if(Pi.setValue(U,"projectionMatrix",B.projectionMatrix),$.logarithmicDepthBuffer&&Pi.setValue(U,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),_!==B&&(_=B,yl=!0,ep=!0),K.isShaderMaterial||K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshStandardMaterial||K.envMap){let Qi=Pi.map.cameraPosition;Qi!==void 0&&Qi.setValue(U,V.setFromMatrixPosition(B.matrixWorld))}(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Pi.setValue(U,"isOrthographic",B.isOrthographicCamera===!0),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial||K.isShadowMaterial||he.isSkinnedMesh)&&Pi.setValue(U,"viewMatrix",B.matrixWorldInverse)}if(he.isSkinnedMesh){Pi.setOptional(U,he,"bindMatrix"),Pi.setOptional(U,he,"bindMatrixInverse");let Qi=he.skeleton;Qi&&($.floatVertexTextures?(Qi.boneTexture===null&&Qi.computeBoneTexture(),Pi.setValue(U,"boneTexture",Qi.boneTexture,oe),Pi.setValue(U,"boneTextureSize",Qi.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 tp=ae.morphAttributes;if((tp.position!==void 0||tp.normal!==void 0||tp.color!==void 0&&$.isWebGL2===!0)&&me.update(he,ae,K,Zn),(yl||ct.receiveShadow!==he.receiveShadow)&&(ct.receiveShadow=he.receiveShadow,Pi.setValue(U,"receiveShadow",he.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(Kn.envMap.value=nt,Kn.flipEnvMap.value=nt.isCubeTexture&&nt.isRenderTargetTexture===!1?-1:1),yl&&(Pi.setValue(U,"toneMappingExposure",g.toneMappingExposure),ct.needsLights&&hM(Kn,ep),Be&&K.fog===!0&&We.refreshFogUniforms(Kn,Be),We.refreshMaterialUniforms(Kn,K,T,C,k),dd.upload(U,ct.uniformsList,Kn,oe)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(dd.upload(U,ct.uniformsList,Kn,oe),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Pi.setValue(U,"center",he.center),Pi.setValue(U,"modelViewMatrix",he.modelViewMatrix),Pi.setValue(U,"normalMatrix",he.normalMatrix),Pi.setValue(U,"modelMatrix",he.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){let Qi=K.uniformsGroups;for(let ip=0,dM=Qi.length;ip<dM;ip++)if($.isWebGL2){let c0=Qi[ip];Ue.update(c0,Zn),Ue.bind(c0,Zn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Zn}function hM(B,ee){B.ambientLightColor.needsUpdate=ee,B.lightProbe.needsUpdate=ee,B.directionalLights.needsUpdate=ee,B.directionalLightShadows.needsUpdate=ee,B.pointLights.needsUpdate=ee,B.pointLightShadows.needsUpdate=ee,B.spotLights.needsUpdate=ee,B.spotLightShadows.needsUpdate=ee,B.rectAreaLights.needsUpdate=ee,B.hemisphereLights.needsUpdate=ee}function cM(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,ee,ae){re.get(B.texture).__webglTexture=ee,re.get(B.depthTexture).__webglTexture=ae;let K=re.get(B);K.__hasExternalTextures=!0,K.__hasExternalTextures&&(K.__autoAllocateDepthBuffer=ae===void 0,K.__autoAllocateDepthBuffer||H.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),K.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(B,ee){let ae=re.get(B);ae.__webglFramebuffer=ee,ae.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(B,ee=0,ae=0){x=B,v=ee,y=ae;let K=!0,he=null,Be=!1,Je=!1;if(B){let rt=re.get(B);rt.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),K=!1):rt.__webglFramebuffer===void 0?oe.setupRenderTarget(B):rt.__hasExternalTextures&&oe.rebindTextures(B,re.get(B.texture).__webglTexture,re.get(B.depthTexture).__webglTexture);let nt=B.texture;(nt.isData3DTexture||nt.isDataArrayTexture||nt.isCompressedArrayTexture)&&(Je=!0);let St=re.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(he=St[ee],Be=!0):$.isWebGL2&&B.samples>0&&oe.useMultisampledRTT(B)===!1?he=re.get(B).__webglMultisampledFramebuffer:he=St,S.copy(B.viewport),A.copy(B.scissor),b=B.scissorTest}else S.copy(P).multiplyScalar(T).floor(),A.copy(N).multiplyScalar(T).floor(),b=W;if(J.bindFramebuffer(36160,he)&&$.drawBuffers&&K&&J.drawBuffers(B,he),J.viewport(S),J.scissor(A),J.setScissorTest(b),Be){let rt=re.get(B.texture);U.framebufferTexture2D(36160,36064,34069+ee,rt.__webglTexture,ae)}else if(Je){let rt=re.get(B.texture),nt=ee||0;U.framebufferTextureLayer(36160,36064,rt.__webglTexture,ae||0,nt)}w=-1},this.readRenderTargetPixels=function(B,ee,ae,K,he,Be,Je){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let rt=re.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&Je!==void 0&&(rt=rt[Je]),rt){J.bindFramebuffer(36160,rt);try{let nt=B.texture,St=nt.format,ut=nt.type;if(St!==Vr&&Me.convert(St)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ht=ut===wh&&(H.has("EXT_color_buffer_half_float")||$.isWebGL2&&H.has("EXT_color_buffer_float"));if(ut!==Ti&&Me.convert(ut)!==U.getParameter(35738)&&!(ut===Pn&&($.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!ht){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=B.width-K&&ae>=0&&ae<=B.height-he&&U.readPixels(ee,ae,K,he,Me.convert(St),Me.convert(ut),Be)}finally{let nt=x!==null?re.get(x).__webglFramebuffer:null;J.bindFramebuffer(36160,nt)}}},this.copyFramebufferToTexture=function(B,ee,ae=0){let K=Math.pow(2,-ae),he=Math.floor(ee.image.width*K),Be=Math.floor(ee.image.height*K);oe.setTexture2D(ee,0),U.copyTexSubImage2D(3553,ae,0,0,B.x,B.y,he,Be),J.unbindTexture()},this.copyTextureToTexture=function(B,ee,ae,K=0){let he=ee.image.width,Be=ee.image.height,Je=Me.convert(ae.format),rt=Me.convert(ae.type);oe.setTexture2D(ae,0),U.pixelStorei(37440,ae.flipY),U.pixelStorei(37441,ae.premultiplyAlpha),U.pixelStorei(3317,ae.unpackAlignment),ee.isDataTexture?U.texSubImage2D(3553,K,B.x,B.y,he,Be,Je,rt,ee.image.data):ee.isCompressedTexture?U.compressedTexSubImage2D(3553,K,B.x,B.y,ee.mipmaps[0].width,ee.mipmaps[0].height,Je,ee.mipmaps[0].data):U.texSubImage2D(3553,K,B.x,B.y,Je,rt,ee.image),K===0&&ae.generateMipmaps&&U.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(B,ee,ae,K,he=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Be=B.max.x-B.min.x+1,Je=B.max.y-B.min.y+1,rt=B.max.z-B.min.z+1,nt=Me.convert(K.format),St=Me.convert(K.type),ut;if(K.isData3DTexture)oe.setTexture3D(K,0),ut=32879;else if(K.isDataArrayTexture)oe.setTexture2DArray(K,0),ut=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,K.flipY),U.pixelStorei(37441,K.premultiplyAlpha),U.pixelStorei(3317,K.unpackAlignment);let ht=U.getParameter(3314),_i=U.getParameter(32878),Yi=U.getParameter(3316),Bs=U.getParameter(3315),Qn=U.getParameter(32877),Yt=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;U.pixelStorei(3314,Yt.width),U.pixelStorei(32878,Yt.height),U.pixelStorei(3316,B.min.x),U.pixelStorei(3315,B.min.y),U.pixelStorei(32877,B.min.z),ae.isDataTexture||ae.isData3DTexture?U.texSubImage3D(ut,he,ee.x,ee.y,ee.z,Be,Je,rt,nt,St,Yt.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(ut,he,ee.x,ee.y,ee.z,Be,Je,rt,nt,Yt.data)):U.texSubImage3D(ut,he,ee.x,ee.y,ee.z,Be,Je,rt,nt,St,Yt),U.pixelStorei(3314,ht),U.pixelStorei(32878,_i),U.pixelStorei(3316,Yi),U.pixelStorei(3315,Bs),U.pixelStorei(32877,Qn),he===0&&K.generateMipmaps&&U.generateMipmap(ut),J.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?oe.setTextureCube(B,0):B.isData3DTexture?oe.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?oe.setTexture2DArray(B,0):oe.setTexture2D(B,0),J.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,J.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var OD=class extends Qb{};OD.prototype.isWebGL1Renderer=!0;var Zb=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ge(e),this.near=t,this.far=i}clone(){return new Zb(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},_a=class extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},ID=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=$f,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ss()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ss()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ss()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Li=new E,rm=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.applyMatrix4(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.applyNormalMatrix(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Li.fromBufferAttribute(this,t),Li.transformDirection(e),this.setXYZ(t,Li.x,Li.y,Li.z);return this}setX(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Qs(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Qs(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Qs(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Qs(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=At(t,this.array),i=At(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=At(t,this.array),i=At(i,this.array),r=At(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=At(t,this.array),i=At(i,this.array),r=At(r,this.array),s=At(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Xe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new rm(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},RD=class extends Xe{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Vn=class extends kh{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Ey=new E,Cy=new E,Ty=new ge,Bp=new tl,Sc=new Tr,Dd=class extends _t{constructor(e=new He,t=new Vn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Ey.fromBufferAttribute(t,r-1),Cy.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Ey.distanceTo(Cy);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,n=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Sc.copy(i.boundingSphere),Sc.applyMatrix4(r),Sc.radius+=s,e.ray.intersectsSphere(Sc)===!1)return;Ty.copy(r).invert(),Bp.copy(e.ray).applyMatrix4(Ty);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new E,h=new E,u=new E,c=new E,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){let x=p.getX(v),w=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,w),Bp.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(c);_<e.near||_>e.far||t.push({distance:_,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,n.start),m=Math.min(f.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),Bp.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}},Py=new E,Dy=new E,Gh=class extends Dd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Py.fromBufferAttribute(t,r),Dy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Py.distanceTo(Dy);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},BD=class extends pi{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isVideoTexture=!0,this.minFilter=n!==void 0?n:gt,this.magFilter=s!==void 0?s:gt,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Ls=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],u=i[r+1]-h,c=(n-h)/u;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new G:new E);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],n=[],a=new E,o=new ge;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new E)}s[0]=new E,n[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),u=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),c<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),n[d]=n[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(si(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(a,p))}n[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(si(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},bu=class extends Ls{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t){let i=t||new G,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),c=o-this.aX,d=l-this.aY;o=c*h-d*u+this.aX,l=c*u+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},ND=class extends bu{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function Mg(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,u,c){let d=(a-n)/h-(o-n)/(h+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+c)+(l-o)/c;d*=u,p*=u,s(a,o,d,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var Ac=new E,Np=new Mg,zp=new Mg,Fp=new Mg,zD=class extends Ls{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new E){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(Ac.subVectors(r[0],r[1]).add(r[0]),l=Ac);let u=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(Ac.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Ac),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(u),d),f=Math.pow(u.distanceToSquared(c),d),g=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),Np.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,g),zp.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,g),Fp.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(Np.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),zp.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),Fp.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(Np.calc(o),zp.calc(o),Fp.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new E().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Ly(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function FD(e,t){let i=1-e;return i*i*t}function UD(e,t){return 2*(1-e)*e*t}function kD(e,t){return e*e*t}function oh(e,t,i,r){return FD(e,t)+UD(e,i)+kD(e,r)}function jD(e,t){let i=1-e;return i*i*i*t}function GD(e,t){let i=1-e;return 3*i*i*e*t}function VD(e,t){return 3*(1-e)*e*e*t}function HD(e,t){return e*e*e*t}function lh(e,t,i,r,s){return jD(e,t)+GD(e,i)+VD(e,r)+HD(e,s)}var Hr=class extends Ls{constructor(e=new G,t=new G,i=new G,r=new G){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(lh(e,r.x,s.x,n.x,a.x),lh(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ud=class extends Ls{constructor(e=new E,t=new E,i=new E,r=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(lh(e,r.x,s.x,n.x,a.x),lh(e,r.y,s.y,n.y,a.y),lh(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Qr=class extends Ls{constructor(e=new G,t=new G){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new G){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new G;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Kb=class extends Ls{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},kn=class extends Ls{constructor(e=new G,t=new G,i=new G){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(oh(e,r.x,s.x,n.x),oh(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},WD=class extends Ls{constructor(e=new E,t=new E,i=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(oh(e,r.x,s.x,n.x),oh(e,r.y,s.y,n.y),oh(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Eg=class extends Ls{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new G){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],u=r[n>r.length-3?r.length-1:n+2];return i.set(Ly(a,o.x,l.x,h.x,u.x),Ly(a,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new G().fromArray(r))}return this}},qD=Object.freeze({__proto__:null,ArcCurve:ND,CatmullRomCurve3:zD,CubicBezierCurve:Hr,CubicBezierCurve3:ud,EllipseCurve:bu,LineCurve:Qr,LineCurve3:Kb,QuadraticBezierCurve:kn,QuadraticBezierCurve3:WD,SplineCurve:Eg}),Jb=class extends Ls{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Qr(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new qD[r.type]().fromJSON(r))}return this}},Ld=class extends Jb{constructor(e){super(),this.type="Path",this.currentPoint=new G,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Qr(this.currentPoint.clone(),new G(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new kn(this.currentPoint.clone(),new G(e,t),new G(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new Hr(this.currentPoint.clone(),new G(e,t),new G(i,r),new G(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Eg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new bu(e,t,i,r,s,n,a,o);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},$b=class extends He{constructor(e=[new G(0,-.5),new G(.5,0),new G(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=si(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,u=new E,c=new G,d=new E,p=new E,f=new E,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),w=Math.cos(y);for(let _=0;_<=e.length-1;_++){u.x=e[_].x*x,u.y=e[_].y,u.z=e[_].x*w,n.push(u.x,u.y,u.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let S=o[3*_+0]*x,A=o[3*_+1],b=o[3*_+0]*w;l.push(S,A,b)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,w=x,_=x+e.length,S=x+e.length+1,A=x+1;s.push(w,_,A),s.push(S,A,_)}this.setIndex(s),this.setAttribute("position",new Ce(n,3)),this.setAttribute("uv",new Ce(a,2)),this.setAttribute("normal",new Ce(l,3))}static fromJSON(e){return new $b(e.points,e.segments,e.phiStart,e.phiLength)}},Cg=class extends He{constructor(e=1,t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],u=[],c=[],d=[],p=0,f=[],g=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Ce(u,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(d,2));function v(){let x=new E,w=new E,_=0,S=(t-e)/i;for(let A=0;A<=s;A++){let b=[],M=A/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,L=D*o+a,P=Math.sin(L),N=Math.cos(L);w.x=C*P,w.y=-M*i+g,w.z=C*N,u.push(w.x,w.y,w.z),x.set(P,S,N).normalize(),c.push(x.x,x.y,x.z),d.push(D,1-M),b.push(p++)}f.push(b)}for(let A=0;A<r;A++)for(let b=0;b<s;b++){let M=f[b][A],C=f[b+1][A],T=f[b+1][A+1],D=f[b][A+1];h.push(M,C,D),h.push(C,T,D),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let w=p,_=new G,S=new E,A=0,b=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)u.push(0,g*M,0),c.push(0,M,0),d.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+a,L=Math.cos(D),P=Math.sin(D);S.x=b*P,S.y=g*M,S.z=b*L,u.push(S.x,S.y,S.z),c.push(0,M,0),_.x=L*.5+.5,_.y=P*.5*M+.5,d.push(_.x,_.y),p++}for(let T=0;T<r;T++){let D=w+T,L=C+T;x===!0?h.push(L,L+1,D):h.push(L+1,L,D),A+=3}l.addGroup(m,A,x===!0?1:2),m+=A}}static fromJSON(e){return new Cg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},e_=class extends Cg{constructor(e=1,t=1,i=32,r=1,s=!1,n=0,a=Math.PI*2){super(0,e,t,i,r,s,n,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:n,thetaLength:a}}static fromJSON(e){return new e_(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Tg=class extends He{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],n=[];a(r),l(i),h(),this.setAttribute("position",new Ce(s,3)),this.setAttribute("normal",new Ce(s.slice(),3)),this.setAttribute("uv",new Ce(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new E,x=new E,w=new E;for(let _=0;_<t.length;_+=3)d(t[_+0],y),d(t[_+1],x),d(t[_+2],w),o(y,x,w,v)}function o(v,y,x,w){let _=w+1,S=[];for(let A=0;A<=_;A++){S[A]=[];let b=v.clone().lerp(x,A/_),M=y.clone().lerp(x,A/_),C=_-A;for(let T=0;T<=C;T++)T===0&&A===_?S[A][T]=b:S[A][T]=b.clone().lerp(M,T/C)}for(let A=0;A<_;A++)for(let b=0;b<2*(_-A)-1;b++){let M=Math.floor(b/2);b%2===0?(c(S[A][M+1]),c(S[A+1][M]),c(S[A][M])):(c(S[A][M+1]),c(S[A+1][M+1]),c(S[A+1][M]))}}function l(v){let y=new E;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new E;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=g(v)/2/Math.PI+.5,w=m(v)/Math.PI+.5;n.push(x,1-w)}p(),u()}function u(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],w=n[v+4],_=Math.max(y,x,w),S=Math.min(y,x,w);_>.9&&S<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),w<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function d(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,w=new E,_=new G,S=new G,A=new G;for(let b=0,M=0;b<s.length;b+=9,M+=6){v.set(s[b+0],s[b+1],s[b+2]),y.set(s[b+3],s[b+4],s[b+5]),x.set(s[b+6],s[b+7],s[b+8]),_.set(n[M+0],n[M+1]),S.set(n[M+2],n[M+3]),A.set(n[M+4],n[M+5]),w.copy(v).add(y).add(x).divideScalar(3);let C=g(w);f(_,M+0,v,C),f(S,M+2,y,C),f(A,M+4,x,C)}}function f(v,y,x,w){w<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Tg(e.vertices,e.indices,e.radius,e.details)}},t_=class extends Tg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,n,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new t_(e.radius,e.detail)}},Od=class extends Ld{constructor(e){super(e),this.uuid=Ss(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Ld().fromJSON(r))}return this}},XD={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=i_(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,u,c,d,p;if(r&&(n=JD(e,t,n,i)),e.length>80*i){o=h=e[0],l=u=e[1];for(let f=i;f<s;f+=i)c=e[f],d=e[f+1],c<o&&(o=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-o,u-l),p=p!==0?32767/p:0}return _h(n,a,i,o,l,p,0),a}};function i_(e,t,i,r,s){let n,a;if(s===hL(e,t,i,r)>0)for(n=t;n<i;n+=r)a=Oy(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=Oy(n,e[n],e[n+1],a);return a&&_u(a,a.next)&&(Ah(a),a=a.next),a}function Da(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(_u(i,i.next)||Bt(i.prev,i,i.next)===0)){if(Ah(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function _h(e,t,i,r,s,n,a){if(!e)return;!a&&n&&rL(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?QD(e,r,s,n):YD(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Ah(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=ZD(Da(e),t,i),_h(e,t,i,r,s,n,2)):a===2&&KD(e,t,i,r,s,n):_h(Da(e),t,i,r,s,n,1);break}}}function YD(e){let t=e.prev,i=e,r=e.next;if(Bt(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,u=s<n?s<a?s:a:n<a?n:a,c=o<l?o<h?o:h:l<h?l:h,d=s>n?s>a?s:a:n>a?n:a,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Mo(s,o,n,l,a,h,f.x,f.y)&&Bt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function QD(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Bt(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,u=s.y,c=n.y,d=a.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,g=o>l?o>h?o:h:l>h?l:h,m=u>c?u>d?u:d:c>d?c:d,v=sm(p,f,t,i,r),y=sm(g,m,t,i,r),x=e.prevZ,w=e.nextZ;for(;x&&x.z>=v&&w&&w.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Mo(o,u,l,c,h,d,x.x,x.y)&&Bt(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=p&&w.x<=g&&w.y>=f&&w.y<=m&&w!==s&&w!==a&&Mo(o,u,l,c,h,d,w.x,w.y)&&Bt(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Mo(o,u,l,c,h,d,x.x,x.y)&&Bt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=y;){if(w.x>=p&&w.x<=g&&w.y>=f&&w.y<=m&&w!==s&&w!==a&&Mo(o,u,l,c,h,d,w.x,w.y)&&Bt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function ZD(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!_u(s,n)&&r_(s,r,r.next,n)&&Sh(s,n)&&Sh(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),Ah(r),Ah(r.next),r=e=n),r=r.next}while(r!==e);return Da(r)}function KD(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&aL(a,o)){let l=s_(a,o);a=Da(a,a.next),l=Da(l,l.next),_h(a,t,i,r,s,n,0),_h(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function JD(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=i_(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(nL(h));for(s.sort($D),n=0;n<s.length;n++)i=eL(s[n],i);return i}function $D(e,t){return e.x-t.x}function eL(e,t){let i=tL(e,t);if(!i)return t;let r=s_(i,e);return Da(r,r.next),Da(i,i.next)}function tL(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let d=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=n&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,u=1/0,c;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&Mo(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(c=Math.abs(a-i.y)/(n-i.x),Sh(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&iL(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function iL(e,t){return Bt(e.prev,e,t.prev)<0&&Bt(t.next,e,e.next)<0}function rL(e,t,i,r){let s=e;do s.z===0&&(s.z=sm(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,sL(s)}function sL(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function sm(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function nL(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Mo(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function aL(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!oL(e,t)&&(Sh(e,t)&&Sh(t,e)&&lL(e,t)&&(Bt(e.prev,e,t.prev)||Bt(e,t.prev,t))||_u(e,t)&&Bt(e.prev,e,e.next)>0&&Bt(t.prev,t,t.next)>0)}function Bt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function _u(e,t){return e.x===t.x&&e.y===t.y}function r_(e,t,i,r){let s=Ec(Bt(e,t,i)),n=Ec(Bt(e,t,r)),a=Ec(Bt(i,r,e)),o=Ec(Bt(i,r,t));return!!(s!==n&&a!==o||s===0&&Mc(e,i,t)||n===0&&Mc(e,r,t)||a===0&&Mc(i,e,r)||o===0&&Mc(i,t,r))}function Mc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Ec(e){return e>0?1:e<0?-1:0}function oL(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&r_(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Sh(e,t){return Bt(e.prev,e,e.next)<0?Bt(e,t,e.next)>=0&&Bt(e,e.prev,t)>=0:Bt(e,t,e.prev)<0||Bt(e,e.next,t)<0}function lL(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function s_(e,t){let i=new nm(e.i,e.x,e.y),r=new nm(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Oy(e,t,i,r){let s=new nm(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Ah(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function nm(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function hL(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var n_=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n_.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Iy(e),Ry(i,e);let n=e.length;t.forEach(Iy);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,Ry(i,t[o]);let a=XD.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function Iy(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Ry(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var a_=class extends Tg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new a_(e.radius,e.detail)}},Pg=class extends He{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:n,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(n+a,Math.PI),l=0,h=[],u=new E,c=new E,d=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&n==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let w=0;w<=t;w++){let _=w/t;u.x=-e*Math.cos(r+_*s)*Math.sin(n+y*a),u.y=e*Math.cos(n+y*a),u.z=e*Math.sin(r+_*s)*Math.sin(n+y*a),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),g.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],w=h[m+1][v],_=h[m+1][v+1];(m!==0||n>0)&&d.push(y,x,_),(m!==i-1||o<Math.PI)&&d.push(x,w,_)}this.setIndex(d),this.setAttribute("position",new Ce(p,3)),this.setAttribute("normal",new Ce(f,3)),this.setAttribute("uv",new Ce(g,2))}static fromJSON(e){return new Pg(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},o_=class extends He{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:n},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],h=[],u=new E,c=new E,d=new E,p=new E,f=new E,g=new E,m=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,n,e,d),v(x+.01,s,n,e,p),g.subVectors(p,d),m.addVectors(p,d),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let w=0;w<=r;++w){let _=w/r*Math.PI*2,S=-t*Math.cos(_),A=t*Math.sin(_);u.x=d.x+(S*m.x+A*f.x),u.y=d.y+(S*m.y+A*f.y),u.z=d.z+(S*m.z+A*f.z),o.push(u.x,u.y,u.z),c.subVectors(u,d).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(w/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let w=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),S=(r+1)*y+x,A=(r+1)*(y-1)+x;a.push(w,_,A),a.push(_,S,A)}this.setIndex(a),this.setAttribute("position",new Ce(o,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(h,2));function v(y,x,w,_,S){let A=Math.cos(y),b=Math.sin(y),M=w/x*y,C=Math.cos(M);S.x=_*(2+C)*.5*A,S.y=_*(2+C)*b*.5,S.z=_*Math.sin(M)*.5}}static fromJSON(e){return new o_(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function un(e,t,i){return l_(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Cc(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function l_(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var Su=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];i:{e:{let n;t:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break e}n=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break e}n=i,i=0;break t}break i}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},cL=class extends Su{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:V0,endingEnd:V0}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case H0:s=e,a=2*t-i;break;case W0:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case H0:n=e,o=2*i-t;break;case W0:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,g=f*p,m=-c*g+2*c*f-c*p,v=(1+c)*g+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-d)*g+(1.5+d)*f+.5*p,x=d*g-d*f;for(let w=0;w!==a;++w)s[w]=m*n[h+w]+v*n[l+w]+y*n[o+w]+x*n[u+w];return s}},dL=class extends Su{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),u=1-h;for(let c=0;c!==a;++c)s[c]=n[l+c]*u+n[o+c]*h;return s}},uL=class extends Su{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},sn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Cc(t,this.TimeBufferType),this.values=Cc(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Cc(e.times,Array),values:Cc(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new uL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new dL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new cL(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ad:t=this.InterpolantFactoryMethodDiscrete;break;case Md:t=this.InterpolantFactoryMethodLinear;break;case hp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ad;case this.InterpolantFactoryMethodLinear:return Md;case this.InterpolantFactoryMethodSmooth:return hp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=un(i,s,n),this.values=un(this.values,s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&l_(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=un(this.times),t=un(this.values),i=this.getValueSize(),r=this.getInterpolation()===hp,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let u=a*i,c=u-i,d=u+i;for(let p=0;p!==i;++p){let f=t[u+p];if(f!==t[c+p]||f!==t[d+p]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let u=a*i,c=n*i;for(let d=0;d!==i;++d)t[c+d]=t[u+d]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=un(e,0,n),this.values=un(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=un(this.times,0),t=un(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};sn.prototype.TimeBufferType=Float32Array;sn.prototype.ValueBufferType=Float32Array;sn.prototype.DefaultInterpolation=Md;var Vh=class extends sn{};Vh.prototype.ValueTypeName="bool";Vh.prototype.ValueBufferType=Array;Vh.prototype.DefaultInterpolation=Ad;Vh.prototype.InterpolantFactoryMethodLinear=void 0;Vh.prototype.InterpolantFactoryMethodSmooth=void 0;var pL=class extends sn{};pL.prototype.ValueTypeName="color";var fL=class extends sn{};fL.prototype.ValueTypeName="number";var mL=class extends Su{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)tt.slerpFlat(s,0,n,l-a,n,l,o);return s}},Dg=class extends sn{InterpolantFactoryMethodLinear(e){return new mL(this.times,this.values,this.getValueSize(),e)}};Dg.prototype.ValueTypeName="quaternion";Dg.prototype.DefaultInterpolation=Md;Dg.prototype.InterpolantFactoryMethodSmooth=void 0;var Hh=class extends sn{};Hh.prototype.ValueTypeName="string";Hh.prototype.ValueBufferType=Array;Hh.prototype.DefaultInterpolation=Ad;Hh.prototype.InterpolantFactoryMethodLinear=void 0;Hh.prototype.InterpolantFactoryMethodSmooth=void 0;var gL=class extends sn{};gL.prototype.ValueTypeName="vector";var By={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},h_=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,c=l.length;u<c;u+=2){let d=l[u],p=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},vL=new h_,Lg=class{constructor(e){this.manager=e!==void 0?e:vL,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},js={},yL=class extends Error{constructor(e,t){super(e),this.response=t}},am=class extends Lg{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=By.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(js[e]!==void 0){js[e].push({onLoad:t,onProgress:i,onError:r});return}js[e]=[],js[e].push({onLoad:t,onProgress:i,onError:r});let n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=js[e],u=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=c?parseInt(c):0,p=d!==0,f=0,g=new ReadableStream({start(m){v();function v(){u.read().then(({done:y,value:x})=>{if(y)m.close();else{f+=x.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let _=0,S=h.length;_<S;_++){let A=h[_];A.onProgress&&A.onProgress(w)}m.enqueue(x),v()}})}}});return new Response(g)}else throw new yL(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{By.add(e,l);let h=js[e];delete js[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=js[e];if(h===void 0)throw this.manager.itemError(e),l;delete js[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Wh=class extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},xL=class extends Wh{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Up=new ge,Ny=new E,zy=new E,Og=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new G(512,512),this.map=null,this.mapPass=null,this.matrix=new ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _g,this._frameExtents=new G(1,1),this._viewportCount=1,this._viewports=[new $e(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;Ny.setFromMatrixPosition(e.matrixWorld),t.position.copy(Ny),zy.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zy),t.updateMatrixWorld(),Up.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Up),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Up)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},wL=class extends Og{constructor(){super(new Ei(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=bh*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},bL=class extends Wh{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new wL}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Fy=new ge,Cl=new E,kp=new E,_L=class extends Og{constructor(){super(new Ei(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new G(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 E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Cl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Cl),kp.copy(i.position),kp.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(kp),i.updateMatrixWorld(),r.makeTranslation(-Cl.x,-Cl.y,-Cl.z),Fy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fy)}},SL=class extends Wh{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new _L}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},AL=class extends Og{constructor(){super(new Pd(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ML=class extends Wh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new AL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},EL=class extends He{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},c_=class extends Lg{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new am(s.manager);n.setPath(s.path),n.setRequestHeader(s.requestHeader),n.setWithCredentials(s.withCredentials),n.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,d){if(t[d]!==void 0)return t[d];let p=c.interleavedBuffers[d],f=s(c,p.buffer),g=sc(p.type,f),m=new ID(g,p.stride);return m.uuid=p.uuid,t[d]=m,m}function s(c,d){if(i[d]!==void 0)return i[d];let p=c.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let n=e.isInstancedBufferGeometry?new EL:new He,a=e.data.index;if(a!==void 0){let c=sc(a.type,a.array);n.setIndex(new Xe(c,1))}let o=e.data.attributes;for(let c in o){let d=o[c],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new rm(f,d.itemSize,d.offset,d.normalized)}else{let f=sc(d.type,d.array),g=d.isInstancedBufferAttribute?RD:Xe;p=new g(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),d.updateRange!==void 0&&(p.updateRange.offset=d.updateRange.offset,p.updateRange.count=d.updateRange.count),n.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,g=d.length;f<g;f++){let m=d[f],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new rm(y,m.itemSize,m.offset,m.normalized)}else{let y=sc(m.type,m.array);v=new Xe(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),p.push(v)}n.morphAttributes[c]=p}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,d=h.length;c!==d;++c){let p=h[c];n.addGroup(p.start,p.count,p.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let c=new E;u.center!==void 0&&c.fromArray(u.center),n.boundingSphere=new Tr(c,u.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},CL=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Uy(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=Uy();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Uy(){return(typeof performance>"u"?Date:performance).now()}var Ig="\\[\\]\\.:\\/",TL=new RegExp("["+Ig+"]","g"),Rg="[^"+Ig+"]",PL="[^"+Ig.replace("\\.","")+"]",DL=/((?:WC+[\/:])*)/.source.replace("WC",Rg),LL=/(WCOD+)?/.source.replace("WCOD",PL),OL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Rg),IL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Rg),RL=new RegExp("^"+DL+LL+OL+IL+"$"),BL=["material","materials","bones","map"],NL=class{constructor(e,t,i){let r=i||Mt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Mt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Mt.parseTrackName(t),this.node=Mt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Mt.Composite(e,t,i):new Mt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(TL,"")}static parseTrackName(e){let t=RL.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);BL.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let n=0;n<s.length;n++){let a=s[n];if(a.name===t||a.uuid===t)return a;let o=i(a.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Mt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let n=e[r];if(n===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=s}else n.fromArray!==void 0&&n.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Mt.Composite=NL;Mt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Mt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Mt.prototype.GetterByBindingType=[Mt.prototype._getValue_direct,Mt.prototype._getValue_array,Mt.prototype._getValue_arrayElement,Mt.prototype._getValue_toArray];Mt.prototype.SetterByBindingTypeAndVersioning=[[Mt.prototype._setValue_direct,Mt.prototype._setValue_direct_setNeedsUpdate,Mt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_array,Mt.prototype._setValue_array_setNeedsUpdate,Mt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_arrayElement,Mt.prototype._setValue_arrayElement_setNeedsUpdate,Mt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_fromArray,Mt.prototype._setValue_fromArray_setNeedsUpdate,Mt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var s7=new Float32Array(1),Oe=class{constructor(e){this.value=e}clone(){return new Oe(this.value.clone===void 0?this.value:this.value.clone())}},d_=class{constructor(e,t,i=0,r=1/0){this.ray=new tl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new wg,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return om(e,this,i,t),i.sort(ky),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)om(e[r],this,i,t);return i.sort(ky),i}};function ky(e,t){return e.distance-t.distance}function om(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let n=0,a=s.length;n<a;n++)om(s[n],t,i,!0)}}var jy=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(si(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Gy=new G,zL=class{constructor(e=new G(1/0,1/0),t=new G(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Gy.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Gy.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Vy=new E,Tc=new E,Ar=class{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Vy.subVectors(e,this.start),Tc.subVectors(this.end,this.start);let i=Tc.dot(Tc),r=Tc.dot(Vy)/i;return t&&(r=si(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Hy=new E,FL=class extends _t{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new He,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let n=0,a=1,o=32;n<o;n++,a++){let l=n/o*Math.PI*2,h=a/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Ce(r,3));let s=new Vn({fog:!1,toneMapped:!1});this.cone=new Gh(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Hy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Hy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},UL=class extends nr{constructor(e,t,i){let r=new Pg(t,4,2),s=new jh({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Wy=new E,Pc=new E,qy=new E,kL=class extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new He;r.setAttribute("position",new Ce([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Vn({fog:!1,toneMapped:!1});this.lightPlane=new Dd(r,s),this.add(this.lightPlane),r=new He,r.setAttribute("position",new Ce([0,0,0,0,0,1],3)),this.targetLine=new Dd(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Wy.setFromMatrixPosition(this.light.matrixWorld),Pc.setFromMatrixPosition(this.light.target.matrixWorld),qy.subVectors(Pc,Wy),this.lightPlane.lookAt(Pc),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(Pc),this.targetLine.scale.z=qy.length()}},Dc=new E,Nt=new rl,Id=class extends Gh{constructor(e){let t=new He,i=new Vn({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),n[p]===void 0&&(n[p]=[]),n[p].push(r.length/3-1)}t.setAttribute("position",new Ce(r,3)),t.setAttribute("color",new Ce(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();let l=new Ge(16755200),h=new Ge(16711680),u=new Ge(43775),c=new Ge(16777215),d=new Ge(3355443);this.setColors(l,h,u,c,d)}setColors(e,t,i,r,s){let n=this.geometry.getAttribute("color");n.setXYZ(0,e.r,e.g,e.b),n.setXYZ(1,e.r,e.g,e.b),n.setXYZ(2,e.r,e.g,e.b),n.setXYZ(3,e.r,e.g,e.b),n.setXYZ(4,e.r,e.g,e.b),n.setXYZ(5,e.r,e.g,e.b),n.setXYZ(6,e.r,e.g,e.b),n.setXYZ(7,e.r,e.g,e.b),n.setXYZ(8,e.r,e.g,e.b),n.setXYZ(9,e.r,e.g,e.b),n.setXYZ(10,e.r,e.g,e.b),n.setXYZ(11,e.r,e.g,e.b),n.setXYZ(12,e.r,e.g,e.b),n.setXYZ(13,e.r,e.g,e.b),n.setXYZ(14,e.r,e.g,e.b),n.setXYZ(15,e.r,e.g,e.b),n.setXYZ(16,e.r,e.g,e.b),n.setXYZ(17,e.r,e.g,e.b),n.setXYZ(18,e.r,e.g,e.b),n.setXYZ(19,e.r,e.g,e.b),n.setXYZ(20,e.r,e.g,e.b),n.setXYZ(21,e.r,e.g,e.b),n.setXYZ(22,e.r,e.g,e.b),n.setXYZ(23,e.r,e.g,e.b),n.setXYZ(24,t.r,t.g,t.b),n.setXYZ(25,t.r,t.g,t.b),n.setXYZ(26,t.r,t.g,t.b),n.setXYZ(27,t.r,t.g,t.b),n.setXYZ(28,t.r,t.g,t.b),n.setXYZ(29,t.r,t.g,t.b),n.setXYZ(30,t.r,t.g,t.b),n.setXYZ(31,t.r,t.g,t.b),n.setXYZ(32,i.r,i.g,i.b),n.setXYZ(33,i.r,i.g,i.b),n.setXYZ(34,i.r,i.g,i.b),n.setXYZ(35,i.r,i.g,i.b),n.setXYZ(36,i.r,i.g,i.b),n.setXYZ(37,i.r,i.g,i.b),n.setXYZ(38,r.r,r.g,r.b),n.setXYZ(39,r.r,r.g,r.b),n.setXYZ(40,s.r,s.g,s.b),n.setXYZ(41,s.r,s.g,s.b),n.setXYZ(42,s.r,s.g,s.b),n.setXYZ(43,s.r,s.g,s.b),n.setXYZ(44,s.r,s.g,s.b),n.setXYZ(45,s.r,s.g,s.b),n.setXYZ(46,s.r,s.g,s.b),n.setXYZ(47,s.r,s.g,s.b),n.setXYZ(48,s.r,s.g,s.b),n.setXYZ(49,s.r,s.g,s.b),n.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;Nt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),jt("c",t,e,Nt,0,0,-1),jt("t",t,e,Nt,0,0,1),jt("n1",t,e,Nt,-i,-r,-1),jt("n2",t,e,Nt,i,-r,-1),jt("n3",t,e,Nt,-i,r,-1),jt("n4",t,e,Nt,i,r,-1),jt("f1",t,e,Nt,-i,-r,1),jt("f2",t,e,Nt,i,-r,1),jt("f3",t,e,Nt,-i,r,1),jt("f4",t,e,Nt,i,r,1),jt("u1",t,e,Nt,i*.7,r*1.1,-1),jt("u2",t,e,Nt,-i*.7,r*1.1,-1),jt("u3",t,e,Nt,0,r*2,-1),jt("cf1",t,e,Nt,-i,0,1),jt("cf2",t,e,Nt,i,0,1),jt("cf3",t,e,Nt,0,-r,1),jt("cf4",t,e,Nt,0,r,1),jt("cn1",t,e,Nt,-i,0,-1),jt("cn2",t,e,Nt,i,0,-1),jt("cn3",t,e,Nt,0,-r,-1),jt("cn4",t,e,Nt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function jt(e,t,i,r,s,n,a){Dc.set(s,n,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],Dc.x,Dc.y,Dc.z)}}var Rd=class extends Gh{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new He;s.setIndex(new Xe(i,1)),s.setAttribute("position",new Ce(r,3)),super(s,new Vn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},jL=class extends Gh{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new He;r.setAttribute("position",new Ce(t,3)),r.setAttribute("color",new Ce(i,3));let s=new Vn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ge,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:el}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=el);var Tl=".",Bg=Symbol("target"),u_=Symbol("unsubscribe");function lm(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function GL(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var gs=Array.isArray;function Ng(e){return typeof e=="symbol"}var VL={after:(e,t)=>gs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>gs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Tl),Ng(t)?e+t.toString():e+t):e,initial:e=>{if(gs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Tl);return t===-1?"":e.slice(0,t)},last:e=>{if(gs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Tl);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(gs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Tl);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(Tl,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},yr=VL;function HL(e){return typeof e=="object"&&typeof e.next=="function"}function WL(e,t,i,r,s){let n=e.next;if(t.name==="entries")e.next=function(){let a=n.call(this);return a.done===!1&&(a.value[0]=s(a.value[0],t,a.value[0],r),a.value[1]=s(a.value[1],t,a.value[0],r)),a};else if(t.name==="values"){let a=i[Bg].keys();e.next=function(){let o=n.call(this);return o.done===!1&&(o.value=s(o.value,t,a.next().value,r)),o}}else e.next=function(){let a=n.call(this);return a.done===!1&&(a.value=s(a.value,t,a.value,r)),a};return e}function Xy(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Ng(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var qL=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],n=s||e;this._pathCache.set(n,t);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(e,i):e,this._proxyCache.set(n,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,yr.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&"set"in n?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function hm(e){return toString.call(e)==="[object Object]"}function Lc(){return!0}function ro(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var p_=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),XL=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),f_={push:Lc,pop:Lc,shift:Lc,unshift:Lc,copyWithin:ro,reverse:ro,sort:ro,splice:ro,flat:ro,fill:ro},YL=new Set([...p_,...XL,...Object.keys(f_)]);function Oc(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var m_=["keys","values","entries"],g_=new Set(["has","toString"]),v_={add:Oc,clear:Oc,delete:Oc,forEach:Oc},QL=new Set([...g_,...Object.keys(v_),...m_]);function Ic(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var ZL=new Set([...g_,"get"]),y_={set:Ic,clear:Ic,delete:Ic,forEach:Ic},KL=new Set([...ZL,...Object.keys(y_),...m_]),jn=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return p_.has(e)}_shallowClone(e){let t=e;if(hm(e))t={...e};else if(gs(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(gs(r)?this._onIsChanged=f_[t]:r instanceof Set?this._onIsChanged=v_[t]:r instanceof Map&&(this._onIsChanged=y_[t]),r):i}update(e,t,i){let r=yr.after(e,this._path);if(t!=="length"){let s=this.clone;yr.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],yr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Yy=class extends jn{static isHandledMethod(e){return YL.has(e)}},JL=class extends jn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Qy=class extends jn{static isHandledMethod(e){return QL.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},Zy=class extends jn{static isHandledMethod(e){return KL.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},$L=class extends jn{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},eO=class extends jn{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},yo=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return hm(e)||gs(e)||lm(e)}static isHandledMethod(e,t){return hm(e)?jn.isHandledMethod(t):gs(e)?Yy.isHandledMethod(t):e instanceof Set?Qy.isHandledMethod(t):e instanceof Map?Zy.isHandledMethod(t):lm(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=jn;gs(e)?r=Yy:e instanceof Date?r=JL:e instanceof Set?r=Qy:e instanceof Map?r=Zy:e instanceof WeakSet?r=$L:e instanceof WeakMap&&(r=eO),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=yo.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},tO={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},zg=(e,t,i={})=>{i={...tO,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new qL(s),h=typeof i.onValidate=="function",u=new yo(h),c=(y,x,w,_,S)=>!h||u.isCloning||i.onValidate(yr.concat(l.getPath(y),x),w,_,S)===!0,d=(y,x,w,_)=>{!Xy(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,w,_)},p=(y,x,w,_,S)=>{u.isCloning?u.update(y,x,_):t(yr.concat(y,x),w,_,S)},f=y=>y&&(y[r]||y),g=(y,x,w,_)=>GL(y)||w==="constructor"||n&&!yo.isHandledMethod(x,w)||Xy(l,i,w)||l.isGetInvariant(x,w)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,yr.concat(_,w),m,r)),m={get(y,x,w){if(Ng(x)){if(x===r||x===Bg)return y;if(x===u_&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=lm(y)?Reflect.get(y,x):Reflect.get(y,x,w);return g(_,y,x)},set(y,x,w,_){w=f(w);let S=y[r]||y,A=S[x];if(s(A,w)&&x in y)return!0;let b=c(y,x,w,A);return b&&l.setProperty(S,x,w,_,A)?(d(y,x,y[x],A),!0):!b},defineProperty(y,x,w){if(!l.isSameDescriptor(w,y,x)){let _=y[x];c(y,x,w.value,_)&&l.defineProperty(y,x,w,_)&&d(y,x,w.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let w=Reflect.get(y,x),_=c(y,x,void 0,w);return _&&l.deleteProperty(y,x,w)?(d(y,x,void 0,w),!0):!_},apply(y,x,w){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,w);if((o===!1||o!==!0&&!o.includes(y.name))&&yo.isHandledType(_)){let S=yr.initial(l.getPath(y)),A=yo.isHandledMethod(_,y.name);u.start(_,S,w);let b=Reflect.apply(y,u.preferredThisArg(y,x,_),A?w.map(T=>f(T)):w),M=u.isChanged(_,s),C=u.stop();if(yo.isHandledType(b)&&A&&(x instanceof Map&&y.name==="get"&&(S=yr.concat(S,w[0])),b=l.getProxy(b,S,m)),M){let T={name:y.name,args:w,result:b},D=u.isCloning?yr.initial(S):S,L=u.isCloning?yr.last(S):"";c(yr.get(e,D),L,_,C,T)?p(D,L,_,C,T):u.undo(_)}return(x instanceof Map||x instanceof Set)&&HL(b)?WL(b,y,x,S,g):b}return Reflect.apply(y,x,w)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};zg.target=e=>e&&e[Bg]||e;zg.unsubscribe=e=>e[u_]||e;var Ky=zg,iO=typeof global=="object"&&global&&global.Object===Object&&global,x_=iO,rO=typeof self=="object"&&self&&self.Object===Object&&self,sO=x_||rO||Function("return this")(),$r=sO,nO=$r.Symbol,Pr=nO,w_=Object.prototype,aO=w_.hasOwnProperty,oO=w_.toString,Pl=Pr?Pr.toStringTag:void 0;function lO(e){var t=aO.call(e,Pl),i=e[Pl];try{e[Pl]=void 0;var r=!0}catch{}var s=oO.call(e);return r&&(t?e[Pl]=i:delete e[Pl]),s}var hO=lO,cO=Object.prototype,dO=cO.toString;function uO(e){return dO.call(e)}var pO=uO,fO="[object Null]",mO="[object Undefined]",Jy=Pr?Pr.toStringTag:void 0;function gO(e){return e==null?e===void 0?mO:fO:Jy&&Jy in Object(e)?hO(e):pO(e)}var Ra=gO;function vO(e){return e!=null&&typeof e=="object"}var en=vO,yO="[object Symbol]";function xO(e){return typeof e=="symbol"||en(e)&&Ra(e)==yO}var Au=xO;function wO(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var b_=wO,bO=Array.isArray,Ts=bO,_O=1/0,$y=Pr?Pr.prototype:void 0,e1=$y?$y.toString:void 0;function __(e){if(typeof e=="string")return e;if(Ts(e))return b_(e,__)+"";if(Au(e))return e1?e1.call(e):"";var t=e+"";return t=="0"&&1/e==-_O?"-0":t}var SO=__,AO=/\s/;function MO(e){for(var t=e.length;t--&&AO.test(e.charAt(t)););return t}var EO=MO,CO=/^\s+/;function TO(e){return e&&e.slice(0,EO(e)+1).replace(CO,"")}var PO=TO;function DO(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Kr=DO,t1=0/0,LO=/^[-+]0x[0-9a-f]+$/i,OO=/^0b[01]+$/i,IO=/^0o[0-7]+$/i,RO=parseInt;function BO(e){if(typeof e=="number")return e;if(Au(e))return t1;if(Kr(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Kr(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=PO(e);var i=OO.test(e);return i||IO.test(e)?RO(e.slice(2),i?2:8):LO.test(e)?t1:+e}var i1=BO;function NO(e){return e}var zO=NO,FO="[object AsyncFunction]",UO="[object Function]",kO="[object GeneratorFunction]",jO="[object Proxy]";function GO(e){if(!Kr(e))return!1;var t=Ra(e);return t==UO||t==kO||t==FO||t==jO}var S_=GO,VO=$r["__core-js_shared__"],jp=VO,r1=function(){var e=/[^.]+$/.exec(jp&&jp.keys&&jp.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function HO(e){return!!r1&&r1 in e}var WO=HO,qO=Function.prototype,XO=qO.toString;function YO(e){if(e!=null){try{return XO.call(e)}catch{}try{return e+""}catch{}}return""}var Ba=YO,QO=/[\\^$.*+?()[\]{}|]/g,ZO=/^\[object .+?Constructor\]$/,KO=Function.prototype,JO=Object.prototype,$O=KO.toString,eI=JO.hasOwnProperty,tI=RegExp("^"+$O.call(eI).replace(QO,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function iI(e){if(!Kr(e)||WO(e))return!1;var t=S_(e)?tI:ZO;return t.test(Ba(e))}var rI=iI;function sI(e,t){return e?.[t]}var nI=sI;function aI(e,t){var i=nI(e,t);return rI(i)?i:void 0}var Na=aI,oI=Na($r,"WeakMap"),cm=oI,s1=Object.create,lI=function(){function e(){}return function(t){if(!Kr(t))return{};if(s1)return s1(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),hI=lI;function cI(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var dI=cI;function uI(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var pI=uI,fI=800,mI=16,gI=Date.now;function vI(e){var t=0,i=0;return function(){var r=gI(),s=mI-(r-i);if(i=r,s>0){if(++t>=fI)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var yI=vI;function xI(e){return function(){return e}}var wI=xI,bI=function(){try{var e=Na(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Bd=bI,_I=Bd?function(e,t){return Bd(e,"toString",{configurable:!0,enumerable:!1,value:wI(t),writable:!0})}:zO,SI=_I,AI=yI(SI),MI=AI;function EI(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var CI=EI,TI=9007199254740991,PI=/^(?:0|[1-9]\d*)$/;function DI(e,t){var i=typeof e;return t=t??TI,!!t&&(i=="number"||i!="symbol"&&PI.test(e))&&e>-1&&e%1==0&&e<t}var Fg=DI;function LI(e,t,i){t=="__proto__"&&Bd?Bd(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var A_=LI;function OI(e,t){return e===t||e!==e&&t!==t}var Ug=OI,II=Object.prototype,RI=II.hasOwnProperty;function BI(e,t,i){var r=e[t];(!(RI.call(e,t)&&Ug(r,i))||i===void 0&&!(t in e))&&A_(e,t,i)}var kg=BI;function NI(e,t,i,r){var s=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?A_(i,o,l):kg(i,o,l)}return i}var qh=NI,n1=Math.max;function zI(e,t,i){return t=n1(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=n1(r.length-t,0),a=Array(n);++s<n;)a[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(a),dI(e,this,o)}}var FI=zI,UI=9007199254740991;function kI(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=UI}var jg=kI;function jI(e){return e!=null&&jg(e.length)&&!S_(e)}var M_=jI,GI=Object.prototype;function VI(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||GI;return e===i}var Gg=VI;function HI(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var WI=HI,qI="[object Arguments]";function XI(e){return en(e)&&Ra(e)==qI}var a1=XI,E_=Object.prototype,YI=E_.hasOwnProperty,QI=E_.propertyIsEnumerable,ZI=a1(function(){return arguments}())?a1:function(e){return en(e)&&YI.call(e,"callee")&&!QI.call(e,"callee")},Vg=ZI;function KI(){return!1}var JI=KI,C_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,o1=C_&&typeof module=="object"&&module&&!module.nodeType&&module,$I=o1&&o1.exports===C_,l1=$I?$r.Buffer:void 0,e4=l1?l1.isBuffer:void 0,t4=e4||JI,Nd=t4,i4="[object Arguments]",r4="[object Array]",s4="[object Boolean]",n4="[object Date]",a4="[object Error]",o4="[object Function]",l4="[object Map]",h4="[object Number]",c4="[object Object]",d4="[object RegExp]",u4="[object Set]",p4="[object String]",f4="[object WeakMap]",m4="[object ArrayBuffer]",g4="[object DataView]",v4="[object Float32Array]",y4="[object Float64Array]",x4="[object Int8Array]",w4="[object Int16Array]",b4="[object Int32Array]",_4="[object Uint8Array]",S4="[object Uint8ClampedArray]",A4="[object Uint16Array]",M4="[object Uint32Array]",Pt={};Pt[v4]=Pt[y4]=Pt[x4]=Pt[w4]=Pt[b4]=Pt[_4]=Pt[S4]=Pt[A4]=Pt[M4]=!0;Pt[i4]=Pt[r4]=Pt[m4]=Pt[s4]=Pt[g4]=Pt[n4]=Pt[a4]=Pt[o4]=Pt[l4]=Pt[h4]=Pt[c4]=Pt[d4]=Pt[u4]=Pt[p4]=Pt[f4]=!1;function E4(e){return en(e)&&jg(e.length)&&!!Pt[Ra(e)]}var C4=E4;function T4(e){return function(t){return e(t)}}var Hg=T4,T_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hh=T_&&typeof module=="object"&&module&&!module.nodeType&&module,P4=hh&&hh.exports===T_,Gp=P4&&x_.process,D4=function(){try{var e=hh&&hh.require&&hh.require("util").types;return e||Gp&&Gp.binding&&Gp.binding("util")}catch{}}(),qo=D4,h1=qo&&qo.isTypedArray,L4=h1?Hg(h1):C4,P_=L4,O4=Object.prototype,I4=O4.hasOwnProperty;function R4(e,t){var i=Ts(e),r=!i&&Vg(e),s=!i&&!r&&Nd(e),n=!i&&!r&&!s&&P_(e),a=i||r||s||n,o=a?WI(e.length,String):[],l=o.length;for(var h in e)(t||I4.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Fg(h,l)))&&o.push(h);return o}var D_=R4;function B4(e,t){return function(i){return e(t(i))}}var L_=B4,N4=L_(Object.keys,Object),z4=N4,F4=Object.prototype,U4=F4.hasOwnProperty;function k4(e){if(!Gg(e))return z4(e);var t=[];for(var i in Object(e))U4.call(e,i)&&i!="constructor"&&t.push(i);return t}var j4=k4;function G4(e){return M_(e)?D_(e):j4(e)}var Wg=G4;function V4(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var H4=V4,W4=Object.prototype,q4=W4.hasOwnProperty;function X4(e){if(!Kr(e))return H4(e);var t=Gg(e),i=[];for(var r in e)r=="constructor"&&(t||!q4.call(e,r))||i.push(r);return i}var Y4=X4;function Q4(e){return M_(e)?D_(e,!0):Y4(e)}var qg=Q4,Z4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K4=/^\w*$/;function J4(e,t){if(Ts(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Au(e)?!0:K4.test(e)||!Z4.test(e)||t!=null&&e in Object(t)}var $4=J4,eR=Na(Object,"create"),Mh=eR;function tR(){this.__data__=Mh?Mh(null):{},this.size=0}var iR=tR;function rR(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var sR=rR,nR="__lodash_hash_undefined__",aR=Object.prototype,oR=aR.hasOwnProperty;function lR(e){var t=this.__data__;if(Mh){var i=t[e];return i===nR?void 0:i}return oR.call(t,e)?t[e]:void 0}var hR=lR,cR=Object.prototype,dR=cR.hasOwnProperty;function uR(e){var t=this.__data__;return Mh?t[e]!==void 0:dR.call(t,e)}var pR=uR,fR="__lodash_hash_undefined__";function mR(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Mh&&t===void 0?fR:t,this}var gR=mR;function nl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}nl.prototype.clear=iR;nl.prototype.delete=sR;nl.prototype.get=hR;nl.prototype.has=pR;nl.prototype.set=gR;var c1=nl;function vR(){this.__data__=[],this.size=0}var yR=vR;function xR(e,t){for(var i=e.length;i--;)if(Ug(e[i][0],t))return i;return-1}var Mu=xR,wR=Array.prototype,bR=wR.splice;function _R(e){var t=this.__data__,i=Mu(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():bR.call(t,i,1),--this.size,!0}var SR=_R;function AR(e){var t=this.__data__,i=Mu(t,e);return i<0?void 0:t[i][1]}var MR=AR;function ER(e){return Mu(this.__data__,e)>-1}var CR=ER;function TR(e,t){var i=this.__data__,r=Mu(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var PR=TR;function al(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}al.prototype.clear=yR;al.prototype.delete=SR;al.prototype.get=MR;al.prototype.has=CR;al.prototype.set=PR;var Eu=al,DR=Na($r,"Map"),Eh=DR;function LR(){this.size=0,this.__data__={hash:new c1,map:new(Eh||Eu),string:new c1}}var OR=LR;function IR(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var RR=IR;function BR(e,t){var i=e.__data__;return RR(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Cu=BR;function NR(e){var t=Cu(this,e).delete(e);return this.size-=t?1:0,t}var zR=NR;function FR(e){return Cu(this,e).get(e)}var UR=FR;function kR(e){return Cu(this,e).has(e)}var jR=kR;function GR(e,t){var i=Cu(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var VR=GR;function ol(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ol.prototype.clear=OR;ol.prototype.delete=zR;ol.prototype.get=UR;ol.prototype.has=jR;ol.prototype.set=VR;var Tu=ol,HR="Expected a function";function Xg(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(HR);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],n=i.cache;if(n.has(s))return n.get(s);var a=e.apply(this,r);return i.cache=n.set(s,a)||n,a};return i.cache=new(Xg.Cache||Tu),i}Xg.Cache=Tu;var WR=Xg,qR=500;function XR(e){var t=WR(e,function(r){return i.size===qR&&i.clear(),r}),i=t.cache;return t}var YR=XR,QR=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ZR=/\\(\\)?/g,KR=YR(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(QR,function(i,r,s,n){t.push(s?n.replace(ZR,"$1"):r||i)}),t}),JR=KR;function $R(e){return e==null?"":SO(e)}var eB=$R;function tB(e,t){return Ts(e)?e:$4(e,t)?[e]:JR(eB(e))}var ll=tB,iB=1/0;function rB(e){if(typeof e=="string"||Au(e))return e;var t=e+"";return t=="0"&&1/e==-iB?"-0":t}var Pu=rB;function sB(e,t){t=ll(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Pu(t[i++])];return i&&i==r?e:void 0}var O_=sB;function nB(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Yg=nB,d1=Pr?Pr.isConcatSpreadable:void 0;function aB(e){return Ts(e)||Vg(e)||!!(d1&&e&&e[d1])}var oB=aB;function I_(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=oB),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?I_(o,t-1,i,r,s):Yg(s,o):r||(s[s.length]=o)}return s}var lB=I_;function hB(e){var t=e==null?0:e.length;return t?lB(e,1):[]}var cB=hB;function dB(e){return MI(FI(e,void 0,cB),e+"")}var R_=dB,uB=L_(Object.getPrototypeOf,Object),Qg=uB,pB="[object Object]",fB=Function.prototype,mB=Object.prototype,B_=fB.toString,gB=mB.hasOwnProperty,vB=B_.call(Object);function yB(e){if(!en(e)||Ra(e)!=pB)return!1;var t=Qg(e);if(t===null)return!0;var i=gB.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&B_.call(i)==vB}var xB=yB;function wB(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var n=Array(s);++r<s;)n[r]=e[r+t];return n}var bB=wB;function _B(){this.__data__=new Eu,this.size=0}var SB=_B;function AB(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var MB=AB;function EB(e){return this.__data__.get(e)}var CB=EB;function TB(e){return this.__data__.has(e)}var PB=TB,DB=200;function LB(e,t){var i=this.__data__;if(i instanceof Eu){var r=i.__data__;if(!Eh||r.length<DB-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Tu(r)}return i.set(e,t),this.size=i.size,this}var OB=LB;function hl(e){var t=this.__data__=new Eu(e);this.size=t.size}hl.prototype.clear=SB;hl.prototype.delete=MB;hl.prototype.get=CB;hl.prototype.has=PB;hl.prototype.set=OB;var pd=hl;function IB(e,t){return e&&qh(t,Wg(t),e)}var RB=IB;function BB(e,t){return e&&qh(t,qg(t),e)}var NB=BB,N_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,u1=N_&&typeof module=="object"&&module&&!module.nodeType&&module,zB=u1&&u1.exports===N_,p1=zB?$r.Buffer:void 0,f1=p1?p1.allocUnsafe:void 0;function FB(e,t){if(t)return e.slice();var i=e.length,r=f1?f1(i):new e.constructor(i);return e.copy(r),r}var UB=FB;function kB(e,t){for(var i=-1,r=e==null?0:e.length,s=0,n=[];++i<r;){var a=e[i];t(a,i,e)&&(n[s++]=a)}return n}var jB=kB;function GB(){return[]}var z_=GB,VB=Object.prototype,HB=VB.propertyIsEnumerable,m1=Object.getOwnPropertySymbols,WB=m1?function(e){return e==null?[]:(e=Object(e),jB(m1(e),function(t){return HB.call(e,t)}))}:z_,Zg=WB;function qB(e,t){return qh(e,Zg(e),t)}var XB=qB,YB=Object.getOwnPropertySymbols,QB=YB?function(e){for(var t=[];e;)Yg(t,Zg(e)),e=Qg(e);return t}:z_,F_=QB;function ZB(e,t){return qh(e,F_(e),t)}var KB=ZB;function JB(e,t,i){var r=t(e);return Ts(e)?r:Yg(r,i(e))}var U_=JB;function $B(e){return U_(e,Wg,Zg)}var dm=$B;function eN(e){return U_(e,qg,F_)}var k_=eN,tN=Na($r,"DataView"),um=tN,iN=Na($r,"Promise"),pm=iN,rN=Na($r,"Set"),fm=rN,g1="[object Map]",sN="[object Object]",v1="[object Promise]",y1="[object Set]",x1="[object WeakMap]",w1="[object DataView]",nN=Ba(um),aN=Ba(Eh),oN=Ba(pm),lN=Ba(fm),hN=Ba(cm),oa=Ra;(um&&oa(new um(new ArrayBuffer(1)))!=w1||Eh&&oa(new Eh)!=g1||pm&&oa(pm.resolve())!=v1||fm&&oa(new fm)!=y1||cm&&oa(new cm)!=x1)&&(oa=function(e){var t=Ra(e),i=t==sN?e.constructor:void 0,r=i?Ba(i):"";if(r)switch(r){case nN:return w1;case aN:return g1;case oN:return v1;case lN:return y1;case hN:return x1}return t});var Ch=oa,cN=Object.prototype,dN=cN.hasOwnProperty;function uN(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&dN.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var pN=uN,fN=$r.Uint8Array,zd=fN;function mN(e){var t=new e.constructor(e.byteLength);return new zd(t).set(new zd(e)),t}var Kg=mN;function gN(e,t){var i=t?Kg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var vN=gN,yN=/\w*$/;function xN(e){var t=new e.constructor(e.source,yN.exec(e));return t.lastIndex=e.lastIndex,t}var wN=xN,b1=Pr?Pr.prototype:void 0,_1=b1?b1.valueOf:void 0;function bN(e){return _1?Object(_1.call(e)):{}}var _N=bN;function SN(e,t){var i=t?Kg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var AN=SN,MN="[object Boolean]",EN="[object Date]",CN="[object Map]",TN="[object Number]",PN="[object RegExp]",DN="[object Set]",LN="[object String]",ON="[object Symbol]",IN="[object ArrayBuffer]",RN="[object DataView]",BN="[object Float32Array]",NN="[object Float64Array]",zN="[object Int8Array]",FN="[object Int16Array]",UN="[object Int32Array]",kN="[object Uint8Array]",jN="[object Uint8ClampedArray]",GN="[object Uint16Array]",VN="[object Uint32Array]";function HN(e,t,i){var r=e.constructor;switch(t){case IN:return Kg(e);case MN:case EN:return new r(+e);case RN:return vN(e,i);case BN:case NN:case zN:case FN:case UN:case kN:case jN:case GN:case VN:return AN(e,i);case CN:return new r;case TN:case LN:return new r(e);case PN:return wN(e);case DN:return new r;case ON:return _N(e)}}var WN=HN;function qN(e){return typeof e.constructor=="function"&&!Gg(e)?hI(Qg(e)):{}}var XN=qN,YN="[object Map]";function QN(e){return en(e)&&Ch(e)==YN}var ZN=QN,S1=qo&&qo.isMap,KN=S1?Hg(S1):ZN,JN=KN,$N="[object Set]";function ez(e){return en(e)&&Ch(e)==$N}var tz=ez,A1=qo&&qo.isSet,iz=A1?Hg(A1):tz,rz=iz,sz=1,nz=2,az=4,j_="[object Arguments]",oz="[object Array]",lz="[object Boolean]",hz="[object Date]",cz="[object Error]",G_="[object Function]",dz="[object GeneratorFunction]",uz="[object Map]",pz="[object Number]",V_="[object Object]",fz="[object RegExp]",mz="[object Set]",gz="[object String]",vz="[object Symbol]",yz="[object WeakMap]",xz="[object ArrayBuffer]",wz="[object DataView]",bz="[object Float32Array]",_z="[object Float64Array]",Sz="[object Int8Array]",Az="[object Int16Array]",Mz="[object Int32Array]",Ez="[object Uint8Array]",Cz="[object Uint8ClampedArray]",Tz="[object Uint16Array]",Pz="[object Uint32Array]",Tt={};Tt[j_]=Tt[oz]=Tt[xz]=Tt[wz]=Tt[lz]=Tt[hz]=Tt[bz]=Tt[_z]=Tt[Sz]=Tt[Az]=Tt[Mz]=Tt[uz]=Tt[pz]=Tt[V_]=Tt[fz]=Tt[mz]=Tt[gz]=Tt[vz]=Tt[Ez]=Tt[Cz]=Tt[Tz]=Tt[Pz]=!0;Tt[cz]=Tt[G_]=Tt[yz]=!1;function fd(e,t,i,r,s,n){var a,o=t&sz,l=t&nz,h=t&az;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!Kr(e))return e;var u=Ts(e);if(u){if(a=pN(e),!o)return pI(e,a)}else{var c=Ch(e),d=c==G_||c==dz;if(Nd(e))return UB(e,o);if(c==V_||c==j_||d&&!s){if(a=l||d?{}:XN(e),!o)return l?KB(e,NB(a,e)):XB(e,RB(a,e))}else{if(!Tt[c])return s?e:{};a=WN(e,c,o)}}n||(n=new pd);var p=n.get(e);if(p)return p;n.set(e,a),rz(e)?e.forEach(function(m){a.add(fd(m,t,i,m,e,n))}):JN(e)&&e.forEach(function(m,v){a.set(v,fd(m,t,i,v,e,n))});var f=h?l?k_:dm:l?qg:Wg,g=u?void 0:f(e);return CI(g||e,function(m,v){g&&(v=m,m=e[v]),kg(a,v,fd(m,t,i,v,e,n))}),a}var H_=fd,Dz=1,Lz=4;function Oz(e){return H_(e,Dz|Lz)}var Du=Oz,Iz="__lodash_hash_undefined__";function Rz(e){return this.__data__.set(e,Iz),this}var Bz=Rz;function Nz(e){return this.__data__.has(e)}var zz=Nz;function Fd(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Tu;++t<i;)this.add(e[t])}Fd.prototype.add=Fd.prototype.push=Bz;Fd.prototype.has=zz;var Fz=Fd;function Uz(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var kz=Uz;function jz(e,t){return e.has(t)}var Gz=jz,Vz=1,Hz=2;function Wz(e,t,i,r,s,n){var a=i&Vz,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var h=n.get(e),u=n.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&Hz?new Fz:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var f=e[c],g=t[c];if(r)var m=a?r(g,f,c,t,e,n):r(f,g,c,e,t,n);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!kz(t,function(v,y){if(!Gz(p,y)&&(f===v||s(f,v,i,r,n)))return p.push(y)})){d=!1;break}}else if(!(f===g||s(f,g,i,r,n))){d=!1;break}}return n.delete(e),n.delete(t),d}var W_=Wz;function qz(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var Xz=qz;function Yz(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var Qz=Yz,Zz=1,Kz=2,Jz="[object Boolean]",$z="[object Date]",e5="[object Error]",t5="[object Map]",i5="[object Number]",r5="[object RegExp]",s5="[object Set]",n5="[object String]",a5="[object Symbol]",o5="[object ArrayBuffer]",l5="[object DataView]",M1=Pr?Pr.prototype:void 0,Vp=M1?M1.valueOf:void 0;function h5(e,t,i,r,s,n,a){switch(i){case l5:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case o5:return!(e.byteLength!=t.byteLength||!n(new zd(e),new zd(t)));case Jz:case $z:case i5:return Ug(+e,+t);case e5:return e.name==t.name&&e.message==t.message;case r5:case n5:return e==t+"";case t5:var o=Xz;case s5:var l=r&Zz;if(o||(o=Qz),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=Kz,a.set(e,t);var u=W_(o(e),o(t),r,s,n,a);return a.delete(e),u;case a5:if(Vp)return Vp.call(e)==Vp.call(t)}return!1}var c5=h5,d5=1,u5=Object.prototype,p5=u5.hasOwnProperty;function f5(e,t,i,r,s,n){var a=i&d5,o=dm(e),l=o.length,h=dm(t),u=h.length;if(l!=u&&!a)return!1;for(var c=l;c--;){var d=o[c];if(!(a?d in t:p5.call(t,d)))return!1}var p=n.get(e),f=n.get(t);if(p&&f)return p==t&&f==e;var g=!0;n.set(e,t),n.set(t,e);for(var m=a;++c<l;){d=o[c];var v=e[d],y=t[d];if(r)var x=a?r(y,v,d,t,e,n):r(v,y,d,e,t,n);if(!(x===void 0?v===y||s(v,y,i,r,n):x)){g=!1;break}m||(m=d=="constructor")}if(g&&!m){var w=e.constructor,_=t.constructor;w!=_&&"constructor"in e&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof _=="function"&&_ instanceof _)&&(g=!1)}return n.delete(e),n.delete(t),g}var m5=f5,g5=1,E1="[object Arguments]",C1="[object Array]",Rc="[object Object]",v5=Object.prototype,T1=v5.hasOwnProperty;function y5(e,t,i,r,s,n){var a=Ts(e),o=Ts(t),l=a?C1:Ch(e),h=o?C1:Ch(t);l=l==E1?Rc:l,h=h==E1?Rc:h;var u=l==Rc,c=h==Rc,d=l==h;if(d&&Nd(e)){if(!Nd(t))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new pd),a||P_(e)?W_(e,t,i,r,s,n):c5(e,t,l,i,r,s,n);if(!(i&g5)){var p=u&&T1.call(e,"__wrapped__"),f=c&&T1.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return n||(n=new pd),s(g,m,i,r,n)}}return d?(n||(n=new pd),m5(e,t,i,r,s,n)):!1}var x5=y5;function q_(e,t,i,r,s){return e===t?!0:e==null||t==null||!en(e)&&!en(t)?e!==e&&t!==t:x5(e,t,i,r,q_,s)}var w5=q_;function b5(e,t){return e!=null&&t in Object(e)}var _5=b5;function S5(e,t,i){t=ll(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=Pu(t[r]);if(!(n=e!=null&&i(e,a)))break;e=e[a]}return n||++r!=s?n:(s=e==null?0:e.length,!!s&&jg(s)&&Fg(a,s)&&(Ts(e)||Vg(e)))}var A5=S5;function M5(e,t){return e!=null&&A5(e,t,_5)}var E5=M5,C5=function(){return $r.Date.now()},Hp=C5,T5="Expected a function",P5=Math.max,D5=Math.min;function L5(e,t,i){var r,s,n,a,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(T5);t=i1(t)||0,Kr(i)&&(u=!!i.leading,c="maxWait"in i,n=c?P5(i1(i.maxWait)||0,t):n,d="trailing"in i?!!i.trailing:d);function p(S){var A=r,b=s;return r=s=void 0,h=S,a=e.apply(b,A),a}function f(S){return h=S,o=setTimeout(v,t),u?p(S):a}function g(S){var A=S-l,b=S-h,M=t-A;return c?D5(M,n-b):M}function m(S){var A=S-l,b=S-h;return l===void 0||A>=t||A<0||c&&b>=n}function v(){var S=Hp();if(m(S))return y(S);o=setTimeout(v,g(S))}function y(S){return o=void 0,d&&r?p(S):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function w(){return o===void 0?a:y(Hp())}function _(){var S=Hp(),A=m(S);if(r=arguments,s=this,l=S,A){if(o===void 0)return f(l);if(c)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),a}return _.cancel=x,_.flush=w,_}var Jg=L5;function O5(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var I5=O5;function R5(e,t){return t.length<2?e:O_(e,bB(t,0,-1))}var B5=R5;function N5(e,t){return w5(e,t)}var $g=N5;function z5(e,t){return t=ll(t,e),e=B5(e,t),e==null||delete e[Pu(I5(t))]}var F5=z5;function U5(e){return xB(e)?void 0:e}var k5=U5,j5=1,G5=2,V5=4,H5=R_(function(e,t){var i={};if(e==null)return i;var r=!1;t=b_(t,function(n){return n=ll(n,e),r||(r=n.length>1),n}),qh(e,k_(e),i),r&&(i=H_(i,j5|G5|V5,k5));for(var s=t.length;s--;)F5(i,t[s]);return i}),mm=H5;function W5(e,t,i,r){if(!Kr(e))return e;t=ll(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=Pu(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=a){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=Kr(u)?u:Fg(t[s+1])?[]:{})}kg(o,l,h),o=o[l]}return e}var q5=W5;function X5(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=O_(e,a);i(o,a)&&q5(n,ll(a,e),o)}return n}var Y5=X5;function Q5(e,t){return Y5(e,t,function(i,r){return E5(e,r)})}var Z5=Q5,K5=R_(function(e,t){return e==null?{}:Z5(e,t)}),Th=K5,J5="Expected a function";function $5(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(J5);return Kr(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),Jg(e,t,{leading:r,maxWait:t,trailing:s})}var eF=$5,X_,tF=new Promise(e=>{X_=e}),P1=!1;async function iF(){if(P1)return;let e=await import("./physics.js");await e.init(),X_(e),P1=!0}var Kt=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Kt.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:n}=e,a={...t,[s]:n};return Object.setPrototypeOf(a,Kt.prototype),{data:a,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,Kt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function ev(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&ev(r)}return Object.freeze(e)}function rF(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var Y_=class extends Error{};function Wp(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Dn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let n=e;e=t,t=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=e+(t-e)*(n+.75+Math.random()*.5)*s;r.push(a)}return r}function tv(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function sF(){return typeof process<"u"}function Q_(e,t){for(let i of e)t(i.id,i.data)!==!0&&Q_(i.children,t)}function Z_(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)Z_(i,t)}var Wi=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Wi.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ev(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&Z_(i,t)}}traverse(e){Q_(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);if(s<0)throw new Error("not expected");let n=r[s];return r=[...r],r[s]={...n,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let n=r,a=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===a);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:n}}Object.setPrototypeOf(r,Wi.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===t);e.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...n,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new Y_("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(c=>c.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=t,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((c,d)=>c.fi-d.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:e,reverse:{type:9,parent:n,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>rF(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Dn(0,i,i);{let s=r[0].fi;return Dn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Dn(a,a+i,i)}else return Dn(s.fi,n.fi,i)}}},Ud;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,n={},a=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");n[l]=a[h],a[h]=s[l],o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let s=r.props,n={},a={...i},o=!1;if(s)for(let l of Object.keys(s)){n[l]=a[l];let h=s[l];h===void 0?delete a[l]:a[l]=h,o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}}e.runOp=t})(Ud||(Ud={}));var et=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,et.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ev(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,et.prototype);let t=e;return sF()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,n={fi:t,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(n=>n.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:t};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:n,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Dn(0,t,t);{let r=i[0].fi;return Dn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Dn(n,n+t,t)}else return Dn(r.fi,s.fi,t)}}};function Xo(e){return e&&typeof e=="object"&&e instanceof wi}var wi=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!Xo(i))return null;r+=1}i=i?Wp(i):new wi;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=Wp(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Wp(o);l[e.path[r-1]]=i,i=l}else{let l=new wi;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,wi.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},Sa;(e=>{function t(s,n){return Ph(s,n)??s}e.apply=t;function i(s,n){return rv(s,n)}e.merge=i;function r(s,n){let a=0,o=n.path,l=s;for(;a<o.length&&l!==void 0;){if(l=As.zoomOnce(l,o[a]),l===void 0)return n;if(!Xo(l))return;a+=1}if(l===void 0)return n;if(Xo(l))if(n.type===0){let h={...n.props};for(let u of Object.keys(l))delete h[u];return{...n,props:h}}else if(n.type===1||n.type===4||n.type===7){let h=iv([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(Sa||(Sa={}));function iv(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Ph(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=iv(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}else return{...s,id:n,data:a}});if(i)return r}function nF(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Ph(s.data,t[n]);return i=i||a!==void 0,a===void 0&&(a=s.data),{...s,id:n,data:a}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function Ph(e,t){if(!Xo(t))return t;if(e instanceof Wi){let i=iv(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof et)return nF(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=Ph(s,t[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof wi)return rv(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=Ph(n,t[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function rv(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Xo(t))return t;if(!Xo(e))return Sa.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new wi;for(let s of i){let n=rv(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function aF(e,t){let i={cur:[],result:[],len:0};return e=Dh(e,t,i)??e,[e,i.result]}function kd(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function jd(e){e&&(e.len-=1)}function oF(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function K_(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Dh(n.data,t,kd(i,a));jd(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=K_(n.children,t,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function lF(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Dh(n.data,t,kd(i,a));return jd(i),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function Dh(e,t,i){if(e instanceof Wi){let r=K_(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof et)return lF(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=Dh(n,t,kd(i,a));return jd(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!tv(e)){let r={},s=!1;for(let[n,a]of Object.entries(e))if(n!=="name"&&n!=="text"){let o=t[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=Dh(a,t,kd(i,n));jd(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];if(r!==void 0){if(e.length!==36)throw new Error("for now you should only call this method when the key is a uuid");oF(i)}return r}else return}}var gm;(e=>{function t(i,r){let s=As.zoom(r,i.path);if(typeof s=="object"){let n={};for(let a of Object.keys(i.props))n[a]=s[a];return{...i,props:n}}else return{...i,props:{}}}e.replaceProps=t})(gm||(gm={}));var ar;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let u=h.path;for(var c=[];;){let d;if(l instanceof wi&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),d===void 0&&c.length===u.length&&(l instanceof Wi||l instanceof et||l instanceof Kt?d=l.runOp(h):d=Ud.runOp(l,h)),d!==void 0)if(d!==null){let g=d.data;for(let m=c.length-1;m>=0;m--){let v=u[m],y=c[m];if(y instanceof Wi){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof et){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof Kt){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof wi){let x={...y,[v]:g};g=Object.setPrototypeOf(x,wi.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let x=g;g=[...y],g[v]=x}else g={...y,[v]:g};else return null}return{data:g,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof Wi){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof et){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)c.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let u=0;u<l.length&&u<h.length;u++)if(l[u]!==h[u])return!0;return!1}e.pathDisjoint=s;function n(l,h){if(l.length!==h.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==h[u])return!1;return!0}e.pathEq=n;function a(l,h){return s(l.path,h.path)}e.commutative=a;function o(l,h){return l.type===0&&h.type===0&&n(l.path,h.path)?Object.keys(l.props).every(u=>h.props[u]!==void 0):!1}e.subsumed=o})(ar||(ar={}));var D1;(e=>{function t(){return[]}e.empty=t;function i(h,u){let c=[];for(let d of h){let[p,...f]=d.path;p===u&&c.push({...d,path:f})}return c}e.removePrefix=i;function r(h,u){return h.map(c=>({...c,path:[u,...c.path]}))}e.addPrefix=r;function s(h,u){return[...h,...u]}e.concat=s;function n(h,u){return[...h.filter(c=>!u.some(d=>ar.subsumed(c,d))),...u]}e.compress=n;function a(h,u){return h.every(c=>u.every(d=>ar.commutative(c,d)))}e.commutative=a;function o(h,u){for(let c of u){let d=l(h,c);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,u){var c=h;let d=[],p=[];for(let f of u)try{if(f.type===3){let g=As.zoom(c,[...f.path,f.id]),m=ar.apply(c,{...f,type:2});if(m!==null){c=m.data;let[v,y]=aF(c,{[f.id]:g});c=v;for(let x of y){let w=x[x.length-1];x.splice(x.length-1,1),d.push({type:0,path:x,props:{[w]:g}}),p.push({type:0,path:x,props:{[w]:f.id}})}p.push(m.reverse),d.push(m.actual)}}else{let g=ar.apply(c,f);g!==null&&(d.push(g.actual),c=g.data,p.push(g.reverse))}}catch(g){if(g instanceof Y_)return null;throw g}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(D1||(D1={}));var J_=Symbol(),hF=Symbol(),Lu=Symbol(),Xh=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof eS);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Lu];i&&i(),delete this._children[e]}}}},cF=class extends Xh{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Ud.runOp(this._current,e),e.path)}},dF=class extends Xh{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Kt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},$_={get(e,t){if(t===Lu)return()=>{e._parent=null};if(t===J_)return e._current;if(t===hF)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let n=i[t],a=Ou(e,t,n);return a!==n?(r===void 0&&(r={},e._children=r),r[t]=a,a):n},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},uF={...$_,set(e,t,i){let r={type:0,props:{[t]:Ci(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},pF={...$_,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},sv=class extends Xh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Lu]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Ou(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},nv=class extends Xh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Lu]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Ou(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function qp(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&As.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var eS=class extends Xh{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){qp(this.ts,t,e),qp(this.actual,i,e),qp(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Ou(e,t,i){return i instanceof Wi?new sv(e,t,i):i instanceof et?new nv(e,t,i):i instanceof Kt?new Proxy(new dF(e,t,i),pF):i!==null&&typeof i=="object"?tv(i)?i:new Proxy(new cF(e,t,i),uF):i}function tS(e){let t=new eS(e);return[Ou(t,"",e),t]}function Gd(e,t){let[i,r]=tS(e);return t(i),r.result()}function Ci(e){return e instanceof sv||e instanceof nv?e._current:e!==null&&typeof e=="object"?e[J_]:e}var As;(e=>{function t(n,a){if(a.length===n.length)for(var o=0;o<n.length;){if(n[o]!==a[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(n,a,o){let l=s(o,n);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...a};return Object.keys(l).forEach(u=>{delete h[u]}),h}else return a}e.removeOverridden=i;function r(n,a){if((n instanceof Wi||n instanceof sv)&&typeof a=="string"||(n instanceof et||n instanceof nv)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n)||typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}e.zoomOnce=r;function s(n,a,o=0){for(;o<a.length&&n!==void 0;)n=r(n,a[o]),o+=1;return n}e.zoom=s})(As||(As={}));function fF(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Mn(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var iS=class{},L1=class extends iS{constructor(e){super(),this.id=e}},O1=class extends iS{constructor(e){super(),this.data=e}},vm;try{vm=new TextDecoder}catch{}var Ae,zn,Z=0,rS=[],ym=rS,xm=0,ji={},pt,Ln,xr=0,vs=0,$i,Js,zi=[],mt,I1={useRecords:!1,mapsAsObjects:!0},sS=class{},nS=new sS;nS.name="MessagePack 0xC1";var Yo=!1,Vd=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Ae)return dS(()=>(bm(),this?this.unpack(e,t):Vd.prototype.unpack.call(I1,e,t)));zn=t>-1?t:e.length,Z=0,xm=0,vs=0,Ln=null,ym=rS,$i=null,Ae=e;try{mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ae=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Vd){if(ji=this,this.structures)return pt=this.structures,Bc();(!pt||pt.length>0)&&(pt=[])}else ji=I1,(!pt||pt.length>0)&&(pt=[]);return Bc()}unpackMultiple(e,t){let i,r=0;try{Yo=!0;let s=e.length,n=this?this.unpack(e,s):Ru.unpack(e,s);if(t){for(t(n);Z<s;)if(r=Z,t(Bc())===!1)return}else{for(i=[n];Z<s;)r=Z,i.push(Bc());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Yo=!1,bm()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Bc(){try{if(!ji.trusted&&!Yo){let t=pt.sharedLength||0;t<pt.length&&(pt.length=t)}let e=zt();if(Z==zn)pt.restoreStructures&&R1(),pt=null,Ae=null,Js&&(Js=null);else if(Z>zn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Yo)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw pt.restoreStructures&&R1(),bm(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function R1(){for(let e in pt.restoreStructures)pt[e]=pt.restoreStructures[e];pt.restoreStructures=null}function zt(){let e=Ae[Z++];if(e<160)if(e<128){if(e<64)return e;{let t=pt[e&63]||ji.getStructures&&aS()[e&63];return t?(t.read||(t.read=av(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,ji.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[lS()]=zt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(zt(),zt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=zt();return t}else if(e<192){let t=e-160;if(vs>=Z)return Ln.slice(Z-xr,(Z+=t)-xr);if(vs==0&&zn<140){let i=t<16?ov(t):oS(t);if(i!=null)return i}return wm(t)}else{let t;switch(e){case 192:return null;case 193:return $i?(t=zt(),t>0?$i[1].slice($i.position1,$i.position1+=t):$i[0].slice($i.position0,$i.position0-=t)):nS;case 194:return!1;case 195:return!0;case 196:return Xp(Ae[Z++]);case 197:return t=mt.getUint16(Z),Z+=2,Xp(t);case 198:return t=mt.getUint32(Z),Z+=4,Xp(t);case 199:return ta(Ae[Z++]);case 200:return t=mt.getUint16(Z),Z+=2,ta(t);case 201:return t=mt.getUint32(Z),Z+=4,ta(t);case 202:if(t=mt.getFloat32(Z),ji.useFloat32>2){let i=lv[(Ae[Z]&127)<<1|Ae[Z+1]>>7];return Z+=4,(i*t+(t>0?.5:-.5)>>0)/i}return Z+=4,t;case 203:return t=mt.getFloat64(Z),Z+=8,t;case 204:return Ae[Z++];case 205:return t=mt.getUint16(Z),Z+=2,t;case 206:return t=mt.getUint32(Z),Z+=4,t;case 207:return ji.int64AsNumber?(t=mt.getUint32(Z)*4294967296,t+=mt.getUint32(Z+4)):t=mt.getBigUint64(Z),Z+=8,t;case 208:return mt.getInt8(Z++);case 209:return t=mt.getInt16(Z),Z+=2,t;case 210:return t=mt.getInt32(Z),Z+=4,t;case 211:return ji.int64AsNumber?(t=mt.getInt32(Z)*4294967296,t+=mt.getUint32(Z+4)):t=mt.getBigInt64(Z),Z+=8,t;case 212:if(t=Ae[Z++],t==114)return U1(Ae[Z++]&63);{let i=zi[t];if(i)return i.read?(Z++,i.read(zt())):i.noBuffer?(Z++,i()):i(Ae.subarray(Z,++Z));throw new Error("Unknown extension "+t)}case 213:return t=Ae[Z],t==114?(Z++,U1(Ae[Z++]&63,Ae[Z++])):ta(2);case 214:return ta(4);case 215:return ta(8);case 216:return ta(16);case 217:return t=Ae[Z++],vs>=Z?Ln.slice(Z-xr,(Z+=t)-xr):gF(t);case 218:return t=mt.getUint16(Z),Z+=2,vs>=Z?Ln.slice(Z-xr,(Z+=t)-xr):vF(t);case 219:return t=mt.getUint32(Z),Z+=4,vs>=Z?Ln.slice(Z-xr,(Z+=t)-xr):yF(t);case 220:return t=mt.getUint16(Z),Z+=2,N1(t);case 221:return t=mt.getUint32(Z),Z+=4,N1(t);case 222:return t=mt.getUint16(Z),Z+=2,z1(t);case 223:return t=mt.getUint32(Z),Z+=4,z1(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var mF=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function av(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>mF.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(zt);return e.highByte===0&&(e.read=B1(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=zt()}return r}return i.count=0,e.highByte===0?B1(t,i):i}var B1=(e,t)=>function(){let i=Ae[Z++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=pt[r]||aS()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=av(s,e)),s.read()};function aS(){let e=dS(()=>(Ae=null,ji.getStructures()));return pt=ji._mergeStructures(e,pt)}var wm=Iu,gF=Iu,vF=Iu,yF=Iu;function Iu(e){let t;if(e<16&&(t=ov(e)))return t;if(e>64&&vm)return vm.decode(Ae.subarray(Z,Z+=e));let i=Z+e,r=[];for(t="";Z<i;){let s=Ae[Z++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Ae[Z++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Ae[Z++]&63,a=Ae[Z++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Ae[Z++]&63,a=Ae[Z++]&63,o=Ae[Z++]&63,l=(s&7)<<18|n<<12|a<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=di.apply(String,r),r.length=0)}return r.length>0&&(t+=di.apply(String,r)),t}function N1(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=zt();return t}function z1(e){if(ji.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[lS()]=zt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(zt(),zt());return t}}var di=String.fromCharCode;function oS(e){let t=Z,i=new Array(e);for(let r=0;r<e;r++){let s=Ae[Z++];if((s&128)>0){Z=t;return}i[r]=s}return di.apply(String,i)}function ov(e){if(e<4)if(e<2){if(e===0)return"";{let t=Ae[Z++];if((t&128)>1){Z-=1;return}return di(t)}}else{let t=Ae[Z++],i=Ae[Z++];if((t&128)>0||(i&128)>0){Z-=2;return}if(e<3)return di(t,i);let r=Ae[Z++];if((r&128)>0){Z-=3;return}return di(t,i,r)}else{let t=Ae[Z++],i=Ae[Z++],r=Ae[Z++],s=Ae[Z++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){Z-=4;return}if(e<6){if(e===4)return di(t,i,r,s);{let n=Ae[Z++];if((n&128)>0){Z-=5;return}return di(t,i,r,s,n)}}else if(e<8){let n=Ae[Z++],a=Ae[Z++];if((n&128)>0||(a&128)>0){Z-=6;return}if(e<7)return di(t,i,r,s,n,a);let o=Ae[Z++];if((o&128)>0){Z-=7;return}return di(t,i,r,s,n,a,o)}else{let n=Ae[Z++],a=Ae[Z++],o=Ae[Z++],l=Ae[Z++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){Z-=8;return}if(e<10){if(e===8)return di(t,i,r,s,n,a,o,l);{let h=Ae[Z++];if((h&128)>0){Z-=9;return}return di(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Ae[Z++],u=Ae[Z++];if((h&128)>0||(u&128)>0){Z-=10;return}if(e<11)return di(t,i,r,s,n,a,o,l,h,u);let c=Ae[Z++];if((c&128)>0){Z-=11;return}return di(t,i,r,s,n,a,o,l,h,u,c)}else{let h=Ae[Z++],u=Ae[Z++],c=Ae[Z++],d=Ae[Z++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){Z-=12;return}if(e<14){if(e===12)return di(t,i,r,s,n,a,o,l,h,u,c,d);{let p=Ae[Z++];if((p&128)>0){Z-=13;return}return di(t,i,r,s,n,a,o,l,h,u,c,d,p)}}else{let p=Ae[Z++],f=Ae[Z++];if((p&128)>0||(f&128)>0){Z-=14;return}if(e<15)return di(t,i,r,s,n,a,o,l,h,u,c,d,p,f);let g=Ae[Z++];if((g&128)>0){Z-=15;return}return di(t,i,r,s,n,a,o,l,h,u,c,d,p,f,g)}}}}}function Xp(e){return ji.copyBuffers?Uint8Array.prototype.slice.call(Ae,Z,Z+=e):Ae.subarray(Z,Z+=e)}function ta(e){let t=Ae[Z++];if(zi[t])return zi[t](Ae.subarray(Z,Z+=e));throw new Error("Unknown extension type "+t)}var F1=new Array(4096);function lS(){let e=Ae[Z++];if(e>=160&&e<192){if(e=e-160,vs>=Z)return Ln.slice(Z-xr,(Z+=e)-xr);if(!(vs==0&&zn<180))return wm(e)}else return Z--,zt();let t=(e<<5^(e>1?mt.getUint16(Z):e>0?Ae[Z]:0))&4095,i=F1[t],r=Z,s=Z+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=mt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Ae[r++],n!=i[a++]){r=1879048192;break}if(r===s)return Z=r,i.string;s-=3,r=Z}for(i=[],F1[t]=i,i.bytes=e;r<s;)n=mt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Ae[r++],i.push(n);let o=e<16?ov(e):oS(e);return o!=null?i.string=o:i.string=wm(e)}var U1=(e,t)=>{var i=zt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=pt[e];return s&&s.isShared&&((pt.restoreStructures||(pt.restoreStructures=[]))[e]=s),pt[e]=i,i.read=av(i,r),i.read()},hS=typeof self=="object"?self:global;zi[0]=()=>{};zi[0].noBuffer=!0;zi[101]=()=>{let e=zt();return(hS[e[0]]||Error)(e[1])};zi[105]=e=>{let t=mt.getUint32(Z-4);Js||(Js=new Map);let i=Ae[Z],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Js.set(t,s);let n=zt();return s.used?Object.assign(r,n):(s.target=n,n)};zi[112]=e=>{let t=mt.getUint32(Z-4),i=Js.get(t);return i.used=!0,i.target};zi[115]=()=>new Set(zt());var cS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");zi[116]=e=>{let t=e[0],i=cS[t];if(!i)throw new Error("Could not find typed array for code "+t);return new hS[i](Uint8Array.prototype.slice.call(e,1).buffer)};zi[120]=()=>{let e=zt();return new RegExp(e[0],e[1])};zi[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Z;Z+=t-4,$i=[zt(),zt()],$i.position0=0,$i.position1=0;let r=Z;Z=i;try{return zt()}finally{Z=r}};zi[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function dS(e){let t=zn,i=Z,r=xm,s=xr,n=vs,a=Ln,o=ym,l=Js,h=$i,u=new Uint8Array(Ae.slice(0,zn)),c=pt,d=pt.slice(0,pt.length),p=ji,f=Yo,g=e();return zn=t,Z=i,xm=r,xr=s,vs=n,Ln=a,ym=o,Js=l,$i=h,Ae=u,Yo=f,pt=c,pt.splice(0,pt.length,...d),ji=p,mt=new DataView(Ae.buffer,Ae.byteOffset,Ae.byteLength),g}function bm(){Ae=null,Js=null,pt=null}function xF(e){e.unpack?zi[e.type]=e.unpack:zi[e.type]=e}var lv=new Array(147);for(let e=0;e<256;e++)lv[e]=+("1e"+Math.floor(45.15-e*.30103));var Ru=new Vd({useRecords:!1}),n7=Ru.unpack,a7=Ru.unpackMultiple,o7=Ru.unpack,wF={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},bF=new Float32Array(1),l7=new Uint8Array(bF.buffer,0,4),md;try{md=new TextEncoder}catch{}var Hd,hv,Bu=typeof Buffer<"u",Yp=Bu?Buffer.allocUnsafeSlow:Uint8Array,uS=Bu?Buffer:Uint8Array,k1=Bu?4294967296:2144337920,le,Gt,te=0,ts,is=null,_F=/[\u0080-\uFFFF]/,Dl=Symbol("record-id"),pS=class extends Vd{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=uS.prototype.utf8Write?function(A,b,M){return le.utf8Write(A,b,M)}:md&&md.encodeInto?function(A,b){return md.encodeInto(A,le.subarray(b)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),u&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,g=d+64,m=d+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(A,b){if(le||(le=new Yp(8192),Gt=new DataView(le.buffer,0,8192),te=0),ts=le.length-10,ts-te<2048?(le=new Yp(le.length),Gt=new DataView(le.buffer,0,le.length),ts=le.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(is=["",""],le[te++]=214,le[te++]=98,is.position=te-i,te+=4):is=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let M=r.sharedLength||0;if(M>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let T=r[C];if(!T)continue;let D,L=r.transitions;for(let P=0,N=T.length;P<N;P++){let W=T[P];D=L[W],D||(D=L[W]=Object.create(null)),L=D}L[Dl]=C+64}o=M}u||(r.nextId=M+64)}s&&(s=!1),n=r||[];try{if(w(A),is){Gt.setUint32(is.position+i,te-is.position-i);let M=is;is=null,w(M[0]),w(M[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>ts&&S(te),h.offset=te;let M=AF(le.subarray(i,te),a.idsToInsert);return a=null,M}return b&MF?(le.start=i,le.end=te,le):le.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let M=0,C=v.length;M<C;M++)v[M][Dl]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||d;r.length>M&&(r=r.slice(0,M));let C=le.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(A)):(o=M,C)}}b&EF&&(te=i)}};let w=A=>{te>ts&&(le=S(te));var b=typeof A,M;if(b==="string"){let C=A.length;if(is&&C>=8&&C<4096){let L=_F.test(A);is[L?0:1]+=A,le[te++]=193,w(L?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>ts&&(le=S(te+D)),C<64||!l){let L,P,N,W=te+T;for(L=0;L<C;L++)P=A.charCodeAt(L),P<128?le[W++]=P:P<2048?(le[W++]=P>>6|192,le[W++]=P&63|128):(P&64512)===55296&&((N=A.charCodeAt(L+1))&64512)===56320?(P=65536+((P&1023)<<10)+(N&1023),L++,le[W++]=P>>18|240,le[W++]=P>>12&63|128,le[W++]=P>>6&63|128,le[W++]=P&63|128):(le[W++]=P>>12|224,le[W++]=P>>6&63|128,le[W++]=P&63|128);M=W-te-T}else M=l(A,te+T,D);M<32?le[te++]=160|M:M<256?(T<2&&le.copyWithin(te+2,te+1,te+1+M),le[te++]=217,le[te++]=M):M<65536?(T<3&&le.copyWithin(te+3,te+2,te+2+M),le[te++]=218,le[te++]=M>>8,le[te++]=M&255):(T<5&&le.copyWithin(te+5,te+3,te+3+M),le[te++]=219,Gt.setUint32(te,M),te+=4),te+=M}else if(b==="number")if(A>>>0===A)A<64?le[te++]=A:A<256?(le[te++]=204,le[te++]=A):A<65536?(le[te++]=205,le[te++]=A>>8,le[te++]=A&255):(le[te++]=206,Gt.setUint32(te,A),te+=4);else if(A>>0===A)A>=-32?le[te++]=256+A:A>=-128?(le[te++]=208,le[te++]=A+256):A>=-32768?(le[te++]=209,Gt.setInt16(te,A),te+=2):(le[te++]=210,Gt.setInt32(te,A),te+=4);else{let C;if((C=this.useFloat32)>0&&A<4294967296&&A>=-2147483648){le[te++]=202,Gt.setFloat32(te,A);let T;if(C<4||(T=A*lv[(le[te]&127)<<1|le[te+1]>>7])>>0===T){te+=4;return}else te--}le[te++]=203,Gt.setFloat64(te,A),te+=8}else if(b==="object")if(!A)le[te++]=192;else{if(a){let T=a.get(A);if(T){if(!T.id){let D=a.idsToInsert||(a.idsToInsert=[]);T.id=D.push(T)}le[te++]=214,le[te++]=112,Gt.setUint32(te,T.id),te+=4;return}else a.set(A,{offset:te-i})}let C=A.constructor;if(C===Object)_(A,!0);else if(C===Array){M=A.length,M<16?le[te++]=144|M:M<65536?(le[te++]=220,le[te++]=M>>8,le[te++]=M&255):(le[te++]=221,Gt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)w(A[T])}else if(C===Map){M=A.size,M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,Gt.setUint32(te,M),te+=4);for(let[T,D]of A)w(T),w(D)}else{for(let T=0,D=Hd.length;T<D;T++){let L=hv[T];if(A instanceof L){let P=Hd[T];if(P.write){P.type&&(le[te++]=212,le[te++]=P.type,le[te++]=0),w(P.write.call(this,A));return}let N=le,W=Gt,q=te;le=null;let z;try{z=P.pack.call(this,A,j=>(le=N,N=null,te+=j,te>ts&&S(te),{target:le,targetView:Gt,position:te-j}),w)}finally{N&&(le=N,Gt=W,te=q,ts=le.length-10)}z&&(z.length+te>ts&&S(z.length+te),te=SF(z,le,te,P.type));return}}_(A,!A.hasOwnProperty)}}else if(b==="boolean")le[te++]=A?195:194;else if(b==="bigint"){if(A<BigInt(1)<<BigInt(63)&&A>=-(BigInt(1)<<BigInt(63)))le[te++]=211,Gt.setBigInt64(te,A);else if(A<BigInt(1)<<BigInt(64)&&A>0)le[te++]=207,Gt.setBigUint64(te,A);else if(this.largeBigIntToFloat)le[te++]=203,Gt.setFloat64(te,Number(A));else throw new RangeError(A+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(b==="undefined")this.encodeUndefinedAsNil?le[te++]=192:(le[te++]=212,le[te++]=0,le[te++]=0);else if(b==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+b)},_=this.useRecords===!1?this.variableMapSize?A=>{let b=Object.keys(A),M=b.length;M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,Gt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)w(C=b[T]),w(A[C])}:(A,b)=>{le[te++]=222;let M=te-i;te+=2;let C=0;for(let T in A)(b||A.hasOwnProperty(T))&&(w(T),w(A[T]),C++);le[M+++i]=C>>8,le[M+i]=C&255}:A=>{let b=Object.keys(A),M,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let L=0,P=b.length;L<P;L++){let N=b[L];M=C[N],M||(M=C[N]=Object.create(null),T++),C=M}let D=C[Dl];if(D)D>=96&&f?(le[te++]=((D-=96)&31)+96,le[te++]=D>>5):le[te++]=D;else{D=n.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(b)?(D=n.nextOwnId,D<m||(D=g),n.nextOwnId=D+1):(D>=m&&(D=g),n.nextId=D+1);let L=b.highByte=D>=96&&f?D-96>>5:-1;C[Dl]=D,n[D-64]=b,D<g?(b.isShared=!0,n.sharedLength=D-63,s=!0,L>=0?(le[te++]=(D&31)+96,le[te++]=L):le[te++]=D):(L>=0?(le[te++]=213,le[te++]=114,le[te++]=(D&31)+96,le[te++]=L):(le[te++]=212,le[te++]=114,le[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[Dl]=0),v.push(C),w(b))}for(let L=0,P=b.length;L<P;L++)w(A[b[L]])},S=A=>{let b;if(A>16777216){if(A-i>k1)throw new Error("Packed buffer would be larger than maximum buffer size");b=Math.min(k1,Math.round(Math.max((A-i)*(A>67108864?1.25:2),4194304)/4096)*4096)}else b=(Math.max(A-i<<2,le.length-1)>>12)+1<<12;let M=new Yp(b);return Gt=new DataView(M.buffer,0,b),le.copy?le.copy(M,0,i,A):M.set(le.slice(i,A)),te-=i,i=0,ts=M.length-10,le=M}}useBuffer(e){le=e,Gt=new DataView(le.buffer,le.byteOffset,le.byteLength),te=0}};hv=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,sS];Hd=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:n,position:a}=t(6);s[a++]=214,s[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:s,targetView:n,position:a}=t(10);s[a++]=215,s[a++]=255,n.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:n,position:a}=t(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:n,position:a}=t(15);s[a++]=199,s[a++]=12,s[a++]=255,n.setUint32(a,e.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(s[n++]=212,s[n++]=115,s[n++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?j1(e,16,t):G1(Bu?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==uS&&this.structuredClone?j1(e,cS.indexOf(i.name),t):G1(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function j1(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:n,position:a}=i(4+s);n[a++]=199,n[a++]=s+1}else if(s+1<65536){var{target:n,position:a}=i(5+s);n[a++]=200,n[a++]=s+1>>8,n[a++]=s+1&255}else{var{target:n,position:a,targetView:o}=i(7+s);n[a++]=201,o.setUint32(a,s+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function G1(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:n}=t(i+5);r[s++]=198,n.setUint32(s,i),s+=4}r.set(e,s)}function SF(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function AF(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);i=t.pop();){let n=i.offset,a=i.id;e.copyWithin(n+r,n,s),r-=6;let o=n+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,s=n}return e}function cl(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");hv.unshift(e.Class),Hd.unshift(e)}xF(e)}var fS=new pS({useRecords:!1}),h7=fS.pack,c7=fS.pack,{NEVER:d7,ALWAYS:u7,DECIMAL_ROUND:p7,DECIMAL_FIT:f7}=wF,MF=512,EF=1024,V1=new pS({structuredClone:!0});cl({Class:Kt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Kt.prototype),e}});cl({Class:et.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,et.prototype),e}});cl({Class:Wi.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Wi.prototype),e}});cl({Class:L1.prototype.constructor,type:4,write(e){return e.id},read(e){return new L1(e)}});cl({Class:O1.prototype.constructor,type:5,write(e){return e.data},read(e){return new O1(e)}});cl({Class:wi.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,wi.prototype),e}});function CF(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function _m(e){if(tv(e))return e;if(Array.isArray(e))return e.map(_m);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=_m(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Sm;(e=>{function t(s){return V1.pack(s)}e.serialize=t;function i(s){return V1.unpack(s)}e.deserialize=i;function r(s){return CF(t(_m(s))).toString()}e.checksum=r})(Sm||(Sm={}));var pn={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"]},H1;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,toggle:!1,actions:new et}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new et}}e.defaultData=i})(H1||(H1={}));var Wd;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Wd||(Wd={}));var Am;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Wd.propertyDefaultData(s),rOperand:{...Wd.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,n){return{type:"State",object:s??null,state:n??null}}e.stateDefaultData=r})(Am||(Am={}));var W1;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new et,outActions:new et,condition:Am.distanceDefaultData(r)}}e.defaultData=i})(W1||(W1={}));var q1;(e=>e.defaultData={type:"DragDrop",cursor:"hand",render:"normal",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 et,drop:new et}})(q1||(q1={}));var Mm;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new et})(Mm||(Mm={}));var Em;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Em||(Em={}));var X1;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new et}}e.defaultData=i})(X1||(X1={}));var Y1;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new et}}e.defaultData=i})(Y1||(Y1={}));var Q1;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new et}}e.defaultData=i})(Q1||(Q1={}));var Z1;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new et}}e.defaultData=i})(Z1||(Z1={}));var Eo;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n]}e.lerp=i})(Eo||(Eo={}));var Aa;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function n(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=n;function a(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=a;function o(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]}e.lerp=o})(Aa||(Aa={}));var qd;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]}e.lerp=i})(qd||(qd={}));var Qo;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,n){for(let a=0;a<16;a++)if(s[a]!==n[a])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,n){let a=n.slice(0);for(var o=0,l=n.length;o<l;o+=3){let h=s[3]*n[o]+s[7]*n[o+1]+s[11]*n[o+2]+s[15];a[o]=(s[0]*n[o]+s[4]*n[o+1]+s[8]*n[o+2]+s[12])/h,a[o+1]=(s[1]*n[o]+s[5]*n[o+1]+s[9]*n[o+2]+s[13])/h,a[o+2]=(s[2]*n[o]+s[6]*n[o+1]+s[10]*n[o+2]+s[14])/h}return a}e.applyMatrix4=r})(Qo||(Qo={}));var rr;(e=>{function t(o){return typeof o=="object"&&typeof o.r=="number"&&typeof o.g=="number"&&typeof o.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(o){return{r:Math.round(o.r*255),g:Math.round(o.g*255),b:Math.round(o.b*255),a:1}}e.toRgb255a1=i;function r(o){return{r:o.r,g:o.g,b:o.b}}e.clone=r;function s(o){return o=Math.floor(o),{r:(o>>16&255)/255,g:(o>>8&255)/255,b:(o&255)/255}}e.fromHex=s;function n(o,l){return o.r===l.r&&o.g===l.g&&o.b===l.b}e.equals=n;function a(o,l,h){return{r:o.r+(l.r-o.r)*h,g:o.g+(l.g-o.g)*h,b:o.b+(l.b-o.b)*h}}e.lerp=a})(rr||(rr={}));var Wr;(e=>{e.white={...rr.white,a:1},e.transparent={...rr.white,a:0};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}e.from0to1=t;function i(a,o){return{...rr.fromHex(a),a:o}}e.fromHexAndA=i;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}e.toRgb255a1=r;function s(a,o){return rr.equals(a,o)&&a.a===o.a}e.equals=s;function n(a,o,l){return{r:a.r+(o.r-a.r)*l,g:a.g+(o.g-a.g)*l,b:a.b+(o.b-a.b)*l,a:a.a+(o.a-a.a)*l}}e.lerp=n})(Wr||(Wr={}));var Cm;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Cm||(Cm={}));var K1;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(K1||(K1={}));var J1;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(J1||(J1={}));var La;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(La||(La={}));var Lh;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Lh||(Lh={}));var On;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(n=>n*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let n={...r};if(mS.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;gS.forEach(l=>{Object.assign(n.radial,{[l]:o[l]??a[l]})})}if(n.linear={...r.linear},s.linear){let a=r.linear,o=s.linear;vS.forEach(l=>{Object.assign(n.linear,{[l]:o[l]??a[l]})})}if(n.grid={...r.grid},s.grid){let a=r.grid,o=s.grid;yS.forEach(l=>{Object.assign(n.grid,{[l]:o[l]??a[l]})})}if(n.toObject={...r.toObject},s.toObject){let a=r.toObject,o=s.toObject;xS.forEach(l=>{Object.assign(n.toObject,{[l]:o[l]??a[l]})})}if(n.randomnessObject={...r.randomnessObject},s.randomnessObject){let a=r.randomnessObject,o=s.randomnessObject;wS.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(On||(On={}));var Tm;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of t){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}e.toOps=i})(Tm||(Tm={}));var mS=["count"],gS=["radius","start","end","position","scale","rotation"],vS=["position","scale","rotation"],yS=["count","size"],xS=["count","position","scale","rotation"],wS=["strength","scale","rotation","position","movement","seed","freqScale"],Oh;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(Oh||(Oh={}));var Pm;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Pm||(Pm={}));var Dm;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Wr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(r==="SpotLight")return{type:r,color:Wr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Wr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Dm||(Dm={}));var Lm;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Lm||(Lm={}));var Om;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Om||(Om={}));var Im;(e=>e.defaultData={...Om.defaultData,...Lm.defaultData})(Im||(Im={}));var Xd;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Xd||(Xd={}));var $1;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="light"}e.is=t})($1||($1={}));var ex;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(ex||(ex={}));var bS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],TF=["wrapping","image","video"],br;(e=>{function t(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let h=n.texture;h&&Object.assign(h,o)}}e.patch=t;function i(n,a){return n==="light"&&a?r(a):s(n)}e.defaultData=i;function r(n){switch(n){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function s(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:Xd.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:rr.fromHex(5526619)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...rr.fromHex(6710886),a:1},colorB:{...rr.fromHex(6710886),a:1},colorC:{...rr.fromHex(16777215),a:1},colorD:{...rr.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:Wr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,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:Wr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:Wr.fromHexAndA(0,1),contourColor:Wr.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{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(br||(br={}));var hr;(e=>{function t(h){return!h.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(h){let u="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([d,p])=>{u+=`${d}${p}`,Array.isArray(p)?p.forEach(f=>u+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?u+=`${f.toFixed(4)}`:u+=`${f}`}):u+=`${p}`})}),u}e.getHash=i;function r(){return{layers:new et}}e.defaultEmptyData=r;function s(h="layer1",u="layer2"){return a("phong",h,u)}e.defaultData=s;function n(h,u){return{...h,name:u}}e.withName=n;function a(h,u="layer1",c="layer2"){let d=new et;return d.push({fi:0,data:br.defaultData("light",h),id:u}),d.push({fi:1,data:br.defaultData("color"),id:c}),{layers:d}}e.defaultTwoLayerData=a;function o(h,u="phong",c="layer1",d="layer2"){let p=br.defaultData("texture");Object.assign(p.texture,{image:h});let f=new et;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:br.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,u="phong",c="layer1",d="layer2"){let p=br.defaultData("video");Object.assign(p.texture,{video:h});let f=new et;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:br.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(hr||(hr={}));var Yd;(e=>{function t(){return{points:new et,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Yd||(Yd={}));var Qd;(e=>{function t(){return{points:new et,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Qd||(Qd={}));var _S={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0},Rm;(e=>{function t(i,r){let s={...i};return AS.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(Rm||(Rm={}));var SS={shape:_S,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},AS=["depth","offset","angle","twist","startScale","endScale"],Zd;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(Zd||(Zd={}));var Bm;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,Rm.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Bm||(Bm={}));var Io;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Qd.defaultData(),extrusion:SS};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Yd.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}e.defaultData=t})(Io||(Io={}));var tx=["width","height","depth"],ix;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(ix||(ix={}));var Zo;(e=>{e.identity={...Cm.identity,hiddenMatrix:Qo.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,n){return{position:n?.position||s.position,rotation:n?.rotation||s.rotation,scale:n?.scale||s.scale,hiddenMatrix:n?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,n){return{position:Aa.isEqual(s.position,n.position)?null:n.position,rotation:Aa.isEqual(s.rotation,n.rotation)?null:n.rotation,scale:Aa.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:Qo.isEqual(s.hiddenMatrix,n.hiddenMatrix)?null:n.hiddenMatrix}}e.diff=r})(Zo||(Zo={}));var rx;(e=>e.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(rx||(rx={}));var Mr;(e=>e.defaultData={states:new et,events:new et,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Zo.identity,cloner:null})(Mr||(Mr={}));var sx;(e=>e.defaultData={type:"Empty",...Mr.defaultData})(sx||(sx={}));var nx;(e=>e.defaultData={type:"Component",...Mr.defaultData})(nx||(nx={}));var Ro;(e=>e.defaultData={type:"Mesh",...Mr.defaultData,...Im.defaultData})(Ro||(Ro={}));var Kd;(e=>e.defaultData={...Mr.defaultData,...Zo.identity,...Lh.defaultData})(Kd||(Kd={}));var Nm;(e=>{function t(i){return{...Mr.defaultData,...Dm.defaultData(i)}}e.defaultData=t})(Nm||(Nm={}));var Jd;(e=>{function t(r,s,n=0){for(;n<s.length;){let a=r?r[s[n]]:void 0;if(s.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=t;function i(r,s,n=0){let a=t(r,s,n);if(a){let o=Object.keys(a);if(o.length===1&&o[0]==="descendants")return}return a}e.resolve=i})(Jd||(Jd={}));var Ko;(e=>{e.rootOverrideProps=["physics"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Mr.defaultData,...s,component:r,overrides:new wi,physics:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Zo.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Ko||(Ko={}));var zm;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Qo.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new et,events:new et,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Lh.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Mr.defaultData,...Ro.defaultData,geometry:Io.defaultData("RectangleGeometry"),material:hr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Mr.defaultData,...Ro.defaultData,geometry:Io.defaultData("BooleanGeometry"),material:hr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Mr.defaultData,...Ro.defaultData,geometry:Io.defaultData("TextGeometry"),material:hr.defaultTwoLayerData("phong","layer1","layer2")}))(zm||(zm={}));var ma;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new wi}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new wi})))):La.is(n.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(n,a){if(a===void 0)return n;let o={...n};return"material"in o&&"material"in a&&a.material&&(o.material=Gd(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&br.patch(c,u)}}).data),o.materials&&a.materials&&(o.materials=Gd(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=a.materials[h];if(typeof u!="string")for(let[c,d]of Object.entries(u.layers)){let p=l[h]?.layers?.data(c);p&&br.patch(p,d)}}}).data),o}function r(n,a){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function u(c,d){for(let[p,f]of Object.entries(d.layers)){let{texture:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let v={path:[...c,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,d]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...Tm.toOps(d,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:d.slide,offset:d.offset},type:0});else if(c==="material")u(["material"],d);else if(c==="materials")for(let[p,f]of Object.entries(d))u(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&d.extrusion!==void 0){let p={path:[c,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[c],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=d;return l}e.toOps=r;function s(n,a){if(a===void 0)return n;let o={...n};if(Object.assign(o,Zo.merge(o,a)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:a.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??o.pathSnapping?.offset??0})}),La.is(n.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=a;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(o,{geometry:Bm.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:On.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:On.merge(o.cloner,a.cloner)});else if(Pm.is(n.type)){let l=a;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=rr.clone(l.color))}return o}e.patch=s})(ma||(ma={}));var $d;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:rr.white,near:.1,far:2e3})($d||($d={}));var eu;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(eu||(eu={}));var Jo;(e=>e.defaultData={orbitControls:eu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),gameControlObject:null})(Jo||(Jo={}));function Oa(e,t){return Object.setPrototypeOf(e,t),e}var PF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),DF=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),LF=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Nu&&"ontouchend"in document,OF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,IF=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,RF=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},BF=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},m7=PF(),Nu=DF(),MS=LF(),NF=OF(),or=IF(),ax=RF(),ox=Number(BF());function ES(e){return Array.isArray(e)?e:[e]}function zF(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Nc(e){return Nu?e.metaKey:e.ctrlKey}var Ve=[],tu={},Jl={},gd={};function CS(e){Ve.includes(e)||Ve.push(e)}function Bo(e){delete tu[e.pointerId];for(let t=0;t<Ve.length;t++)if(Ve[t].pointerId===e.pointerId){Ve.splice(t,1);break}}function FF(){Ve.splice(0,Ve.length)}function iu(e){if(e.pointerType!=="touch")return;let t=tu[e.pointerId];t===void 0&&(t={x:0,y:0},tu[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Qp(e){let t=e.pointerId===Ve[0].pointerId?Ve[1]:Ve[0];return tu[t.pointerId]}function TS(e){Jl[e.key]=!0,gd[e.key]=gd[e.key]===void 0?1:gd[e.key]+1}function PS(e){if(Nu&&Jl.Meta)for(let t in Jl)Jl[t]=!1;else Jl[e.key]=!1;gd={}}function UF(e){e.addEventListener("pointerdown",CS,!0),e.addEventListener("pointerdown",iu,!0),e.addEventListener("pointermove",iu,!0),e.addEventListener("pointerup",Bo,!0),e.addEventListener("pointercancel",Bo,!0),e.addEventListener("pointerleave",Bo,!0),window.addEventListener("keydown",TS,!0),window.addEventListener("keyup",PS,!0)}function kF(e){e.removeEventListener("pointerdown",CS,!0),e.removeEventListener("pointerdown",iu,!0),e.removeEventListener("pointermove",iu,!0),e.removeEventListener("pointerup",Bo,!0),e.removeEventListener("pointercancel",Bo,!0),e.removeEventListener("pointerleave",Bo,!0),window.removeEventListener("keydown",TS,!0),window.removeEventListener("keyup",PS,!0)}var tr;(e=>e.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(tr||(tr={}));var Fm;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=new Wi,a=zm.defaultMeshObject;return s.withLight===!0&&n.push({fi:-1,data:{...Nm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]}),n}e.defaultData={backgroundColor:Wr.fromHexAndA(2960946,1),postprocessing:Oh.defaultData,fog:$d.defaultData,objects:t(),environment:tr.defaultData,publish:Jo.defaultData},e.emptyData=function(s){return{backgroundColor:Wr.fromHexAndA(2960946,1),postprocessing:Oh.defaultData,fog:$d.defaultData,objects:s?t(s):new Wi,environment:tr.defaultData,publish:Jo.defaultData}};function i(s){return{...e.defaultData,objects:Oa(s,Wi.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(Fm||(Fm={}));var ru;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(ru||(ru={}));var su;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Oa(s,Kt.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...ru.emptyImage,name:"AI generated image"}),Oa(n,Kt.prototype)}e.defaultImages=i;function r(){return{materials:new Kt,images:new Kt,videos:new Kt,colors:new Kt,audios:new Kt,fonts:new Kt,penumbraSize:[2,2,2]}}e.emptyData=r})(su||(su={}));function lx(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...Th(Ci(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Ci(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function vd(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function yd(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach(s=>{typeof s!="string"&&t(s)}):"material"in r&&typeof r.material!="string"&&t(r.material)})}function jF(e){Object.assign(e.scene.publish,{orbitControls:{...eu.defaultData,...Ci(e.scene.publish.orbitControls)}})}function GF(e){Object.assign(e.scene.publish.settings,{video:{...Jo.defaultData.settings.video,...Ci(e.scene.publish.settings.video)}})}function VF(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,n]of Object.entries(r))if((bS.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(TF.includes(a)||typeof o=="boolean")&&delete n[a]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let n=s;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function HF(e){e.scene.publish.withBackground=!0}function WF(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function qF(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function XF(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function YF(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=Ci(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Ci(i).booleanExclude!==!0)}})}function QF(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function ZF(e){function t(r){Object.setPrototypeOf(r,wi.prototype),r.texture&&Object.setPrototypeOf(r.texture,wi.prototype)}function i(r){Object.setPrototypeOf(r,wi.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(n=>{let a=n;if(a.material){let o=Ci(a.material).layers;i(o),a.material.layers=o}if(a.materials)for(let o=0;o<a.materials.length;o++){let l=a.materials[o],h=Ci(l).layers;i(h),l.layers=h}})})}function hx(e){e.layers===void 0&&Object.assign(e,hr.defaultTwoLayerData("lambert"))}function Zp(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...Ci(t),colors:i,steps:r};Object.assign(t,s)}})}function KF(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function cx(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Zp(r)}):"material"in i&&typeof i.material!="string"&&Zp(i.material)}),Object.values(e.shared.materials).forEach(t=>Zp(t))}function JF(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function $F(e){e.shared.audios=Oa({},Kt.prototype)}function eU(e){e.shared.videos=Oa({},Kt.prototype)}function tU(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function iU(e){Object.entries(Ci(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Ci(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function rU(e){e.scene.publish.settings.web.preload=!1}function dx(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function sU(e){e.shared.fonts=Oa({},Kt.prototype)}function nU(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function aU(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=hr.defaultTwoLayerData("phong"),a=typeof s.color=="string"?e.shared.colors[s.color]:s.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=s.alpha;let o=nU(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Mr.defaultData,...Ro.defaultData,flatShading:!1,wireframe:!1,geometry:{...Io.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:Ci(s.states),events:Ci(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Ci(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function oU(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new et,move:new et,jump:new et}});else{let n=new et;Object.assign(s,{actions:n}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&n.push({fi:0,id:it.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((a,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,Th(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let c={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...c,...u},p={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new et({fi:0,id:it.generateUUID(),data:h},{fi:1,id:it.generateUUID(),data:d})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function lU(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new et,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...Th(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...Th(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&a.push({fi:u,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),a.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):i.events.insertBefore(null,[{id:it.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function ux(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=br.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function px(e){vd(e,ux),yd(e,ux)}function hU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function cU(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function dU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=hr.defaultTwoLayerData("phong"))})}function uU(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function pU(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function fU(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function mU(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function gU(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function vU(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}var fx=37;function yU(e){let t=e.schema??0;t!==fx&&(console.warn("updating from ",t,"to ",fx),t<1&&(yd(e,lx),vd(e,lx),e.schema=1),t<2&&(jF(e),e.schema=2),t<3&&(VF(e),e.schema=3),t<4&&(HF(e),e.schema=4),t<5&&(WF(e),e.schema=5),t<6&&(qF(e),e.schema=6),t<7&&(XF(e),e.schema=7),t<8&&(e.schema=8),t<9&&(cx(e),e.schema=9),t<10&&(KF(e),e.schema=10),t<11&&(JF(e),e.schema=11),t<12&&(cx(e),e.schema=12),t<13&&($F(e),e.schema=13),t<14&&(tU(e),e.schema=14),t<15&&(iU(e),e.schema=15),t<16&&(rU(e),e.schema=16),t<17&&(yd(e,dx),vd(e,dx),e.schema=17),t<18&&(yd(e,hx),vd(e,hx),e.schema=18),t<19&&(GF(e),e.schema=19),t<20&&(sU(e),aU(e),e.schema=20),t<21&&(oU(e),lU(e),e.schema=21),t<22&&(px(e),e.schema=22),t<23&&(hU(e),e.schema=23),t<24&&(cU(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(eU(e),t<25&&(e.schema=25)),t<26&&(YF(e),e.schema=26),t<27&&(QF(e),e.schema=27),t<28&&(px(e),e.schema=28),t<29&&(ZF(e),e.schema=29),t<30&&(dU(e),e.schema=30),t<31&&(uU(e),e.schema=31),t<33&&(pU(e),e.schema=33),t<34&&(fU(e),e.schema=34),t<35&&(mU(e),e.schema=35),t<36&&(gU(e),e.schema=36),t<37&&(vU(e),e.schema=37))}function Co(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),n={},a={},o=e[0].morphTargetsRelative,l=new He,h=0;for(let u=0;u<e.length;++u){let c=e[u],d=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,u),h+=p}}if(i){let u=0,c=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+u);u+=e[d].attributes.position.count}l.setIndex(c)}for(let u in n){let c=mx(n[u]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,c)}for(let u in a){let c=a[u][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<c;++d){let p=[];for(let g=0;g<a[u].length;++g)p.push(a[u][g][d]);let f=mx(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}return l}function mx(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let n=new t(s),a=0;for(let o=0;o<e.length;++o)n.set(e[o].array,a),a+=e[o].array.length;return new Xe(n,i,r)}var Um;(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 et,move:new et,jump:new et}}))(Um||(Um={}));var xU=Math.pow(2,-24),zc=class{constructor(){}};function ys(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function gx(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function vx(e,t){t.set(e)}function yx(e,t,i){let r,s;for(let n=0;n<3;n++){let a=n+3;r=e[n],s=t[n],i[n]=r<s?r:s,r=e[a],s=t[a],i[a]=r>s?r:s}}function Fc(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],n=t[e+2*r+1],a=s-n,o=s+n;a<i[r]&&(i[r]=a),o>i[r+3]&&(i[r+3]=o)}}function Ll(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function wU(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new Xe(s,1));for(let n=0;n<i;n++)s[n]=n}}function bU(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,n)=>s-n);for(let s=0;s<r.length-1;s++){let n=r[s],a=r[s+1];t.push({offset:n/3,count:(a-n)/3})}return t}function Kp(e,t,i,r,s=null){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0,c=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let w=e[y+0],_=e[y+1],S=w-_,A=w+_;S<n&&(n=S),A>l&&(l=A),v&&w<c&&(c=w),v&&w>f&&(f=w);let b=e[y+2],M=e[y+3],C=b-M,T=b+M;C<a&&(a=C),T>h&&(h=T),v&&b<d&&(d=b),v&&b>g&&(g=b);let D=e[y+4],L=e[y+5],P=D-L,N=D+L;P<o&&(o=P),N>u&&(u=N),v&&D<p&&(p=D),v&&D>m&&(m=D)}r[0]=n,r[1]=a,r[2]=o,r[3]=l,r[4]=h,r[5]=u,v&&(s[0]=c,s[1]=d,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function _U(e,t,i,r){let s=1/0,n=1/0,a=1/0,o=-1/0,l=-1/0,h=-1/0;for(let u=t*6,c=(t+i)*6;u<c;u+=6){let d=e[u+0];d<s&&(s=d),d>o&&(o=d);let p=e[u+2];p<n&&(n=p),p>l&&(l=p);let f=e[u+4];f<a&&(a=f),f>h&&(h=f)}r[0]=s,r[1]=n,r[2]=a,r[3]=o,r[4]=l,r[5]=h}function SU(e,t,i,r,s){let n=i,a=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;n<=a&&t[n*6+l]<o;)n++;for(;n<=a&&t[a*6+l]>=o;)a--;if(n<a){for(let h=0;h<3;h++){let u=e[n*3+h];e[n*3+h]=e[a*3+h],e[a*3+h]=u;let c=t[n*6+h*2+0];t[n*6+h*2+0]=t[a*6+h*2+0],t[a*6+h*2+0]=c;let d=t[n*6+h*2+1];t[n*6+h*2+1]=t[a*6+h*2+1],t[a*6+h*2+1]=d}n++,a--}else return n}}var Xs=32,AU=(e,t)=>e.candidate-t.candidate,fn=new Array(Xs).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Uc=new Float32Array(6);function MU(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=gx(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=gx(e),a!==-1&&(o=EU(i,r,s,a));else if(n===2){let l=Ll(e),h=1.25*s,u=r*6,c=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/Xs;if(s<Xs/4){let g=[...fn];g.length=s;let m=0;for(let y=u;y<c;y+=6,m++){let x=g[m];x.candidate=i[y+2*d],x.count=0;let{bounds:w,leftCacheBounds:_,rightCacheBounds:S}=x;for(let A=0;A<3;A++)S[A]=1/0,S[A+3]=-1/0,_[A]=1/0,_[A+3]=-1/0,w[A]=1/0,w[A+3]=-1/0;Fc(y,i,w)}g.sort(AU);let v=s;for(let y=0;y<v;y++){let x=g[y];for(;y+1<v&&g[y+1].candidate===x.candidate;)g.splice(y+1,1),v--}for(let y=u;y<c;y+=6){let x=i[y+2*d];for(let w=0;w<v;w++){let _=g[w];x>=_.candidate?Fc(y,i,_.rightCacheBounds):(Fc(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=g[y],w=x.count,_=s-x.count,S=x.leftCacheBounds,A=x.rightCacheBounds,b=0;w!==0&&(b=Ll(S)/l);let M=0;_!==0&&(M=Ll(A)/l);let C=1+1.25*(b*w+M*_);C<h&&(a=d,h=C,o=x.candidate)}}else{for(let v=0;v<Xs;v++){let y=fn[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let w=0;w<3;w++)x[w]=1/0,x[w+3]=-1/0}for(let v=u;v<c;v+=6){let y=~~((i[v+2*d]-p)/f);y>=Xs&&(y=Xs-1);let x=fn[y];x.count++,Fc(v,i,x.bounds)}let g=fn[Xs-1];vx(g.bounds,g.rightCacheBounds);for(let v=Xs-2;v>=0;v--){let y=fn[v],x=fn[v+1];yx(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<Xs-1;v++){let y=fn[v],x=y.count,w=y.bounds,_=fn[v+1].rightCacheBounds;x!==0&&(m===0?vx(w,Uc):yx(w,Uc,Uc)),m+=x;let S=0,A=0;m!==0&&(S=Ll(Uc)/l);let b=s-m;b!==0&&(A=Ll(_)/l);let M=1+1.25*(S*m+A*b);M<h&&(a=d,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function EU(e,t,i,r){let s=0;for(let n=t,a=t+i;n<a;n++)s+=e[n*6+r*2];return s/i}function CU(e,t){let i=e.attributes.position,r=i.array,s=e.index.array,n=s.length/3,a=new Float32Array(n*6),o=i.offset||0,l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);for(let h=0;h<n;h++){let u=h*3,c=h*6,d=s[u+0]*l+o,p=s[u+1]*l+o,f=s[u+2]*l+o;for(let g=0;g<3;g++){let m=r[d+g],v=r[p+g],y=r[f+g],x=m;v<x&&(x=v),y<x&&(x=y);let w=m;v>w&&(w=v),y>w&&(w=y);let _=(w-x)/2,S=g*2;a[c+S+0]=x+_,a[c+S+1]=_+(Math.abs(x)+_)*xU,x<t[g]&&(t[g]=x),w>t[g+3]&&(t[g+3]=w)}}return a}function TU(e,t){function i(v){d&&d(v/p)}function r(v,y,x,w=null,_=0){if(!f&&_>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=u||_>=l)return i(y+x),v.offset=y,v.count=x,v;let S=MU(v.boundingData,w,a,y,x,c);if(S.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let A=SU(o,a,y,x,S);if(A===y||A===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=S.axis;let b=new zc,M=y,C=A-y;v.left=b,b.boundingData=new Float32Array(6),Kp(a,M,C,b.boundingData,n),r(b,M,C,n,_+1);let T=new zc,D=A,L=x-C;v.right=T,T.boundingData=new Float32Array(6),Kp(a,D,L,T.boundingData,n),r(T,D,L,n,_+1)}return v}wU(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=CU(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,u=t.maxLeafTris,c=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,g=[],m=bU(e);if(m.length===1){let v=m[0],y=new zc;y.boundingData=s,_U(a,v.offset,v.count,n),r(y,v.offset,v.count,n),g.push(y)}else for(let v of m){let y=new zc;y.boundingData=new Float32Array(6),Kp(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),g.push(y)}return g}function PU(e,t){let i=TU(e,t),r,s,n,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<i.length;u++){let c=i[u],d=l(c),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),n=new Uint16Array(p),h(0,c),a.push(p)}return a;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function h(u,c){let d=u/4,p=u/2,f=!!c.count,g=c.boundingData;for(let m=0;m<6;m++)r[d+m]=g[m];if(f){let m=c.offset,v=c.count;return s[d+6]=m,n[p+14]=v,n[p+15]=65535,u+32}else{let m=c.left,v=c.right,y=c.splitAxis,x;if(x=h(u+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=x/4,x=h(x,v),s[d+7]=y,x}}}var Ps=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,n=e.length;s<n;s++){let a=e[s][t];i=a<i?a:i,r=a>r?a:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,n=t.length;s<n;s++){let a=t[s],o=e.dot(a);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};Ps.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,n=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let u=t.dot(e);n=Math.min(u,n),a=Math.max(u,a)}this.min=n,this.max=a}}();var g7=function(){let e=new Ps;return function(t,i){let r=t.points,s=t.satAxes,n=t.satBounds,a=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let u=n[h],c=s[h];if(e.setFromPoints(c,a),u.isSeparated(e))return!1}for(let h=0;h<3;h++){let u=l[h],c=o[h];if(e.setFromPoints(c,r),u.isSeparated(e))return!1}}}(),DU=function(){let e=new E,t=new E,i=new E;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,s.start),t.subVectors(s.end,s.start);let u=i.dot(h),c=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-c*c,g,m;f!==0?g=(u*c-p*d)/f:g=0,m=(u+g*c)/d,n.x=g,n.y=m}}(),cv=function(){let e=new G,t=new E,i=new E;return function(r,s,n,a){DU(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,n),s.at(l,a);return}else if(o>=0&&o<=1){l<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,n);return}else if(l>=0&&l<=1){o<0?r.at(0,n):r.at(1,n),s.closestPointToPoint(n,!0,a);return}else{let h;o<0?h=r.start:h=r.end;let u;l<0?u=s.start:u=s.end;let c=t,d=i;if(r.closestPointToPoint(u,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(u)<=d.distanceToSquared(h)){n.copy(c),a.copy(u);return}else{n.copy(h),a.copy(d);return}}}}(),LU=function(){let e=new E,t=new E,i=new er,r=new Ar;return function(s,n){let{radius:a,center:o}=s,{a:l,b:h,c:u}=n;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a))return!0;let c=n.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=a){let d=c.projectPoint(o,t);if(n.containsPoint(d))return!0}return!1}}(),OU=1e-15;function so(e){return Math.abs(e)<OU}var tn=class extends ki{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Ps),this.points=[this.a,this.b,this.c],this.sphere=new Tr,this.plane=new er,this.needsUpdate=!0}intersectsSphere(e){return LU(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,n=this.satBounds,a=s[0],o=n[0];this.getNormal(a),o.setFromPoints(a,r);let l=s[1],h=n[1];l.subVectors(e,t),h.setFromPoints(l,r);let u=s[2],c=n[2];u.subVectors(t,i),c.setFromPoints(u,r);let d=s[3],p=n[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};tn.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new Ar;return function(r,s=null,n=null){let{start:a,end:o}=r,l=this.points,h,u=1/0;for(let c=0;c<3;c++){let d=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[d]),cv(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),n&&n.copy(t))}return this.closestPointToPoint(a,e),h=a.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(a)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(o)),Math.sqrt(u)}}();tn.prototype.intersectsTriangle=function(){let e=new tn,t=new Array(3),i=new Array(3),r=new Ps,s=new Ps,n=new E,a=new E,o=new E,l=new E,h=new Ar,u=new Ar,c=new Ar;return function(d,p=null){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let f=this.plane,g=d.plane;if(Math.abs(f.normal.dot(g.normal))>1-1e-10){let m=this.satBounds,v=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let w=0;w<4;w++){let _=m[w],S=v[w];if(r.setFromPoints(S,i),_.isSeparated(r))return!1}let y=d.satBounds,x=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let _=y[w],S=x[w];if(r.setFromPoints(S,t),_.isSeparated(r))return!1}for(let w=0;w<4;w++){let _=v[w];for(let S=0;S<4;S++){let A=x[S];if(n.crossVectors(_,A),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let m=this.points,v=!1,y=0;for(let D=0;D<3;D++){let L=m[D],P=m[(D+1)%3];h.start.copy(L),h.end.copy(P),h.delta(a);let N=v?u.start:u.end,W=so(g.distanceToPoint(L));if(so(g.normal.dot(a))&&W){u.copy(h),y=2;break}if((g.intersectLine(h,N)||W)&&!so(N.distanceTo(P))){if(y++,v)break;v=!0}}if(y===1&&this.containsPoint(u.start))return p&&(p.start.copy(u.start),p.end.copy(u.start)),!0;if(y!==2)return!1;let x=d.points,w=!1,_=0;for(let D=0;D<3;D++){let L=x[D],P=x[(D+1)%3];h.start.copy(L),h.end.copy(P),h.delta(o);let N=w?c.start:c.end,W=so(f.distanceToPoint(L));if(so(f.normal.dot(o))&&W){c.copy(h),_=2;break}if((f.intersectLine(h,N)||W)&&!so(N.distanceTo(P))){if(_++,w)break;w=!0}}if(_===1&&this.containsPoint(c.start))return p&&(p.start.copy(c.start),p.end.copy(c.start)),!0;if(_!==2)return!1;if(u.delta(a),c.delta(o),a.dot(o)<0){let D=c.start;c.start=c.end,c.end=D}let S=u.start.dot(a),A=u.end.dot(a),b=c.start.dot(a),M=c.end.dot(a),C=A<b,T=S<M;return S!==M&&b!==A&&C===T?!1:(p&&(l.subVectors(u.start,c.start),l.dot(a)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(a)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();tn.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();tn.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new Ar,s=new Ar;return function(n,a=null,o=null){let l=a||o?r:null;if(this.intersectsTriangle(n,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let u=0;u<3;u++){let c,d=i[u],p=n[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,a&&a.copy(e),o&&o.copy(p));let f=this[d];n.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,a&&a.copy(f),o&&o.copy(e))}for(let u=0;u<3;u++){let c=i[u],d=i[(u+1)%3];r.set(this[c],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];s.set(n[f],n[g]),cv(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Ds=class extends $t{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new ge,this.invMatrix=new ge,this.points=new Array(8).fill().map(()=>new E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new Ps),this.alignedSatBounds=new Array(3).fill().map(()=>new Ps),this.needsUpdate=!1}set(e,t,i){super.set(e,t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Ds.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){let c=1*l|2*h|4*u,d=r[c];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=u?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,n=this.satAxes,a=r[0];for(let l=0;l<3;l++){let h=n[l],u=s[l],c=1<<l,d=r[c];h.subVectors(a,d),u.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Ds.prototype.intersectsBox=function(){let e=new Ps;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,n=this.satAxes,a=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,a[0].isSeparated(e)||(e.min=i.y,e.max=r.y,a[1].isSeparated(e))||(e.min=i.z,e.max=r.z,a[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=n[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Ds.prototype.intersectsTriangle=function(){let e=new tn,t=new Array(3),i=new Ps,r=new Ps,s=new E;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);let a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let c=0;c<3;c++){let d=a[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=n.satBounds,h=n.satAxes,u=this.points;for(let c=0;c<3;c++){let d=l[c],p=h[c];if(i.setFromPoints(p,u),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}();Ds.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Ds.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ds.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Ar),i=new Array(12).fill().map(()=>new Ar),r=new E,s=new E;return function(n,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(s),this.closestPointToPoint(s,r),n.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=a*a,u=n.min,c=n.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];s.copy(m).clamp(u,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(g+1)%3,x=(g+2)%3,w=m<<y|v<<x,_=1<<g|m<<y|v<<x,S=d[w],A=d[_];t[f].set(S,A);let b=e[g],M=e[y],C=e[x],T=i[f],D=T.start,L=T.end;D[b]=u[b],D[M]=m?u[M]:c[M],D[C]=v?u[C]:c[M],L[b]=c[b],L[M]=m?u[M]:c[M],L[C]=v?u[C]:c[M],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=g?c.x:u.x,s.y=m?c.y:u.y,s.z=v?c.z:u.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let g=0;g<12;g++){let m=t[g];for(let v=0;v<12;v++){let y=i[v];cv(m,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var kc=new E,jc=new E,Gc=new E,xx=new G,wx=new G,bx=new G,_x=new E;function IU(e,t,i,r,s,n){let a;return n===ui?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==sr,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function RU(e,t,i,r,s,n,a){kc.fromBufferAttribute(t,r),jc.fromBufferAttribute(t,s),Gc.fromBufferAttribute(t,n);let o=IU(e,kc,jc,Gc,_x,a);if(o){i&&(xx.fromBufferAttribute(i,r),wx.fromBufferAttribute(i,s),bx.fromBufferAttribute(i,n),o.uv=ki.getUV(_x,kc,jc,Gc,xx,wx,bx,new G));let l={a:r,b:s,c:n,normal:new E,materialIndex:0};ki.getNormal(kc,jc,Gc,l.normal),o.face=l,o.faceIndex=r}return o}function DS(e,t,i,r,s){let n=r*3,a=e.index.getX(n),o=e.index.getX(n+1),l=e.index.getX(n+2),h=RU(i,e.attributes.position,e.attributes.uv,a,o,l,t);return h?(h.faceIndex=r,s&&s.push(h),h):null}function BU(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)DS(e,t,i,a,n)}function NU(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=DS(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function LS(e,t,i){return e===null||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far)?null:e}function ms(e,t,i,r){let s=e.a,n=e.b,a=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),n.x=r.getX(l),n.y=r.getY(l),n.z=r.getZ(l),a.x=r.getX(h),a.y=r.getY(h),a.z=r.getZ(h)}function Sx(e,t,i,r,s,n,a){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(ms(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var OS=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function En(e,t){return t[e+15]===65535}function No(e,t){return t[e+6]}function Ih(e,t){return t[e+14]}function Rh(e){return e+8}function Bh(e,t){return t[e+6]}function zU(e,t){return t[e+7]}var To=new $t,nu=new E,FU=["x","y","z"];function km(e,t,i,r,s){let n=e*2,a=dl,o=Fn,l=Un;if(En(n,o)){let h=No(e,l),u=Ih(n,o);BU(t,i,r,h,u,s)}else{let h=Rh(e);au(h,a,r,nu)&&km(h,t,i,r,s);let u=Bh(e,l);au(u,a,r,nu)&&km(u,t,i,r,s)}}function jm(e,t,i,r){let s=e*2,n=dl,a=Fn,o=Un;if(En(s,a)){let l=No(e,o),h=Ih(s,a);return NU(t,i,r,l,h)}else{let l=zU(e,o),h=FU[l],u=r.direction[h]>=0,c,d;u?(c=Rh(e),d=Bh(e,o)):(c=Bh(e,o),d=Rh(e));let p=au(c,n,r,nu)?jm(c,t,i,r):null;if(p){let g=p.point[h];if(u?g<=n[d+l]:g>=n[d+l+3])return p}let f=au(d,n,r,nu)?jm(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var UU=function(){let e,t,i=[],r=new OS(()=>new $t);return function(...n){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let a=s(...n);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),a};function s(n,a,o,l,h=null,u=0,c=0){function d(y){let x=y*2,w=Fn,_=Un;for(;!En(x,w);)y=Rh(y),x=y*2;return No(y,_)}function p(y){let x=y*2,w=Fn,_=Un;for(;!En(x,w);)y=Bh(y,_),x=y*2;return No(y,_)+Ih(x,w)}let f=n*2,g=dl,m=Fn,v=Un;if(En(f,m)){let y=No(n,v),x=Ih(f,m);return ys(n,g,e),l(y,x,!1,c,u+n,e)}else{let y=Rh(n),x=Bh(n,v),w=y,_=x,S,A,b,M;if(h&&(b=e,M=t,ys(w,g,b),ys(_,g,M),S=h(b),A=h(M),A<S)){w=x,_=y;let W=S;S=A,A=W,b=M}b||(b=e,ys(w,g,b));let C=En(w*2,m),T=o(b,C,S,c+1,u+w),D;if(T===2){let W=d(w),q=p(w)-W;D=l(W,q,!0,c+1,u+w,b)}else D=T&&s(w,a,o,l,h,u,c+1);if(D)return!0;M=t,ys(_,g,M);let L=En(_*2,m),P=o(M,L,A,c+1,u+_),N;if(P===2){let W=d(_),q=p(_)-W;N=l(W,q,!0,c+1,u+_,M)}else N=P&&s(_,a,o,l,h,u,c+1);return!!N}}}(),kU=function(){let e=new tn,t=new tn,i=new ge,r=new Ds,s=new Ds;return function n(a,o,l,h,u=null){let c=a*2,d=dl,p=Fn,f=Un;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),En(c,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,x=l.attributes.position,w=No(a,f),_=Ih(c,p);if(i.copy(h).invert(),l.boundsTree)return ys(a,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>s.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(h),S.b.applyMatrix4(h),S.c.applyMatrix4(h),S.needsUpdate=!0;for(let A=w*3,b=(_+w)*3;A<b;A+=3)if(ms(t,A,m,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let S=w*3,A=_+w*3;S<A;S+=3){ms(e,S,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let b=0,M=y.count;b<M;b+=3)if(ms(t,b,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=a+8,m=f[a+6];return ys(g,d,To),!!(u.intersectsBox(To)&&n(g,o,l,h,u)||(ys(m,d,To),u.intersectsBox(To)&&n(m,o,l,h,u)))}}}();function au(e,t,i,r){return ys(e,t,To),i.intersectBox(To,r)}var Gm=[],xd,dl,Fn,Un;function $l(e){xd&&Gm.push(xd),xd=e,dl=new Float32Array(e),Fn=new Uint16Array(e),Un=new Uint32Array(e)}function Vc(){xd=null,dl=null,Fn=null,Un=null,Gm.length&&$l(Gm.pop())}var Jp=Symbol("skip tree generation"),$p=new $t,ef=new $t,no=new ge,ia=new Ds,Ol=new Ds,Il=new E,Hc=new E,jU=new E,GU=new E,VU=new E,Ax=new $t,rs=new OS(()=>new tn),bi=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),bi.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),n;return t.cloneBuffers?n={roots:r.map(a=>a.slice()),index:s.array.slice()}:n={roots:r,index:s.array},n}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),bi.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,n=new bi(t,{...i,[Jp]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new Xe(e.index,1,!1);t.setIndex(o)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return n}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Jp]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Jp]||(this._roots=PU(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new $t))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s=r.array,n=r.offset||0,a=3;r.isInterleavedBufferAttribute&&(a=r.data.stride);let o,l,h,u,c=0,d=this._roots;for(let f=0,g=d.length;f<g;f++)o=d[f],l=new Uint32Array(o),h=new Uint16Array(o),u=new Float32Array(o),p(0,c),c+=o.byteLength;function p(f,g,m=!1){let v=f*2;if(h[v+15]===65535){let y=l[f+6],x=h[v+14],w=1/0,_=1/0,S=1/0,A=-1/0,b=-1/0,M=-1/0;for(let C=3*y,T=3*(y+x);C<T;C++){let D=i[C]*a+n,L=s[D+0],P=s[D+1],N=s[D+2];L<w&&(w=L),L>A&&(A=L),P<_&&(_=P),P>b&&(b=P),N<S&&(S=N),N>M&&(M=N)}return u[f+0]!==w||u[f+1]!==_||u[f+2]!==S||u[f+3]!==A||u[f+4]!==b||u[f+5]!==M?(u[f+0]=w,u[f+1]=_,u[f+2]=S,u[f+3]=A,u[f+4]=b,u[f+5]=M,!0):!1}else{let y=f+8,x=l[f+6],w=y+g,_=x+g,S=m,A=!1,b=!1;e?S||(A=e.has(w),b=e.has(_),S=!A&&!b):(A=!0,b=!0);let M=S||A,C=S||b,T=!1;M&&(T=p(y,g,S));let D=!1;C&&(D=p(x,g,S));let L=T||D;if(L)for(let P=0;P<3;P++){let N=y+P,W=x+P,q=u[N],z=u[N+3],j=u[W],k=u[W+3];u[f+P]=q<j?q:j,u[f+P+3]=z>k?z:k}return L}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);n(0);function n(a,o=0){let l=a*2,h=s[l+15]===65535;if(h){let u=r[a+6],c=s[l+14];e(o,h,new Float32Array(i,a*4,6),u,c)}else{let u=a+8,c=r[a+6],d=r[a+7];e(o,h,new Float32Array(i,a*4,6),d)||(n(u,o+1),n(c,o+1))}}}raycast(e,t=Zr){let i=this._roots,r=this.geometry,s=[],n=t.isMaterial,a=Array.isArray(t),o=r.groups,l=n?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l,d=s.length;if($l(i[h]),km(0,r,c,e,s),Vc(),a){let p=o[h].materialIndex;for(let f=d,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=Zr){let i=this._roots,r=this.geometry,s=t.isMaterial,n=Array.isArray(t),a=null,o=r.groups,l=s?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l;$l(i[h]);let d=jm(0,r,c,e);Vc(),d!=null&&(a==null||d.distance<a.distance)&&(a=d,n&&(d.face.materialIndex=o[h].materialIndex))}return a}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if($l(s),r=kU(0,i,e,t),Vc(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(d,p,f,g)=>{let m=p*3;return c(d,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=rs.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,g,m)=>c(d,p,f,g,m)?!0:Sx(d,p,r,l,f,g,s)}else o||(l?o=(c,d,p,f)=>Sx(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if($l(c),h=UU(0,r,a,o,n,u),Vc(),h)break;u+=c.byteLength}return rs.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,n=this.geometry.index,a=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;no.copy(t).invert();let h=rs.getPrimitive(),u=rs.getPrimitive();if(s){let d=function(p,f,g,m,v,y,x,w){for(let _=g,S=g+m;_<S;_++){ms(u,_*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let A=p,b=p+f;A<b;A++)if(ms(h,A*3,n,a),h.needsUpdate=!0,s(h,u,A,_,v,y,x,w))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,x,w,_){return p(f,g,m,v,y,x,w,_)?!0:d(f,g,m,v,y,x,w,_)}}else r=d}e.getBoundingBox(ef),ef.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>ef.intersectsBox(d),intersectsRange:(d,p,f,g,m,v)=>($p.copy(v),$p.applyMatrix4(no),e.shapecast({intersectsBounds:y=>$p.intersectsBox(y),intersectsRange:(y,x,w,_,S)=>r(d,p,y,x,g,m,_,S)}))});return rs.releasePrimitive(h),rs.releasePrimitive(u),c}intersectsBox(e,t){return ia.set(e.min,e.max,t),ia.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ia.intersectsBox(i),intersectsTriangle:i=>ia.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,n=1/0){e.boundingBox||e.computeBoundingBox(),ia.set(e.boundingBox.min,e.boundingBox.max,t),ia.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,u=e.index,c=rs.getPrimitive(),d=rs.getPrimitive(),p=Hc,f=jU,g=null,m=null;r&&(g=GU,m=VU);let v=1/0,y=null,x=null;return no.copy(t).invert(),Ol.matrix.copy(no),this.shapecast({boundsTraverseOrder:w=>ia.distanceToBox(w),intersectsBounds:(w,_,S)=>S<v&&S<n?(_&&(Ol.min.copy(w.min),Ol.max.copy(w.max),Ol.needsUpdate=!0),!0):!1,intersectsRange:(w,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>Ol.distanceToBox(S),intersectsBounds:(S,A,b)=>b<v&&b<n,intersectsRange:(S,A)=>{for(let b=S*3,M=(S+A)*3;b<M;b+=3){ms(d,b,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=w*3,T=(w+_)*3;C<T;C+=3){ms(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(d,p,g);if(D<v&&(f.copy(p),m&&m.copy(g),v=D,y=C/3,x=b/3),D<s)return!0}}}});{let S=u?u.count:h.count;for(let A=0,b=S;A<b;A+=3){ms(d,A,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=w*3,C=(w+_)*3;M<C;M+=3){ms(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(d,p,g);if(T<v&&(f.copy(p),m&&m.copy(g),v=T,y=M/3,x=A/3),T<s)return!0}}}}}),rs.releasePrimitive(c),rs.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(no),f.applyMatrix4(no),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,n=r*r,a=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Il.copy(e).clamp(h.min,h.max),Il.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<a&&c<n,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,Il);let c=e.distanceToSquared(Il);return c<a&&(Hc.copy(Il),a=c,o=u),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Hc):t.point=Hc.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ys(0,new Float32Array(t),Ax),e.union(Ax)}),e}},Mx=bi.prototype.raycast;bi.prototype.raycast=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,i,r,s]=e;return Mx.call(this,r,t.material).forEach(n=>{n=LS(n,t,i),n&&s.push(n)}),s}else return Mx.apply(this,e)};var Ex=bi.prototype.raycastFirst;bi.prototype.raycastFirst=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,i,r]=e;return LS(Ex.call(this,r,t.material),t,i)}else return Ex.apply(this,e)};var Cx=bi.prototype.closestPointToPoint;bi.prototype.closestPointToPoint=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),e.unshift();let t=e[1],i={};return e[1]=i,Cx.apply(this,e),t&&t.copy(i.point),i.distance}else return Cx.apply(this,e)};var Tx=bi.prototype.closestPointToGeometry;bi.prototype.closestPointToGeometry=function(...e){let t=e[2],i=e[3];if(t&&t.isVector3||i&&i.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let r={},s={},n=e[1];return e[2]=r,e[3]=s,Tx.apply(this,e),t&&t.copy(r.point),i&&i.copy(s.point).applyMatrix4(n),r.distance}else return Tx.apply(this,e)};var Px=bi.prototype.refit;bi.prototype.refit=function(...e){let t=e[0],i=e[1];if(i&&(i instanceof Set||Array.isArray(i))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let r=new Set;i.forEach(s=>r.add(s)),t&&t.forEach(s=>r.add(s)),Px.call(this,r)}else Px.apply(this,e)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(e=>{let t=bi.prototype[e];bi.prototype[e]=function(...i){return(i[0]===null||i[0].isMesh)&&(i.shift(),console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,i)}});var Rl=Fh(MM()),HU=.5*(Math.sqrt(3)-1),Bl=(3-Math.sqrt(3))/6,WU=1/3,ss=1/6,v7=(Math.sqrt(5)-1)/4,y7=(5-Math.sqrt(5))/20,ch=e=>Math.floor(e)|0,Dx=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]),tf=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 rf(e=Math.random){let t=IS(e),i=new Float64Array(t).map(s=>Dx[s%12*2]),r=new Float64Array(t).map(s=>Dx[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*HU,u=ch(s+h),c=ch(n+h),d=(u+c)*Bl,p=u-d,f=c-d,g=s-p,m=n-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let x=g-v+Bl,w=m-y+Bl,_=g-1+2*Bl,S=m-1+2*Bl,A=u&255,b=c&255,M=.5-g*g-m*m;if(M>=0){let D=A+t[b],L=i[D],P=r[D];M*=M,a=M*M*(L*g+P*m)}let C=.5-x*x-w*w;if(C>=0){let D=A+v+t[b+y],L=i[D],P=r[D];C*=C,o=C*C*(L*x+P*w)}let T=.5-_*_-S*S;if(T>=0){let D=A+1+t[b+1],L=i[D],P=r[D];T*=T,l=T*T*(L*_+P*S)}return 70*(a+o+l)}}function qU(e=Math.random){let t=IS(e),i=new Float64Array(t).map(n=>tf[n%12*3]),r=new Float64Array(t).map(n=>tf[n%12*3+1]),s=new Float64Array(t).map(n=>tf[n%12*3+2]);return function(n,a,o){let l,h,u,c,d=(n+a+o)*WU,p=ch(n+d),f=ch(a+d),g=ch(o+d),m=(p+f+g)*ss,v=p-m,y=f-m,x=g-m,w=n-v,_=a-y,S=o-x,A,b,M,C,T,D;w>=_?_>=S?(A=1,b=0,M=0,C=1,T=1,D=0):w>=S?(A=1,b=0,M=0,C=1,T=0,D=1):(A=0,b=0,M=1,C=1,T=0,D=1):_<S?(A=0,b=0,M=1,C=0,T=1,D=1):w<S?(A=0,b=1,M=0,C=0,T=1,D=1):(A=0,b=1,M=0,C=1,T=1,D=0);let L=w-A+ss,P=_-b+ss,N=S-M+ss,W=w-C+2*ss,q=_-T+2*ss,z=S-D+2*ss,j=w-1+3*ss,k=_-1+3*ss,F=S-1+3*ss,R=p&255,V=f&255,Q=g&255,Y=.6-w*w-_*_-S*S;if(Y<0)l=0;else{let $=R+t[V+t[Q]];Y*=Y,l=Y*Y*(i[$]*w+r[$]*_+s[$]*S)}let U=.6-L*L-P*P-N*N;if(U<0)h=0;else{let $=R+A+t[V+b+t[Q+M]];U*=U,h=U*U*(i[$]*L+r[$]*P+s[$]*N)}let se=.6-W*W-q*q-z*z;if(se<0)u=0;else{let $=R+C+t[V+T+t[Q+D]];se*=se,u=se*se*(i[$]*W+r[$]*q+s[$]*z)}let H=.6-j*j-k*k-F*F;if(H<0)c=0;else{let $=R+1+t[V+1+t[Q+1]];H*=H,c=H*H*(i[$]*j+r[$]*k+s[$]*F)}return 32*(l+h+u+c)}}function IS(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var zr=new ki,XU=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;zr.a.fromBufferAttribute(e,r),zr.b.fromBufferAttribute(e,r+1),zr.c.fromBufferAttribute(e,r+2),s*=zr.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||t[n-1]<=e&&t[n]>e){s=n;break}else e<t[n]?r=n-1:i=n+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),zr.a.fromBufferAttribute(this.positionAttribute,e*3),zr.b.fromBufferAttribute(this.positionAttribute,e*3+1),zr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(zr.a,r).addScaledVector(zr.b,s).addScaledVector(zr.c,1-(r+s)),zr.getNormal(i),this}},YU=Fh(Tb()),QU=new ge,ZU=new ge,KU=new ge,ou;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(ou||(ou={}));var dv=e=>class extends e{constructor(){super(...arguments),this.hiddenMatrix=new ge,this.matrixWorldRigid=new ge,this.shearScale=new ge,this.shearScaleInv=new ge}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof _t&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)ou.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:n}=(0,YU.SVD)(i),a=QU.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=ZU.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=KU.copy(o).transpose();this.shearScale.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,l).copyPosition(this.matrixWorld),n.every(h=>Math.abs(n[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new ge().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof ge?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}},JU=class extends dv(_t){},$U=e=>e.type==="Mesh",qr=class extends JU{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new qr(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return $U(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}},da=new E,ua=new E,zo=new ge,RS=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],e6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],t6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Lx=(e,t,i)=>{e.updateEntityBoxSize(da,ua),zo.copy(t).multiply(e.matrixWorld),ua.x===0&&ua.y===0&&ua.z===0?i.push(new E(da.x,da.y,da.z).applyMatrix4(zo)):RS.forEach(r=>{i.push(r.clone().multiply(ua).add(da).applyMatrix4(zo))})},Ox=class extends $t{constructor(){super(...arguments),this.matrix=new ge,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ge().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}Lx(s,t,r)}}):Lx(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(zo.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(ua).multiplyScalar(.5),this.getCenter(da),zo.copy(this.matrix).setPosition(da),this.vertices=RS.map(e=>e.clone().multiply(ua).applyMatrix4(zo))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=e6.map(([e,t])=>new Ar(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=t6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},In={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},i6=class extends Jb{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(e*l/s),u=o.getPoints(h);for(let c=0;c<u.length;c++){let d=u[c];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},Vm=.001;function Hm(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Vm}function sf(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),n=new E(...t.position);return Hm(i,r,n)&&Hm(i,s,n)}function BS(e){let t=e.points.map(u=>new E(...u.data.position)),i=[e.points[0]],r=new E(...i[0].data.position);for(let u=0;u<e.points.length-1;u++)Hm(r,t[u],t[u+1])||(i.push(e.points[u]),r=t[u]);i.push(e.points[e.points.length-1]);let s=e.isClosed,n=i.length-(s?0:1),a=i.length,o=[];for(let u=0;u<a;u++){let c=i[u].data,d=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),g={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===a-1)){o[u]={...g,removedLength:0};continue}let m=s&&u==0?a-1:u-1,v=s&&u==a-1?0:u+1,y=i[m].data,x=i[v].data,w=new E(...y.position),_=new E(...x.position),S=w.clone().sub(d).normalize(),A=_.clone().sub(d).normalize();Object.assign(g,{prevDir:S,nextDir:A});let b=sf(y,c),M=sf(c,x);if(!b||!M)o[u]={...g,removedLength:0};else{let C=S.clone().add(A).normalize(),T=C.clone().cross(S).length()/S.dot(C);o[u]={...g,tan:T,removedLength:c.roundness/T}}}for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/2)}}let l=[];for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d],g=null;if(!sf(i[c].data,i[d].data))p.position.distanceTo(f.position)>Vm&&(g=new ud(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>Vm&&(g=new ud(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*u+1]=g}for(let u=0;u<a;u++){let c=o[u];if(c.removedLength===0){l[2*u]=null;continue}let d=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(d),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(d),g=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),w=m.clone().multiplyScalar(-g).add(x),_=d.distanceTo(w)/d.distanceTo(v),S=c.prevDir.clone().multiplyScalar(_*d.distanceTo(p)).add(d),A=S.clone().lerp(w,2),b=p.clone().lerp(S,4/3),M=f.clone().lerp(A,4/3);l[2*u]=new ud(p,b,M,f)}let h=new i6;return l.forEach(u=>{u&&h.add(u)}),h}var xt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(xt||(xt={}));var Cn=e=>xt.is(e),r6={type:"completeState",isfromEntity:!0},NS=e=>class extends dv(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new Ox,this._recursiveBBox=new Ox,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(xt.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(xt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)ma.toOps(this.data,s.data).forEach(n=>{let a=gm.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=ma.patch(this.data,s),ma.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{Cn(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(xt.is(i[r]))return i[r];if(xt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&xt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)Cn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{xt.is(i)&&t(i)})}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Cn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Cn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>Cn(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return mm(i,t)}updateTransformState(t){let i=!1;return t.position&&(this.position.fromArray(t.position),i=!0),t.rotation&&(this.rotation.fromArray(t.rotation),i=!0),t.scale&&(i=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Qo.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)xt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{xt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return mm(i,t)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=Mn(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=As.zoom(u,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(h[d]=c[d])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:u,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:u,...c}=l;l=c}let h=As.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,ma.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Mn(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[u],c.updateState(Sa.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=As.zoom(u.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=c[p]);t={...t,props:d}}u.overrideData=Jd.resolve(i.overrides,l),u.updateByOp(t,ar.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Ko.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Ko.rootOverrideProps)if(Mn(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=Sa.filterOp(h.overrideData,l);u&&h.updateByOp(u,ar.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=Sa.filterOp(h.overrideData,t);if(u){let c;n===h.data&&t===u?c=i:c=ar.applySimple(h.data,u),h.updateByOp(u,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!La.is(t.props.type)&&In.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){In.changeEntityProptotype(this,i,r);for(let s of this.children)xt.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Mn(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Mn(t.path,["cloner"])!==null){let s=ar.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=a.data,l=BS(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let u=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new ge;a.updateMatrixWorld();let d=new ge().multiplyMatrices(c.clone().invert(),a.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(n==="tangential"){let f=new ge().extractRotation(a.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(u),m=new ge().lookAt(u,g,new E(0,1,0)),v=new vi().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(r6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof In.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new In.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}},s6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters),r=i.width/2,s=i.radiusTop??r,n=i.radiusBottom??r;return s===n?(s=r,n=r):s>n?(s=r,n=n*r/s):(s=s*r/n,n=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:n})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return c||p?f=new zS(h,u,r,s,n,a,o,l*Math.PI/180,c,c,d,p):f=new Cg(h,u,r,s,n,a,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function mn(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Ix(e){return new G(e.y,-e.x)}var zS=class extends He{constructor(e,t,i,r,s,n,a,o,l,h,u,c,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,o=o!==void 0?o:Math.PI*2,n&&(l=0,h=0);let p=[],f=[],g=[],m=[],v=0,y=i/2,x=new E,w=new E;d&&e==0&&(e=l),d&&t==0&&(t=h);let _=new G(e,y),S=new G(t,-y),A=null,b=null,M=null,C=null,T=_.clone().sub(S),D=0,L=0,P=0;c>0&&(D=Math.min(e,t)*(1-c),L=e-D,P=t-D);let N=_.clone();N.x-=D;let W=Math.PI-T.angle(),q=T.angle(),z=Math.tan(q/2),j=Math.tan(W/2),k=z+j,F=c?k:j,R=c?k:z;if(l=Math.min(l,(e-L)/F,T.length()/k),h=Math.min(h,(t-P)/R,T.length()/k),l>0){let H=l/z;A=_.clone().sub(new G(H,l)),c&&(M=A.clone(),M.x-=D-k*l),_.sub(T.clone().setLength(H))}if(h>0){let H=h/j;b=S.clone().sub(new G(H,-h)),S.add(T.clone().setLength(H)),c&&(C=b.clone(),C.x-=D-k*h,N.sub(T.clone().setLength(H)))}T=_.clone().sub(S);let V=T.length()<.5,Q=[];for(let H=0;H<=r;H++){let $=[],J=H/r,ue=J*o+a,re=new G(Math.sin(ue),Math.cos(ue));C&&b?(Y($,J,re,W,h,C,-1,!0),Y($,J,re,q,h,b,-1,!1)):b?(U($,re,b.x,0,-1),Y($,J,re,q,h,b,-1,!1)):n||U($,re,t,P,-1);let oe=Ix(T).normalize();if(mn(oe,re,x),!V)for(let pe=0;pe<=s;pe++){let ye=pe/s,Te=T.clone().multiplyScalar(ye).add(S);mn(Te,re,w),f.push(w.x,w.y,w.z),g.push(x.x,x.y,x.z),m.push(J,.5+w.y/i),$.push(v++)}if(M&&A?(Y($,J,re,W,l,A,1,!1),Y($,J,re,q,l,M,1,!0)):A?(Y($,J,re,W,l,A,1,!1),U($,re,A.x,0,1)):n||U($,re,e,L,1),c&&!V){let pe=Ix(T).multiplyScalar(-1).normalize();mn(pe,re,x);for(let ye=0;ye<=s;ye++){let Te=ye/s,xe=T.clone().multiplyScalar(-Te).add(N);mn(xe,re,w),f.push(w.x,w.y,w.z),g.push(x.x,x.y,x.z),m.push(J,.5+w.y/i),$.push(v++)}}c&&!n&&$.push($[0]),Q.push($)}for(let H=0;H<Q.length-1;H++)for(let $=0;$<Q[0].length-1;$++){if(n&&c&&$==s)continue;let J=Q[H][$],ue=Q[H+1][$],re=Q[H+1][$+1],oe=Q[H][$+1],pe=f[re*3+0],ye=f[re*3+2];p.push(J,ue,oe),(pe!=0||ye!=0)&&p.push(ue,re,oe)}o<Math.PI*2&&(se(-1,Q[0],a),se(1,Q[Q.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Ce(f,3)),this.setAttribute("normal",new Ce(g,3)),this.setAttribute("uv",new Ce(m,2));function Y(H,$,J,ue,re,oe,pe,ye){for(let Te=0;Te<u+1;Te++){let xe=Te/u,be=pe<0?xe:1-xe;ye&&(be-=1),be*=ue;let Ie=new G(Math.sin(be),Math.cos(be)*pe),We=Ie.clone().multiplyScalar(re).add(oe);mn(We,J,w),f.push(w.x,w.y,w.z),mn(Ie,J,x),g.push(x.x,x.y,x.z),m.push($,.5+w.y/i),H.push(v++)}}function U(H,$,J,ue,re){let oe=new E,pe=new G,ye=[J,ue];re<0&&ye.reverse();for(let Te of ye)pe.set(Te,y*re),mn(pe,$,oe),f.push(oe.x,oe.y,oe.z),g.push(0,re,0),m.push(.5,.5),H.push(v++)}function se(H,$,J){let ue=new G(Math.sin(J),Math.cos(J)),re=new G(-Math.cos(J),Math.sin(J)),oe=new E,pe=H<0?(xe,be,Ie)=>p.push(xe,be,Ie):(xe,be,Ie)=>p.push(xe,Ie,be),ye=new G((e+t+L+P)/4,0);mn(ye,ue,oe),f.push(oe.x,oe.y,oe.z),g.push(re.x,0,re.y),m.push(.5,.5);let Te=v++;for(let xe of $){let be=f.slice(xe*3,xe*3+3);f.push(...be),g.push(re.x,0,re.y);let Ie=m.slice(xe*2,xe*2+2);m.push(...Ie),v++}for(let xe=Te+1;xe<v-1;xe++)pe(Te,xe,xe+1);pe(Te,v-1,Te+1)}}},n6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:u,cornerSegments:c}=e.parameters,d;return h>0||u>0||l<360?d=new zS(0,t/2,r,s,n,a,o,l*Math.PI/180,h,u,c,0,!0):d=new e_(t/2,r,s,n,a),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},a6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Cs(t,i,r,s,n,a):h=new o6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},nf=Math.PI/2,o6=class extends He{constructor(e=1,t=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o),a=Math.min(a,e/2,t/2,i/2);let h=[],u=[],c=[],d=[],p=0,f=0;g("z","y","x",-1,-1,i,t,e,n,s,0),g("z","y","x",1,-1,i,t,-e,n,s,1),g("x","z","y",1,1,e,i,t,r,n,2),g("x","z","y",1,-1,e,i,-t,r,n,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("y","x","z",-1,1,-1,t,e,i,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Ce(u,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(d,2));function g(y,x,w,_,S,A,b,M,C,T,D){let L=(A-2*a)/C,P=(b-2*a)/T,N=A/2-a,W=b/2-a,q=M/2,z=C+1,j=T+1,k=0,F=0,R=new E;for(let V=0;V<j;V++){let Q=V*P-W;for(let Y=0;Y<z;Y++){let U=Y*L-N;R[y]=U*_,R[x]=Q*S,R[w]=q,u.push(R.x,R.y,R.z),R[y]=0,R[x]=0,R[w]=M>0?1:-1,c.push(R.x,R.y,R.z),d.push(Y/C),d.push(1-V/T),k+=1}}for(let V=0;V<T;V++)for(let Q=0;Q<C;Q++){let Y=p+Q+z*V,U=p+Q+z*(V+1),se=p+(Q+1)+z*(V+1),H=p+(Q+1)+z*V;h.push(Y,U,H),h.push(U,se,H),F+=6}l.addGroup(f,F,D),f+=F,p+=k}function m(y,x,w,_,S,A,b,M,C,T,D){let L=(b-2*a)/T,P=b/2-a,N=M/2-a,W=C/2,q=T+1,z=0,j=0,k=new E,F=new E;for(let R=0;R<o+1;R++){let V=R/o*nf,Q=Math.sin(V)*a,Y=(1-Math.cos(V))*a,U=Math.sin(V),se=Math.cos(V);k[x]=(N+Q)*S,k[w]=(W-Y)*A,F[y]=0,F[x]=U*Math.sign(k[x]),F[w]=se*Math.sign(k[w]);for(let H=0;H<q;H++){let $=H*L-P;k[y]=$*_,u.push(k.x,k.y,k.z),c.push(F.x,F.y,F.z),d.push(H/T),d.push(0),z+=1}}for(let R=0;R<o;R++)for(let V=0;V<T;V++){let Q=p+V+q*R,Y=p+V+q*(R+1),U=p+(V+1)+q*(R+1),se=p+(V+1)+q*R;h.push(Q,Y,se),h.push(Y,U,se),j+=6}l.addGroup(f,j,D),f+=j,p+=z}function v(y,x,w){let _=new E,S=new E(e/2,t/2,i/2);S.subScalar(a);let A=[],b=y*x*w>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=nf*(1-C/o),L=Math.cos(D),P=Math.sin(D),N=0;for(let W=0;W<=C;W++){let q=Math.cos(N),z=Math.sin(N);_.x=L*q,_.y=P,_.z=L*z;let j=S.clone().addScaledVector(_,a);u.push(y*j.x,x*j.y,w*j.z),c.push(y*_.x,x*_.y,w*_.z),d.push(0,0),T.push(p++),N+=nf/C}A.push(T)}let M=A.length-1;for(let C=0;C<M;C++){let T=A[C],D=A[C+1],L=T.length-1;b(T[0],D[1],D[0]);for(let P=1;P<=L;P++)b(T[P-1],T[P],D[P]),b(T[P],D[P+1],D[P])}}}},uv=class extends He{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),u(),this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(n=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,p=d.clone(),f=new ki,g=s*r,m=r-g,v=n+1,y=new E,x=(q,z)=>y.subVectors(q,z).normalize(),w=(q,z)=>Array(q).fill(void 0).map(z),_=w(e.length/3,(q,z)=>new E().fromArray(e,z*3).setLength(r)),S=[],A=1e6;for(let q=0;q<_.length;q++){let z=_[q],j=[],k,F,R,V=1e10,Q=-1;for(;(Q=t.indexOf(q,Q+1))!=-1;){let H=Q-Q%3;k=t[H+(Q+1)%3],F=t[H+(Q+2)%3],R=z.distanceToSquared(_[k]),V=Math.min(V,R),j.push([k,F,R])}V+=1e-6;let Y=[],U=0,se=j.length;for(let H=0;H<se;H++){[k,F,R]=j[U];let $=S[k]?.includes(q)==!0;R<=V&&Y.push(k+ +$*A),U=j.findIndex(J=>J[0]==F)}S.push(Y)}let b=[];{let q=0,z=0,j,k,F=c==3;for(let R=0;R<=n;R++){j=R*(R+1)/2,k=(R+1)*(R+2)/2;for(let V=0;V<n-R;V++)[q,z]=[j+V+R+2,k+V+R+3],b.push(j,k,...F?[z,j]:[q,k],z,q),[j,k]=[q,z];b.push(j,k,j+n+2)}}let M=d.clone(),C=d.clone(),T=d.clone(),D=d.clone(),L=d.clone(),P=[],N=w(_.length,()=>w(c,()=>d.clone()));for(let q=0;q<_.length;q++){d.copy(_[q]).normalize(),M.copy(d).multiplyScalar(m);let z=S[q];for(let Y=0;Y<z.length;Y++){let U=z[Y],se=z[(Y+1)%c];f.setFromPointsAndIndices(_,q,U%A,se%A),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,N[q][Y])}let j=[],k=[],F=[],R=new E;n==0&&[...N[q]].reduce((Y,U)=>Y.add(U),R).multiplyScalar(1/c);for(let Y=0;Y<c;Y++){let U=[],se=(Y-1+c)%c,H=N[q][se],$=N[q][Y];d.copy(H).sub(M),p.copy($).sub(M);let J=M.angleTo(d),ue=d.angleTo(p),re=Math.cos(J)*g;n==0?C.copy(R):C.copy(M).setLength(m+re),k.push(re);let oe=[C,H,$];for(let pe=0;pe<2;pe++){let ye=oe[pe],Te=oe[pe+1];D.subVectors(ye,M),L.subVectors(Te,M),T.crossVectors(D,L).normalize();for(let xe=0;xe<v;xe++){let be=[J,ue][pe]*xe/v;d.copy(D).applyAxisAngle(T,be).add(M),j.push(d.clone()),pe&&(x(d,M),U.push([xe==0?ye:d.clone(),y.clone()]))}pe&&(x(Te,M),U.push([Te,y.clone()]))}F.push(U)}P.push(F);let V=2*v,Q=2;for(let Y=0;Y<c;Y++){let U=V*Y,se=V*((Y+1)%c),H=[j[U]];for(let J=1;J<v;J++){D=j[U+J],L=j[se+J],H.push(D);for(let ue=1,re=J-Q+1;ue<=re;ue++)d.lerpVectors(D,L,ue/(re+1)),d.sub(M).setLength(k[Y]).add(M),H.push(d.clone());H.push(L)}for(let J=0;J<v;J++)H.push(j[J+v+U]);H.push(j[se+v]);let $=b.map(J=>H[J]);a.push(...$.map(J=>[J.x,J.y,J.z]).flat()),l.push(...$.map(J=>(x(J,M),[y.x,y.y,y.z])).flat())}}let W=[];for(let q=0;q<S.length;q++)for(let z=0;z<c;z++){let j=S[q][z];if(j<A){let k=S[j].findIndex(V=>V%A==q),F=P[q][z],R=P[j][k];for(let V=0;V<v;V++){let Q=F[V],Y=R[v-V],U=F[V+1],se=R[v-(V+1)];[Q,Y,U,U,Y,se].forEach(H=>{a.push(H[0].x,H[0].y,H[0].z),l.push(H[1].x,H[1].y,H[1].z)})}W.push(F[0][0],R[v][0],F[v][0],R[0][0])}}for(;W.length;){let q,z,j,k;[q,z]=W.splice(0,2);let F=[q];for(;q!=z;)F.push(z),j=W.indexOf(z),k=j%2,z=W.splice(j-k,2)[1-k];y.subVectors(F[0],F[1]).cross(d.subVectors(F[0],F[2])).normalize();let R=y.dot(F[0])<0;R&&y.negate();for(let V=1;V<=F.length-2;V++)[F[V+ +R],F[V+1-+R],F[0]].forEach(Q=>{a.push(Q.x,Q.y,Q.z),l.push(y.x,y.y,y.z)})}}function u(){let c=new E;for(let S=0;S<a.length;S+=3){c.x=a[S+0],c.y=a[S+1],c.z=a[S+2];let A=w(c)/2/Math.PI+.5,b=_(c)/Math.PI+.5;o.push(A,1-b)}let d=new E,p=new E,f=new E,g=new E,m=new G,v=new G,y=new G,x=(S,A,b,M)=>{M<0&&S.x===1&&(o[A]=S.x-1),b.x===0&&b.z===0&&(o[A]=M/2/Math.PI+.5)};for(let S=0,A=0;S<a.length;S+=9,A+=6){d.set(a[S+0],a[S+1],a[S+2]),p.set(a[S+3],a[S+4],a[S+5]),f.set(a[S+6],a[S+7],a[S+8]),m.set(o[A+0],o[A+1]),v.set(o[A+2],o[A+3]),y.set(o[A+4],o[A+5]),g.copy(d).add(p).add(f).divideScalar(3);let b=w(g);x(m,A+0,d,b),x(v,A+2,p,b),x(y,A+4,f,b)}for(let S=0;S<o.length;S+=6){let A=o[S+0],b=o[S+2],M=o[S+4],C=Math.max(A,b,M),T=Math.min(A,b,M);C>.9&&T<.1&&(A<.2&&(o[S+0]+=1),b<.2&&(o[S+2]+=1),M<.2&&(o[S+4]+=1))}function w(S){return Math.atan2(S.z,-S.x)}function _(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}}static fromJSON(e){return new uv(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},l6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new FS(t*.5,n,a):new t_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},FS=class extends uv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(n,a,o,e,t,i),this.type=o}static fromJSON(e){return new FS(e.radius,e.corner,e.cornerSides)}},Nl=1e-12,pv=class{constructor(e){this.position=new G,this.startPosition=new G,this.uuid=it.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new pv(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Wm=class extends pv{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Wm(this.parent).copy(this)}},Fo=class extends pv{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Wm(this),new Wm(this))}static create(e,t){let i=new Fo(e,new G(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Fo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new G,t=new G){let[i,r]=this.computeTangents();return i&&r&&(Rx(i,e),Rx(r,t)),[e,t]}computeTangent(e=new G){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new G){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Rx(e,t=new G){let i=e.length();return t.set(-e.y/i,e.x/i)}var fv=e=>e,ul=new G,zu=new G,h6=new G,c6=new G,d6=new G,u6=new G,US=new E,kS=new E;function p6(e){let t=new G;t.addVectors(e.v0,ul.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new G;return i.addVectors(e.v2,zu.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Hr(e.v0,t,i,e.v2)}function eh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function f6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function m6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function jS(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function g6(e,t,i){return Nx(e,t)&&Nx(t,i)&&qm(e.position,t.position,i.position)}function qm(e,t,i){return ul.copy(t).sub(e).cross(zu.copy(i).sub(e))===0}function v6(e,t,i,r,s){let n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.y-t.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.x-e.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function y6(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function x6(e,t,i,r,s,n){let a=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,u=Math.sqrt((a+l)*(a+l)+(o+h)*(o+h)),c;return jS(t,e,i)>Math.PI&&(u*=-1),eh(h,o)?c=(o+h)*(r/u-.5)*8/3/(a-l):c=(a+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*a),n.set(i.x+c*h,i.y-c*l),[s,n]}function Bx(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Nx(e,t){return qm(e.position,e.controls[1].position,t.position)&&qm(e.position,t.controls[0].position,t.position)}function w6(e,t,i,r,s=.5){let n=ul.subVectors(t,e).multiplyScalar(s).add(e),a=zu.subVectors(i,t).multiplyScalar(s).add(t),o=h6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=c6.subVectors(a,n).multiplyScalar(s).add(n),u=d6.subVectors(o,a).multiplyScalar(s).add(a),c=o,d=u6.subVectors(u,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,u.x,u.y,c.x,c.y,r.x,r.y]}function b6(e,t,i=12,r=!0){let s=kS.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=fv(t[l]),u=ul,c=Ma(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof Hr||h instanceof kn||h instanceof Qr){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),n!==void 0&&m6(n,s))continue;n===void 0&&(n=US),n.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}return r&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),e}function _6(e,t,i,r=12,s=!0){let n=kS.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=fv(t[l]),c=ul,d=Ma(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof Hr||u instanceof kn||u instanceof Qr){if(u.getPoint(p/d,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=US:(e.setXYZ(a,h.x,h.y,h.z),a++,e.setXYZ(a,n.x,n.y,n.z),a++),h.copy(n)}}return s&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),o}function zx(e,t=12,i=!1){let r=[];for(let s=0,n=e.length;s<n;s++){let a=e[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=Ma(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Ma(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Ma(e[0].roundedCurveCorner,t)*.5),r}function Ma(e,t=12){return e&&e instanceof bu?t*2:e&&(e instanceof Qr||e instanceof Kb)?1:e&&e instanceof Eg?t*e.points.length:t}function S6(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=fv(t[a]),l=Ma(o,i),h=ul;for(let u=0;u<=l;u++)if(o instanceof Hr||o instanceof kn||o instanceof Qr){if(o.getPoint(u/l,h),s!==void 0&&f6(s,h,Nl))continue;s===void 0&&(s=zu),s.copy(h),e.push(h.x,h.y),n++}}return eh(e[0],e[e.length-2],Nl)&&eh(e[1],e[e.length-1],Nl)&&(e.pop(),e.pop()),r&&n>1&&!(eh(e[n-1],e[1],Nl)&&eh(e[n-2],e[0],Nl))&&(e.push(e[0],e[1]),n++),e}var af=new G,A6=new G,M6=new G,E6=new G,C6=new G,T6=new G,Ft=class extends Od{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new er(new E(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=it.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Ft;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Fo.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Ft.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=e-t;if(n<=s.points.length-1)return s.points[n];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=af.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=it.generateUUID()){let r;e instanceof G?r=e:r=new G(e,t);let s=new Fo(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return b6(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=zx(this.points,e,!1),this.roundedCurveDivisions=zx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return _6(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),S6(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Ma(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if(Bx(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(af.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=n[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){Bx(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&g6(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let c=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=u.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,x=v/f,w=h.getPointAt(y,af),_=u.getPointAt(x,A6);this._subSplitCurve(h,c,y,w,void 0),this._subSplitCurve(u,d,x,void 0,_);let S;if(this.useCubicForRoundedCorners){let A=jS(w,s.position,_)/2,b=Math.tan(A)*w.distanceTo(s.position),[M,C]=v6(w,_,b,M6,E6),T=y6(M,C,s.position),[D,L]=x6(T,w,_,b,C6,T6);S=new Hr(w.clone(),D.clone(),L.clone(),_.clone())}else S=new kn(w.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=S,this.roundedCurves.splice(i+t,0,S),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof Qr)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,o=n.getUtoTmapping(i,0),l=w6(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return t}clone(){let e=new Ft(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],n=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],u=e.points[r+6],c=new Fo(it.generateUUID(),new G(s,n));c.controls[0].position.set(a,o),c.controls[1].position.set(l,h),c.roundness=u,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Ft;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof Hr&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)},i=r=>{let s=[],n,a;for(n=0,a=r.length;n<a;n++)r[n]instanceof kn&&(r[n]=p6(r[n]));for(n=0,a=r.length;n<a;n++){let h=r[n],u=n>0?r[n-1]:null,c;h instanceof Hr?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof Qr&&(c=this.createPoint(h.v1)),c!==void 0&&(u!==null&&t(c,u),s.push(c))}let o=r[r.length-1],l=!1;return o instanceof Hr?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof Qr&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof Od&&(this.shapeHoles=e.holes.map(r=>{let s=new Ft;return s.fromShape(r),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},Xm=Math.PI*2;function of({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function P6(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),n=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function Fx(e,t,i,r){let s=e*r-t*i<0?-1:1,n=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(n)}function D6(e,t,i,r,s,n,a,o,l,h){let u=Math.pow(s,2),c=Math.pow(n,2),d=Math.pow(a,2),p=Math.pow(o,2),f=u*c-u*p-c*d;f<0&&(f=0),f/=u*p+c*d,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/n*o,m=f*-n/s*a,v=g+(e+i)/2,y=m+(t+r)/2,x=(a-g)/s,w=(o-m)/n,_=(-a-g)/s,S=(-o-m)/n,A=Fx(1,0,x,w),b=Fx(x,w,_,S);return!h&&b>0&&(b-=Xm),h&&b<0&&(b+=Xm),{centerx:v,centery:y,ang1:A,ang2:b}}function L6({px:e,py:t,cx:i,cy:r,rx:s,ry:n,largeArcFlag:a,sweepFlag:o}){let l=[];if(s===0||n===0)return[];let h=(e-i)/2,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),n=Math.abs(n);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(n,2);c>1&&(s*=Math.sqrt(c),n*=Math.sqrt(c));let d=D6(e,t,i,r,s,n,h,u,a,o),{ang1:p,ang2:f}=d,{centerx:g,centery:m}=d,v=Math.abs(f)/(Xm/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push(P6(p,f)),p+=f;return l.map(x=>{let{x:w,y:_}=of(x[0],s,n,g,m),{x:S,y:A}=of(x[1],s,n,g,m),{x:b,y:M}=of(x[2],s,n,g,m);return{x1:w,y1:_,x2:S,y2:A,x:b,y:M}})}var wt;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(wt||(wt={}));var Jt;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Jt||(Jt={}));function ke(e,t){if(!e)throw t||"Assertion Failed!"}var Ne=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){ke(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?s<n?i.t-t.t+(t.t-r.t)*(s/(s+n)):i.t-r.t+(r.t-t.t)*(n/(s+n)):0},e.edgeSign=function(t,i,r){ke(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?(i.t-r.t)*s+(i.t-t.t)*n:0},e.transEval=function(t,i,r){ke(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?s<n?i.s-t.s+(t.s-r.s)*(s/(s+n)):i.s-r.s+(r.s-t.s)*(n/(s+n)):0},e.transSign=function(t,i,r){ke(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?(i.s-r.s)*s+(i.s-t.s)*n:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,n){var a,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(a=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,i.s)):(a=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,s.s)):n.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(a=e.transEval(t,r,i),o=e.transEval(r,i,s),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,i.t)):(a=e.transSign(t,r,i),o=-e.transSign(t,s,i),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,s.t)):n.t=(r.t+i.t)/2},e}(),zl=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),Wc=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),xo=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),Ux=function(){function e(){var t=new xo,i=new zl,r=new Wc(0),s=new Wc(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new Wc(0),r=new Wc(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;ke(s,"Vertex can't be null!");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i;var a=i;do a.Org=s,a=a.Onext;while(a!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;ke(s,"Face can't be null");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var a=i;do a.Lface=s,a=a.Lnext;while(a!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.makeEdge=function(){var t=new xo,i=new xo,r=new zl,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var n=new xo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new zl;this.makeFace_(a,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new zl;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new xo;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),n=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(n,i),s.Org=t.Dst,n.Org=i.Org,s.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new zl;this.makeFace_(a,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,n,a,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=i);a=t.prev,o=t.next,o.prev=a,a.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,n,a,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,a=r.Org;s=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(n.Lface),o+l-2<=t&&Ne.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Ne.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(s=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,n,a,o,l,h;for(n=t,n=t;(s=n.next)!==t;n=s){ke(s.prev===n),l=s.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===s),l=l.Lnext;while(l!==s.anEdge)}for(ke(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){ke(a.prev===o),l=a.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===a),l=l.Onext;while(l!==a.anEdge)}for(ke(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)ke(l.Sym.next===h.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===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),kx=function(){function e(){this.handle=null}return e}(),jx=function(){function e(){this.key=null,this.node=0}return e}(),O6=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new kx,this.handles[r]=new jx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[i[a+1].handle].key,r[i[a].handle].key)&&++a,ke(a<=this.max),n=i[a].handle,a>this.size||this.leq(r[s].key,r[n].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t>>1,n=i[a].handle,a===0||this.leq(r[n].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,n;for(n=this.nodes.length,this.nodes.length=this.max+1,s=n;s<this.nodes.length;s++)this.nodes[s]=new kx;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new jx}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;ke(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),lf=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),Gx=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),I6=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new Gx,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new Gx;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),R6=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,n=i.eUp,a=r.eUp;if(n.Dst===s)return a.Dst===s?Ne.vertLeq(n.Org,a.Org)?Ne.edgeSign(a.Dst,n.Org,a.Org)<=0:Ne.edgeSign(n.Dst,a.Org,n.Org)>=0:Ne.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Ne.edgeSign(n.Dst,s,n.Org)>=0;var o=Ne.edgeEval(n.Dst,s,n.Org),l=Ne.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&ke(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){ke(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new lf;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case wt.ODD:return(i&1)!==0;case wt.NONZERO:return i!==0;case wt.POSITIVE:return i>0;case wt.NEGATIVE:return i<0;case wt.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,n=null,a=i,o=i.eUp;a!==r;){if(a.fixUpperEdge=!1,n=e.regionBelow(a),s=n.eUp,s.Org!=o.Org){if(!n.fixUpperEdge){e.finishRegion(t,a);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,n,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,a),o=n.eUp,a=n}return o},e.addRightEdges=function(t,i,r,s,n,a){var o,l,h,u,c=!0;h=r;do ke(Ne.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(n===null&&(n=e.regionBelow(i).eUp.Rprev),l=i,u=n;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===u.Org;)h.Onext!==u&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(u.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,u),e.deleteRegion(t,l),t.mesh.delete(u)),c=!1,l=o,u=h;l.dirty=!0,ke(l.windingNumber-h.winding===o.windingNumber),a&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Ne.vertL1dist(i,t),n=Ne.vertL1dist(r,t),a=.5*n/(s+n),o=.5*s/(s+n);t.coords[0]+=a*i.coords[0]+o*r.coords[0],t.coords[1]+=a*i.coords[1]+o*r.coords[1],t.coords[2]+=a*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,n,a){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,n,a)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp;if(Ne.vertLeq(s.Org,n.Org)){if(Ne.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Ne.vertEq(s.Org,n.Org)?s.Org!==n.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,n.Oprev,s)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(s,n.Oprev),i.dirty=r.dirty=!0)}else{if(Ne.edgeSign(s.Dst,n.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a;if(ke(!Ne.vertEq(s.Dst,n.Dst)),Ne.vertLeq(s.Dst,n.Dst)){if(Ne.edgeSign(s.Dst,n.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,a=t.mesh.splitEdge(s),t.mesh.splice(n.Sym,a),a.Lface.inside=i.inside}else{if(Ne.edgeSign(n.Dst,s.Dst,n.Org)>0)return!1;i.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(s.Lnext,n.Sym),a.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a=s.Org,o=n.Org,l=s.Dst,h=n.Dst,u,c,d=new xo,p,f;if(ke(!Ne.vertEq(h,l)),ke(Ne.edgeSign(l,t.event,a)<=0),ke(Ne.edgeSign(h,t.event,o)>=0),ke(a!==t.event&&o!==t.event),ke(!i.fixUpperEdge&&!r.fixUpperEdge),a===o||(u=Math.min(a.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(Ne.vertLeq(a,o)){if(Ne.edgeSign(h,a,o)>0)return!1}else if(Ne.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Ne.intersect(l,a,h,o,d),ke(Math.min(a.t,l.t)<=d.t),ke(d.t<=Math.max(o.t,h.t)),ke(Math.min(h.s,l.s)<=d.s),ke(d.s<=Math.max(o.s,a.s)),Ne.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Ne.vertLeq(a,o)?a:o,Ne.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Ne.vertEq(d,a)||Ne.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Ne.vertEq(l,t.event)&&Ne.edgeSign(l,t.event,d)>=0||!Ne.vertEq(h,t.event)&&Ne.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Lnext,n.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=n.Oprev,n=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,n.Onext,s.Rprev,f,!0),!0):(Ne.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Ne.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,s),s.Org.s=d.s,s.Org.t=d.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,a,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,n;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,n=r.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(n),r=e.regionBelow(i),n=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==n.Org)if(s.Dst!==n.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||n.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,n=r.Onext,a=e.regionBelow(i),o=i.eUp,l=a.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Ne.vertEq(o.Org,t.event)&&(t.mesh.splice(n.Oprev,o),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),h=!0),Ne.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,a,null),h=!0),h){e.addRightEdges(t,i,r.Onext,n,n,!0);return}Ne.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,n,a,o,l;if(s=i.eUp,Ne.vertEq(s.Org,r)){ke(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Ne.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}ke(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(ke(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Ne.edgeGoesLeft(n)||(n=null),e.addRightEdges(t,i,a.Onext,o,n,!0)},e.connectLeftVertex=function(t,i){var r,s,n,a,o,l,h=new lf;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Ne.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Ne.vertLeq(o.Dst,a.Dst)?r:s,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(i.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(o.Dnext,i.anEdge);l=u.Sym}n.fixUpperEdge?e.fixUpperEdge(t,n,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);ke(s!==null);var n=e.regionBelow(s),a=n.eUp,o=e.finishLeftRegions(t,n,null);o.Onext===a?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,a,a,!0)},e.addSentinel=function(t,i,r,s){var n=new lf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=s,a.Dst.s=i,a.Dst.t=s,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new I6(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,n=t.bmax[0]+i,a=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,n,a),e.addSentinel(t,s,n,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(ke(i.fixUpperEdge),ke(++r===1)),ke(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,n=t.mesh.eHead;for(i=n.next;i!==n;i=r)r=i.next,s=i.Lnext,Ne.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,n=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)n++;for(n+=8,i=t.pq=new O6(n,Ne.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,n;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,n=r.anEdge,ke(n.Lnext!==n),n.Lnext.Lnext===n&&(e.addWinding(n.Onext,n),t.mesh.delete(n));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Ne.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),B6=function(){function e(){this.mesh=new Ux,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=wt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,n,a,o,l=[0,0,0],h=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,f[m]=i,l[m]=n,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var v=0;v<3;++v)n=i.coords[v],n<h[v]&&(h[v]=n,f[v]=i),n>l[v]&&(l[v]=n,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[y],s=p[y],u[0]=r.coords[0]-s.coords[0],u[1]=r.coords[1]-s.coords[1],u[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],d[0]=u[1]*c[2]-u[2]*c[1],d[1]=u[2]*c[0]-u[0]*c[2],d[2]=u[0]*c[1]-u[1]*c[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>o&&(o=a,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,n=0,a=t.next;a!==t;a=a.next)if(s=a.anEdge,!(s.winding<=0))do n+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==a.anEdge);if(n<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),n=!0),r=this.sUnit,s=this.tUnit;var a=this.longAxis_(i);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,s[a]=0,s[(a+1)%3]=0,s[(a+2)%3]=i[a]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);n&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ne.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ne.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Ne.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Ne.edgeGoesLeft(s.Lnext)||Ne.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)n=t.connect(s.Lnext,s),s=n.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Ne.edgeGoesRight(r.Lprev)||Ne.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)n=t.connect(s.Lnext,s),s=n.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,n=t.eHead.next;n!==t.eHead;n=s)s=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?i:-i:r?t.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var n,a=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){n=u.anEdge,l=0;do{var h=n.Org;h.n===-1&&(h.n=o,o++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,i===Jt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(u.inside){n=u.anEdge,l=0;do{var h=n.Org;this.elements[d++]=h.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===Jt.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,u=0;n=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==s);this.elements[u++]=n,this.elements[u++]=a,n+=a}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new Ux),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,n,a){if(t===void 0&&(t=wt.ODD),i===void 0&&(i=Jt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),R6.computeInterior(this,a);var o=this.mesh;return i===Jt.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===Jt.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Rn(e){var t=e.windingRule,i=t===void 0?wt.ODD:t,r=e.elementType,s=r===void 0?Jt.POLYGONS:r,n=e.polySize,a=n===void 0?3:n,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,c=e.contours,d=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new B6;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(i,s,a,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}var x7=wt.ODD,w7=wt.NONZERO,b7=wt.POSITIVE,_7=wt.NEGATIVE,S7=wt.ABS_GEQ_TWO,A7=Jt.POLYGONS,M7=Jt.CONNECTED_POLYGONS,E7=Jt.BOUNDARY_CONTOURS,Ym=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*Ym.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*Ym.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(r,n*s,3*e);n+=3*e;let o=new Float32Array(r,n*s,3*e);n+=3*e;let l=new Float32Array(r,n*s,2*e);a.set(this.positions.slice(0,this.size*3)),o.set(this.normals.slice(0,this.size*3)),l.set(this.uvs.slice(0,this.size*2)),this.buffer=r,this.positions=a,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},GS=Ym;GS.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var mv={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},VS={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},HS={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},hf=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),WS=class extends He{constructor(e,t,i=0,r=12,s=3,n=wt.ODD){super(),this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,t/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],r),o=this._shape.shapeHoles.map(_=>{let S=_.extractShapePointsToFlatArray([],r),A=[];for(let b=S.length-1;b>=1;b-=2){let M=S[b-1],C=S[b-0];A.push(M,C)}return A}),l;try{l=Rn({windingRule:n,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]})}catch{l=mv}let h;try{h=Rn({windingRule:wt.ODD,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{h=VS}if(!l)throw new Error("error generating geometry");let u=l.elementCount;if(h){l.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let S=h.elements[_],A=_%2===0?l.vertexCount:0;l.elements.push(S+A)}for(let _=0;_<h.vertexIndices.length;_++){let S=h.vertexIndices[_],A=l.vertexCount;l.vertexIndices.push(S+A)}for(let _=0;_<h.vertices.length;_++){let S=h.vertices[_];l.vertices.push(S)}}let c=1/0,d=-1/0,p=1/0,f=-1/0;for(let _=0,S=l.vertexCount;_<S;_++){let A=_*2,b=l.vertices[A+0],M=l.vertices[A+1];b<c&&(c=b),b>d&&(d=b),M<p&&(p=M),M>f&&(f=M)}this._minX=c,this._minY=p,this._width=d-c,this._height=f-p,this._buffer=new GS(this._computeBufferEstimatedSize(l));let g=[],m=[];for(let _=l.elementCount-1;_>=0;_--){let S=_>=u,A=_*2,b=l.elements[A+0],M=l.elements[A+1],C=b+M,T={start:b,count:M,normals:[],continuous:[],concave:[]},D=b,L=C-1,P=b+1,N=this._shape.roundedCurves.length;do{let j=D-b,k=l.vertices[L*2+0],F=l.vertices[L*2+1],R=l.vertices[D*2+0],V=l.vertices[D*2+1],Q=l.vertices[P*2+0],Y=l.vertices[P*2+1],U=R-k,se=V-F,H=Math.sqrt(U*U+se*se);U/=H,se/=H;let $=R-Q,J=V-Y,ue=Math.sqrt($*$+J*J);$/=ue,J/=ue,T.normals[j*2+0]=-J,T.normals[j*2+1]=$,T.concave[j]=U*J-se*$>0;let re=l.vertexIndices[D];if(Array.isArray(re))T.continuous[j]=!1;else{let[oe,pe]=this._shape.getCurveIndexFromVertexId(re-1,!0);if(pe>0&&pe<1)T.continuous[j]=!0;else{let ye=pe===1?oe+1:oe-1;ye=(ye+N)%N;let Te=pe===1?0:1,xe=this._shape.roundedCurves[oe].getTangent(pe),be=this._shape.roundedCurves[ye].getTangent(Te);T.continuous[j]=xe.dot(be)>.95}}S&&(T.normals[j*2+0]*=-1,T.normals[j*2+1]*=-1),[L,D,P]=[D,P,P+1],P>=C&&(P-=M)}while(P!==b+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(b*2,C*2),vertexCount:M,vertexIndices:new Array(M).fill(!0).map((j,k)=>[k,k]),elements:[0,M],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(b*2,C*2)});for(let j=1;j<=this._bevelSegments;j++){let k=j/this._bevelSegments*Math.PI/2,F=(1-Math.cos(k))*this._bevelSize,R=[],V=[],Q=[],Y=[],U=0;for(let H=0;H<M;H++){let $=H*2,J=(H-1+M)%M*2,ue=l.vertices[T.start*2+$+0],re=l.vertices[T.start*2+$+1],oe=-T.normals[J+0]*F,pe=-T.normals[J+1]*F,ye=-T.normals[$+0]*F,Te=-T.normals[$+1]*F;if(T.concave[H]||!T.concave[H]&&S){let xe=Math.atan2(pe,oe),be=Math.atan2(Te,ye);be>xe&&(be-=Math.PI*2);let Ie=be-xe;if(T.continuous[H]||S){let We=xe+Ie/2,dt=Math.cos(We)*F,I=Math.sin(We)*F;R[2*U+0]=ue+dt*(S?-1:1),R[2*U+1]=re+I*(S?-1:1),Y[U]=H,U++}else{let We=Math.max(1,Math.floor(r/4*Math.abs(Ie)/Math.PI));for(let dt=0;dt<=We;dt++){let I=xe+Ie*(dt/We),O=Math.cos(I)*F,ie=Math.sin(I)*F;R[2*U+0]=ue+O,R[2*U+1]=re+ie,Y[U]=H,U++}}}else R[2*U+0]=ue+oe,R[2*U+1]=re+pe,Y[U]=H,V[H]=U,U++,R[2*U+0]=ue,R[2*U+1]=re,Y[U]=H,U++,R[2*U+0]=ue+ye,R[2*U+1]=re+Te,Y[U]=H,Q[H]=U,U++}let se=Rn({windingRule:wt.POSITIVE,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[R],edgeCreateCallback:H=>{let $=H.Org.idx,J=Y[$],ue=Y[($+1)%Y.length];H.idx=[J,ue],H.Sym.idx=[ue,J]},vertexIdCallback:H=>{let $=H.Lprev.idx;return[$?$[1]:0,H.idx?H.idx[0]:0]}});if(!se)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!se.vertexCount)break;for(let H=0;H<se.vertexIndices.length;H++){let[$,J]=se.vertexIndices[H];if($===J)continue;let ue=J;J<$&&(ue+=M);for(let re=$;re<ue;re++){let oe=re%M,pe=(re+1)%M;if(!T.continuous[oe]||!T.continuous[pe]){se.vertexIndices[H]=[$,oe],se.vertexIndices.splice(H+1,0,[pe,J]),se.vertices.splice((H+1)*2,0,se.vertices[H*2],se.vertices[H*2+1]);break}}}W.push({bevelI:j,angle:k,size:F,boundary:se,reverseMap:Y,insetPoints:R})}let q=(j,k,F)=>{let R=0,V=j.boundary.vertexIndices.length;for(;R<V&&F(j.boundary.vertexIndices[k]);)k=(k+1)%V,R++;return R},z=g.length;for(let j=1;j<W.length;j++){let k=W[j-1],F=W[j],R=k.boundary.vertexIndices.length,V=F.boundary.vertexIndices.length;if(!R||!V)break;let Q=T.concave.length,Y=0,U=hf(Y,M);for(;!k.boundary.vertexIndices.filter(U).length||!F.boundary.vertexIndices.filter(U).length;)Y++,U=hf(Y,M);let se=k.boundary.vertexIndices.findIndex(U),H=F.boundary.vertexIndices.findIndex(U);do se=(se+1)%R;while(U(k.boundary.vertexIndices[se]));do H=(H+1)%V;while(U(F.boundary.vertexIndices[H]));Y=(Y+1)%M;let $=Y,J=this._buildBevelVert(T,k,(se-1+R)%R),ue=this._buildBevelVert(T,F,(H-1+V)%V),re=J,oe=ue,pe,ye,Te=!1;do{U=hf(Y,M);let xe=q(k,se,U),be=q(F,H,U),Ie=Te;if(Te=!1,xe&&!be){for(let We=0;We<xe;We++)pe=this._buildBevelVert(T,k,(se+We)%R,We/(xe-1)),g.push(re.topN,pe.topP,oe.topN),g.push(pe.bottomP,re.bottomN,oe.bottomN),re=pe;Te=!0}else if(!xe&&be)for(let We=0;We<be;We++)ye=this._buildBevelVert(T,F,(H+We)%V,We/(be-1)),g.push(oe.topN,re.topP,ye.topP),g.push(re.bottomP,oe.bottomN,ye.bottomP),oe=ye;else if(xe&&be)if(pe=this._buildBevelVert(T,k,se,0),ye=this._buildBevelVert(T,F,H,0),Ie?(g.push(re.topN,ye.topP,oe.topN),g.push(re.topN,pe.topP,ye.topP),g.push(ye.bottomP,re.bottomN,oe.bottomN),g.push(ye.bottomP,pe.bottomP,re.bottomN)):(g.push(oe.topN,re.topN,pe.topP),g.push(oe.topN,pe.topP,ye.topP),g.push(pe.bottomP,re.bottomN,oe.bottomN),g.push(pe.bottomP,oe.bottomN,ye.bottomP)),re=pe,oe=ye,xe===be)for(let We=1;We<xe;We++)pe=this._buildBevelVert(T,k,(se+We)%R,We/(xe-1)),ye=this._buildBevelVert(T,F,(H+We)%V,We/(be-1)),g.push(re.topN,pe.topP,oe.topN),g.push(oe.topN,pe.topP,ye.topP),g.push(pe.bottomP,re.bottomN,oe.bottomN),g.push(pe.bottomP,oe.bottomN,ye.bottomP),re=pe,oe=ye;else if(xe>be){let We=xe/be,dt=0;for(let I=1;I<xe;I++)pe=this._buildBevelVert(T,k,(se+I)%R,I/(xe-1)),g.push(re.topN,pe.topP,oe.topN),g.push(pe.bottomP,re.bottomN,oe.bottomN),re=pe,I>(dt+1)*We&&(dt++,ye=this._buildBevelVert(T,F,(H+dt)%V,dt/(be-1)),g.push(oe.topN,pe.topP,ye.topP),g.push(pe.bottomP,oe.bottomN,ye.bottomP),oe=ye)}else{let We=be/xe,dt=0;for(let I=1;I<be;I++)ye=this._buildBevelVert(T,F,(H+I)%V,I/(be-1)),g.push(oe.topN,pe.topP,ye.topP),g.push(pe.bottomP,oe.bottomN,ye.bottomP),oe=ye,I>(dt+1)*We&&(dt++,pe=this._buildBevelVert(T,k,(se+dt)%R,dt/(xe-1)),g.push(re.topN,pe.topP,oe.topN),g.push(pe.bottomP,re.bottomN,oe.bottomN),re=pe)}se=(se+xe)%R,H=(H+be)%V,Y=(Y+1)%Q}while(Y!==$)}if(this._buildWall(W,T,g),S){let j=[];for(let k=g.length-1;k>=z+2;k-=3){let F=g[k-2],R=g[k-1],V=g[k-0];j.push(V,R,F)}g.splice(z,g.length-z,...j)}if(S){let j=[];for(let k=W[W.length-1].boundary.vertices.length-1;k>=1;k-=2){let F=W[W.length-1].boundary.vertices[k-1],R=W[W.length-1].boundary.vertices[k-0];j.push(F,R)}m.push(j)}if(!S){let j=W[W.length-1],k;try{k=Rn({windingRule:W.length>1?wt.POSITIVE:wt.ODD,elementType:Jt.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...m]})}catch{k=HS}if(!k)throw new Error("Error generating geometry for surface");o.length===0&&Object.assign(this,{capStartIndex:g.length});for(let F=0;F<k.elementCount*3;F+=3){let R=this._buildSurfaceVert(k,k.elements[F+0]),V=this._buildSurfaceVert(k,k.elements[F+1]),Q=this._buildSurfaceVert(k,k.elements[F+2]);g.push(R.top,V.top,Q.top),g.push(Q.bottom,V.bottom,R.bottom)}}this.vertexCache={}}this._buffer.shrink();let v=new Xe(Uint32Array.from(g),1),y=new Xe(this._buffer.positions,3),x=new Xe(this._buffer.normals,3),w=new Xe(this._buffer.uvs,2);y.needsUpdate=!0,x.needsUpdate=!0,w.needsUpdate=!0,v.needsUpdate=!0,this.setAttribute("position",y),this.setAttribute("normal",x),this.setAttribute("uv",w),this.setIndex(v)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(e,t){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let r=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(r-this._minX)/this._width,a=(s-this._minY)/this._height,o=this._buffer.get(2),l=o*3,h=o*2,u={top:o+0,bottom:o+1};return this._buffer.positions[l+0]=r,this._buffer.positions[l+1]=s,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[h+0]=n,this._buffer.uvs[h+1]=a,this._buffer.positions[l+3]=r,this._buffer.positions[l+4]=s,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[h+2]=n,this._buffer.uvs[h+3]=a,this.vertexCache[i]=u,u}_buildBevelVert(e,t,i,r=1){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[n,a]=t.boundary.vertexIndices[i],o,l,h,u;n!==a?(l=n,o=a,u=!1,h=e.continuous[l]&&e.continuous[o]):(o=n,l=(o-1+e.count)%e.count,u=e.concave[o]&&t.bevelI>0,h=e.continuous[o]||u);let c=Math.cos(t.angle),d=Math.sin(t.angle),p=i*2,f=o*2,g=l*2,m=t.boundary.vertices[p+0],v=t.boundary.vertices[p+1],y=(1-d)*this._bevelSize,x=(m-this._minX)/this._width,w=(v-this._minY)/this._height,_=e.normals[f+0],S=e.normals[f+1],A=e.normals[g+0],b=e.normals[g+1];if(u){let L=A-_,P=b-S;_=_+L*(1-r),S=S+P*(1-r);let N=Math.sqrt(_*_+S*S);_/=N,S/=N}let M=this._buffer.get(h?2:4),C=M*3,T=M*2,D={i,fi:o,topP:M+0,topN:M+0,bottomP:M+1,bottomN:M+1};return this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=_*c,this._buffer.normals[C+1]=S*c,this._buffer.normals[C+2]=d,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=_*c,this._buffer.normals[C+4]=S*c,this._buffer.normals[C+5]=-d,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x,h||(M+=2,C+=6,T+=4,D.topP=M+0,D.bottomP=M+1,this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=A*c,this._buffer.normals[C+1]=b*c,this._buffer.normals[C+2]=d,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=A*c,this._buffer.normals[C+4]=b*c,this._buffer.normals[C+5]=-d,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x),this.vertexCache[s]=D,D}clone(){let e=new WS(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Du(this.userData),e}},qS=class extends He{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=wt.ODD,this.elementType=Jt.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:wt.ODD,elementType:Jt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),n,a=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!a&&!o)break}if(!a&&!o)try{n=Rn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=mv}let u=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(u*3),3),this._normalAttribute=new Xe(new Float32Array(u*3),3),this._uvAttribute=new Xe(new Float32Array(u*2),2),this._indexAttribute=new Xe(new Uint32Array(c*3),1),n){let d=1/0,p=-1/0,f=1/0,g=-1/0;for(let y=0,x=u;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1];_<d&&(d=_),_>p&&(p=_),S<f&&(f=S),S>g&&(g=S)}let m=p-d,v=g-f;for(let y=0,x=u;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1],A=(_-d)/m,b=(S-f)/v;this._positionAttribute.setXYZ(y,_,S,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,A,b)}for(let y=0,x=c;y<x;y++){let w=y*3,_=n.elements[w+0],S=n.elements[w+1],A=n.elements[w+2];this._indexAttribute.setX(w+0,_),this._indexAttribute.setX(w+1,S),this._indexAttribute.setX(w+2,A)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(n?.elementCount??1)*3)}clone(){let e=new qS(this._shape,this._curveSegments);return e.userData=Du(this.userData),e}},XS=class extends WS{constructor(e,t,i=0,r=12,s=3,n=wt.ODD){super(e,t,i,r,s,n),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let e=new XS(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Du(this.userData),e}},za=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:wt.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=e.shape??t?.shape,o=a?.roundness??i.roundness;a!==void 0&&(a instanceof Ft?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Ft(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Ft(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:n,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:n,windingRule:a}=e.parameters;e.shape.roundness=n;let o;return t<=0?o=new qS(e.shape,s,{windingRule:a}):o=new XS(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},YS=Math.PI*2,gv=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,u=t*.5,c=i*.5,d=N6(h,u,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=za.create({shape:h,parameters:{subdivisions:d,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function N6(e,t,i,r,s,n){if(r>=YS)return s>30||s%4===0?(F6(e,t,i,n),Math.round(s/4)):Vx(e,r,s,t,i,n);r=Math.max(r,.001);let a={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=L6({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?z6(e,a.x,a.y,h,s,t,i,n):Vx(e,r,s,t,i,n)}function z6(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(Uo(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=Uo(c.x,c.y);d.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?QS(e,n,a,o):e.addPoint(Uo(0,0)),l}function Vx(e,t,i,r,s,n){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;e.addPoint(Uo(h,u))}return t<YS?n>0?QS(e,r,s,n):e.addPoint(Uo(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&ZS(e,r,s,n)),1}function F6(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(qc(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(qc(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(qc(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(qc(s,n-i,s+o,n-i,s-o,n-i)),r>0&&ZS(e,t,i,r)}function Uo(e,t){return new Fo(it.generateUUID(),new G(e,t))}function qc(e,t,i,r,s,n){let a=Uo(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function QS(e,t,i,r){KS(e,t,i,r).forEach(s=>e.addPoint(s))}function ZS(e,t,i,r){let s=KS(e,t,i,r),n=new Ft;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function KS(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new G(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=it.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var U6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:c}=e.parameters,d=new vv(!1,t,i,r,s,n,a,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},vv=class extends He{constructor(e=!0,t=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,c=1,d=!1){super();let p=e&&n===1;p&&(c=0),u>100&&(u=100);let f=()=>new E,g=new E,m=f(),v=f(),y=f(),x,w,_,S,A,b,M,C,T=f(),D=f(),L=f(),P=f(),N=f(),W=f(),q=f(),z=f(),j=i-2*o+.001,k=j/n,F=Math.ceil(a*n),R=F+1,V=j/F,Q=-j/2,Y=h+1,U=2*Math.PI/h,se=Math.PI/2/c,H=.01,$=Math.min((1-u/100)*o,o-H),J=o-$,ue=0,re=2,oe=c*re+re,pe=Y*oe/re,ye=pe+Y*R,Te=Y*(R+oe),[xe,be,Ie]=[3,3,2].map(Ee=>Array(Te*Ee).fill(0)),We=[],dt=s-o;function I(Ee,_e){let Le=Math.PI/2;b=_e*V,C=2*Math.PI*(b%k)/k+Le,b+=Q,M=Math.sin(C)*dt,A=Math.cos(C)*dt,e?Ee.set(A,M,b):Ee.set(A,b,M)}I(g,-1e-10),I(m,0),T.copy(g),I(g,1);let O=g.distanceTo(m),ie=p?0:J+$,fe=O*F+2*ie,me=$,we=fe-ie;for(let Ee=0;Ee<=F;Ee++){I(v,Ee),z.subVectors(v,T).normalize(),T.copy(v),W.copy(v).setComponent(+e+1,0).normalize(),q.crossVectors(z,W).normalize();let _e=Ee===0,Le=Ee===F,ze=_e?3*Math.PI/2:se,ot=_e?me:we,Ct=_e?Y:ye,qt=_e?0:Te-Y,X=z.clone().multiplyScalar(_e?-J:J).add(v),ne=z.clone().multiplyScalar(_e?-1:1).normalize();for(let de=0;de<Y;de++){let Se=de*U;if(D.addVectors(g.copy(W).multiplyScalar(o*Math.cos(Se)),m.copy(q).multiplyScalar(o*Math.sin(Se))),L.copy(D).normalize(),_e||Le){p||(ue=qt+de,[0,1,2].forEach(De=>{xe[ue*3+De]=X.getComponent(De),be[ue*3+De]=ne.getComponent(De)}),Ie[ue*2]=+Le,Ie[ue*2+1]=de/h),m.copy(L).multiplyScalar($),y.addVectors(v,m);for(let De=0;De<c;De++){let lt=De*se+ze;P.addVectors(g.copy(z).multiplyScalar(J*Math.sin(lt)),m.copy(L).multiplyScalar(J*Math.cos(lt))),N.copy(P).normalize(),m.addVectors(y,P),P.normalize(),ue=Ct+De*Y+de,[0,1,2].forEach(kt=>{xe[ue*3+kt]=m.getComponent(kt),be[ue*3+kt]=N.getComponent(kt)});let Xt=+_e+Math.sin(lt);Ie[ue*2]=(ot+J*Xt)/fe,Ie[ue*2+1]=de/h}}m.addVectors(v,D),ue=pe+Ee*Y+de,[0,1,2].forEach(De=>{xe[ue*3+De]=m.getComponent(De),be[ue*3+De]=L.getComponent(De)}),Ie[ue*2]=(ie+Ee*O)/fe,Ie[ue*2+1]=de/h}}let qe=R+2*c+re,Me=1,[ce,Ue]=[+p,qe-1];d&&(Ue-=1);for(let Ee=ce;Ee<=Ue-1;Ee++){let _e=p&&Ee===Ue-1;for(let Le=0;Le<Y-1;Le++)x=Ee*Y+Le,w=x+1,_=(_e?Le:x)+Y,S=(_e?Le+1:w)+Y,Ee===0?We.push(w,S,_):Ee===qe-2?We.push(x,w,_):We.push(x,w,_,w,S,_)}this.setIndex(We),this.setAttribute("position",new Ce(xe,3)),this.setAttribute("normal",new Ce(be,3)),this.setAttribute("uv",new Ce(Ie,2))}},k6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new JS(t*.5,n,a):new a_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},JS=class extends uv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,n,a,e,t,i),this.type=a}static fromJSON(e){return new JS(e.radius,e.corner,e.cornerSides)}},j6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new Od;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new $b(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ns=new ge,cf=new _t,Xc=new E,lu=class extends Fi{constructor(){super(),this.uuid=it.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new yi().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let n=0,a=s.vertexNormals.length;n<a;n++)s.vertexNormals[n].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ns.makeRotationX(e),this.applyMatrix4(ns),this}rotateY(e){return ns.makeRotationY(e),this.applyMatrix4(ns),this}rotateZ(e){return ns.makeRotationZ(e),this.applyMatrix4(ns),this}translate(e,t,i){return ns.makeTranslation(e,t,i),this.applyMatrix4(ns),this}scale(e,t,i){return ns.makeScale(e,t,i),this.applyMatrix4(ns),this}lookAt(e){return cf.lookAt(e),cf.updateMatrix(),this.applyMatrix4(cf.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,n=r.normal,a=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<s.count;c++)t.vertices.push(new E().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new Ge().fromBufferAttribute(a,c));function h(c,d,p,f){let g=a===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],m=n===void 0?[]:[new E().fromBufferAttribute(n,c),new E().fromBufferAttribute(n,d),new E().fromBufferAttribute(n,p)],v=new Qm(c,d,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new G().fromBufferAttribute(o,c),new G().fromBufferAttribute(o,d),new G().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new G().fromBufferAttribute(l,c),new G().fromBufferAttribute(l,d),new G().fromBufferAttribute(l,p)])}let u=e.groups;if(u.length>0)for(let c=0;c<u.length;c++){let d=u[c],p=d.start,f=d.count;for(let g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),d.materialIndex):h(g,g+1,g+2,d.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xc).negate(),this.translate(Xc.x,Xc.y,Xc.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new ge;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new E,t=new E;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=this.vertices[s.a],a=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,a),t.subVectors(n,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new E;if(e){let i=new E,r=new E;for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=this.vertices[a.a],l=this.vertices[a.b],h=this.vertices[a.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[a.a].add(i),t[a.b].add(i),t[a.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=s.vertexNormals;n.length===3?(n[0].copy(t[s.a]),n[1].copy(t[s.b]),n[2].copy(t[s.c])):(n[0]=t[s.a].clone(),n[1]=t[s.b].clone(),n[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,n=r.vertexNormals.length;s<n;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new lu;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let a=0,o=this.faces.length;a<o;a++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),n.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(a.normal),l.a.copy(a.vertexNormals[0]),l.b.copy(a.vertexNormals[1]),l.c.copy(a.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new $t),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,n=this.vertices,a=e.vertices,o=this.faces,l=e.faces,h=this.colors,u=e.colors;t!==void 0&&(r=new yi().getNormalMatrix(t));for(let c=0,d=a.length;c<d;c++){let p=a[c].clone();t!==void 0&&p.applyMatrix4(t),n.push(p)}for(let c=0,d=u.length;c<d;c++)h.push(u[c].clone());for(let c=0,d=l.length;c<d;c++){let p=l[c],f,g,m=p.vertexNormals,v=p.vertexColors,y=new Qm(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,w=m.length;x<w;x++)f=m[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,w=v.length;x<w;x++)g=v[x],y.vertexColors.push(g.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[y].clone());this.faceVertexUvs[c].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[u]]}let n=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let u=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(u[c]===u[(c+1)%3]){n.push(o);break}}for(let o=n.length-1;o>=0;o--){let l=n[o];this.faces.splice(l,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(l,1)}let a=this.vertices.length-i.length;return this.vertices=i,a}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new E(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],n,a;r&&r.length===t&&(n=[]),s&&s.length===t&&(a=[]);for(let o=0;o<t;o++){let l=e[o]._id;n&&n.push(r[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],s={},n=[],a={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],g=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,w=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,S=0;if(S=h(S,0,0),S=h(S,1,g),S=h(S,2,m),S=h(S,3,v),S=h(S,4,y),S=h(S,5,x),S=h(S,6,w),S=h(S,7,_),i.push(S),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let A=this.faceVertexUvs[0][p];i.push(d(A[0]),d(A[1]),d(A[2]))}if(y&&i.push(u(f.normal)),x){let A=f.vertexNormals;i.push(u(A[0]),u(A[1]),u(A[2]))}if(w&&i.push(c(f.color)),_){let A=f.vertexColors;i.push(c(A[0]),c(A[1]),c(A[2]))}}function h(p,f,g){return g?p|1<<f:p&~(1<<f)}function u(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function c(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return a[f]!==void 0||(a[f]=n.length,n.push(p.getHex())),a[f]}function d(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,n.length>0&&(e.data.colors=n),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new lu().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,d=t.length;c<d;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,d=i.length;c<d;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,d=r.length;c<d;c++)this.faces.push(r[c].clone());for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++){let w=m[y];v.push(w.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,d=s.length;c<d;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,g=s[c].vertices.length;f<g;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,g=s[c].normals.length;f<g;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let n=e.morphNormals;for(let c=0,d=n.length;c<d;c++){let p={};if(n[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,g=n[c].vertexNormals.length;f<g;f++){let m=n[c].vertexNormals[f],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=n[c].faceNormals.length;f<g;f++)p.faceNormals.push(n[c].faceNormals[f].clone())}this.morphNormals.push(p)}let a=e.skinWeights;for(let c=0,d=a.length;c<d;c++)this.skinWeights.push(a[c].clone());let o=e.skinIndices;for(let c=0,d=o.length;c<d;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,d=l.length;c<d;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new G6().fromGeometry(this),t=new He,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Yc.call(new Xe(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Yc.call(new Xe(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",Hx.call(new Xe(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",Wx.call(new Xe(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",Wx.call(new Xe(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],n=e.morphTargets[r];for(let a=0,o=n.length;a<o;a++){let l=n[a],h=new Ce(l.data.length*3,3);h.name=l.name,s.push(Yc.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Ce(e.skinIndices.length*4,4);t.setAttribute("skinIndex",qx.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Ce(e.skinWeights.length*4,4);t.setAttribute("skinWeight",qx.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new He,i=e.geometry;if(e.isPoints||e.isLine){let r=new Ce(i.vertices.length*3,3),s=new Ce(i.colors.length*3,3);if(t.setAttribute("position",Yc.call(r,i.vertices)),t.setAttribute("color",Hx.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Ce(i.lineDistances.length,1);t.setAttribute("lineDistance",V6.call(n,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};lu.prototype.isGeometry=!0;var G6=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,n=e.faces;for(r=0;r<n.length;r++){let a=n[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,n=r[1]&&r[1].length>0,a=e.morphTargets,o=a.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let m=0;m<u;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let w=v.normal;this.normals.push(w,w,w)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][m];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new G,new G,new G))}if(n===!0){let w=r[1][m];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new G,new G,new G))}for(let w=0;w<o;w++){let _=a[w].vertices;l[w].data.push(_[v.a],_[v.b],_[v.c])}for(let w=0;w<u;w++){let _=h[w].vertexNormals[m];c[w].data.push(_.a,_.b,_.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Qm=class{constructor(e,t,i,r,s,n=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new E,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Ge,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=n}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function V6(e){return this.array.set(e),this}function Hx(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new Ge),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function Wx(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new G),t[i++]=n.x,t[i++]=n.y}return this}function Yc(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new E),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function qx(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new $e),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var H6=["a","b","c"];function W6(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function df(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function uf(e,t,i,r,s,n){let a=Math.min(e,t),o=Math.max(e,t),l=a+"_"+o,h;if(r.has(l))h=r.get(l);else{let u=i[a],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),n[e].edges.push(h),n[t].edges.push(h)}function q6(e,t,i,r){let s,n,a;for(s=0,n=e.length;s<n;s++)i[s]={edges:[]};for(s=0,n=t.length;s<n;s++)a=t[s],uf(a.a,a.b,e,r,a,i),uf(a.b,a.c,e,r,a,i),uf(a.c,a.a,e,r,a,i)}function Qc(e,t,i,r,s){e.push(new Qm(t,i,r,void 0,void 0,s))}function ao(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Zc(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var X6=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof He?e=new lu().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new E,i,r,s,n,a,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,c=[],d=new Map;q6(o,l,c,d);let p=[],f,g,m,v,y,x,w;for(let se of Array.from(d.keys())){for(g=d.get(se),m=new E,y=3/8,x=1/8,w=g.faces.length,w!=2&&(y=.5,x=0,w!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),n=0;n<w;n++){for(v=g.faces[n],a=0;a<3&&(f=o[W6(v,H6[a])],!(f!==g.a&&f!==g.b));a++);f&&t.add(f)}t.multiplyScalar(x),m.add(t),g.newEdge=p.length,p.push(m)}let _,S,A,b,M,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?_=3/16:i>3&&(_=3/(8*i)),S=1-i*Number(_),A=_,i<=2&&(i==2?(S=3/4,A=1/8):i==1||i==0),T=C.clone().multiplyScalar(S),t.set(0,0,0),n=0;n<i;n++)b=M[n],f=b.a!==C?b.a:b.b,t.add(f);t.multiplyScalar(Number(A)),T.add(t),D.push(T)}let L=D.concat(p),P=D.length,N,W,q,z=[],j=[],k,F,R,V,Q=new G,Y=new G,U=new G;for(r=0,s=l.length;r<s;r++)v=l[r],N=Number(df(v.a,v.b,d).newEdge)+P,W=Number(df(v.b,v.c,d).newEdge)+P,q=Number(df(v.c,v.a,d).newEdge)+P,Qc(z,N,W,q,v.materialIndex),Qc(z,v.a,N,q,v.materialIndex),Qc(z,v.b,W,N,v.materialIndex),Qc(z,v.c,q,W,v.materialIndex),u&&(k=h[r],F=k[0],R=k[1],V=k[2],Q.set(ao(F.x,R.x),ao(F.y,R.y)),Y.set(ao(R.x,V.x),ao(R.y,V.y)),U.set(ao(F.x,V.x),ao(F.y,V.y)),Zc(j,Q,Y,U),Zc(j,F,Q,U),Zc(j,R,Y,Q),Zc(j,V,U,Y));e.vertices=L,e.faces=z,u&&(e.faceVertexUvs[0]=j)}},ti=new E,Y6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new He().copy(new Cs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ti),r={width:ti.x,height:ti.y,depth:ti.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,n=e.geometry??new He().copy(new Cs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ti)):ti.set(a.width,a.height,a.depth),(t!==ti.x||i!==ti.y||r!==ti.z)&&n.scale(ti.x===0?1:t/ti.x,ti.y===0?1:i/ti.y,ti.z===0?1:r/ti.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new X6(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new c_(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ti);let n=100/ti.x;Object.assign(s.parameters,{width:100,height:ti.y*n,depth:ti.z*n}),t(this.build(s))})}},$S=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let g=0;g<r;g++){let m=p*g,v=c+Math.sin(m)*h,y=d+Math.cos(m)*u;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=za.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},Q6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new K6(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Fl(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function pf(e,t,i,r,s,n){let a=t.clone().sub(e),o=i.clone().sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(e),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function Z6(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var K6=class extends He{constructor(e=.5,t=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),g=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new E(0,-d,0),x=new E(0,d,0),w=new G(e,-d),_=new G(f,-d),S=new G(0,x.y).sub(_),A=new G(0,x.y).sub(w),b=new G(S.y,-S.x).normalize(),M=new G(A.y,-A.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new E(b.x,b.y,0),j=new E(Math.cos(g)*z.x,z.y,Math.sin(g)*z.x);T=z.angleTo(j)}let D=n/Math.tan((Math.PI-S.angle())/2),L=n/Math.tan((Math.PI-T)/2),P=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),u.push(0,0);let z=c++,j=[],k=w.clone(),F=D/Math.cos(Math.PI/i);k.x-=F;for(let R=0;R<i;R++){let V=R/i*Math.PI*2+p,Q=new G(Math.sin(V),Math.cos(V));Fl(k,Q,P),l.push(P.x,P.y,P.z),h.push(0,-1,0),u.push(0,0),j.push(c++)}for(let R=0;R<j.length;R++)o.push(j[R],z,j[(R+1)%j.length])}let N=[];{let z=new E,j=new E,k=new E,F=new E,R=new E,V=new E;for(let Q=0;Q<i;Q++){let Y=Q/i*Math.PI*2+p,U=(Q+.5)/i*Math.PI*2+p,se=(Q+1)/i*Math.PI*2+p,H=new G(Math.sin(Y),Math.cos(Y)),$=new G(Math.sin(U),Math.cos(U)),J=new G(Math.sin(se),Math.cos(se));Fl(w,H,j),Fl(w,J,k),Fl(b,$,z),pf(x,j,k,L,L,F),l.push(F.x,F.y,F.z),pf(j,x,k,L,D,R),l.push(R.x,R.y,R.z),pf(k,j,x,D,L,V),l.push(V.x,V.y,V.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),u.push(0,0),u.push(0,0),u.push(0,0);let ue=c++,re=c++,oe=c++;if(o.push(ue,re,oe),n>0){{let Te=j.clone().add(k).multiplyScalar(.5),xe=x.clone().sub(Te).normalize(),be=y.clone().sub(Te).normalize().add(xe).normalize().multiplyScalar(-1),Ie=V.clone().sub(R);W(Te,Ie,be,S.angle())}let pe,ye;{let Te=new E;Fl(M,J,Te);let xe=V.clone().add(F).multiplyScalar(.5);xe=Z6(xe,k,x);let be=V.clone().sub(F);[pe,ye]=W(xe,be,Te,T,F.y)}{let Te=pe,xe=Te.clone().setY(0).normalize(),be=new E(0,-1,0),Ie=xe.clone().cross(be);q(Te,xe,be,Ie)}N.concat(ye);{let Te=S.angle(),xe=Math.PI-Te,be=x.clone();be.y-=n/Math.sin(Te-Math.PI/2);let Ie=new E,We=[];for(let I=0;I<a;I++){let O=[],ie=Math.PI/2-xe*I/a,fe=Math.cos(ie),me=Math.sin(ie),we=U;for(let qe=0;qe<=I;qe++){let Me=Math.cos(we),ce=Math.sin(we);z.x=fe*ce,z.y=me,z.z=fe*Me,Ie.copy(be).addScaledVector(z,n),l.push(Ie.x,Ie.y,Ie.z),h.push(z.x,z.y,z.z),u.push(0,0),O.push(c++),we+=Math.PI*2/I/i}We.push(O)}ye.reverse(),We.push(ye);let dt=We.length-1;for(let I=0;I<dt;I++){let O=We[I],ie=We[I+1],fe=O.length-1;o.push(ie[1],O[0],ie[0]);for(let me=1;me<=fe;me++)o.push(O[me],O[me-1],ie[me]),o.push(ie[me+1],O[me],ie[me])}}}}}this.setIndex(o),this.setAttribute("position",new Ce(l,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(u,2));function W(z,j,k,F,R){let V=-F/2,Q=(Math.PI-F)/2,Y=j.clone().normalize().cross(k);z.addScaledVector(k,-n/Math.sin(Q));let U=new E,se=new E,H=1,$=c,J=[];for(let ue=0;ue<=a;ue++){let re=V+ue/a*F;se.set(0,0,0),se.addScaledVector(Y,Math.sin(re)),se.addScaledVector(k,Math.cos(re));for(let oe=0;oe<=H;oe++){let pe=oe/H-.5;if(U.copy(z),U.addScaledVector(j,pe),U.addScaledVector(se,n),R!=null){let ye=Math.max(0,U.y-R);U.addScaledVector(j,-ye/j.y)}l.push(U.x,U.y,U.z),h.push(se.x,se.y,se.z),u.push(0,0),oe===0&&J.push(c),c++}}for(let ue=0;ue<a;ue++)for(let re=0;re<H;re++){let oe=$+re+(H+1)*ue,pe=oe+(H+1),ye=pe+1,Te=oe+1;o.push(oe,pe,Te),o.push(pe,ye,Te)}return[z.clone().addScaledVector(j,.5),J]}function q(z,j,k,F){let R=Math.PI/2,V=A.angle()-R,Q=[],Y=new E,U=new E;for(let H=0;H<=a;H++){let $=[],J=H/a;for(let ue=0;ue<=H;ue++){let re=((H?ue/H:0)-.5)*v,oe=Math.cos(re),pe=Math.sin(re),ye=Math.atan(Math.tan(V)*oe),Te=(R+ye)*J,xe=Math.cos(Te),be=Math.sin(Te);Y.set(0,0,0),Y.addScaledVector(j,be*oe),Y.addScaledVector(k,xe),Y.addScaledVector(F,be*pe),U.copy(z).addScaledVector(Y,n),l.push(U.x,U.y,U.z),h.push(Y.x,Y.y,Y.z),u.push(0,0),$.push(c++)}Q.push($)}let se=Q.length-1;for(let H=0;H<se;H++){let $=Q[H],J=Q[H+1],ue=$.length-1;o.push($[0],J[1],J[0]);for(let re=1;re<=ue;re++)o.push($[re-1],$[re],J[re]),o.push($[re],J[re+1],J[re])}}}},eA=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},u={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function d(w,_,S){return _>i&&S>r?Math.min(w*i/_,w*r/S):_>i?w*i/_:S>r?w*r/S:w}let p=[];p[0]=s[0]===0?0:d(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:d(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:d(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:d(s[3],s[3]+s[0],s[3]+s[2]);let f=u.x,g=c.x,m=c.y,v=u.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let w=0,_=t.points.length;w<_;w++)t.points[w].roundness=p[w],w>0&&p[w]!==p[w-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=za.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},J6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:n=64,phiStart:a,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,u=new Pg(.5*t,s,n,a,o,l,h);return u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},$6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,n=new xu(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},ek=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=e.parameters,o=new tk(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},tk=class extends He{constructor(e=1,t=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],c=Math.PI/2,d=(se=0,H=0,$=0)=>new E(se,H,$),p=d(),f=d(),[g,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[w,_,S]=[d(y,-g,+v),d(y,-g,-v),d(y,+g,-v)],A=(se,H=!1)=>Math.sin(se-Math.PI/(1+ +H)),b=(se,H=!1)=>Math.cos(se-Math.PI/(1+ +H));S.y=Math.sin(r)*t-g;let M=Math.cos(r)*t-v,C=w.z-h;r<=c?(S.z=Math.min(M,C),S.z==C&&(S.y-=(M-C)/Math.tan(c-r))):_.z=Math.min(_.z-M-v,w.z-h),p.subVectors(w,_),f.subVectors(S,_);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),L=T/Math.cos(r/2),P=p.clone().normalize().add(f.normalize()).setLength(L).add(_);p.set(0,A(r,!0),b(r,!0)),u.push([S,p.clone()]);let N=(Math.PI-r)/n;for(let se=0;se<=n;se++){let H=c+r+se*N;p.set(0,Math.sin(H)*D,Math.cos(H)*D),p.add(P),f.set(0,A(H),b(H)),u.push([p.clone(),f.clone()])}u.push([w,d(0,1,0)]);let W=Math.sin(N/2)*D*2,q=u.length-1,z=u[0][0].distanceTo(u[1][0]),j=u[q-1][0].distanceTo(u[q][0]),k=z+W*n+j;u[0].push(1);for(let se=0;se<=n;se++)u[se+1].push(1-(z+se*W)/k);u[q].push(0);let[F,R,V]=u[0],Q,Y,U;for(let se=1;se<u.length;se++)[Q,Y,U]=u[se],a.push(y,F.y,F.z,y,Q.y,Q.z,x,F.y,F.z,x,F.y,F.z,y,Q.y,Q.z,x,Q.y,Q.z),o.push(0,R.y,R.z,0,Y.y,Y.z,0,R.y,R.z,0,R.y,R.z,0,Y.y,Y.z,0,Y.y,Y.z),l.push(0,V,0,U,1,V,1,V,0,U,1,U),[F,R,V]=[Q,Y,U];this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(o,3)),this.setAttribute("uv",new Ce(l,2))}},tA=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,g=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=d*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let w=0;w<s;w++){let _=g*w,S=p+Math.sin(_)*c,A=f+Math.cos(_)*d;u.addPoint(u.createPoint(S,A))}}else for(let w=0;w<s;w++){let _=p+Math.cos(m)*c,S=f+Math.sin(m)*d;u.addPoint(u.createPoint(_,S)),m+=g,_=p+Math.cos(m)*v,S=f+Math.sin(m)*y,w<=s,u.addPoint(u.createPoint(_,S)),m+=g}u.isClosed=!0;for(let w=0,_=u.points.length;w<_;w++)u.points[w].roundness=n;u.roundness=n,u.update();let x=za.create({shape:u,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},ik=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new xu(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},rk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=sk(t,i,r,t*.5,a,n,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function sk(e,t,i,r,s,n,a,o,l,h,u){return[t,i]=[i,t],a=t/2,s/=2*Math.PI,s==1&&(h=0),new vv(!0,e,t,i,r,s,n,a,o,l,h,u)}var nk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new o_(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},ak=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5;o?(l.addPoint(l.createPoint(-h,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let c=za.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function ok(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function lk(e,t,i){let r=[new E,new E,new E],s=[new E,new E,new E];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((n,a)=>{let o=s[a],l=it.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new ge().makeBasis(r[0],r[1],r[2])}var hk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=t?.shapeData??gv.create({parameters:_S}).userData.shape;return{path:e.path??Qd.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...SS,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new ck(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new He,{userData:{...e,type:"PathGeometry"}})}},ck=class extends He{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!ok(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,n=Math.floor(r*s),a=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,a-n+1),s+2),l=[],h=[];for(let C=0;C<o;C++){let T=this.inputs.path.isClosed?(C+n)%e.length:Math.min(C+n,e.length-1);l.push(e[T].clone()),h.push(t[T].clone())}let u=(C,T,D)=>{l[C]=l[C].clone().lerp(l[T],D),h[C]=lk(h[C],h[T],D)},c=0,d=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(d||r===0)&&(c=d,u(0,1,c));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,u(l.length-1,l.length-2,1-p)),i===0){let C=l.length-1;l[C].copy(l[0]),h[C].copy(h[0])}this._applyPathModifiers(h,c,p);let{regions:g,infos:m,vertices:v}=this._computeShapePoints(5),y=0,x=0;m.sort((C,T)=>C.start-T.start),m.forEach(C=>{C.verticesStart=y,C.verticesCount=C.continuous.reduce((T,D,L)=>T+(L===0||!D?2:1),0),x+=C.verticesCount,y=x});let w=x*o,_,S=0;if(this._isOpenEnded()){try{_=Rn({windingRule:wt.ODD,elementType:Jt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:g})}catch{_=HS}S=_.vertexCount}let A=w+2*S,b={positions:new Float32Array(A*3),normals:new Float32Array(A*3),uvs:new Float32Array(A*2)},M=[];m.forEach(C=>{this._extrudeRegion(C,v,h,l,b,M,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,w,M,b,h[0],l[0],!1),this._closeEnd(_,w+S,M,b,h[h.length-1],l[l.length-1],!0)),this.setAttribute("position",new Xe(b.positions,3)),this.setAttribute("normal",new Xe(b.normals,3)),this.setAttribute("uv",new Xe(b.uvs,2)),this.setIndex(M)}_extractPathPoints(){let e=BS(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new E,n=new E,a=new E,o=new E,l=new E(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),x=v.clone().sub(g).normalize(),w=y.clone().add(x).normalize();a.copy(w),f===0&&(w.equals(l)||w.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(w).normalize(),S=w.clone().cross(_).normalize();l.copy(S),o.copy(_),f===0&&(s.copy(S),n.copy(w));let A=new ge().makeBasis(_,S,w);t.push(A)}let h=r?n:a,u=r?s:new E(0,1,0),c=h.clone().cross(o).normalize(),d=Math.acos(u.dot(c));if(isNaN(d))return t;let p=u.clone().cross(c);h.dot(p)>0&&(d*=-1);for(let f=1;f<t.length;f++){let g=new ge().makeRotationZ(d*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new ge,h=new ge;return e.forEach((u,c)=>{let d=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(it.lerp(s,s+n,d));let p=it.lerp(a,o,d);h.makeScale(p,p,p),u.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=wt.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),g=[];for(let m=f.length-1;m>=1;m-=2){let v=f[m-1],y=f[m-0];g.push(v,y)}return g}),n;try{n=Rn({windingRule:t,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=mv}let a;try{a=Rn({windingRule:wt.ODD,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=VS}if(!n)throw new Error("error generating geometry");let o=n.elementCount;if(a){n.elementCount+=a.elementCount;for(let p=0;p<a.elements.length;p++){let f=a.elements[p],g=p%2===0?n.vertexCount:0;n.elements.push(f+g)}for(let p=0;p<a.vertexIndices.length;p++){let f=a.vertexIndices[p],g=n.vertexCount;n.vertexIndices.push(f+g)}for(let p=0;p<a.vertices.length;p++){let f=a.vertices[p];n.vertices.push(f)}}let l=1/0,h=-1/0,u=1/0,c=-1/0;for(let p=0,f=n.vertexCount;p<f;p++){let g=p*2,m=n.vertices[g+0],v=n.vertices[g+1];m<l&&(l=m),m>h&&(h=m),v<u&&(u=v),v>c&&(c=v)}let d=[];for(let p=n.elementCount-1;p>=0;p--){let f=p>=o,g=p*2,m=n.elements[g+0],v=n.elements[g+1],y=m+v,x={start:m,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(x);let w=m,_=y-1,S=m+1,A=i.roundedCurves.length;do{let b=w-m,M=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[w*2+0],D=n.vertices[w*2+1],L=n.vertices[S*2+0],P=n.vertices[S*2+1],N=T-M,W=D-C,q=Math.sqrt(N*N+W*W);N/=q,W/=q;let z=T-L,j=D-P,k=Math.sqrt(z*z+j*j);z/=k,j/=k,x.normals[b*2+0]=-j,x.normals[b*2+1]=z;let F=n.vertexIndices[w];if(Array.isArray(F))x.continuous[b]=!1;else{let[R,V]=i.getCurveIndexFromVertexId(F-1,!0);if(V>0&&V<1)x.continuous[b]=!0;else{let Q=V===1?R+1:R-1;Q=(Q+A)%A;let Y=V===1?0:1,U=i.roundedCurves[R].getTangent(V),se=i.roundedCurves[Q].getTangent(Y);x.continuous[b]=U.dot(se)>.95}}f&&(x.normals[b*2+0]*=-1,x.normals[b*2+1]*=-1),[_,w,S]=[w,S,S+1],S>=y&&(S-=v)}while(S!==m+1)}return{regions:[r,...s],infos:d,vertices:n.vertices}}_insertVertex(e,t,i,r,s){let n=t*2,a=t*3;e.positions[a+0]=i.x,e.positions[a+1]=i.y,e.positions[a+2]=i.z,e.normals[a+0]=r.x,e.normals[a+1]=r.y,e.normals[a+2]=r.z,e.uvs[n+0]=s.x,e.uvs[n+1]=s.y}_extrudeRegion(e,t,i,r,s,n,a){let o=new E,l=new E,h=new E,u=new E,c=new G;i.forEach((p,f)=>{let g=r[f],m=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(g),e.continuous[v])u.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v==0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),u.copy(o).sub(l),u.set(-u.y,u.x,0),e.isHole||u.negate()}if(u.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(s,m,h,u,c),m++,!e.continuous[v]||v===0){if(v===0)u.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,f/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),u.copy(l).sub(o),u.set(-u.y,u.x,0),e.isHole||u.negate()}u.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,u,c),m++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=f+m,w=f+y,_=g+y,S=g+m;e.isHole?n.push(x,_,w,x,S,_):n.push(x,w,_,x,_,S),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new E(0,0,a?-1:1).applyMatrix4(s),h=new E,u=new G;for(let d=0;d<o;d++){let p=2*d;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(n),this._insertVertex(r,t+d,h,l,u)}let c=e.elements;for(let d=0;d<e.elementCount;d++){let p=3*d,f=c[p+0]+t,g=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(f,g,m)}}};function iA(){let e=new He;return e.setAttribute("position",new Xe(new Float32Array([]),3)),e.setIndex(new Xe(new Uint16Array([]),1)),e}var dk=iA().attributes,uk=12,pk=1,rA=class extends He{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,dk),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,text:o,textTransform:l}=e,h=l===2?o.toUpperCase():l===3?o.toLowerCase():o,u=fk(e,t,h),{shapes:c,charWidths:d,charCoords:p}=t.generateShapes(u,e),f=i*.5,g=r*.5,m=c.map(x=>new Ft().fromShape(x));this.vectorShapes=m;let v=m.map(x=>za.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?wt.NONZERO:wt.ODD,subdivisions:this.isLowResolution&&s>0?pk:uk}})),y=v.length?Co(v):iA();y.translate(-f,g,0),this.dispose(),this.wrappedText=u,this.charCoords=p,this.charWidths=d,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,w])=>{this.setAttribute(x,w)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Oa(new He,rA.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function fk(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
|
|
3139
3139
|
`?(r[r.length-1]+=s,s="",n===`
|
|
3140
|
-
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var sA,yv=new Promise(e=>{sA=e}),Xx=!1;async function mk(){if(Xx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.332/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});sA(s),Xx=!0}function hu(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Ft.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new c_().parse(e);else{if(e.type==="SubdivGeometry")return new Bi(e,i);if(e.type==="TextGeometry")return new rA(e,t)}let s;try{s=$x(r)}catch(n){console.error(n)}if(!s){let n=Ft.createFromState(Yd.defaultData(),100,100);r.shape=n,s=$x(r)}return s}var gk=new ge;function Zm(e,t,i,r){let s=e.position.array,n=e.normal.array,a=gk.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=n[u],l=n[u+1],h=n[u+2],n[u]=a[0]*o+a[4]*l+a[8]*h,n[u+1]=a[1]*o+a[5]*l+a[9]*h,n[u+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var Kc=new $t,oo=new E,Fe;yv.then(e=>{Fe=e});var Yx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Qx=new Uint32Array([0,1,2,3]),Zx=new Uint8Array([4]),Bi=class extends He{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=Aa.div(t,i);this.subdividedGeometry&&Zm(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Zm(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(oo.fromArray(r));let n=oo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Bi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Cs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Bi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Kc.setFromBufferAttribute(t),Kc.getCenter(i),e.boundingSphere.radius=i.distanceTo(Kc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Kc.getSize(oo);let r={width:oo.x,height:oo.y,depth:oo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Fe.free_bvh(t),Fe.free_subdivision_surface(t));try{s=Bi.allocate(e,r)}catch(l){console.error(l,e),s=Bi.allocate({positionWASM:Yx,indexWASM:Qx,verticesPerFaceWASM:Zx},r)}if(Fe.set_destination_refinement_level(s,0),n=Bi.buildLevel(s,!0,o),e.subdivisions>0)try{Fe.set_destination_refinement_level(s,e.subdivisions),a=Bi.buildLevel(s,!1,o)}catch{try{Fe.set_destination_refinement_level(s,e.subdivisions-1),a=Bi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:h,height:u,depth:c,arc:d,tubularSegments:p,radialSegments:f}=e;r=new vv(!0,h,c,u,h*.5,d/(2*Math.PI),p,c/2,0,f,0,0,!0)}else r=e.shape!==void 0?t.geometry:hu(e,i,!1);let s,n,a,o;({positions:s,triIndices:o}=xv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,u=h+e.radialSegments*3;l=[h,u]}return{indices:n,verticesPerFace:a}=nA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Yx,r=Qx,s=Zx);let o=i.length,l=r.length,h=s.length,u=i.length+n.length+a.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,g=Fe._malloc(d),m=new Float32Array(Fe.HEAPF32.buffer,g,u),v=new Uint32Array(Fe.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(w=>w!==1)&&(y=new ge().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Fe.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Fe.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Fe._free(g),x}static buildLevel(e,t,i,r,s){let n=s?Fe.get_mesh_data2(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i,s.elements):Fe.get_mesh_data(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i),a=8,o=Fe.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=Fe.HEAPU32[o[h]>>2],c=Fe.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Fe.HEAPU32[o[h]>>2],p=Fe.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Fe.HEAPU32[o[h]>>2],g=Fe.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Fe.HEAPU32[o[h]>>2],v=Fe.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new He;if(y.setIndex(new ah(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new ah(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Xe(x,4))}return Fe.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Fe.free_mesh_data(n)}static freeSubdivPointer(e){Fe.free_bvh(e),Fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Fe.get_wireframe_data_for_base_level(e),s=4,n=Fe.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Fe.HEAPU32[n[o]>>2],h=Fe.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=Fe.HEAPU32[n[o]>>2],c=Fe.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new He;d.setAttribute("position",new Ce(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Xe(p,3)),d.setIndex(new ah(c,1)),Fe.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Fe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Fe.set_destination_refinement_level(e,t);let s=i?Fe.get_topological_data2(e,r?Fe.Level.CONTROL:Fe.Level.REFINED,i.elements):Fe.get_topological_data(e,r?Fe.Level.CONTROL:Fe.Level.REFINED),n=6,a=Fe.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Fe.HEAPU32[a[l]>>2],u=new Float32Array(Fe.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Fe.HEAPU32[a[l]>>2],d=new Uint32Array(Fe.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Fe.HEAPU32[a[l]>>2],f=new Uint8Array(Fe.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Fe.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Kx=["getX","getY","getZ"];function xv(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[Kx[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[Kx[d]](u));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var Jc=new E,ff=new E,mf=new E,gf=new E;function nA(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let u=a.length/2/o;a=a.filter((c,d)=>Math.floor(d/2)%u===0)}let l=0;for(let u=0;u<a.length;u+=2)l+=(a[u]-a[(u===0?a.length:u)-2])*(a[u+1]+a[(u===0?a.length:u)-1]);e.length=0;let h=0;if(l<0)for(let u=0;u<a.length;u+=2)e.push(a[u],a[u+1],0),s.push(h++);else for(let u=a.length-2;u>=0;u-=2)e.push(a[u],a[u+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Jc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),ff.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),mf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),gf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),ff.sub(Jc).normalize(),mf.sub(Jc).normalize(),gf.sub(Jc).normalize();let l=ff.cross(mf).dot(gf);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let u=0,c=0;u<e.length;u+=3,c++)e[u+2]===0&&(a.push(c),l++),e[u+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let u=o[0];o[0]=o[1],o[1]=u}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var Sn={};SM(Sn,{calcBoolean:()=>bk,calcBooleanTopological:()=>wk,freeMeshSet:()=>Ak,getMeshSet:()=>_k,transformMeshSet:()=>Sk});var aA,vk=new Promise(e=>{aA=e}),Jx=!1;async function yk(){if(Jx)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.332/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});aA(s),Jx=!0}var st,ko;vk.then(e=>st=e);function xk(e,t,i){let r,{positions:s,triIndices:n}=xv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=nA(s,n,e);a=l.length,r=[];for(let h=0,u=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[u++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function oA(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=st._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(st.HEAPU32.buffer,n,t):new Float32Array(st.HEAPF32.buffer,n,t)).set(e,0),n}function lA(e){switch(e){case 0:return st.OP.UNION;case 1:return st.OP.INTERSECTION;case 2:return st.OP.A_MINUS_B;case 3:return st.OP.B_MINUS_A;case 4:return st.OP.SYMMETRIC_DIFFERENCE;case 5:return st.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function wk(e,t){ko===void 0&&(ko=st.init_csg());let i=oA(e),r=st.csg_calc_topological(ko,i,e.length,lA(t));st._free(i);let s=6,n=st.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=st.HEAPU32[n[o]>>2],h=new Float32Array(st.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=st.HEAPU32[n[o]>>2],c=new Uint32Array(st.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=st.HEAPU32[n[o]>>2],p=new Uint8Array(st.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return st.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function bk(e,t,i,r){ko===void 0&&(ko=st.init_csg());let s=oA(e),n=st.csg_calc(ko,s,e.length,r,lA(t));st._free(s);let a=5,o=st.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=st.HEAPU32[o[h]>>2],c=st.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=st.HEAPU32[o[h]>>2],p=st.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let g=st.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Tr),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},st.free_mesh_data(n),f}function _k(e,t,i){if(st===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let w=0;w<m.verticesPerFace[v];w++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=xk(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=st._malloc(u),f=new Float32Array(st.HEAPF32.buffer,p,l),g=new Uint32Array(st.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),st.get_csg_mesh(p,a,p+c,o,n)}function Sk(e,t){st.transform_csg_mesh(e,t.elements)}function Ak(e){st.free_csg_mesh(e)}var Mk={ConeGeometry:n6,CubeGeometry:a6,CylinderGeometry:s6,DodecahedronGeometry:l6,EllipseGeometry:gv,HelixGeometry:U6,IcosahedronGeometry:k6,LatheGeometry:j6,NonParametricGeometry:Y6,PolygonGeometry:$S,PyramidGeometry:Q6,RectangleGeometry:eA,SphereGeometry:J6,PlaneGeometry:$6,BackdropGeometry:ek,StarGeometry:tA,TextFrameGeometry:ik,TorusGeometry:rk,TorusKnotGeometry:nk,TriangleGeometry:ak,PathGeometry:hk,VectorGeometry:za},$x=e=>Mk[e.type].create(e);function Ul(e){return e!==null&&"booleanOp"in e}var hA=class extends NS(nr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ge}updateVisible(){super.updateVisible(),this.visible=!Ul(this.parent)&&this.visible,Ul(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Sn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ul(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof hA&&(e.freeBooleanPointer(),Ul(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ul(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},$c=new $t;function wv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<n&&(n=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}$c.min.set(n,a,o),$c.max.set(l,h,u),$c.getCenter(r),$c.getSize(s).multiplyScalar(.5)}var Ek=new He,Ck=new jh,Xi=class extends hA{constructor(e,t){super(Ek,Ck),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?wv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},ew=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},Hn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=it.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof Hn&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},Tk=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Gi=new Tk,Et=class extends Hn{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=it.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},cr=class extends Et{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},wr=class extends cr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},vr=class extends cr{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},qi=class extends Ge{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},pa=class extends cr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof qi?e:new qi(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Pk=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,tw=/[a-z_0-9]+/gi,Re=class extends Et{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=tw.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&Gi.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=Gi.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||Gi.getKeyword(c,e),g.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+a-1]!=="."&&(o=o.substring(0,u.index+a)+p+o.substring(u.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&Gi.contains(p)&&e.include(Gi.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=Pk.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(tw);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Dk=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,cA=class extends Et{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||cA.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=Dk.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},yt=cA;yt.PI="PI",yt.PI2="PI2",yt.RECIPROCAL_PI="RECIPROCAL_PI",yt.RECIPROCAL_PI2="RECIPROCAL_PI2",yt.LOG2="LOG2",yt.EPSILON="EPSILON";var Lk=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3140
|
+
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var sA,yv=new Promise(e=>{sA=e}),Xx=!1;async function mk(){if(Xx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.333/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});sA(s),Xx=!0}function hu(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Ft.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new c_().parse(e);else{if(e.type==="SubdivGeometry")return new Bi(e,i);if(e.type==="TextGeometry")return new rA(e,t)}let s;try{s=$x(r)}catch(n){console.error(n)}if(!s){let n=Ft.createFromState(Yd.defaultData(),100,100);r.shape=n,s=$x(r)}return s}var gk=new ge;function Zm(e,t,i,r){let s=e.position.array,n=e.normal.array,a=gk.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=n[u],l=n[u+1],h=n[u+2],n[u]=a[0]*o+a[4]*l+a[8]*h,n[u+1]=a[1]*o+a[5]*l+a[9]*h,n[u+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var Kc=new $t,oo=new E,Fe;yv.then(e=>{Fe=e});var Yx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Qx=new Uint32Array([0,1,2,3]),Zx=new Uint8Array([4]),Bi=class extends He{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=Aa.div(t,i);this.subdividedGeometry&&Zm(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Zm(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(oo.fromArray(r));let n=oo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Bi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Cs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Bi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Kc.setFromBufferAttribute(t),Kc.getCenter(i),e.boundingSphere.radius=i.distanceTo(Kc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Kc.getSize(oo);let r={width:oo.x,height:oo.y,depth:oo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Fe.free_bvh(t),Fe.free_subdivision_surface(t));try{s=Bi.allocate(e,r)}catch(l){console.error(l,e),s=Bi.allocate({positionWASM:Yx,indexWASM:Qx,verticesPerFaceWASM:Zx},r)}if(Fe.set_destination_refinement_level(s,0),n=Bi.buildLevel(s,!0,o),e.subdivisions>0)try{Fe.set_destination_refinement_level(s,e.subdivisions),a=Bi.buildLevel(s,!1,o)}catch{try{Fe.set_destination_refinement_level(s,e.subdivisions-1),a=Bi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:h,height:u,depth:c,arc:d,tubularSegments:p,radialSegments:f}=e;r=new vv(!0,h,c,u,h*.5,d/(2*Math.PI),p,c/2,0,f,0,0,!0)}else r=e.shape!==void 0?t.geometry:hu(e,i,!1);let s,n,a,o;({positions:s,triIndices:o}=xv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,u=h+e.radialSegments*3;l=[h,u]}return{indices:n,verticesPerFace:a}=nA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Yx,r=Qx,s=Zx);let o=i.length,l=r.length,h=s.length,u=i.length+n.length+a.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,g=Fe._malloc(d),m=new Float32Array(Fe.HEAPF32.buffer,g,u),v=new Uint32Array(Fe.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(w=>w!==1)&&(y=new ge().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Fe.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Fe.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Fe._free(g),x}static buildLevel(e,t,i,r,s){let n=s?Fe.get_mesh_data2(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i,s.elements):Fe.get_mesh_data(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i),a=8,o=Fe.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=Fe.HEAPU32[o[h]>>2],c=Fe.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Fe.HEAPU32[o[h]>>2],p=Fe.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Fe.HEAPU32[o[h]>>2],g=Fe.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Fe.HEAPU32[o[h]>>2],v=Fe.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new He;if(y.setIndex(new ah(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new ah(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Xe(x,4))}return Fe.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Fe.free_mesh_data(n)}static freeSubdivPointer(e){Fe.free_bvh(e),Fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Fe.get_wireframe_data_for_base_level(e),s=4,n=Fe.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Fe.HEAPU32[n[o]>>2],h=Fe.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=Fe.HEAPU32[n[o]>>2],c=Fe.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new He;d.setAttribute("position",new Ce(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Xe(p,3)),d.setIndex(new ah(c,1)),Fe.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Fe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Fe.set_destination_refinement_level(e,t);let s=i?Fe.get_topological_data2(e,r?Fe.Level.CONTROL:Fe.Level.REFINED,i.elements):Fe.get_topological_data(e,r?Fe.Level.CONTROL:Fe.Level.REFINED),n=6,a=Fe.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Fe.HEAPU32[a[l]>>2],u=new Float32Array(Fe.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Fe.HEAPU32[a[l]>>2],d=new Uint32Array(Fe.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Fe.HEAPU32[a[l]>>2],f=new Uint8Array(Fe.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Fe.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Kx=["getX","getY","getZ"];function xv(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[Kx[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[Kx[d]](u));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var Jc=new E,ff=new E,mf=new E,gf=new E;function nA(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let u=a.length/2/o;a=a.filter((c,d)=>Math.floor(d/2)%u===0)}let l=0;for(let u=0;u<a.length;u+=2)l+=(a[u]-a[(u===0?a.length:u)-2])*(a[u+1]+a[(u===0?a.length:u)-1]);e.length=0;let h=0;if(l<0)for(let u=0;u<a.length;u+=2)e.push(a[u],a[u+1],0),s.push(h++);else for(let u=a.length-2;u>=0;u-=2)e.push(a[u],a[u+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Jc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),ff.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),mf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),gf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),ff.sub(Jc).normalize(),mf.sub(Jc).normalize(),gf.sub(Jc).normalize();let l=ff.cross(mf).dot(gf);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let u=0,c=0;u<e.length;u+=3,c++)e[u+2]===0&&(a.push(c),l++),e[u+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let u=o[0];o[0]=o[1],o[1]=u}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var Sn={};SM(Sn,{calcBoolean:()=>bk,calcBooleanTopological:()=>wk,freeMeshSet:()=>Ak,getMeshSet:()=>_k,transformMeshSet:()=>Sk});var aA,vk=new Promise(e=>{aA=e}),Jx=!1;async function yk(){if(Jx)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.333/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});aA(s),Jx=!0}var st,ko;vk.then(e=>st=e);function xk(e,t,i){let r,{positions:s,triIndices:n}=xv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=nA(s,n,e);a=l.length,r=[];for(let h=0,u=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[u++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function oA(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=st._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(st.HEAPU32.buffer,n,t):new Float32Array(st.HEAPF32.buffer,n,t)).set(e,0),n}function lA(e){switch(e){case 0:return st.OP.UNION;case 1:return st.OP.INTERSECTION;case 2:return st.OP.A_MINUS_B;case 3:return st.OP.B_MINUS_A;case 4:return st.OP.SYMMETRIC_DIFFERENCE;case 5:return st.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function wk(e,t){ko===void 0&&(ko=st.init_csg());let i=oA(e),r=st.csg_calc_topological(ko,i,e.length,lA(t));st._free(i);let s=6,n=st.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=st.HEAPU32[n[o]>>2],h=new Float32Array(st.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=st.HEAPU32[n[o]>>2],c=new Uint32Array(st.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=st.HEAPU32[n[o]>>2],p=new Uint8Array(st.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return st.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function bk(e,t,i,r){ko===void 0&&(ko=st.init_csg());let s=oA(e),n=st.csg_calc(ko,s,e.length,r,lA(t));st._free(s);let a=5,o=st.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=st.HEAPU32[o[h]>>2],c=st.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=st.HEAPU32[o[h]>>2],p=st.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let g=st.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Tr),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},st.free_mesh_data(n),f}function _k(e,t,i){if(st===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let w=0;w<m.verticesPerFace[v];w++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=xk(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=st._malloc(u),f=new Float32Array(st.HEAPF32.buffer,p,l),g=new Uint32Array(st.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),st.get_csg_mesh(p,a,p+c,o,n)}function Sk(e,t){st.transform_csg_mesh(e,t.elements)}function Ak(e){st.free_csg_mesh(e)}var Mk={ConeGeometry:n6,CubeGeometry:a6,CylinderGeometry:s6,DodecahedronGeometry:l6,EllipseGeometry:gv,HelixGeometry:U6,IcosahedronGeometry:k6,LatheGeometry:j6,NonParametricGeometry:Y6,PolygonGeometry:$S,PyramidGeometry:Q6,RectangleGeometry:eA,SphereGeometry:J6,PlaneGeometry:$6,BackdropGeometry:ek,StarGeometry:tA,TextFrameGeometry:ik,TorusGeometry:rk,TorusKnotGeometry:nk,TriangleGeometry:ak,PathGeometry:hk,VectorGeometry:za},$x=e=>Mk[e.type].create(e);function Ul(e){return e!==null&&"booleanOp"in e}var hA=class extends NS(nr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ge}updateVisible(){super.updateVisible(),this.visible=!Ul(this.parent)&&this.visible,Ul(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Sn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ul(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof hA&&(e.freeBooleanPointer(),Ul(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ul(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},$c=new $t;function wv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<n&&(n=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}$c.min.set(n,a,o),$c.max.set(l,h,u),$c.getCenter(r),$c.getSize(s).multiplyScalar(.5)}var Ek=new He,Ck=new jh,Xi=class extends hA{constructor(e,t){super(Ek,Ck),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?wv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},ew=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},Hn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=it.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof Hn&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},Tk=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Gi=new Tk,Et=class extends Hn{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=it.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},cr=class extends Et{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},wr=class extends cr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},vr=class extends cr{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},qi=class extends Ge{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},pa=class extends cr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof qi?e:new qi(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Pk=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,tw=/[a-z_0-9]+/gi,Re=class extends Et{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=tw.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&Gi.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=Gi.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||Gi.getKeyword(c,e),g.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+a-1]!=="."&&(o=o.substring(0,u.index+a)+p+o.substring(u.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&Gi.contains(p)&&e.include(Gi.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=Pk.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(tw);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Dk=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,cA=class extends Et{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||cA.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=Dk.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},yt=cA;yt.PI="PI",yt.PI2="PI2",yt.RECIPROCAL_PI="RECIPROCAL_PI",yt.RECIPROCAL_PI2="RECIPROCAL_PI2",yt.LOG2="LOG2",yt.EPSILON="EPSILON";var Lk=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3141
3141
|
)*?)}`,"gim"),Ok=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),dA=class extends Et{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=Lk.exec(e);if(t){let i=t[2],r;for(;r=Ok.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},bv=class extends Et{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};Gi.addKeyword("uv",function(){return new bv});Gi.addKeyword("uv2",function(){return new bv(1)});var wo=class extends Et{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??wo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Es:return["Linear"];case Ke:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=wo.Nodes[this.method],n=e.include(s);if(n===wo.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let a=this.factor.build(e,"f");return e.format(n+"( "+i+", "+a+" )",r,t)}else return e.format(n+"( "+i+" )",r,t)}fromEncoding(e){let t=wo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=wo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},ws=wo;ws.Nodes={LinearToLinear:new Re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3142
3142
|
`)),sRGBToLinear:new Re(["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 Re(["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(`
|
|
@@ -5209,7 +5209,7 @@ outputColor=vec4(color,inputColor.a);}`,hd={DEFAULT:0,ESKIL:1},M9=class extends
|
|
|
5209
5209
|
void main() {
|
|
5210
5210
|
gl_FragColor = vec4(0.0);
|
|
5211
5211
|
}
|
|
5212
|
-
`}),Yf=class extends Or{constructor(e,t){super("OpaquePass",e??Mb,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??Mb}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof Xi&&(this.originalMaterials.set(r.id,r.material),r.material=N9)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function Eb(e,t){return t&&t.enabled&&e.push(t.effect),e}var z9=e=>Object.values(at).includes(e)?e:at.NORMAL,F9=class extends Fi{constructor(e){super(),this.postprocessingState=Oh.defaultData,this._scene=new _a,this._camera=new Ni,this.effects=new Map,this._renderToScreen=!0,this.clock=new CL,this.renderer=e,this.debug=!1,this.effects.set("bloom",new E9),this.effects.set("chromaticAberration",new T9),this.effects.set("vignette",new O9),this.effects.set("noise",new L9),this.effects.set("colorAverage",new P9),this.effects.set("hueSaturation",new D9),this.effects.set("brightnessContrast",new C9),this.effects.set("depthOfField",new I9),this.effects.set("pixelation",new R9),this.effectComposer=new r9(this.renderer),this.opaquePass=new Yf(this.scene,this.camera),this.transmissionPass=new B9(this.scene,this.camera,this.renderer),this.helperPass=new Yf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Hu(!1,!0,!1),this.helperPassOnTop=new Yf(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 S9({preset:_o.ULTRA,edgeDetectionMode:Hv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=k2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Wf(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(Eb,[]);e.length>0&&(this.uvEffectPass=new Wf(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Eb,[]);t.length>0&&(this.effectPass=new Wf(this.camera,...t),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 G;this.renderer.getDrawingBufferSize(e),this._rt=new ni(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:xh,wrapT:xh}),this._rt.samples=0,this._savePass=new vu(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=z9(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){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,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Cb=new pi,U9=class extends Qb{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new F9(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ni(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ho,magFilter:gt,wrapS:ir,wrapT:ir,depthBuffer:!1}),this.transmissionDepthTarget=new ni(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Rt,magFilter:Rt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ni(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Rt,magFilter:Rt,type:Pn,depthTexture:new Ag(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Ni?Ef.uniforms.depthContrast.value=(t.far-t.near)/1e4:Ef.uniforms.depthContrast.value=1,e.overrideMaterial=Ef,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?sg:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{It.penumbraSize.value[o]=a}),It.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?It.resolution.value.set(this.resolution.x,this.resolution.y):It.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(It.normalRenderTarget.value=this.overrideNormal,It.normalRenderTargetDepth.value=Cb):e.needsNormal()&&(this.createNormalRenderTarget(),It.normalRenderTarget.value=this.normalRenderTarget.texture,It.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)It.transmissionRenderTarget.value=this.overrideTransmission,It.transmissionRenderTargetDepth.value=Cb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),It.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,It.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?sg:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},k9=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Fu(e.shared,t),this.scene=new Er(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Dr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},j9=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function G9(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function yh(e){return e instanceof Nh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function V9(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Xi)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Xi&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!hr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!hr.isMergable(l.material))return;n=hr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][yh(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][yh(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][yh(r)].push(l)}),i}function H9(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function W9(e,t){let i=V9(t,e),r=H9(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof Xi&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&G9(a[m]);let g=Co(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new nr(g,l[0].material);break}default:{m=new nr(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof Xi&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][yh(x)]&&i[x.material.uuid][yh(x)].length>1||(u[c++]=x));for(let x=0;x<c;x++)t.attach(u[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var q9=Fh(CM(),1),X9=new G;function Y9(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var qv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&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._resize=Jg(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=X9.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.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new j9({x:10,y:10})),UF(e)}async load(e,t){Y9(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await sH(e);this._data=i,i.version&&(0,q9.default)(i.version,"0.9.332")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([ww(i)&&yk(),D8(i)&&mk(),i.scene.environment.usePhysics&&iF(),mw(i)&&v8()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new k9(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();W9(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}ww(i)&&this._scene.traverse(n=>{Zs(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(n=>{n instanceof va&&n.pendingMediaLoad&&n.update()})});let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this.requestRender()}),mw(i)&&IV(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),D2(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new U9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?yg:Pb,mj(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new aH(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}t&&(this._scene.updateMatrixWorld(!0),this._controls=new RV(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new nH(this._renderer,this._scene,this._camera,i.scene.publish,this._sharedAssetsManager,this.requestRender,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)),this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof F2&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new qi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}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(e=>{Ky.unsubscribe(e)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),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(),kF(this.canvas)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=Ky(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Wu=window,qu=Wu.ShadowRoot&&(Wu.ShadyCSS===void 0||Wu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Xv=Symbol(),V2=new WeakMap,Jh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Xv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(qu&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=V2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&V2.set(i,t))}return t}toString(){return this.cssText}},H2=e=>new Jh(typeof e=="string"?e:e+"",void 0,Xv),Yv=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new Jh(i,e,Xv)},Qv=(e,t)=>{qu?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Wu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Xu=qu?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return H2(i)})(e):e;var Zv,Yu=window,W2=Yu.trustedTypes,Q9=W2?W2.emptyScript:"",q2=Yu.reactiveElementPolyfillSupport,Jv={toAttribute(e,t){switch(t){case Boolean:e=e?Q9:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},X2=(e,t)=>t!==e&&(t==t||e==e),Kv={attribute:!0,type:String,converter:Jv,reflect:!1,hasChanged:X2},on=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=Kv){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Kv}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Xu(s))}else t!==void 0&&i.push(Xu(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Qv(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=Kv){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Jv).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:Jv;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||X2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};on.finalized=!0,on.elementProperties=new Map,on.elementStyles=[],on.shadowRootOptions={mode:"open"},q2?.({ReactiveElement:on}),((Zv=Yu.reactiveElementVersions)!==null&&Zv!==void 0?Zv:Yu.reactiveElementVersions=[]).push("1.6.0");var $v,Qu=window,fl=Qu.trustedTypes,Y2=fl?fl.createPolicy("lit-html",{createHTML:e=>e}):void 0,qn=`lit$${(Math.random()+"").slice(9)}$`,tM="?"+qn,Z9=`<${tM}>`,ml=document,ec=(e="")=>ml.createComment(e),tc=e=>e===null||typeof e!="object"&&typeof e!="function",iM=Array.isArray,K9=e=>iM(e)||typeof e?.[Symbol.iterator]=="function",$h=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Q2=/-->/g,Z2=/>/g,Ua=RegExp(`>|[
|
|
5212
|
+
`}),Yf=class extends Or{constructor(e,t){super("OpaquePass",e??Mb,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??Mb}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof Xi&&(this.originalMaterials.set(r.id,r.material),r.material=N9)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function Eb(e,t){return t&&t.enabled&&e.push(t.effect),e}var z9=e=>Object.values(at).includes(e)?e:at.NORMAL,F9=class extends Fi{constructor(e){super(),this.postprocessingState=Oh.defaultData,this._scene=new _a,this._camera=new Ni,this.effects=new Map,this._renderToScreen=!0,this.clock=new CL,this.renderer=e,this.debug=!1,this.effects.set("bloom",new E9),this.effects.set("chromaticAberration",new T9),this.effects.set("vignette",new O9),this.effects.set("noise",new L9),this.effects.set("colorAverage",new P9),this.effects.set("hueSaturation",new D9),this.effects.set("brightnessContrast",new C9),this.effects.set("depthOfField",new I9),this.effects.set("pixelation",new R9),this.effectComposer=new r9(this.renderer),this.opaquePass=new Yf(this.scene,this.camera),this.transmissionPass=new B9(this.scene,this.camera,this.renderer),this.helperPass=new Yf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Hu(!1,!0,!1),this.helperPassOnTop=new Yf(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 S9({preset:_o.ULTRA,edgeDetectionMode:Hv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=k2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Wf(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(Eb,[]);e.length>0&&(this.uvEffectPass=new Wf(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Eb,[]);t.length>0&&(this.effectPass=new Wf(this.camera,...t),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 G;this.renderer.getDrawingBufferSize(e),this._rt=new ni(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:xh,wrapT:xh}),this._rt.samples=0,this._savePass=new vu(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=z9(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){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,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Cb=new pi,U9=class extends Qb{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new F9(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ni(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ho,magFilter:gt,wrapS:ir,wrapT:ir,depthBuffer:!1}),this.transmissionDepthTarget=new ni(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Rt,magFilter:Rt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ni(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Rt,magFilter:Rt,type:Pn,depthTexture:new Ag(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Ni?Ef.uniforms.depthContrast.value=(t.far-t.near)/1e4:Ef.uniforms.depthContrast.value=1,e.overrideMaterial=Ef,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?sg:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{It.penumbraSize.value[o]=a}),It.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?It.resolution.value.set(this.resolution.x,this.resolution.y):It.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(It.normalRenderTarget.value=this.overrideNormal,It.normalRenderTargetDepth.value=Cb):e.needsNormal()&&(this.createNormalRenderTarget(),It.normalRenderTarget.value=this.normalRenderTarget.texture,It.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)It.transmissionRenderTarget.value=this.overrideTransmission,It.transmissionRenderTargetDepth.value=Cb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),It.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,It.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?sg:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},k9=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Fu(e.shared,t),this.scene=new Er(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Dr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},j9=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function G9(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function yh(e){return e instanceof Nh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function V9(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Xi)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Xi&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!hr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!hr.isMergable(l.material))return;n=hr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][yh(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][yh(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][yh(r)].push(l)}),i}function H9(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function W9(e,t){let i=V9(t,e),r=H9(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof Xi&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&G9(a[m]);let g=Co(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new nr(g,l[0].material);break}default:{m=new nr(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof Xi&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][yh(x)]&&i[x.material.uuid][yh(x)].length>1||(u[c++]=x));for(let x=0;x<c;x++)t.attach(u[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var q9=Fh(CM(),1),X9=new G;function Y9(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var qv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&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._resize=Jg(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=X9.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.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new j9({x:10,y:10})),UF(e)}async load(e,t){Y9(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await sH(e);this._data=i,i.version&&(0,q9.default)(i.version,"0.9.333")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([ww(i)&&yk(),D8(i)&&mk(),i.scene.environment.usePhysics&&iF(),mw(i)&&v8()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new k9(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();W9(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}ww(i)&&this._scene.traverse(n=>{Zs(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(n=>{n instanceof va&&n.pendingMediaLoad&&n.update()})});let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this.requestRender()}),mw(i)&&IV(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),D2(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new U9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?yg:Pb,mj(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new aH(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}t&&(this._scene.updateMatrixWorld(!0),this._controls=new RV(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new nH(this._renderer,this._scene,this._camera,i.scene.publish,this._sharedAssetsManager,this.requestRender,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)),this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof F2&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new qi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}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(e=>{Ky.unsubscribe(e)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),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(),kF(this.canvas)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=Ky(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Wu=window,qu=Wu.ShadowRoot&&(Wu.ShadyCSS===void 0||Wu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Xv=Symbol(),V2=new WeakMap,Jh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Xv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(qu&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=V2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&V2.set(i,t))}return t}toString(){return this.cssText}},H2=e=>new Jh(typeof e=="string"?e:e+"",void 0,Xv),Yv=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new Jh(i,e,Xv)},Qv=(e,t)=>{qu?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Wu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Xu=qu?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return H2(i)})(e):e;var Zv,Yu=window,W2=Yu.trustedTypes,Q9=W2?W2.emptyScript:"",q2=Yu.reactiveElementPolyfillSupport,Jv={toAttribute(e,t){switch(t){case Boolean:e=e?Q9:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},X2=(e,t)=>t!==e&&(t==t||e==e),Kv={attribute:!0,type:String,converter:Jv,reflect:!1,hasChanged:X2},on=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=Kv){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Kv}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Xu(s))}else t!==void 0&&i.push(Xu(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Qv(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=Kv){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Jv).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:Jv;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||X2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};on.finalized=!0,on.elementProperties=new Map,on.elementStyles=[],on.shadowRootOptions={mode:"open"},q2?.({ReactiveElement:on}),((Zv=Yu.reactiveElementVersions)!==null&&Zv!==void 0?Zv:Yu.reactiveElementVersions=[]).push("1.6.0");var $v,Qu=window,fl=Qu.trustedTypes,Y2=fl?fl.createPolicy("lit-html",{createHTML:e=>e}):void 0,qn=`lit$${(Math.random()+"").slice(9)}$`,tM="?"+qn,Z9=`<${tM}>`,ml=document,ec=(e="")=>ml.createComment(e),tc=e=>e===null||typeof e!="object"&&typeof e!="function",iM=Array.isArray,K9=e=>iM(e)||typeof e?.[Symbol.iterator]=="function",$h=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Q2=/-->/g,Z2=/>/g,Ua=RegExp(`>|[
|
|
5213
5213
|
\f\r](?:([^\\s"'>=/]+)([
|
|
5214
5214
|
\f\r]*=[
|
|
5215
5215
|
\f\r]*(?:[^
|