@splinetool/runtime 0.9.381 → 0.9.382

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.cjs CHANGED
@@ -3135,9 +3135,9 @@ void main() {
3135
3135
  squared_mean = squared_mean / samples;
3136
3136
  float std_dev = sqrt( squared_mean - mean * mean );
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
- }`;function PB(r,t,e){let n=new yh,i=new F,s=new F,o=new Ze,a=new vh({depthPacking:J0}),l=new T0,u={},c=e.maxTextureSize,d={[si]:On,[On]:si,[Ir]:Ir},h=new ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:TB,fragmentShader:CB}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new Me;m.setAttribute("position",new Be(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new In(m,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=im,this.render=function(w,S,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let M=r.getRenderTarget(),b=r.getActiveCubeFace(),E=r.getActiveMipmapLevel(),T=r.state;T.setBlending(Dt),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let P=0,D=w.length;P<D;P++){let C=w[P],O=C.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",C,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);let B=O.getFrameExtents();if(i.multiply(B),s.copy(O.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/B.x),i.x=s.x*B.x,O.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/B.y),i.y=s.y*B.y,O.mapSize.y=s.y)),O.map===null){let Y=this.type!==ah?{minFilter:Pt,magFilter:Pt}:{};O.map=new st(i.x,i.y,Y),O.map.texture.name=C.name+".shadowMap",O.camera.updateProjectionMatrix()}r.setRenderTarget(O.map),r.clear();let V=O.getViewportCount();for(let Y=0;Y<V;Y++){let W=O.getViewport(Y);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),T.viewport(o),O.updateMatrices(C,Y),n=O.getFrustum(),x(S,_,O.camera,C,this.type)}O.isPointLightShadow!==!0&&this.type===ah&&y(O,_),O.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(M,b,E)};function y(w,S){let _=t.update(p);h.defines.VSM_SAMPLES!==w.blurSamples&&(h.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new st(i.x,i.y)),h.uniforms.shadow_pass.value=w.map.texture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(S,null,_,h,p,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(S,null,_,f,p,null)}function v(w,S,_,M,b,E){let T=null,P=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(P!==void 0)T=P;else if(T=_.isPointLight===!0?l:a,r.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let D=T.uuid,C=S.uuid,O=u[D];O===void 0&&(O={},u[D]=O);let B=O[C];B===void 0&&(B=T.clone(),O[C]=B),T=B}return T.visible=S.visible,T.wireframe=S.wireframe,E===ah?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:d[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,_.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(_.matrixWorld),T.nearDistance=M,T.farDistance=b),T}function x(w,S,_,M,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===ah)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let P=t.update(w),D=w.material;if(Array.isArray(D)){let C=P.groups;for(let O=0,B=C.length;O<B;O++){let V=C[O],Y=D[V.materialIndex];if(Y&&Y.visible){let W=v(w,Y,M,_.near,_.far,b);r.renderBufferDirect(_,null,P,W,w,V)}}}else if(D.visible){let C=v(w,D,M,_.near,_.far,b);r.renderBufferDirect(_,null,P,C,w,null)}}let T=w.children;for(let P=0,D=T.length;P<D;P++)x(T[P],S,_,M,b)}}function DB(r,t,e){let n=e.isWebGL2;function i(){let Q=!1,se=new Ze,ge=null,Le=new Ze(0,0,0,0);return{setMask:function(Oe){ge!==Oe&&!Q&&(r.colorMask(Oe,Oe,Oe,Oe),ge=Oe)},setLocked:function(Oe){Q=Oe},setClear:function(Oe,vt,Tn,pn,Oa){Oa===!0&&(Oe*=pn,vt*=pn,Tn*=pn),se.set(Oe,vt,Tn,pn),Le.equals(se)===!1&&(r.clearColor(Oe,vt,Tn,pn),Le.copy(se))},reset:function(){Q=!1,ge=null,Le.set(-1,0,0,0)}}}function s(){let Q=!1,se=null,ge=null,Le=null;return{setTest:function(Oe){Oe?re(2929):K(2929)},setMask:function(Oe){se!==Oe&&!Q&&(r.depthMask(Oe),se=Oe)},setFunc:function(Oe){if(ge!==Oe){switch(Oe){case oO:r.depthFunc(512);break;case aO:r.depthFunc(519);break;case lO:r.depthFunc(513);break;case h0:r.depthFunc(515);break;case cO:r.depthFunc(514);break;case uO:r.depthFunc(518);break;case dO:r.depthFunc(516);break;case hO:r.depthFunc(517);break;default:r.depthFunc(515)}ge=Oe}},setLocked:function(Oe){Q=Oe},setClear:function(Oe){Le!==Oe&&(r.clearDepth(Oe),Le=Oe)},reset:function(){Q=!1,se=null,ge=null,Le=null}}}function o(){let Q=!1,se=null,ge=null,Le=null,Oe=null,vt=null,Tn=null,pn=null,Oa=null;return{setTest:function(Qt){Q||(Qt?re(2960):K(2960))},setMask:function(Qt){se!==Qt&&!Q&&(r.stencilMask(Qt),se=Qt)},setFunc:function(Qt,Qs,pi){(ge!==Qt||Le!==Qs||Oe!==pi)&&(r.stencilFunc(Qt,Qs,pi),ge=Qt,Le=Qs,Oe=pi)},setOp:function(Qt,Qs,pi){(vt!==Qt||Tn!==Qs||pn!==pi)&&(r.stencilOp(Qt,Qs,pi),vt=Qt,Tn=Qs,pn=pi)},setLocked:function(Qt){Q=Qt},setClear:function(Qt){Oa!==Qt&&(r.clearStencil(Qt),Oa=Qt)},reset:function(){Q=!1,se=null,ge=null,Le=null,Oe=null,vt=null,Tn=null,pn=null,Oa=null}}}let a=new i,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,P=null,D=null,C=null,O=null,B=r.getParameter(35661),V=!1,Y=0,W=r.getParameter(7938);W.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(W)[1]),V=Y>=1):W.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),V=Y>=2);let q=null,j={},X=r.getParameter(3088),L=r.getParameter(2978),U=new Ze().fromArray(X),G=new Ze().fromArray(L);function H(Q,se,ge){let Le=new Uint8Array(4),Oe=r.createTexture();r.bindTexture(Q,Oe),r.texParameteri(Q,10241,9728),r.texParameteri(Q,10240,9728);for(let vt=0;vt<ge;vt++)r.texImage2D(se+vt,0,6408,1,1,0,6408,5121,Le);return Oe}let z={};z[3553]=H(3553,3553,1),z[34067]=H(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(h0),ve(!1),Ee(XS),re(2884),ye(Dt);function re(Q){h[Q]!==!0&&(r.enable(Q),h[Q]=!0)}function K(Q){h[Q]!==!1&&(r.disable(Q),h[Q]=!1)}function Z(Q,se){return f[Q]!==se?(r.bindFramebuffer(Q,se),f[Q]=se,n&&(Q===36009&&(f[36160]=se),Q===36160&&(f[36009]=se)),!0):!1}function k(Q,se){let ge=p,Le=!1;if(Q)if(ge=m.get(se),ge===void 0&&(ge=[],m.set(se,ge)),Q.isWebGLMultipleRenderTargets){let Oe=Q.texture;if(ge.length!==Oe.length||ge[0]!==36064){for(let vt=0,Tn=Oe.length;vt<Tn;vt++)ge[vt]=36064+vt;ge.length=Oe.length,Le=!0}}else ge[0]!==36064&&(ge[0]=36064,Le=!0);else ge[0]!==1029&&(ge[0]=1029,Le=!0);Le&&(e.isWebGL2?r.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function he(Q){return g!==Q?(r.useProgram(Q),g=Q,!0):!1}let fe={[rc]:32774,[QI]:32778,[KI]:32779};if(n)fe[ZS]=32775,fe[JS]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(fe[ZS]=Q.MIN_EXT,fe[JS]=Q.MAX_EXT)}let ce={[ZI]:0,[JI]:1,[$I]:768,[MA]:770,[sO]:776,[rO]:774,[tO]:772,[eO]:769,[EA]:771,[iO]:775,[nO]:773};function ye(Q,se,ge,Le,Oe,vt,Tn,pn){if(Q===Dt){y===!0&&(K(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Q!==YI){if(Q!==v||pn!==E){if((x!==rc||_!==rc)&&(r.blendEquation(32774),x=rc,_=rc),pn)switch(Q){case oc:r.blendFuncSeparate(1,771,1,771);break;case YS:r.blendFunc(1,1);break;case QS:r.blendFuncSeparate(0,769,0,1);break;case KS:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case oc:r.blendFuncSeparate(770,771,1,771);break;case YS:r.blendFunc(770,1);break;case QS:r.blendFuncSeparate(0,769,0,1);break;case KS:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}w=null,S=null,M=null,b=null,v=Q,E=pn}return}Oe=Oe||se,vt=vt||ge,Tn=Tn||Le,(se!==x||Oe!==_)&&(r.blendEquationSeparate(fe[se],fe[Oe]),x=se,_=Oe),(ge!==w||Le!==S||vt!==M||Tn!==b)&&(r.blendFuncSeparate(ce[ge],ce[Le],ce[vt],ce[Tn]),w=ge,S=Le,M=vt,b=Tn),v=Q,E=!1}function Se(Q,se){Q.side===Ir?K(2884):re(2884);let ge=Q.side===On;se&&(ge=!ge),ve(ge),Q.blending===oc&&Q.transparent===!1?ye(Dt):ye(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let Le=Q.stencilWrite;u.setTest(Le),Le&&(u.setMask(Q.stencilWriteMask),u.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),u.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),we(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?re(32926):K(32926)}function ve(Q){T!==Q&&(Q?r.frontFace(2304):r.frontFace(2305),T=Q)}function Ee(Q){Q!==qI?(re(2884),Q!==P&&(Q===XS?r.cullFace(1029):Q===XI?r.cullFace(1028):r.cullFace(1032))):K(2884),P=Q}function Te(Q){Q!==D&&(V&&r.lineWidth(Q),D=Q)}function we(Q,se,ge){Q?(re(32823),(C!==se||O!==ge)&&(r.polygonOffset(se,ge),C=se,O=ge)):K(32823)}function Ge(Q){Q?re(3089):K(3089)}function gt(Q){Q===void 0&&(Q=33984+B-1),q!==Q&&(r.activeTexture(Q),q=Q)}function R(Q,se,ge){ge===void 0&&(q===null?ge=33984+B-1:ge=q);let Le=j[ge];Le===void 0&&(Le={type:void 0,texture:void 0},j[ge]=Le),(Le.type!==Q||Le.texture!==se)&&(q!==ge&&(r.activeTexture(ge),q=ge),r.bindTexture(Q,se||z[Q]),Le.type=Q,Le.texture=se)}function I(){let Q=j[q];Q!==void 0&&Q.type!==void 0&&(r.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ee(){try{r.compressedTexImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function me(){try{r.compressedTexImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function xe(){try{r.texSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ce(){try{r.texSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ve(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Pe(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function de(){try{r.texStorage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Xe(){try{r.texStorage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Re(){try{r.texImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function De(){try{r.texImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ue(Q){U.equals(Q)===!1&&(r.scissor(Q.x,Q.y,Q.z,Q.w),U.copy(Q))}function Ye(Q){G.equals(Q)===!1&&(r.viewport(Q.x,Q.y,Q.z,Q.w),G.copy(Q))}function yt(Q,se){let ge=d.get(se);ge===void 0&&(ge=new WeakMap,d.set(se,ge));let Le=ge.get(Q);Le===void 0&&(Le=r.getUniformBlockIndex(se,Q.name),ge.set(Q,Le))}function zt(Q,se){let Le=d.get(se).get(Q);c.get(se)!==Le&&(r.uniformBlockBinding(se,Le,Q.__bindingPointIndex),c.set(se,Le))}function En(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},q=null,j={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,P=null,D=null,C=null,O=null,U.set(0,0,r.canvas.width,r.canvas.height),G.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:re,disable:K,bindFramebuffer:Z,drawBuffers:k,useProgram:he,setBlending:ye,setMaterial:Se,setFlipSided:ve,setCullFace:Ee,setLineWidth:Te,setPolygonOffset:we,setScissorTest:Ge,activeTexture:gt,bindTexture:R,unbindTexture:I,compressedTexImage2D:ee,compressedTexImage3D:me,texImage2D:Re,texImage3D:De,updateUBOMapping:yt,uniformBlockBinding:zt,texStorage2D:de,texStorage3D:Xe,texSubImage2D:xe,texSubImage3D:Ce,compressedTexSubImage2D:Ve,compressedTexSubImage3D:Pe,scissor:Ue,viewport:Ye,reset:En}}function IB(r,t,e,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,d=i.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,I){return y?new OffscreenCanvas(R,I):Fp("canvas")}function x(R,I,ee,me){let xe=1;if((R.width>me||R.height>me)&&(xe=me/Math.max(R.width,R.height)),xe<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ce=I?Bp:Math.floor,Ve=Ce(xe*R.width),Pe=Ce(xe*R.height);p===void 0&&(p=v(Ve,Pe));let de=ee?v(Ve,Pe):p;return de.width=Ve,de.height=Pe,de.getContext("2d").drawImage(R,0,0,Ve,Pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Ve+"x"+Pe+")."),de}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function w(R){return v0(R.width)&&v0(R.height)}function S(R){return a?!1:R.wrapS!==Gt||R.wrapT!==Gt||R.minFilter!==Pt&&R.minFilter!==qe}function _(R,I){return R.generateMipmaps&&I&&R.minFilter!==Pt&&R.minFilter!==qe}function M(R){r.generateMipmap(R)}function b(R,I,ee,me,xe=!1){if(a===!1)return I;if(R!==null){if(r[R]!==void 0)return r[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ce=I;return I===6403&&(ee===5126&&(Ce=33326),ee===5131&&(Ce=33325),ee===5121&&(Ce=33321)),I===33319&&(ee===5126&&(Ce=33328),ee===5131&&(Ce=33327),ee===5121&&(Ce=33323)),I===6408&&(ee===5126&&(Ce=34836),ee===5131&&(Ce=34842),ee===5121&&(Ce=me===Qe&&xe===!1?35907:32856),ee===32819&&(Ce=32854),ee===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&t.get("EXT_color_buffer_float"),Ce}function E(R,I,ee){return _(R,ee)===!0||R.isFramebufferTexture&&R.minFilter!==Pt&&R.minFilter!==qe?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function T(R){return R===Pt||R===$S||R===Pv?9728:9729}function P(R){let I=R.target;I.removeEventListener("dispose",P),C(I),I.isVideoTexture&&m.delete(I)}function D(R){let I=R.target;I.removeEventListener("dispose",D),B(I)}function C(R){let I=n.get(R);if(I.__webglInit===void 0)return;let ee=R.source,me=g.get(ee);if(me){let xe=me[I.__cacheKey];xe.usedTimes--,xe.usedTimes===0&&O(R),Object.keys(me).length===0&&g.delete(ee)}n.remove(R)}function O(R){let I=n.get(R);r.deleteTexture(I.__webglTexture);let ee=R.source,me=g.get(ee);delete me[I.__cacheKey],o.memory.textures--}function B(R){let I=R.texture,ee=n.get(R),me=n.get(I);if(me.__webglTexture!==void 0&&(r.deleteTexture(me.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++)r.deleteFramebuffer(ee.__webglFramebuffer[xe]),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer[xe]);else{if(r.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let xe=0;xe<ee.__webglColorRenderbuffer.length;xe++)ee.__webglColorRenderbuffer[xe]&&r.deleteRenderbuffer(ee.__webglColorRenderbuffer[xe]);ee.__webglDepthRenderbuffer&&r.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let xe=0,Ce=I.length;xe<Ce;xe++){let Ve=n.get(I[xe]);Ve.__webglTexture&&(r.deleteTexture(Ve.__webglTexture),o.memory.textures--),n.remove(I[xe])}n.remove(I),n.remove(R)}let V=0;function Y(){V=0}function W(){let R=V;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),V+=1,R}function q(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.wrapR||0),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function j(R,I){let ee=n.get(R);if(R.isVideoTexture&&Ge(R),R.isRenderTargetTexture===!1&&R.version>0&&ee.__version!==R.version){let me=R.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(ee,R,I);return}}e.bindTexture(3553,ee.__webglTexture,33984+I)}function X(R,I){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,I);return}e.bindTexture(35866,ee.__webglTexture,33984+I)}function L(R,I){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,I);return}e.bindTexture(32879,ee.__webglTexture,33984+I)}function U(R,I){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){Z(ee,R,I);return}e.bindTexture(34067,ee.__webglTexture,33984+I)}let G={[Bi]:10497,[Gt]:33071,[m0]:33648},H={[Pt]:9728,[$S]:9984,[Pv]:9986,[qe]:9729,[bO]:9985,[Ha]:9987};function z(R,I,ee){if(ee?(r.texParameteri(R,10242,G[I.wrapS]),r.texParameteri(R,10243,G[I.wrapT]),(R===32879||R===35866)&&r.texParameteri(R,32882,G[I.wrapR]),r.texParameteri(R,10240,H[I.magFilter]),r.texParameteri(R,10241,H[I.minFilter])):(r.texParameteri(R,10242,33071),r.texParameteri(R,10243,33071),(R===32879||R===35866)&&r.texParameteri(R,32882,33071),(I.wrapS!==Gt||I.wrapT!==Gt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(R,10240,T(I.magFilter)),r.texParameteri(R,10241,T(I.minFilter)),I.minFilter!==Pt&&I.minFilter!==qe&&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 me=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===Pt||I.minFilter!==Pv&&I.minFilter!==Ha||I.type===wr&&t.has("OES_texture_float_linear")===!1||a===!1&&I.type===Wa&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||n.get(I).__currentAnisotropy)&&(r.texParameterf(R,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy)}}function re(R,I){let ee=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",P));let me=I.source,xe=g.get(me);xe===void 0&&(xe={},g.set(me,xe));let Ce=q(I);if(Ce!==R.__cacheKey){xe[Ce]===void 0&&(xe[Ce]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),xe[Ce].usedTimes++;let Ve=xe[R.__cacheKey];Ve!==void 0&&(xe[R.__cacheKey].usedTimes--,Ve.usedTimes===0&&O(I)),R.__cacheKey=Ce,R.__webglTexture=xe[Ce].texture}return ee}function K(R,I,ee){let me=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(me=35866),I.isData3DTexture&&(me=32879);let xe=re(R,I),Ce=I.source;e.bindTexture(me,R.__webglTexture,33984+ee);let Ve=n.get(Ce);if(Ce.version!==Ve.__version||xe===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Pe=S(I)&&w(I.image)===!1,de=x(I.image,Pe,!1,c);de=gt(I,de);let Xe=w(de)||a,Re=s.convert(I.format,I.encoding),De=s.convert(I.type),Ue=b(I.internalFormat,Re,De,I.encoding,I.isVideoTexture);z(me,I,Xe);let Ye,yt=I.mipmaps,zt=a&&I.isVideoTexture!==!0,En=Ve.__version===void 0||xe===!0,Q=E(I,de,Xe);if(I.isDepthTexture)Ue=6402,a?I.type===wr?Ue=36012:I.type===ro?Ue=33190:I.type===Vo?Ue=35056:Ue=33189:I.type===wr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Ga&&Ue===6402&&I.type!==PA&&I.type!==ro&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=ro,De=s.convert(I.type)),I.format===jo&&Ue===6402&&(Ue=34041,I.type!==Vo&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Vo,De=s.convert(I.type))),En&&(zt?e.texStorage2D(3553,1,Ue,de.width,de.height):e.texImage2D(3553,0,Ue,de.width,de.height,0,Re,De,null));else if(I.isDataTexture)if(yt.length>0&&Xe){zt&&En&&e.texStorage2D(3553,Q,Ue,yt[0].width,yt[0].height);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],zt?e.texSubImage2D(3553,se,0,0,Ye.width,Ye.height,Re,De,Ye.data):e.texImage2D(3553,se,Ue,Ye.width,Ye.height,0,Re,De,Ye.data);I.generateMipmaps=!1}else zt?(En&&e.texStorage2D(3553,Q,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,de.width,de.height,Re,De,de.data)):e.texImage2D(3553,0,Ue,de.width,de.height,0,Re,De,de.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){zt&&En&&e.texStorage3D(35866,Q,Ue,yt[0].width,yt[0].height,de.depth);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],I.format!==gi?Re!==null?zt?e.compressedTexSubImage3D(35866,se,0,0,0,Ye.width,Ye.height,de.depth,Re,Ye.data,0,0):e.compressedTexImage3D(35866,se,Ue,Ye.width,Ye.height,de.depth,0,Ye.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?e.texSubImage3D(35866,se,0,0,0,Ye.width,Ye.height,de.depth,Re,De,Ye.data):e.texImage3D(35866,se,Ue,Ye.width,Ye.height,de.depth,0,Re,De,Ye.data)}else{zt&&En&&e.texStorage2D(3553,Q,Ue,yt[0].width,yt[0].height);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],I.format!==gi?Re!==null?zt?e.compressedTexSubImage2D(3553,se,0,0,Ye.width,Ye.height,Re,Ye.data):e.compressedTexImage2D(3553,se,Ue,Ye.width,Ye.height,0,Ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?e.texSubImage2D(3553,se,0,0,Ye.width,Ye.height,Re,De,Ye.data):e.texImage2D(3553,se,Ue,Ye.width,Ye.height,0,Re,De,Ye.data)}else if(I.isDataArrayTexture)zt?(En&&e.texStorage3D(35866,Q,Ue,de.width,de.height,de.depth),e.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Re,De,de.data)):e.texImage3D(35866,0,Ue,de.width,de.height,de.depth,0,Re,De,de.data);else if(I.isData3DTexture)zt?(En&&e.texStorage3D(32879,Q,Ue,de.width,de.height,de.depth),e.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Re,De,de.data)):e.texImage3D(32879,0,Ue,de.width,de.height,de.depth,0,Re,De,de.data);else if(I.isFramebufferTexture){if(En)if(zt)e.texStorage2D(3553,Q,Ue,de.width,de.height);else{let se=de.width,ge=de.height;for(let Le=0;Le<Q;Le++)e.texImage2D(3553,Le,Ue,se,ge,0,Re,De,null),se>>=1,ge>>=1}}else if(yt.length>0&&Xe){zt&&En&&e.texStorage2D(3553,Q,Ue,yt[0].width,yt[0].height);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],zt?e.texSubImage2D(3553,se,0,0,Re,De,Ye):e.texImage2D(3553,se,Ue,Re,De,Ye);I.generateMipmaps=!1}else zt?(En&&e.texStorage2D(3553,Q,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,Re,De,de)):e.texImage2D(3553,0,Ue,Re,De,de);_(I,Xe)&&M(me),Ve.__version=Ce.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function Z(R,I,ee){if(I.image.length!==6)return;let me=re(R,I),xe=I.source;e.bindTexture(34067,R.__webglTexture,33984+ee);let Ce=n.get(xe);if(xe.version!==Ce.__version||me===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Ve=I.isCompressedTexture||I.image[0].isCompressedTexture,Pe=I.image[0]&&I.image[0].isDataTexture,de=[];for(let se=0;se<6;se++)!Ve&&!Pe?de[se]=x(I.image[se],!1,!0,u):de[se]=Pe?I.image[se].image:I.image[se],de[se]=gt(I,de[se]);let Xe=de[0],Re=w(Xe)||a,De=s.convert(I.format,I.encoding),Ue=s.convert(I.type),Ye=b(I.internalFormat,De,Ue,I.encoding),yt=a&&I.isVideoTexture!==!0,zt=Ce.__version===void 0||me===!0,En=E(I,Xe,Re);z(34067,I,Re);let Q;if(Ve){yt&&zt&&e.texStorage2D(34067,En,Ye,Xe.width,Xe.height);for(let se=0;se<6;se++){Q=de[se].mipmaps;for(let ge=0;ge<Q.length;ge++){let Le=Q[ge];I.format!==gi?De!==null?yt?e.compressedTexSubImage2D(34069+se,ge,0,0,Le.width,Le.height,De,Le.data):e.compressedTexImage2D(34069+se,ge,Ye,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):yt?e.texSubImage2D(34069+se,ge,0,0,Le.width,Le.height,De,Ue,Le.data):e.texImage2D(34069+se,ge,Ye,Le.width,Le.height,0,De,Ue,Le.data)}}}else{Q=I.mipmaps,yt&&zt&&(Q.length>0&&En++,e.texStorage2D(34067,En,Ye,de[0].width,de[0].height));for(let se=0;se<6;se++)if(Pe){yt?e.texSubImage2D(34069+se,0,0,0,de[se].width,de[se].height,De,Ue,de[se].data):e.texImage2D(34069+se,0,Ye,de[se].width,de[se].height,0,De,Ue,de[se].data);for(let ge=0;ge<Q.length;ge++){let Oe=Q[ge].image[se].image;yt?e.texSubImage2D(34069+se,ge+1,0,0,Oe.width,Oe.height,De,Ue,Oe.data):e.texImage2D(34069+se,ge+1,Ye,Oe.width,Oe.height,0,De,Ue,Oe.data)}}else{yt?e.texSubImage2D(34069+se,0,0,0,De,Ue,de[se]):e.texImage2D(34069+se,0,Ye,De,Ue,de[se]);for(let ge=0;ge<Q.length;ge++){let Le=Q[ge];yt?e.texSubImage2D(34069+se,ge+1,0,0,De,Ue,Le.image[se]):e.texImage2D(34069+se,ge+1,Ye,De,Ue,Le.image[se])}}}_(I,Re)&&M(34067),Ce.__version=xe.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function k(R,I,ee,me,xe){let Ce=s.convert(ee.format,ee.encoding),Ve=s.convert(ee.type),Pe=b(ee.internalFormat,Ce,Ve,ee.encoding);n.get(I).__hasExternalTextures||(xe===32879||xe===35866?e.texImage3D(xe,0,Pe,I.width,I.height,I.depth,0,Ce,Ve,null):e.texImage2D(xe,0,Pe,I.width,I.height,0,Ce,Ve,null)),e.bindFramebuffer(36160,R),we(I)?h.framebufferTexture2DMultisampleEXT(36160,me,xe,n.get(ee).__webglTexture,0,Te(I)):(xe===3553||xe>=34069&&xe<=34074)&&r.framebufferTexture2D(36160,me,xe,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function he(R,I,ee){if(r.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let me=33189;if(ee||we(I)){let xe=I.depthTexture;xe&&xe.isDepthTexture&&(xe.type===wr?me=36012:xe.type===ro&&(me=33190));let Ce=Te(I);we(I)?h.renderbufferStorageMultisampleEXT(36161,Ce,me,I.width,I.height):r.renderbufferStorageMultisample(36161,Ce,me,I.width,I.height)}else r.renderbufferStorage(36161,me,I.width,I.height);r.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let me=Te(I);ee&&we(I)===!1?r.renderbufferStorageMultisample(36161,me,35056,I.width,I.height):we(I)?h.renderbufferStorageMultisampleEXT(36161,me,35056,I.width,I.height):r.renderbufferStorage(36161,34041,I.width,I.height),r.framebufferRenderbuffer(36160,33306,36161,R)}else{let me=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let xe=0;xe<me.length;xe++){let Ce=me[xe],Ve=s.convert(Ce.format,Ce.encoding),Pe=s.convert(Ce.type),de=b(Ce.internalFormat,Ve,Pe,Ce.encoding),Xe=Te(I);ee&&we(I)===!1?r.renderbufferStorageMultisample(36161,Xe,de,I.width,I.height):we(I)?h.renderbufferStorageMultisampleEXT(36161,Xe,de,I.width,I.height):r.renderbufferStorage(36161,de,I.width,I.height)}}r.bindRenderbuffer(36161,null)}function fe(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),j(I.depthTexture,0);let me=n.get(I.depthTexture).__webglTexture,xe=Te(I);if(I.depthTexture.format===Ga)we(I)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,me,0,xe):r.framebufferTexture2D(36160,36096,3553,me,0);else if(I.depthTexture.format===jo)we(I)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,me,0,xe):r.framebufferTexture2D(36160,33306,3553,me,0);else throw new Error("Unknown depthTexture format")}function ce(R){let I=n.get(R),ee=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");fe(I.__webglFramebuffer,R)}else if(ee){I.__webglDepthbuffer=[];for(let me=0;me<6;me++)e.bindFramebuffer(36160,I.__webglFramebuffer[me]),I.__webglDepthbuffer[me]=r.createRenderbuffer(),he(I.__webglDepthbuffer[me],R,!1)}else e.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=r.createRenderbuffer(),he(I.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function ye(R,I,ee){let me=n.get(R);I!==void 0&&k(me.__webglFramebuffer,R,R.texture,36064,3553),ee!==void 0&&ce(R)}function Se(R){let I=R.texture,ee=n.get(R),me=n.get(I);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=r.createTexture()),me.__version=I.version,o.memory.textures++);let xe=R.isWebGLCubeRenderTarget===!0,Ce=R.isWebGLMultipleRenderTargets===!0,Ve=w(R)||a;if(xe){ee.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)ee.__webglFramebuffer[Pe]=r.createFramebuffer()}else{if(ee.__webglFramebuffer=r.createFramebuffer(),Ce)if(i.drawBuffers){let Pe=R.texture;for(let de=0,Xe=Pe.length;de<Xe;de++){let Re=n.get(Pe[de]);Re.__webglTexture===void 0&&(Re.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&we(R)===!1){let Pe=Ce?I:[I];ee.__webglMultisampledFramebuffer=r.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let de=0;de<Pe.length;de++){let Xe=Pe[de];ee.__webglColorRenderbuffer[de]=r.createRenderbuffer(),r.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[de]);let Re=s.convert(Xe.format,Xe.encoding),De=s.convert(Xe.type),Ue=b(Xe.internalFormat,Re,De,Xe.encoding,R.isXRRenderTarget===!0),Ye=Te(R);r.renderbufferStorageMultisample(36161,Ye,Ue,R.width,R.height),r.framebufferRenderbuffer(36160,36064+de,36161,ee.__webglColorRenderbuffer[de])}r.bindRenderbuffer(36161,null),R.depthBuffer&&(ee.__webglDepthRenderbuffer=r.createRenderbuffer(),he(ee.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(xe){e.bindTexture(34067,me.__webglTexture),z(34067,I,Ve);for(let Pe=0;Pe<6;Pe++)k(ee.__webglFramebuffer[Pe],R,I,36064,34069+Pe);_(I,Ve)&&M(34067),e.unbindTexture()}else if(Ce){let Pe=R.texture;for(let de=0,Xe=Pe.length;de<Xe;de++){let Re=Pe[de],De=n.get(Re);e.bindTexture(3553,De.__webglTexture),z(3553,Re,Ve),k(ee.__webglFramebuffer,R,Re,36064+de,3553),_(Re,Ve)&&M(3553)}e.unbindTexture()}else{let Pe=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?Pe=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Pe,me.__webglTexture),z(Pe,I,Ve),k(ee.__webglFramebuffer,R,I,36064,Pe),_(I,Ve)&&M(Pe),e.unbindTexture()}R.depthBuffer&&ce(R)}function ve(R){let I=w(R)||a,ee=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let me=0,xe=ee.length;me<xe;me++){let Ce=ee[me];if(_(Ce,I)){let Ve=R.isWebGLCubeRenderTarget?34067:3553,Pe=n.get(Ce).__webglTexture;e.bindTexture(Ve,Pe),M(Ve),e.unbindTexture()}}}function Ee(R){if(a&&R.samples>0&&we(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ee=R.width,me=R.height,xe=16384,Ce=[],Ve=R.stencilBuffer?33306:36096,Pe=n.get(R),de=R.isWebGLMultipleRenderTargets===!0;if(de)for(let Xe=0;Xe<I.length;Xe++)e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Xe,36161,null),e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Xe,3553,null,0);e.bindFramebuffer(36008,Pe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Pe.__webglFramebuffer);for(let Xe=0;Xe<I.length;Xe++){Ce.push(36064+Xe),R.depthBuffer&&Ce.push(Ve);let Re=Pe.__ignoreDepthValues!==void 0?Pe.__ignoreDepthValues:!1;if(Re===!1&&(R.depthBuffer&&(xe|=256),R.stencilBuffer&&(xe|=1024)),de&&r.framebufferRenderbuffer(36008,36064,36161,Pe.__webglColorRenderbuffer[Xe]),Re===!0&&(r.invalidateFramebuffer(36008,[Ve]),r.invalidateFramebuffer(36009,[Ve])),de){let De=n.get(I[Xe]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,De,0)}r.blitFramebuffer(0,0,ee,me,0,0,ee,me,xe,9728),f&&r.invalidateFramebuffer(36008,Ce)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),de)for(let Xe=0;Xe<I.length;Xe++){e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Xe,36161,Pe.__webglColorRenderbuffer[Xe]);let Re=n.get(I[Xe]).__webglTexture;e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Xe,3553,Re,0)}e.bindFramebuffer(36009,Pe.__webglMultisampledFramebuffer)}}function Te(R){return Math.min(d,R.samples)}function we(R){let I=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ge(R){let I=o.render.frame;m.get(R)!==I&&(m.set(R,I),R.update())}function gt(R,I){let ee=R.encoding,me=R.format,xe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===y0||ee!==oi&&(ee===Qe?a===!1?t.has("EXT_sRGB")===!0&&me===gi?(R.format=y0,R.minFilter=qe,R.generateMipmaps=!1):I=Up.sRGBToLinear(I):(me!==gi||xe!==qt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ee)),I}this.allocateTextureUnit=W,this.resetTextureUnits=Y,this.setTexture2D=j,this.setTexture2DArray=X,this.setTexture3D=L,this.setTextureCube=U,this.rebindTextures=ye,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=ve,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=ce,this.setupFrameBufferTexture=k,this.useMultisampledRTT=we}function OB(r,t,e){let n=e.isWebGL2;function i(s,o=null){let a;if(s===qt)return 5121;if(s===_O)return 32819;if(s===MO)return 32820;if(s===wO)return 5120;if(s===SO)return 5122;if(s===PA)return 5123;if(s===AO)return 5124;if(s===ro)return 5125;if(s===wr)return 5126;if(s===Wa)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===EO)return 6406;if(s===gi)return 6408;if(s===TO)return 6409;if(s===CO)return 6410;if(s===Ga)return 6402;if(s===jo)return 34041;if(s===y0)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===PO)return 6403;if(s===DO)return 36244;if(s===Z0)return 33319;if(s===IO)return 33320;if(s===OO)return 36249;if(s===Dv||s===Iv||s===Ov||s===Rv)if(o===Qe)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Dv)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Iv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Ov)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Rv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Dv)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Iv)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ov)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Rv)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===e1||s===t1||s===n1||s===r1)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===e1)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===t1)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===n1)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===r1)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===RO)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===i1||s===s1)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===i1)return o===Qe?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===s1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===o1||s===a1||s===l1||s===c1||s===u1||s===d1||s===h1||s===f1||s===p1||s===m1||s===g1||s===y1||s===v1||s===x1)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===o1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===a1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===l1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===c1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===u1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===d1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===h1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===f1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===p1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===m1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===g1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===y1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===v1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===x1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Lv)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Lv)return o===Qe?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===LO||s===b1||s===w1||s===S1)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Lv)return a.COMPRESSED_RED_RGTC1_EXT;if(s===b1)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===w1)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===S1)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Vo?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var C0=class extends gn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},gs=class extends pt{constructor(){super(),this.isGroup=!0,this.type="Group"}},RB={type:"move"},dh=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new gs,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 gs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new gs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let p of t.hand.values()){let g=e.getJointPose(p,n),y=this._getHandJoint(u,p);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,m=.005;u.inputState.pinching&&h>f+m?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=f-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(RB)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new gs;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},yi=class extends Vt{constructor(t,e,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Ga,c!==Ga&&c!==jo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Ga&&(n=ro),n===void 0&&c===jo&&(n=Vo),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Pt,this.minFilter=l!==void 0?l:Pt,this.flipY=!1,this.generateMipmaps=!1}},P0=class extends Ht{constructor(t,e){super();let n=this,i=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,m=null,p=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,_=new gn;_.layers.enable(1),_.viewport=new Ze;let M=new gn;M.layers.enable(2),M.viewport=new Ze;let b=[_,M],E=new C0;E.layers.enable(1),E.layers.enable(2);let T=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(L){let U=v[L];return U===void 0&&(U=new dh,v[L]=U),U.getTargetRaySpace()},this.getControllerGrip=function(L){let U=v[L];return U===void 0&&(U=new dh,v[L]=U),U.getGripSpace()},this.getHand=function(L){let U=v[L];return U===void 0&&(U=new dh,v[L]=U),U.getHandSpace()};function D(L){let U=x.indexOf(L.inputSource);if(U===-1)return;let G=v[U];G!==void 0&&G.dispatchEvent({type:L.type,data:L.inputSource})}function C(){i.removeEventListener("select",D),i.removeEventListener("selectstart",D),i.removeEventListener("selectend",D),i.removeEventListener("squeeze",D),i.removeEventListener("squeezestart",D),i.removeEventListener("squeezeend",D),i.removeEventListener("end",C),i.removeEventListener("inputsourceschange",O);for(let L=0;L<v.length;L++){let U=x[L];U!==null&&(x[L]=null,v[L].disconnect(U))}T=null,P=null,t.setRenderTarget(g),f=null,h=null,d=null,i=null,y=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(L){s=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(L){a=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(L){u=L},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(L){if(i=L,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",D),i.addEventListener("selectstart",D),i.addEventListener("selectend",D),i.addEventListener("squeeze",D),i.addEventListener("squeezestart",D),i.addEventListener("squeezeend",D),i.addEventListener("end",C),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let U={antialias:i.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,U),i.updateRenderState({baseLayer:f}),y=new st(f.framebufferWidth,f.framebufferHeight,{format:gi,type:qt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let U=null,G=null,H=null;p.depth&&(H=p.stencil?35056:33190,U=p.stencil?jo:Ga,G=p.stencil?Vo:ro);let z={colorFormat:32856,depthFormat:H,scaleFactor:s};d=new XRWebGLBinding(i,e),h=d.createProjectionLayer(z),i.updateRenderState({layers:[h]}),y=new st(h.textureWidth,h.textureHeight,{format:gi,type:qt,depthTexture:new yi(h.textureWidth,h.textureHeight,G,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let re=t.properties.get(y);re.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await i.requestReferenceSpace(a),X.setContext(i),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function O(L){for(let U=0;U<L.removed.length;U++){let G=L.removed[U],H=x.indexOf(G);H>=0&&(x[H]=null,v[H].disconnect(G))}for(let U=0;U<L.added.length;U++){let G=L.added[U],H=x.indexOf(G);if(H===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(G),H=re;break}else if(x[re]===null){x[re]=G,H=re;break}if(H===-1)break}let z=v[H];z&&z.connect(G)}}let B=new A,V=new A;function Y(L,U,G){B.setFromMatrixPosition(U.matrixWorld),V.setFromMatrixPosition(G.matrixWorld);let H=B.distanceTo(V),z=U.projectionMatrix.elements,re=G.projectionMatrix.elements,K=z[14]/(z[10]-1),Z=z[14]/(z[10]+1),k=(z[9]+1)/z[5],he=(z[9]-1)/z[5],fe=(z[8]-1)/z[0],ce=(re[8]+1)/re[0],ye=K*fe,Se=K*ce,ve=H/(-fe+ce),Ee=ve*-fe;U.matrixWorld.decompose(L.position,L.quaternion,L.scale),L.translateX(Ee),L.translateZ(ve),L.matrixWorld.compose(L.position,L.quaternion,L.scale),L.matrixWorldInverse.copy(L.matrixWorld).invert();let Te=K+ve,we=Z+ve,Ge=ye-Ee,gt=Se+(H-Ee),R=k*Z/we*Te,I=he*Z/we*Te;L.projectionMatrix.makePerspective(Ge,gt,R,I,Te,we)}function W(L,U){U===null?L.matrixWorld.copy(L.matrix):L.matrixWorld.multiplyMatrices(U.matrixWorld,L.matrix),L.matrixWorldInverse.copy(L.matrixWorld).invert()}this.updateCamera=function(L){if(i===null)return;E.near=M.near=_.near=L.near,E.far=M.far=_.far=L.far,(T!==E.near||P!==E.far)&&(i.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,P=E.far);let U=L.parent,G=E.cameras;W(E,U);for(let z=0;z<G.length;z++)W(G[z],U);E.matrixWorld.decompose(E.position,E.quaternion,E.scale),L.matrix.copy(E.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);let H=L.children;for(let z=0,re=H.length;z<re;z++)H[z].updateMatrixWorld(!0);G.length===2?Y(E,_,M):E.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(L){l=L,h!==null&&(h.fixedFoveation=L),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=L)},this.getPlanes=function(){return w};let q=null;function j(L,U){if(c=U.getViewerPose(u||o),m=U,c!==null){let G=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let H=!1;G.length!==E.cameras.length&&(E.cameras.length=0,H=!0);for(let z=0;z<G.length;z++){let re=G[z],K=null;if(f!==null)K=f.getViewport(re);else{let k=d.getViewSubImage(h,re);K=k.viewport,z===0&&(t.setRenderTargetTextures(y,k.colorTexture,h.ignoreDepthValues?void 0:k.depthStencilTexture),t.setRenderTarget(y))}let Z=b[z];Z===void 0&&(Z=new gn,Z.layers.enable(z),Z.viewport=new Ze,b[z]=Z),Z.matrix.fromArray(re.transform.matrix),Z.projectionMatrix.fromArray(re.projectionMatrix),Z.viewport.set(K.x,K.y,K.width,K.height),z===0&&E.matrix.copy(Z.matrix),H===!0&&E.cameras.push(Z)}}for(let G=0;G<v.length;G++){let H=x[G],z=v[G];H!==null&&z!==void 0&&z.update(H,U,u||o)}if(q&&q(L,U),U.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:U.detectedPlanes});let G=null;for(let H of w)U.detectedPlanes.has(H)||(G===null&&(G=[]),G.push(H));if(G!==null)for(let H of G)w.delete(H),S.delete(H),n.dispatchEvent({type:"planeremoved",data:H});for(let H of U.detectedPlanes)if(!w.has(H))w.add(H),S.set(H,U.lastChangedTime),n.dispatchEvent({type:"planeadded",data:H});else{let z=S.get(H);H.lastChangedTime>z&&(S.set(H,H.lastChangedTime),n.dispatchEvent({type:"planechanged",data:H}))}}m=null}let X=new RA;X.setAnimationLoop(j),this.setAnimationLoop=function(L){q=L},this.dispose=function(){}}};function LB(r,t){function e(p,g){g.color.getRGB(p.fogColor.value,OA(r)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),c(p,g)):g.isMeshPhongMaterial?(i(p,g),u(p,g)):g.isMeshStandardMaterial?(i(p,g),d(p,g),g.isMeshPhysicalMaterial&&h(p,g,x)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,y,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===On&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===On&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let w=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uv2Transform.value.copy(x.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,y,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function c(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function d(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function h(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===On&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function NB(r,t,e,n){let i={},s={},o=[],a=e.isWebGL2?r.getParameter(35375):0;function l(v,x){let w=x.program;n.uniformBlockBinding(v,w)}function u(v,x){let w=i[v.id];w===void 0&&(m(v),w=c(v),i[v.id]=w,v.addEventListener("dispose",g));let S=x.program;n.updateUBOMapping(v,S);let _=t.render.frame;s[v.id]!==_&&(h(v),s[v.id]=_)}function c(v){let x=d();v.__bindingPointIndex=x;let w=r.createBuffer(),S=v.__size,_=v.usage;return r.bindBuffer(35345,w),r.bufferData(35345,S,_),r.bindBuffer(35345,null),r.bindBufferBase(35345,x,w),w}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let x=i[v.id],w=v.uniforms,S=v.__cache;r.bindBuffer(35345,x);for(let _=0,M=w.length;_<M;_++){let b=w[_];if(f(b,_,S)===!0){let E=b.__offset,T=Array.isArray(b.value)?b.value:[b.value],P=0;for(let D=0;D<T.length;D++){let C=T[D],O=p(C);typeof C=="number"?(b.__data[0]=C,r.bufferSubData(35345,E+P,b.__data)):C.isMatrix3?(b.__data[0]=C.elements[0],b.__data[1]=C.elements[1],b.__data[2]=C.elements[2],b.__data[3]=C.elements[0],b.__data[4]=C.elements[3],b.__data[5]=C.elements[4],b.__data[6]=C.elements[5],b.__data[7]=C.elements[0],b.__data[8]=C.elements[6],b.__data[9]=C.elements[7],b.__data[10]=C.elements[8],b.__data[11]=C.elements[0]):(C.toArray(b.__data,P),P+=O.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(35345,E,b.__data)}}r.bindBuffer(35345,null)}function f(v,x,w){let S=v.value;if(w[x]===void 0){if(typeof S=="number")w[x]=S;else{let _=Array.isArray(S)?S:[S],M=[];for(let b=0;b<_.length;b++)M.push(_[b].clone());w[x]=M}return!0}else if(typeof S=="number"){if(w[x]!==S)return w[x]=S,!0}else{let _=Array.isArray(w[x])?w[x]:[w[x]],M=Array.isArray(S)?S:[S];for(let b=0;b<_.length;b++){let E=_[b];if(E.equals(M[b])===!1)return E.copy(M[b]),!0}}return!1}function m(v){let x=v.uniforms,w=0,S=16,_=0;for(let M=0,b=x.length;M<b;M++){let E=x[M],T={boundary:0,storage:0},P=Array.isArray(E.value)?E.value:[E.value];for(let D=0,C=P.length;D<C;D++){let O=P[D],B=p(O);T.boundary+=B.boundary,T.storage+=B.storage}if(E.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=w,M>0){_=w%S;let D=S-_;_!==0&&D-T.boundary<0&&(w+=S-_,E.__offset=w)}w+=T.storage}return _=w%S,_>0&&(w+=S-_),v.__size=w,v.__cache={},this}function p(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)r.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:u,dispose:y}}function BB(){let r=Fp("canvas");return r.style.display="block",r}function tx(r={}){this.isWebGLRenderer=!0;let t=r.canvas!==void 0?r.canvas:BB(),e=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let d=null,h=null,f=[],m=[];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=oi,this.physicallyCorrectLights=!1,this.toneMapping=so,this.toneMappingExposure=1;let p=this,g=!1,y=0,v=0,x=null,w=-1,S=null,_=new Ze,M=new Ze,b=null,E=t.width,T=t.height,P=1,D=null,C=null,O=new Ze(0,0,E,T),B=new Ze(0,0,E,T),V=!1,Y=new yh,W=!1,q=!1,j=null,X=new ae,L=new F,U=new A,G={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function H(){return x===null?P:1}let z=e;function re(N,te){for(let oe=0;oe<N.length;oe++){let $=N[oe],ue=t.getContext($,te);if(ue!==null)return ue}return null}try{let N={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${lo}`),t.addEventListener("webglcontextlost",Ue,!1),t.addEventListener("webglcontextrestored",Ye,!1),t.addEventListener("webglcontextcreationerror",yt,!1),z===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),z=re(te,N),z===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let K,Z,k,he,fe,ce,ye,Se,ve,Ee,Te,we,Ge,gt,R,I,ee,me,xe,Ce,Ve,Pe,de,Xe;function Re(){K=new rN(z),Z=new Z3(z,K,r),K.init(Z),Pe=new OB(z,K,Z),k=new DB(z,K,Z),he=new oN,fe=new vB,ce=new IB(z,K,k,fe,Z,Pe,he),ye=new $3(p),Se=new nN(p),ve=new mR(z,Z),de=new Q3(z,K,ve,Z),Ee=new iN(z,ve,he,de),Te=new uN(z,Ee,ve,he),xe=new cN(z,Z,ce),I=new J3(fe),we=new yB(p,ye,Se,K,Z,de,I),Ge=new LB(p,fe),gt=new bB,R=new EB(K,Z),me=new Y3(p,ye,Se,k,Te,c,o),ee=new PB(p,Te,Z),Xe=new NB(z,he,Z,k),Ce=new K3(z,K,he,Z),Ve=new sN(z,K,he,Z),he.programs=we.programs,p.capabilities=Z,p.extensions=K,p.properties=fe,p.renderLists=gt,p.shadowMap=ee,p.state=k,p.info=he}Re();let De=new P0(p,z);this.xr=De,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let N=K.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=K.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(N){N!==void 0&&(P=N,this.setSize(E,T,!1))},this.getSize=function(N){return N.set(E,T)},this.setSize=function(N,te,oe){if(De.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=N,T=te,t.width=Math.floor(N*P),t.height=Math.floor(te*P),oe!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(E*P,T*P).floor()},this.setDrawingBufferSize=function(N,te,oe){E=N,T=te,P=oe,t.width=Math.floor(N*oe),t.height=Math.floor(te*oe),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(_)},this.getViewport=function(N){return N.copy(O)},this.setViewport=function(N,te,oe,$){N.isVector4?O.set(N.x,N.y,N.z,N.w):O.set(N,te,oe,$),k.viewport(_.copy(O).multiplyScalar(P).floor())},this.getScissor=function(N){return N.copy(B)},this.setScissor=function(N,te,oe,$){N.isVector4?B.set(N.x,N.y,N.z,N.w):B.set(N,te,oe,$),k.scissor(M.copy(B).multiplyScalar(P).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(N){k.setScissorTest(V=N)},this.setOpaqueSort=function(N){D=N},this.setTransparentSort=function(N){C=N},this.getClearColor=function(N){return N.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(N=!0,te=!0,oe=!0){let $=0;N&&($|=16384),te&&($|=256),oe&&($|=1024),z.clear($)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ue,!1),t.removeEventListener("webglcontextrestored",Ye,!1),t.removeEventListener("webglcontextcreationerror",yt,!1),gt.dispose(),R.dispose(),fe.dispose(),ye.dispose(),Se.dispose(),Te.dispose(),de.dispose(),Xe.dispose(),we.dispose(),De.dispose(),De.removeEventListener("sessionstart",Le),De.removeEventListener("sessionend",Oe),j&&(j.dispose(),j=null),vt.stop()};function Ue(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Ye(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=he.autoReset,te=ee.enabled,oe=ee.autoUpdate,$=ee.needsUpdate,ue=ee.type;Re(),he.autoReset=N,ee.enabled=te,ee.autoUpdate=oe,ee.needsUpdate=$,ee.type=ue}function yt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function zt(N){let te=N.target;te.removeEventListener("dispose",zt),En(te)}function En(N){Q(N),fe.remove(N)}function Q(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(oe){we.releaseProgram(oe)}),N.isShaderMaterial&&we.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,oe,$,ue,tt){te===null&&(te=G);let at=ue.isMesh&&ue.matrixWorld.determinant()<0,ct=BI(N,te,oe,$,ue);k.setMaterial($,at);let ft=oe.index,Tt=1;$.wireframe===!0&&(ft=Ee.getWireframeAttribute(oe),Tt=2);let xt=oe.drawRange,bt=oe.attributes.position,Cn=xt.start*Tt,ti=(xt.start+xt.count)*Tt;tt!==null&&(Cn=Math.max(Cn,tt.start*Tt),ti=Math.min(ti,(tt.start+tt.count)*Tt)),ft!==null?(Cn=Math.max(Cn,0),ti=Math.min(ti,ft.count)):bt!=null&&(Cn=Math.max(Cn,0),ti=Math.min(ti,bt.count));let Ks=ti-Cn;if(Ks<0||Ks===1/0)return;de.setup(ue,$,ct,oe,ft);let Ra,Pn=Ce;if(ft!==null&&(Ra=ve.get(ft),Pn=Ve,Pn.setIndex(Ra)),ue.isMesh)$.wireframe===!0?(k.setLineWidth($.wireframeLinewidth*H()),Pn.setMode(1)):Pn.setMode(4);else if(ue.isLine){let wt=$.linewidth;wt===void 0&&(wt=1),k.setLineWidth(wt*H()),ue.isLineSegments?Pn.setMode(1):ue.isLineLoop?Pn.setMode(2):Pn.setMode(3)}else ue.isPoints?Pn.setMode(0):ue.isSprite&&Pn.setMode(4);if(ue.isInstancedMesh)Pn.renderInstances(Cn,Ks,ue.count);else if(oe.isInstancedBufferGeometry){let wt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Mv=Math.min(oe.instanceCount,wt);Pn.renderInstances(Cn,Ks,Mv)}else Pn.render(Cn,Ks)},this.compile=function(N,te){function oe($,ue,tt){$.transparent===!0&&$.side===Ir&&$.forceSinglePass===!1?($.side=On,$.needsUpdate=!0,pi($,ue,tt),$.side=si,$.needsUpdate=!0,pi($,ue,tt),$.side=Ir):pi($,ue,tt)}h=R.get(N),h.init(),m.push(h),N.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),N.traverse(function($){let ue=$.material;if(ue)if(Array.isArray(ue))for(let tt=0;tt<ue.length;tt++){let at=ue[tt];oe(at,N,$)}else oe(ue,N,$)}),m.pop(),h=null};let se=null;function ge(N){se&&se(N)}function Le(){vt.stop()}function Oe(){vt.start()}let vt=new RA;vt.setAnimationLoop(ge),typeof self<"u"&&vt.setContext(self),this.setAnimationLoop=function(N){se=N,De.setAnimationLoop(N),N===null?vt.stop():vt.start()},De.addEventListener("sessionstart",Le),De.addEventListener("sessionend",Oe),this.render=function(N,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),De.enabled===!0&&De.isPresenting===!0&&(De.cameraAutoUpdate===!0&&De.updateCamera(te),te=De.getCamera()),N.isScene===!0&&N.onBeforeRender(p,N,te,x),h=R.get(N,m.length),h.init(),m.push(h),X.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),Y.setFromProjectionMatrix(X),q=this.localClippingEnabled,W=I.init(this.clippingPlanes,q),d=gt.get(N,f.length),d.init(),f.push(d),Tn(N,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(D,C),W===!0&&I.beginShadows();let oe=h.state.shadowsArray;if(ee.render(oe,N,te),W===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(d,N),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let ue=0,tt=$.length;ue<tt;ue++){let at=$[ue];pn(d,N,at,at.viewport)}}else pn(d,N,te);x!==null&&(ce.updateMultisampleRenderTarget(x),ce.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(p,N,te),de.resetDefaultState(),w=-1,S=null,m.pop(),m.length>0?h=m[m.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function Tn(N,te,oe,$){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)oe=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||Y.intersectsSprite(N)){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),ct=N.material;ct.visible&&d.push(N,at,ct,oe,U.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==he.render.frame&&(N.skeleton.update(),N.skeleton.frame=he.render.frame),!N.frustumCulled||Y.intersectsObject(N))){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),ct=N.material;if(Array.isArray(ct)){let ft=at.groups;for(let Tt=0,xt=ft.length;Tt<xt;Tt++){let bt=ft[Tt],Cn=ct[bt.materialIndex];Cn&&Cn.visible&&d.push(N,at,Cn,oe,U.z,bt)}}else ct.visible&&d.push(N,at,ct,oe,U.z,null)}}let tt=N.children;for(let at=0,ct=tt.length;at<ct;at++)Tn(tt[at],te,oe,$)}function pn(N,te,oe,$){let ue=N.opaque,tt=N.transmissive,at=N.transparent;h.setupLightsView(oe),W===!0&&I.setGlobalState(p.clippingPlanes,oe),tt.length>0&&Oa(ue,te,oe),$&&k.viewport(_.copy($)),ue.length>0&&Qt(ue,te,oe),tt.length>0&&Qt(tt,te,oe),at.length>0&&Qt(at,te,oe),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function Oa(N,te,oe){let $=Z.isWebGL2;j===null&&(j=new st(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?Wa:qt,minFilter:Ha,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(L),$?j.setSize(L.x,L.y):j.setSize(Bp(L.x),Bp(L.y));let ue=p.getRenderTarget();p.setRenderTarget(j),p.clear();let tt=p.toneMapping;p.toneMapping=so,Qt(N,te,oe),p.toneMapping=tt,ce.updateMultisampleRenderTarget(j),ce.updateRenderTargetMipmap(j),p.setRenderTarget(ue)}function Qt(N,te,oe){let $=te.isScene===!0?te.overrideMaterial:null;for(let ue=0,tt=N.length;ue<tt;ue++){let at=N[ue],ct=at.object,ft=at.geometry,Tt=$===null?at.material:$,xt=at.group;ct.layers.test(oe.layers)&&Qs(ct,te,oe,ft,Tt,xt)}}function Qs(N,te,oe,$,ue,tt){N.onBeforeRender(p,te,oe,$,ue,tt),N.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),ue.onBeforeRender(p,te,oe,$,N,tt),ue.transparent===!0&&ue.side===Ir&&ue.forceSinglePass===!1?(ue.side=On,ue.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ue,N,tt),ue.side=si,ue.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ue,N,tt),ue.side=Ir):p.renderBufferDirect(oe,te,$,ue,N,tt),N.onAfterRender(p,te,oe,$,ue,tt)}function pi(N,te,oe){te.isScene!==!0&&(te=G);let $=fe.get(N),ue=h.state.lights,tt=h.state.shadowsArray,at=ue.state.version,ct=we.getParameters(N,ue.state,tt,te,oe),ft=we.getProgramCacheKey(ct),Tt=$.programs;$.environment=N.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(N.isMeshStandardMaterial?Se:ye).get(N.envMap||$.environment),Tt===void 0&&(N.addEventListener("dispose",zt),Tt=new Map,$.programs=Tt);let xt=Tt.get(ft);if(xt!==void 0){if($.currentProgram===xt&&$.lightsStateVersion===at)return VS(N,ct),xt}else ct.uniforms=we.getUniforms(N),N.onBuild(oe,ct,p),N.onBeforeCompile(ct,p),xt=we.acquireProgram(ct,ft),Tt.set(ft,xt),$.uniforms=ct.uniforms;let bt=$.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(bt.clippingPlanes=I.uniform),VS(N,ct),$.needsLights=UI(N),$.lightsStateVersion=at,$.needsLights&&(bt.ambientLightColor.value=ue.state.ambient,bt.lightProbe.value=ue.state.probe,bt.directionalLights.value=ue.state.directional,bt.directionalLightShadows.value=ue.state.directionalShadow,bt.spotLights.value=ue.state.spot,bt.spotLightShadows.value=ue.state.spotShadow,bt.rectAreaLights.value=ue.state.rectArea,bt.ltc_1.value=ue.state.rectAreaLTC1,bt.ltc_2.value=ue.state.rectAreaLTC2,bt.pointLights.value=ue.state.point,bt.pointLightShadows.value=ue.state.pointShadow,bt.hemisphereLights.value=ue.state.hemi,bt.directionalShadowMap.value=ue.state.directionalShadowMap,bt.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,bt.spotShadowMap.value=ue.state.spotShadowMap,bt.spotLightMatrix.value=ue.state.spotLightMatrix,bt.spotLightMap.value=ue.state.spotLightMap,bt.pointShadowMap.value=ue.state.pointShadowMap,bt.pointShadowMatrix.value=ue.state.pointShadowMatrix);let Cn=xt.getUniforms(),ti=ac.seqWithValue(Cn.seq,bt);return $.currentProgram=xt,$.uniformsList=ti,xt}function VS(N,te){let oe=fe.get(N);oe.outputEncoding=te.outputEncoding,oe.instancing=te.instancing,oe.skinning=te.skinning,oe.morphTargets=te.morphTargets,oe.morphNormals=te.morphNormals,oe.morphColors=te.morphColors,oe.morphTargetsCount=te.morphTargetsCount,oe.numClippingPlanes=te.numClippingPlanes,oe.numIntersection=te.numClipIntersection,oe.vertexAlphas=te.vertexAlphas,oe.vertexTangents=te.vertexTangents,oe.toneMapping=te.toneMapping}function BI(N,te,oe,$,ue){te.isScene!==!0&&(te=G),ce.resetTextureUnits();let tt=te.fog,at=$.isMeshStandardMaterial?te.environment:null,ct=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:oi,ft=($.isMeshStandardMaterial?Se:ye).get($.envMap||at),Tt=$.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,xt=!!$.normalMap&&!!oe.attributes.tangent,bt=!!oe.morphAttributes.position,Cn=!!oe.morphAttributes.normal,ti=!!oe.morphAttributes.color,Ks=$.toneMapped?p.toneMapping:so,Ra=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,Pn=Ra!==void 0?Ra.length:0,wt=fe.get($),Mv=h.state.lights;if(W===!0&&(q===!0||N!==S)){let ni=N===S&&$.id===w;I.setState($,N,ni)}let Jn=!1;$.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==Mv.state.version||wt.outputEncoding!==ct||ue.isInstancedMesh&&wt.instancing===!1||!ue.isInstancedMesh&&wt.instancing===!0||ue.isSkinnedMesh&&wt.skinning===!1||!ue.isSkinnedMesh&&wt.skinning===!0||wt.envMap!==ft||$.fog===!0&&wt.fog!==tt||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==I.numPlanes||wt.numIntersection!==I.numIntersection)||wt.vertexAlphas!==Tt||wt.vertexTangents!==xt||wt.morphTargets!==bt||wt.morphNormals!==Cn||wt.morphColors!==ti||wt.toneMapping!==Ks||Z.isWebGL2===!0&&wt.morphTargetsCount!==Pn)&&(Jn=!0):(Jn=!0,wt.__version=$.version);let La=wt.currentProgram;Jn===!0&&(La=pi($,te,ue));let HS=!1,Jd=!1,Ev=!1,pr=La.getUniforms(),Na=wt.uniforms;if(k.useProgram(La.program)&&(HS=!0,Jd=!0,Ev=!0),$.id!==w&&(w=$.id,Jd=!0),HS||S!==N){if(pr.setValue(z,"projectionMatrix",N.projectionMatrix),Z.logarithmicDepthBuffer&&pr.setValue(z,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),S!==N&&(S=N,Jd=!0,Ev=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let ni=pr.map.cameraPosition;ni!==void 0&&ni.setValue(z,U.setFromMatrixPosition(N.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&pr.setValue(z,"isOrthographic",N.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||ue.isSkinnedMesh)&&pr.setValue(z,"viewMatrix",N.matrixWorldInverse)}if(ue.isSkinnedMesh){pr.setOptional(z,ue,"bindMatrix"),pr.setOptional(z,ue,"bindMatrixInverse");let ni=ue.skeleton;ni&&(Z.floatVertexTextures?(ni.boneTexture===null&&ni.computeBoneTexture(),pr.setValue(z,"boneTexture",ni.boneTexture,ce),pr.setValue(z,"boneTextureSize",ni.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 Tv=oe.morphAttributes;if((Tv.position!==void 0||Tv.normal!==void 0||Tv.color!==void 0&&Z.isWebGL2===!0)&&xe.update(ue,oe,$,La),(Jd||wt.receiveShadow!==ue.receiveShadow)&&(wt.receiveShadow=ue.receiveShadow,pr.setValue(z,"receiveShadow",ue.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(Na.envMap.value=ft,Na.flipEnvMap.value=ft.isCubeTexture&&ft.isRenderTargetTexture===!1?-1:1),Jd&&(pr.setValue(z,"toneMappingExposure",p.toneMappingExposure),wt.needsLights&&FI(Na,Ev),tt&&$.fog===!0&&Ge.refreshFogUniforms(Na,tt),Ge.refreshMaterialUniforms(Na,$,P,T,j),ac.upload(z,wt.uniformsList,Na,ce)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(ac.upload(z,wt.uniformsList,Na,ce),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&pr.setValue(z,"center",ue.center),pr.setValue(z,"modelViewMatrix",ue.modelViewMatrix),pr.setValue(z,"normalMatrix",ue.normalMatrix),pr.setValue(z,"modelMatrix",ue.matrixWorld),ue.previousModelViewMatrix&&pr.setValue(z,"previousModelViewMatrix",ue.previousModelViewMatrix),N.previousProjectionMatrix&&pr.setValue(z,"previousProjectionMatrix",N.previousProjectionMatrix),$.isShaderMaterial||$.isRawShaderMaterial){let ni=$.uniformsGroups;for(let Cv=0,kI=ni.length;Cv<kI;Cv++)if(Z.isWebGL2){let WS=ni[Cv];Xe.update(WS,La),Xe.bind(WS,La)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return La}function FI(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function UI(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,oe){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=oe;let $=fe.get(N);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=oe===void 0,$.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let oe=fe.get(N);oe.__webglFramebuffer=te,oe.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,oe=0){x=N,y=te,v=oe;let $=!0,ue=null,tt=!1,at=!1;if(N){let ft=fe.get(N);ft.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),$=!1):ft.__webglFramebuffer===void 0?ce.setupRenderTarget(N):ft.__hasExternalTextures&&ce.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let Tt=N.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(at=!0);let xt=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(ue=xt[te],tt=!0):Z.isWebGL2&&N.samples>0&&ce.useMultisampledRTT(N)===!1?ue=fe.get(N).__webglMultisampledFramebuffer:ue=xt,_.copy(N.viewport),M.copy(N.scissor),b=N.scissorTest}else _.copy(O).multiplyScalar(P).floor(),M.copy(B).multiplyScalar(P).floor(),b=V;if(k.bindFramebuffer(36160,ue)&&Z.drawBuffers&&$&&k.drawBuffers(N,ue),k.viewport(_),k.scissor(M),k.setScissorTest(b),tt){let ft=fe.get(N.texture);z.framebufferTexture2D(36160,36064,34069+te,ft.__webglTexture,oe)}else if(at){let ft=fe.get(N.texture),Tt=te||0;z.framebufferTextureLayer(36160,36064,ft.__webglTexture,oe||0,Tt)}w=-1},this.readRenderTargetPixels=function(N,te,oe,$,ue,tt,at){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ct=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&at!==void 0&&(ct=ct[at]),ct){k.bindFramebuffer(36160,ct);try{let ft=N.texture,Tt=ft.format,xt=ft.type;if(Tt!==gi&&Pe.convert(Tt)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let bt=xt===Wa&&(K.has("EXT_color_buffer_half_float")||Z.isWebGL2&&K.has("EXT_color_buffer_float"));if(xt!==qt&&Pe.convert(xt)!==z.getParameter(35738)&&!(xt===wr&&(Z.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!bt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-$&&oe>=0&&oe<=N.height-ue&&z.readPixels(te,oe,$,ue,Pe.convert(Tt),Pe.convert(xt),tt)}finally{let ft=x!==null?fe.get(x).__webglFramebuffer:null;k.bindFramebuffer(36160,ft)}}},this.copyFramebufferToTexture=function(N,te,oe=0){let $=Math.pow(2,-oe),ue=Math.floor(te.image.width*$),tt=Math.floor(te.image.height*$);ce.setTexture2D(te,0),z.copyTexSubImage2D(3553,oe,0,0,N.x,N.y,ue,tt),k.unbindTexture()},this.copyTextureToTexture=function(N,te,oe,$=0){let ue=te.image.width,tt=te.image.height,at=Pe.convert(oe.format),ct=Pe.convert(oe.type);ce.setTexture2D(oe,0),z.pixelStorei(37440,oe.flipY),z.pixelStorei(37441,oe.premultiplyAlpha),z.pixelStorei(3317,oe.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,$,N.x,N.y,ue,tt,at,ct,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,$,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,at,te.mipmaps[0].data):z.texSubImage2D(3553,$,N.x,N.y,at,ct,te.image),$===0&&oe.generateMipmaps&&z.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(N,te,oe,$,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let tt=N.max.x-N.min.x+1,at=N.max.y-N.min.y+1,ct=N.max.z-N.min.z+1,ft=Pe.convert($.format),Tt=Pe.convert($.type),xt;if($.isData3DTexture)ce.setTexture3D($,0),xt=32879;else if($.isDataArrayTexture)ce.setTexture2DArray($,0),xt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,$.flipY),z.pixelStorei(37441,$.premultiplyAlpha),z.pixelStorei(3317,$.unpackAlignment);let bt=z.getParameter(3314),Cn=z.getParameter(32878),ti=z.getParameter(3316),Ks=z.getParameter(3315),Ra=z.getParameter(32877),Pn=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;z.pixelStorei(3314,Pn.width),z.pixelStorei(32878,Pn.height),z.pixelStorei(3316,N.min.x),z.pixelStorei(3315,N.min.y),z.pixelStorei(32877,N.min.z),oe.isDataTexture||oe.isData3DTexture?z.texSubImage3D(xt,ue,te.x,te.y,te.z,tt,at,ct,ft,Tt,Pn.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(xt,ue,te.x,te.y,te.z,tt,at,ct,ft,Pn.data)):z.texSubImage3D(xt,ue,te.x,te.y,te.z,tt,at,ct,ft,Tt,Pn),z.pixelStorei(3314,bt),z.pixelStorei(32878,Cn),z.pixelStorei(3316,ti),z.pixelStorei(3315,Ks),z.pixelStorei(32877,Ra),ue===0&&$.generateMipmaps&&z.generateMipmap(xt),k.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ce.setTextureCube(N,0):N.isData3DTexture?ce.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ce.setTexture2DArray(N,0):ce.setTexture2D(N,0),k.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,k.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var D0=class extends tx{};D0.prototype.isWebGL1Renderer=!0;var uc=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ne(t),this.near=e,this.far=n}clone(){return new uc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Or=class extends pt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},jp=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=g0,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ys()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ys()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ys()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Pr=new A,Xa=class{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Pr.fromBufferAttribute(this,e),Pr.applyMatrix4(t),this.setXYZ(e,Pr.x,Pr.y,Pr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Pr.fromBufferAttribute(this,e),Pr.applyNormalMatrix(t),this.setXYZ(e,Pr.x,Pr.y,Pr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Pr.fromBufferAttribute(this,e),Pr.transformDirection(t),this.setXYZ(e,Pr.x,Pr.y,Pr.z);return this}setX(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=io(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=io(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=io(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=io(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ut(e,this.array),n=Ut(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ut(e,this.array),n=Ut(n,this.array),i=Ut(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ut(e,this.array),n=Ut(n,this.array),i=Ut(i,this.array),s=Ut(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Be(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Xa(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var qo=class extends Vt{constructor(t=null,e=1,n=1,i,s,o,a,l,u=Pt,c=Pt,d,h){super(null,o,a,l,u,c,i,s,d,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var qp=class extends Be{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var vi=class extends ja{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ne(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},sA=new A,oA=new A,aA=new ae,o0=new Fi,Mp=new Rn,Ya=class extends pt{constructor(t=new Me,e=new vi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let i=1,s=e.count;i<s;i++)sA.fromBufferAttribute(e,i-1),oA.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=sA.distanceTo(oA);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Mp.copy(n.boundingSphere),Mp.applyMatrix4(i),Mp.radius+=s,t.ray.intersectsSphere(Mp)===!1)return;aA.copy(i).invert(),o0.copy(t.ray).applyMatrix4(aA);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let y=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){let S=m.getX(x),_=m.getX(x+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,_),o0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(h);b<t.near||b>t.far||e.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),o0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let _=t.ray.origin.distanceTo(h);_<t.near||_>t.far||e.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},lA=new A,cA=new A,Xo=class extends Ya{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,s=e.count;i<s;i+=2)lA.fromBufferAttribute(e,i),cA.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+lA.distanceTo(cA);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Xp=class extends Vt{constructor(t,e,n,i,s,o,a,l,u){super(t,e,n,i,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:qe,this.magFilter=s!==void 0?s:qe,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var xi=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],h=n[i+1]-c,f=(o-c)/h;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new F:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,i=[],s=[],o=[],a=new A,l=new ae;for(let f=0;f<=t;f++){let m=f/t;i[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),d=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(zn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(zn(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Qa=class extends xi{constructor(t=0,e=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new F,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},I0=class extends Qa{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function nx(){let r=0,t=0,e=0,n=0;function i(s,o,a,l){r=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,i(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return r+t*s+e*o+n*a}}}var Ep=new A,a0=new nx,l0=new nx,c0=new nx,O0=class extends xi{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new A){let n=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=i[(a-1)%s]:(Ep.subVectors(i[0],i[1]).add(i[0]),u=Ep);let d=i[a%s],h=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Ep.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Ep),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(c),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),a0.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,m,p,g),l0.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,m,p,g),c0.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(a0.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),l0.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),c0.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(a0.calc(l),l0.calc(l),c0.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new A().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function uA(r,t,e,n,i){let s=(n-t)*.5,o=(i-e)*.5,a=r*r,l=r*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*r+e}function FB(r,t){let e=1-r;return e*e*t}function UB(r,t){return 2*(1-r)*r*t}function kB(r,t){return r*r*t}function hh(r,t,e,n){return FB(r,t)+UB(r,e)+kB(r,n)}function zB(r,t){let e=1-r;return e*e*e*t}function GB(r,t){let e=1-r;return 3*e*e*r*t}function VB(r,t){return 3*(1-r)*r*r*t}function HB(r,t){return r*r*r*t}function fh(r,t,e,n,i){return zB(r,t)+GB(r,e)+VB(r,n)+HB(r,i)}var Sr=class extends xi{constructor(t=new F,e=new F,n=new F,i=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(fh(t,i.x,s.x,o.x,a.x),fh(t,i.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Ka=class extends xi{constructor(t=new A,e=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(fh(t,i.x,s.x,o.x,a.x),fh(t,i.y,s.y,o.y,a.y),fh(t,i.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Ar=class extends xi{constructor(t=new F,e=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new F){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new F;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},xh=class extends xi{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},ai=class extends xi{constructor(t=new F,e=new F,n=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(hh(t,i.x,s.x,o.x),hh(t,i.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},R0=class extends xi{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(hh(t,i.x,s.x,o.x),hh(t,i.y,s.y,o.y),hh(t,i.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},dc=class extends xi{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new F){let n=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],d=i[o>i.length-3?i.length-1:o+2];return n.set(uA(a,l.x,u.x,c.x,d.x),uA(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new F().fromArray(i))}return this}},WB=Object.freeze({__proto__:null,ArcCurve:I0,CatmullRomCurve3:O0,CubicBezierCurve:Sr,CubicBezierCurve3:Ka,EllipseCurve:Qa,LineCurve:Ar,LineCurve3:xh,QuadraticBezierCurve:ai,QuadraticBezierCurve3:R0,SplineCurve:dc}),bh=class extends xi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ar(e,t))}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(e.push(c),n=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(new WB[i.type]().fromJSON(i))}return this}},Za=class extends bh{constructor(t){super(),this.type="Path",this.currentPoint=new F,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Ar(this.currentPoint.clone(),new F(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let s=new ai(this.currentPoint.clone(),new F(t,e),new F(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,o){let a=new Sr(this.currentPoint.clone(),new F(t,e),new F(n,i),new F(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new dc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,i,s,o),this}absarc(t,e,n,i,s,o){return this.absellipse(t,e,n,n,i,s,o),this}ellipse(t,e,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,i,s,o,a,l),this}absellipse(t,e,n,i,s,o,a,l){let u=new Qa(t,e,n,i,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},hc=class extends Me{constructor(t=[new F(0,-.5),new F(.5,0),new F(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=zn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new F,f=new A,m=new A,p=new A,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let v=0;v<=e;v++){let x=n+v*c*i,w=Math.sin(x),S=Math.cos(x);for(let _=0;_<=t.length-1;_++){d.x=t[_].x*w,d.y=t[_].y,d.z=t[_].x*S,o.push(d.x,d.y,d.z),h.x=v/e,h.y=_/(t.length-1),a.push(h.x,h.y);let M=l[3*_+0]*w,b=l[3*_+1],E=l[3*_+0]*S;u.push(M,b,E)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let w=x+v*t.length,S=w,_=w+t.length,M=w+t.length+1,b=w+1;s.push(S,_,b),s.push(M,b,_)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(u,3))}static fromJSON(t){return new hc(t.points,t.segments,t.phiStart,t.phiLength)}};var Ja=class extends Me{constructor(t=1,e=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],d=[],h=[],f=[],m=0,p=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function v(){let w=new A,S=new A,_=0,M=(e-t)/n;for(let b=0;b<=s;b++){let E=[],T=b/s,P=T*(e-t)+t;for(let D=0;D<=i;D++){let C=D/i,O=C*l+a,B=Math.sin(O),V=Math.cos(O);S.x=P*B,S.y=-T*n+g,S.z=P*V,d.push(S.x,S.y,S.z),w.set(B,M,V).normalize(),h.push(w.x,w.y,w.z),f.push(C,1-T),E.push(m++)}p.push(E)}for(let b=0;b<i;b++)for(let E=0;E<s;E++){let T=p[E][b],P=p[E+1][b],D=p[E+1][b+1],C=p[E][b+1];c.push(T,P,C),c.push(P,D,C),_+=6}u.addGroup(y,_,0),y+=_}function x(w){let S=m,_=new F,M=new A,b=0,E=w===!0?t:e,T=w===!0?1:-1;for(let D=1;D<=i;D++)d.push(0,g*T,0),h.push(0,T,0),f.push(.5,.5),m++;let P=m;for(let D=0;D<=i;D++){let O=D/i*l+a,B=Math.cos(O),V=Math.sin(O);M.x=E*V,M.y=g*T,M.z=E*B,d.push(M.x,M.y,M.z),h.push(0,T,0),_.x=B*.5+.5,_.y=V*.5*T+.5,f.push(_.x,_.y),m++}for(let D=0;D<i;D++){let C=S+D,O=P+D;w===!0?c.push(O,O+1,C):c.push(O+1,O,C),b+=3}u.addGroup(y,b,w===!0?1:2),y+=b}}static fromJSON(t){return new Ja(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},fc=class extends Ja{constructor(t=1,e=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new fc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},pc=class extends Me{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,w=new A,S=new A;for(let _=0;_<e.length;_+=3)f(e[_+0],x),f(e[_+1],w),f(e[_+2],S),l(x,w,S,v)}function l(v,x,w,S){let _=S+1,M=[];for(let b=0;b<=_;b++){M[b]=[];let E=v.clone().lerp(w,b/_),T=x.clone().lerp(w,b/_),P=_-b;for(let D=0;D<=P;D++)D===0&&b===_?M[b][D]=E:M[b][D]=E.clone().lerp(T,D/P)}for(let b=0;b<_;b++)for(let E=0;E<2*(_-b)-1;E++){let T=Math.floor(E/2);E%2===0?(h(M[b][T+1]),h(M[b+1][T]),h(M[b][T])):(h(M[b][T+1]),h(M[b+1][T+1]),h(M[b+1][T]))}}function u(v){let x=new A;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,S=y(v)/Math.PI+.5;o.push(w,1-S)}m(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],S=o[v+4],_=Math.max(x,w,S),M=Math.min(x,w,S);_>.9&&M<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function m(){let v=new A,x=new A,w=new A,S=new A,_=new F,M=new F,b=new F;for(let E=0,T=0;E<s.length;E+=9,T+=6){v.set(s[E+0],s[E+1],s[E+2]),x.set(s[E+3],s[E+4],s[E+5]),w.set(s[E+6],s[E+7],s[E+8]),_.set(o[T+0],o[T+1]),M.set(o[T+2],o[T+3]),b.set(o[T+4],o[T+5]),S.copy(v).add(x).add(w).divideScalar(3);let P=g(S);p(_,T+0,v,P),p(M,T+2,x,P),p(b,T+4,w,P)}}function p(v,x,w,S){S<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new pc(t.vertices,t.indices,t.radius,t.details)}},mc=class extends pc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new mc(t.radius,t.detail)}};var ao=class extends Za{constructor(t){super(t),this.uuid=ys(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(new Za().fromJSON(i))}return this}},jB={triangulate:function(r,t,e=2){let n=t&&t.length,i=n?t[0]*e:r.length,s=UA(r,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=KB(r,t,s,e)),r.length>80*e){a=u=r[0],l=c=r[1];for(let m=e;m<i;m+=e)d=r[m],h=r[m+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return wh(s,o,e,a,l,f,0),o}};function UA(r,t,e,n,i){let s,o;if(i===aF(r,t,e,n)>0)for(s=t;s<e;s+=n)o=dA(s,r[s],r[s+1],o);else for(s=e-n;s>=t;s-=n)o=dA(s,r[s],r[s+1],o);return o&&om(o,o.next)&&(Ah(o),o=o.next),o}function $a(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(om(e,e.next)||rn(e.prev,e,e.next)===0)){if(Ah(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function wh(r,t,e,n,i,s,o){if(!r)return;!o&&s&&tF(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?XB(r,n,i,s):qB(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),Ah(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=YB($a(r),t,e),wh(r,t,e,n,i,s,2)):o===2&&QB(r,t,e,n,i,s):wh($a(r),t,e,n,i,s,1);break}}}function qB(r){let t=r.prev,e=r,n=r.next;if(rn(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=i<s?i<o?i:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=i>s?i>o?i:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,m=n.next;for(;m!==t;){if(m.x>=c&&m.x<=h&&m.y>=d&&m.y<=f&&sc(i,a,s,l,o,u,m.x,m.y)&&rn(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function XB(r,t,e,n){let i=r.prev,s=r,o=r.next;if(rn(i,s,o)>=0)return!1;let a=i.x,l=s.x,u=o.x,c=i.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,m=c<d?c<h?c:h:d<h?d:h,p=a>l?a>u?a:u:l>u?l:u,g=c>d?c>h?c:h:d>h?d:h,y=L0(f,m,t,e,n),v=L0(p,g,t,e,n),x=r.prevZ,w=r.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&sc(a,c,l,d,u,h,x.x,x.y)&&rn(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==i&&w!==o&&sc(a,c,l,d,u,h,w.x,w.y)&&rn(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&sc(a,c,l,d,u,h,x.x,x.y)&&rn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==i&&w!==o&&sc(a,c,l,d,u,h,w.x,w.y)&&rn(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function YB(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!om(i,s)&&kA(i,n,n.next,s)&&Sh(i,s)&&Sh(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Ah(n),Ah(n.next),n=r=s),n=n.next}while(n!==r);return $a(n)}function QB(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&iF(o,a)){let l=zA(o,a);o=$a(o,o.next),l=$a(l,l.next),wh(o,t,e,n,i,s,0),wh(l,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function KB(r,t,e,n){let i=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:r.length,u=UA(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(rF(u));for(i.sort(ZB),s=0;s<i.length;s++)e=JB(i[s],e);return e}function ZB(r,t){return r.x-t.x}function JB(r,t){let e=$B(r,t);if(!e)return t;let n=zA(e,r);return $a(n,n.next),$a(e,e.next)}function $B(r,t){let e=t,n=-1/0,i,s=r.x,o=r.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,i=e.x<e.next.x?e:e.next,h===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,u=i.y,c=1/0,d;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&sc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),Sh(e,r)&&(d<c||d===c&&(e.x>i.x||e.x===i.x&&eF(i,e)))&&(i=e,c=d)),e=e.next;while(e!==a);return i}function eF(r,t){return rn(r.prev,r,t.prev)<0&&rn(t.next,r,r.next)<0}function tF(r,t,e,n){let i=r;do i.z===0&&(i.z=L0(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,nF(i)}function nF(r){let t,e,n,i,s,o,a,l,u=1;do{for(e=r,r=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,u*=2}while(o>1);return r}function L0(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function rF(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function sc(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function iF(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!sF(r,t)&&(Sh(r,t)&&Sh(t,r)&&oF(r,t)&&(rn(r.prev,r,t.prev)||rn(r,t.prev,t))||om(r,t)&&rn(r.prev,r,r.next)>0&&rn(t.prev,t,t.next)>0)}function rn(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function om(r,t){return r.x===t.x&&r.y===t.y}function kA(r,t,e,n){let i=Cp(rn(r,t,e)),s=Cp(rn(r,t,n)),o=Cp(rn(e,n,r)),a=Cp(rn(e,n,t));return!!(i!==s&&o!==a||i===0&&Tp(r,e,t)||s===0&&Tp(r,n,t)||o===0&&Tp(e,r,n)||a===0&&Tp(e,t,n))}function Tp(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Cp(r){return r>0?1:r<0?-1:0}function sF(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&kA(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Sh(r,t){return rn(r.prev,r,r.next)<0?rn(r,t,r.next)>=0&&rn(r,r.prev,t)>=0:rn(r,t,r.prev)<0||rn(r,r.next,t)<0}function oF(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function zA(r,t){let e=new N0(r.i,r.x,r.y),n=new N0(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function dA(r,t,e,n){let i=new N0(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ah(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function N0(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function aF(r,t,e,n){let i=0;for(let s=t,o=e-n;s<e;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var gc=class{static area(t){let e=t.length,n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return gc.area(t)<0}static triangulateShape(t,e){let n=[],i=[],s=[];hA(t),fA(n,t);let o=t.length;e.forEach(hA);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,fA(n,e[l]);let a=jB.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function hA(r){let t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function fA(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}var yc=class extends pc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new yc(t.radius,t.detail)}};var el=class extends Me{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],d=new A,h=new A,f=[],m=[],p=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,w=0;y==0&&o==0?w=.5/e:y==n&&l==Math.PI&&(w=-.5/e);for(let S=0;S<=e;S++){let _=S/e;d.x=-t*Math.cos(i+_*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(i+_*s)*Math.sin(o+x*a),m.push(d.x,d.y,d.z),h.copy(d).normalize(),p.push(h.x,h.y,h.z),g.push(_+w,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],w=c[y][v],S=c[y+1][v],_=c[y+1][v+1];(y!==0||o>0)&&f.push(x,w,_),(y!==n-1||l<Math.PI)&&f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(t){return new el(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var vc=class extends Me{constructor(t=1,e=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],d=new A,h=new A,f=new A,m=new A,p=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let w=x/n*s*Math.PI*2;v(w,s,o,t,f),v(w+.01,s,o,t,m),g.subVectors(m,f),y.addVectors(m,f),p.crossVectors(g,y),y.crossVectors(p,g),p.normalize(),y.normalize();for(let S=0;S<=i;++S){let _=S/i*Math.PI*2,M=-e*Math.cos(_),b=e*Math.sin(_);d.x=f.x+(M*y.x+b*p.x),d.y=f.y+(M*y.y+b*p.y),d.z=f.z+(M*y.z+b*p.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(S/i)}}for(let x=1;x<=n;x++)for(let w=1;w<=i;w++){let S=(i+1)*(x-1)+(w-1),_=(i+1)*x+(w-1),M=(i+1)*x+w,b=(i+1)*(x-1)+w;a.push(S,_,b),a.push(_,M,b)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(c,2));function v(x,w,S,_,M){let b=Math.cos(x),E=Math.sin(x),T=S/w*x,P=Math.cos(T);M.x=_*(2+P)*.5*b,M.y=_*(2+P)*E*.5,M.z=_*Math.sin(T)*.5}}static fromJSON(t){return new vc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Go(r,t,e){return GA(r)?new r.constructor(r.subarray(t,e!==void 0?e:r.length)):r.slice(t,e)}function Pp(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function GA(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var xc=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{e:{let o;t:{r:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break e}o=e.length;break t}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=e[--n-1],t>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},B0=class extends xc{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:A1,endingEnd:A1}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case _1:s=t,a=2*e-n;break;case M1:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case _1:o=t,l=2*n-e;break;case M1:o=1,l=n+i[1]-i[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(n-e)/(i-e),p=m*m,g=p*m,y=-h*g+2*h*p-h*m,v=(1+h)*g+(-1.5-2*h)*p+(-.5+h)*m+1,x=(-1-f)*g+(1.5+f)*p+.5*m,w=f*g-f*p;for(let S=0;S!==a;++S)s[S]=y*o[c+S]+v*o[u+S]+x*o[l+S]+w*o[d+S];return s}},F0=class extends xc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(i-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},U0=class extends xc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},zi=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Pp(e,this.TimeBufferType),this.values=Pp(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Pp(t.times,Array),values:Pp(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new U0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new F0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new B0(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Lp:e=this.InterpolantFactoryMethodDiscrete;break;case Np:e=this.InterpolantFactoryMethodLinear;break;case Nv:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Lp;case this.InterpolantFactoryMethodLinear:return Np;case this.InterpolantFactoryMethodSmooth:return Nv}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Go(n,s,o),this.values=Go(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&GA(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Go(this.times),e=Go(this.values),n=this.getValueSize(),i=this.getInterpolation()===Nv,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(i)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let m=0;m!==n;++m){let p=e[d+m];if(p!==e[h+m]||p!==e[f+m]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Go(t,0,o),this.values=Go(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=Go(this.times,0),e=Go(this.values,0),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};zi.prototype.TimeBufferType=Float32Array;zi.prototype.ValueBufferType=Float32Array;zi.prototype.DefaultInterpolation=Np;var tl=class extends zi{};tl.prototype.ValueTypeName="bool";tl.prototype.ValueBufferType=Array;tl.prototype.DefaultInterpolation=Lp;tl.prototype.InterpolantFactoryMethodLinear=void 0;tl.prototype.InterpolantFactoryMethodSmooth=void 0;var k0=class extends zi{};k0.prototype.ValueTypeName="color";var z0=class extends zi{};z0.prototype.ValueTypeName="number";var G0=class extends xc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e),u=t*a;for(let c=u+a;u!==c;u+=4)Je.slerpFlat(s,0,o,u-a,o,u,l);return s}},_h=class extends zi{InterpolantFactoryMethodLinear(t){return new G0(this.times,this.values,this.getValueSize(),t)}};_h.prototype.ValueTypeName="quaternion";_h.prototype.DefaultInterpolation=Np;_h.prototype.InterpolantFactoryMethodSmooth=void 0;var nl=class extends zi{};nl.prototype.ValueTypeName="string";nl.prototype.ValueBufferType=Array;nl.prototype.DefaultInterpolation=Lp;nl.prototype.InterpolantFactoryMethodLinear=void 0;nl.prototype.InterpolantFactoryMethodSmooth=void 0;var V0=class extends zi{};V0.prototype.ValueTypeName="vector";var pA={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(this.files[r]=t)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Mh=class{constructor(t,e,n){let i=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],m=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return m}return null}}},lF=new Mh,bc=class{constructor(t){this.manager=t!==void 0?t:lF,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},no={},H0=class extends Error{constructor(t,e){super(t),this.response=e}},wc=class extends bc{constructor(t){super(t)}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=pA.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(no[t]!==void 0){no[t].push({onLoad:e,onProgress:n,onError:i});return}no[t]=[],no[t].push({onLoad:e,onProgress:n,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=no[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,m=f!==0,p=0,g=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:w})=>{if(x)y.close();else{p+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let _=0,M=c.length;_<M;_++){let b=c[_];b.onProgress&&b.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw new H0(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(m=>f.decode(m))}}}).then(u=>{pA.add(t,u);let c=no[t];delete no[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=no[t];if(c===void 0)throw this.manager.itemError(t),u;delete no[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Yo=class extends pt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ne(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Yp=class extends Yo{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ne(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},u0=new ae,mA=new A,gA=new A,Eh=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new ae,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yh,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;mA.setFromMatrixPosition(t.matrixWorld),e.position.copy(mA),gA.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(gA),e.updateMatrixWorld(),u0.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(u0),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(u0)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},W0=class extends Eh{constructor(){super(new gn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=mh*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Qp=class extends Yo{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(pt.DEFAULT_UP),this.updateMatrix(),this.target=new pt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new W0}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},yA=new ae,oh=new A,d0=new A,j0=class extends Eh{constructor(){super(new gn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),oh.setFromMatrixPosition(t.matrixWorld),n.position.copy(oh),d0.copy(n.position),d0.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(d0),n.updateMatrixWorld(),i.makeTranslation(-oh.x,-oh.y,-oh.z),yA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yA)}},Kp=class extends Yo{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new j0}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},q0=class extends Eh{constructor(){super(new qa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Zp=class extends Yo{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(pt.DEFAULT_UP),this.updateMatrix(),this.target=new pt,this.shadow=new q0}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var X0=class extends Me{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Sc=class extends bc{constructor(t){super(t)}load(t,e,n,i){let s=this,o=new wc(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){let e={},n={};function i(f,m){if(e[m]!==void 0)return e[m];let g=f.interleavedBuffers[m],y=s(f,g.buffer),v=op(g.type,y),x=new jp(v,g.stride);return x.uuid=g.uuid,e[m]=x,x}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],y=new Uint32Array(g).buffer;return n[m]=y,y}let o=t.isInstancedBufferGeometry?new X0:new Me,a=t.data.index;if(a!==void 0){let f=op(a.type,a.array);o.setIndex(new Be(f,1))}let l=t.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(t.data,m.data);p=new Xa(g,m.itemSize,m.offset,m.normalized)}else{let g=op(m.type,m.array),y=m.isInstancedBufferAttribute?qp:Be;p=new y(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let u=t.data.morphAttributes;if(u)for(let f in u){let m=u[f],p=[];for(let g=0,y=m.length;g<y;g++){let v=m[g],x;if(v.isInterleavedBufferAttribute){let w=i(t.data,v.data);x=new Xa(w,v.itemSize,v.offset,v.normalized)}else{let w=op(v.type,v.array);x=new Be(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),p.push(x)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,m=d.length;f!==m;++f){let p=d[f];o.addGroup(p.start,p.count,p.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Rn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Jp=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vA(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=vA();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function vA(){return(typeof performance>"u"?Date:performance).now()}var rx="\\[\\]\\.:\\/",cF=new RegExp("["+rx+"]","g"),ix="[^"+rx+"]",uF="[^"+rx.replace("\\.","")+"]",dF=/((?:WC+[\/:])*)/.source.replace("WC",ix),hF=/(WCOD+)?/.source.replace("WCOD",uF),fF=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ix),pF=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ix),mF=new RegExp("^"+dF+hF+fF+pF+"$"),gF=["material","materials","bones","map"],Y0=class{constructor(t,e,n){let i=n||Rt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Rt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Rt.parseTrackName(e),this.node=Rt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Rt.Composite(t,e,n):new Rt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(cF,"")}static parseTrackName(t){let e=mF.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);gF.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=Rt.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[i];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Rt.Composite=Y0;Rt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Rt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Rt.prototype.GetterByBindingType=[Rt.prototype._getValue_direct,Rt.prototype._getValue_array,Rt.prototype._getValue_arrayElement,Rt.prototype._getValue_toArray];Rt.prototype.SetterByBindingTypeAndVersioning=[[Rt.prototype._setValue_direct,Rt.prototype._setValue_direct_setNeedsUpdate,Rt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_array,Rt.prototype._setValue_array_setNeedsUpdate,Rt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_arrayElement,Rt.prototype._setValue_arrayElement_setNeedsUpdate,Rt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_fromArray,Rt.prototype._setValue_fromArray_setNeedsUpdate,Rt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Oq=new Float32Array(1);var ie=class{constructor(t){this.value=t}clone(){return new ie(this.value.clone===void 0?this.value:this.value.clone())}};var Ac=class{constructor(t,e,n=0,i=1/0){this.ray=new Fi(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new gh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return Q0(t,this,n,e),n.sort(xA),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)Q0(t[i],this,n,e);return n.sort(xA),n}};function xA(r,t){return r.distance-t.distance}function Q0(r,t,e,n){if(r.layers.test(t.layers)&&r.raycast(t,e),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Q0(i[s],t,e,!0)}}var Th=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(zn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var bA=new F,$p=class{constructor(t=new F(1/0,1/0),e=new F(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=bA.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return bA.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},wA=new A,Dp=new A,Hn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){wA.subVectors(t,this.start),Dp.subVectors(this.end,this.start);let n=Dp.dot(Dp),s=Dp.dot(wA)/n;return e&&(s=zn(s,0,1)),s}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},SA=new A,em=class extends pt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Me,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Ae(i,3));let s=new vi({fog:!1,toneMapped:!1});this.cone=new Xo(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),SA.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(SA),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var tm=class extends In{constructor(t,e,n){let i=new el(e,4,2),s=new Ui({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var AA=new A,Ip=new A,_A=new A,nm=class extends pt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Me;i.setAttribute("position",new Ae([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new vi({fog:!1,toneMapped:!1});this.lightPlane=new Ya(i,s),this.add(this.lightPlane),i=new Me,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new Ya(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),AA.setFromMatrixPosition(this.light.matrixWorld),Ip.setFromMatrixPosition(this.light.target.matrixWorld),_A.subVectors(Ip,AA),this.lightPlane.lookAt(Ip),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(Ip),this.targetLine.scale.z=_A.length()}},Op=new A,on=new ki,Qo=class extends Xo{constructor(t){let e=new Me,n=new vi({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}e.setAttribute("position",new Ae(i,3)),e.setAttribute("color",new Ae(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Ne(16755200),c=new Ne(16711680),d=new Ne(43775),h=new Ne(16777215),f=new Ne(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,i=1;on.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mn("c",e,t,on,0,0,-1),mn("t",e,t,on,0,0,1),mn("n1",e,t,on,-n,-i,-1),mn("n2",e,t,on,n,-i,-1),mn("n3",e,t,on,-n,i,-1),mn("n4",e,t,on,n,i,-1),mn("f1",e,t,on,-n,-i,1),mn("f2",e,t,on,n,-i,1),mn("f3",e,t,on,-n,i,1),mn("f4",e,t,on,n,i,1),mn("u1",e,t,on,n*.7,i*1.1,-1),mn("u2",e,t,on,-n*.7,i*1.1,-1),mn("u3",e,t,on,0,i*2,-1),mn("cf1",e,t,on,-n,0,1),mn("cf2",e,t,on,n,0,1),mn("cf3",e,t,on,0,-i,1),mn("cf4",e,t,on,0,i,1),mn("cn1",e,t,on,-n,0,-1),mn("cn2",e,t,on,n,0,-1),mn("cn3",e,t,on,0,-i,-1),mn("cn4",e,t,on,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mn(r,t,e,n,i,s,o){Op.set(i,s,o).unproject(n);let a=t[r];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Op.x,Op.y,Op.z)}}var Ko=class extends Xo{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Me;s.setIndex(new Be(n,1)),s.setAttribute("position",new Ae(i,3)),super(s,new vi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var rm=class extends Xo{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Me;i.setAttribute("position",new Ae(e,3)),i.setAttribute("color",new Ae(n,3));let s=new vi({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){let i=new Ne,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:lo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=lo);var Ec=".",Ch=Symbol("target"),sx=Symbol("unsubscribe");function Ph(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function VA(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var ci=Array.isArray;function rl(r){return typeof r=="symbol"}var yF={after:(r,t)=>ci(r)?r.slice(t.length):t===""?r:r.slice(t.length+1),concat:(r,t)=>ci(r)?(r=[...r],t&&r.push(t),r):t&&t.toString!==void 0?(r!==""&&(r+=Ec),rl(t)?r+t.toString():r+t):r,initial:r=>{if(ci(r))return r.slice(0,-1);if(r==="")return r;let t=r.lastIndexOf(Ec);return t===-1?"":r.slice(0,t)},last:r=>{if(ci(r))return r[r.length-1]||"";if(r==="")return r;let t=r.lastIndexOf(Ec);return t===-1?r:r.slice(t+1)},walk:(r,t)=>{if(ci(r))for(let e of r)t(e);else if(r!==""){let e=0,n=r.indexOf(Ec);if(n===-1)t(r);else for(;e<r.length;)n===-1&&(n=r.length),t(r.slice(e,n)),e=n+1,n=r.indexOf(Ec,e)}},get(r,t){return this.walk(t,e=>{r&&(r=r[e])}),r}},Rr=yF;function ox(r){return typeof r=="object"&&typeof r.next=="function"}function ax(r,t,e,n,i){let s=r.next;if(t.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],n),o.value[1]=i(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[Ch].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,n)),o};return r}function am(r,t,e){return r.isUnsubscribed||t.ignoreSymbols&&rl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Dh=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),i=n[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),n[e]=i),i}getProxy(t,e,n,i){if(this.isUnsubscribed)return t;let s=t[i],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,n):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Rr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,i,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,i):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let i=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Tc(r){return toString.call(r)==="[object Object]"}function Cc(){return!0}function Zo(r,t){return r.length!==t.length||r.some((e,n)=>t[n]!==e)}var lm=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var vF=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),lx={push:Cc,pop:Cc,shift:Cc,unshift:Cc,copyWithin:Zo,reverse:Zo,sort:Zo,splice:Zo,flat:Zo,fill:Zo},HA=new Set([...lm,...vF,...Object.keys(lx)]);function Pc(r,t){if(r.size!==t.size)return!0;for(let e of r)if(!t.has(e))return!0;return!1}var cx=["keys","values","entries"],ux=new Set(["has","toString"]),dx={add:Pc,clear:Pc,delete:Pc,forEach:Pc},WA=new Set([...ux,...Object.keys(dx),...cx]);function Dc(r,t){if(r.size!==t.size)return!0;let e;for(let[n,i]of r)if(e=t.get(n),e!==i||e===void 0&&!t.has(n))return!0;return!1}var xF=new Set([...ux,"get"]),hx={set:Dc,clear:Dc,delete:Dc,forEach:Dc},jA=new Set([...xF,...Object.keys(hx),...cx]);var nr=class{constructor(t,e,n,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return lm.has(t)}_shallowClone(t){let e=t;if(Tc(t))e={...t};else if(ci(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,i]of t.entries())e.set(n,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,i){return t?(ci(i)?this._onIsChanged=lx[e]:i instanceof Set?this._onIsChanged=dx[e]:i instanceof Map&&(this._onIsChanged=hx[e]),i):n}update(t,e,n){let i=Rr.after(t,this._path);if(e!=="length"){let s=this.clone;Rr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],Rr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Ic=class extends nr{static isHandledMethod(t){return HA.has(t)}};var Ih=class extends nr{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Oc=class extends nr{static isHandledMethod(t){return WA.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var Rc=class extends nr{static isHandledMethod(t){return jA.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var Oh=class extends nr{constructor(t,e,n,i){super(void 0,e,n,i),this._arg1=n[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var Rh=class extends nr{constructor(t,e,n,i){super(void 0,e,n,i),this._weakKey=n[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Vi=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Tc(t)||ci(t)||Ph(t)}static isHandledMethod(t,e){return Tc(t)?nr.isHandledMethod(e):ci(t)?Ic.isHandledMethod(e):t instanceof Set?Oc.isHandledMethod(e):t instanceof Map?Rc.isHandledMethod(e):Ph(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let i=nr;ci(t)?i=Ic:t instanceof Date?i=Ih:t instanceof Set?i=Oc:t instanceof Map?i=Rc:t instanceof WeakSet?i=Oh:t instanceof WeakMap&&(i=Rh),this._stack.push(new i(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:i}=t,s=Vi.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var bF={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},fx=(r,t,e={})=>{e={...bF,...e};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new Dh(i),u=typeof e.onValidate=="function",c=new Vi(u),d=(v,x,w,S,_)=>!u||c.isCloning||e.onValidate(Rr.concat(l.getPath(v),x),w,S,_)===!0,h=(v,x,w,S)=>{!am(l,e,x)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,_)=>{c.isCloning?c.update(v,x,S):t(Rr.concat(v,x),w,S,_)},m=v=>v&&(v[n]||v),p=(v,x,w,S)=>VA(v)||w==="constructor"||s&&!Vi.isHandledMethod(x,w)||am(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,r)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,Rr.concat(S,w),g,n)),g={get(v,x,w){if(rl(x)){if(x===n||x===Ch)return v;if(x===sx&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Ph(v)?Reflect.get(v,x):Reflect.get(v,x,w);return p(S,v,x)},set(v,x,w,S){w=m(w);let _=v[n]||v,M=_[x];if(i(M,w)&&x in v)return!0;let b=d(v,x,w,M);return b&&l.setProperty(_,x,w,S,M)?(h(v,x,v[x],M),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];d(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&h(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=d(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(h(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&Vi.isHandledType(S)){let _=Rr.initial(l.getPath(v)),M=Vi.isHandledMethod(S,v.name);c.start(S,_,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),M?w.map(P=>m(P)):w),E=c.isChanged(S,i),T=c.stop();if(Vi.isHandledType(b)&&M&&(x instanceof Map&&v.name==="get"&&(_=Rr.concat(_,w[0])),b=l.getProxy(b,_,g)),E){let P={name:v.name,args:w,result:b},D=c.isCloning?Rr.initial(_):_,C=c.isCloning?Rr.last(_):"";d(Rr.get(r,D),C,S,T,P)?f(D,C,S,T,P):c.undo(S)}return(x instanceof Map||x instanceof Set)&&ox(b)?ax(b,v,x,_,p):b}return Reflect.apply(v,x,w)}},y=l.getProxy(r,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};fx.target=r=>r&&r[Ch]||r;fx.unsubscribe=r=>r[sx]||r;var px=fx;var wF=typeof global=="object"&&global&&global.Object===Object&&global,cm=wF;var SF=typeof self=="object"&&self&&self.Object===Object&&self,AF=cm||SF||Function("return this")(),ln=AF;var _F=ln.Symbol,rr=_F;var qA=Object.prototype,MF=qA.hasOwnProperty,EF=qA.toString,Lh=rr?rr.toStringTag:void 0;function TF(r){var t=MF.call(r,Lh),e=r[Lh];try{r[Lh]=void 0;var n=!0}catch{}var i=EF.call(r);return n&&(t?r[Lh]=e:delete r[Lh]),i}var XA=TF;var CF=Object.prototype,PF=CF.toString;function DF(r){return PF.call(r)}var YA=DF;var IF="[object Null]",OF="[object Undefined]",QA=rr?rr.toStringTag:void 0;function RF(r){return r==null?r===void 0?OF:IF:QA&&QA in Object(r)?XA(r):YA(r)}var ui=RF;function LF(r){return r!=null&&typeof r=="object"}var mr=LF;var NF="[object Symbol]";function BF(r){return typeof r=="symbol"||mr(r)&&ui(r)==NF}var Jo=BF;function FF(r,t){for(var e=-1,n=r==null?0:r.length,i=Array(n);++e<n;)i[e]=t(r[e],e,r);return i}var um=FF;var UF=Array.isArray,Wn=UF;var kF=1/0,KA=rr?rr.prototype:void 0,ZA=KA?KA.toString:void 0;function JA(r){if(typeof r=="string")return r;if(Wn(r))return um(r,JA)+"";if(Jo(r))return ZA?ZA.call(r):"";var t=r+"";return t=="0"&&1/r==-kF?"-0":t}var $A=JA;var zF=/\s/;function GF(r){for(var t=r.length;t--&&zF.test(r.charAt(t)););return t}var e_=GF;var VF=/^\s+/;function HF(r){return r&&r.slice(0,e_(r)+1).replace(VF,"")}var t_=HF;function WF(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var Ln=WF;var n_=0/0,jF=/^[-+]0x[0-9a-f]+$/i,qF=/^0b[01]+$/i,XF=/^0o[0-7]+$/i,YF=parseInt;function QF(r){if(typeof r=="number")return r;if(Jo(r))return n_;if(Ln(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=Ln(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=t_(r);var e=qF.test(r);return e||XF.test(r)?YF(r.slice(2),e?2:8):jF.test(r)?n_:+r}var mx=QF;function KF(r){return r}var r_=KF;var ZF="[object AsyncFunction]",JF="[object Function]",$F="[object GeneratorFunction]",eU="[object Proxy]";function tU(r){if(!Ln(r))return!1;var t=ui(r);return t==JF||t==$F||t==ZF||t==eU}var dm=tU;var nU=ln["__core-js_shared__"],hm=nU;var i_=function(){var r=/[^.]+$/.exec(hm&&hm.keys&&hm.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function rU(r){return!!i_&&i_ in r}var s_=rU;var iU=Function.prototype,sU=iU.toString;function oU(r){if(r!=null){try{return sU.call(r)}catch{}try{return r+""}catch{}}return""}var co=oU;var aU=/[\\^$.*+?()[\]{}|]/g,lU=/^\[object .+?Constructor\]$/,cU=Function.prototype,uU=Object.prototype,dU=cU.toString,hU=uU.hasOwnProperty,fU=RegExp("^"+dU.call(hU).replace(aU,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pU(r){if(!Ln(r)||s_(r))return!1;var t=dm(r)?fU:lU;return t.test(co(r))}var o_=pU;function mU(r,t){return r?.[t]}var a_=mU;function gU(r,t){var e=a_(r,t);return o_(e)?e:void 0}var Vr=gU;var yU=Vr(ln,"WeakMap"),fm=yU;var l_=Object.create,vU=function(){function r(){}return function(t){if(!Ln(t))return{};if(l_)return l_(t);r.prototype=t;var e=new r;return r.prototype=void 0,e}}(),c_=vU;function xU(r,t,e){switch(e.length){case 0:return r.call(t);case 1:return r.call(t,e[0]);case 2:return r.call(t,e[0],e[1]);case 3:return r.call(t,e[0],e[1],e[2])}return r.apply(t,e)}var u_=xU;function bU(r,t){var e=-1,n=r.length;for(t||(t=Array(n));++e<n;)t[e]=r[e];return t}var d_=bU;var wU=800,SU=16,AU=Date.now;function _U(r){var t=0,e=0;return function(){var n=AU(),i=SU-(n-e);if(e=n,i>0){if(++t>=wU)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var h_=_U;function MU(r){return function(){return r}}var f_=MU;var EU=function(){try{var r=Vr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Lc=EU;var TU=Lc?function(r,t){return Lc(r,"toString",{configurable:!0,enumerable:!1,value:f_(t),writable:!0})}:r_,p_=TU;var CU=h_(p_),m_=CU;function PU(r,t){for(var e=-1,n=r==null?0:r.length;++e<n&&t(r[e],e,r)!==!1;);return r}var g_=PU;var DU=9007199254740991,IU=/^(?:0|[1-9]\d*)$/;function OU(r,t){var e=typeof r;return t=t??DU,!!t&&(e=="number"||e!="symbol"&&IU.test(r))&&r>-1&&r%1==0&&r<t}var Nc=OU;function RU(r,t,e){t=="__proto__"&&Lc?Lc(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e}var pm=RU;function LU(r,t){return r===t||r!==r&&t!==t}var Bc=LU;var NU=Object.prototype,BU=NU.hasOwnProperty;function FU(r,t,e){var n=r[t];(!(BU.call(r,t)&&Bc(n,e))||e===void 0&&!(t in r))&&pm(r,t,e)}var Fc=FU;function UU(r,t,e,n){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],r[a],a,e,r):void 0;l===void 0&&(l=r[a]),i?pm(e,a,l):Fc(e,a,l)}return e}var xs=UU;var y_=Math.max;function kU(r,t,e){return t=y_(t===void 0?r.length-1:t,0),function(){for(var n=arguments,i=-1,s=y_(n.length-t,0),o=Array(s);++i<s;)o[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=e(o),u_(r,this,a)}}var v_=kU;var zU=9007199254740991;function GU(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=zU}var Uc=GU;function VU(r){return r!=null&&Uc(r.length)&&!dm(r)}var mm=VU;var HU=Object.prototype;function WU(r){var t=r&&r.constructor,e=typeof t=="function"&&t.prototype||HU;return r===e}var kc=WU;function jU(r,t){for(var e=-1,n=Array(r);++e<r;)n[e]=t(e);return n}var x_=jU;var qU="[object Arguments]";function XU(r){return mr(r)&&ui(r)==qU}var gx=XU;var b_=Object.prototype,YU=b_.hasOwnProperty,QU=b_.propertyIsEnumerable,KU=gx(function(){return arguments}())?gx:function(r){return mr(r)&&YU.call(r,"callee")&&!QU.call(r,"callee")},zc=KU;function ZU(){return!1}var w_=ZU;var __=typeof exports=="object"&&exports&&!exports.nodeType&&exports,S_=__&&typeof module=="object"&&module&&!module.nodeType&&module,JU=S_&&S_.exports===__,A_=JU?ln.Buffer:void 0,$U=A_?A_.isBuffer:void 0,ek=$U||w_,il=ek;var tk="[object Arguments]",nk="[object Array]",rk="[object Boolean]",ik="[object Date]",sk="[object Error]",ok="[object Function]",ak="[object Map]",lk="[object Number]",ck="[object Object]",uk="[object RegExp]",dk="[object Set]",hk="[object String]",fk="[object WeakMap]",pk="[object ArrayBuffer]",mk="[object DataView]",gk="[object Float32Array]",yk="[object Float64Array]",vk="[object Int8Array]",xk="[object Int16Array]",bk="[object Int32Array]",wk="[object Uint8Array]",Sk="[object Uint8ClampedArray]",Ak="[object Uint16Array]",_k="[object Uint32Array]",Xt={};Xt[gk]=Xt[yk]=Xt[vk]=Xt[xk]=Xt[bk]=Xt[wk]=Xt[Sk]=Xt[Ak]=Xt[_k]=!0;Xt[tk]=Xt[nk]=Xt[pk]=Xt[rk]=Xt[mk]=Xt[ik]=Xt[sk]=Xt[ok]=Xt[ak]=Xt[lk]=Xt[ck]=Xt[uk]=Xt[dk]=Xt[hk]=Xt[fk]=!1;function Mk(r){return mr(r)&&Uc(r.length)&&!!Xt[ui(r)]}var M_=Mk;function Ek(r){return function(t){return r(t)}}var Gc=Ek;var E_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Nh=E_&&typeof module=="object"&&module&&!module.nodeType&&module,Tk=Nh&&Nh.exports===E_,yx=Tk&&cm.process,Ck=function(){try{var r=Nh&&Nh.require&&Nh.require("util").types;return r||yx&&yx.binding&&yx.binding("util")}catch{}}(),uo=Ck;var T_=uo&&uo.isTypedArray,Pk=T_?Gc(T_):M_,gm=Pk;var Dk=Object.prototype,Ik=Dk.hasOwnProperty;function Ok(r,t){var e=Wn(r),n=!e&&zc(r),i=!e&&!n&&il(r),s=!e&&!n&&!i&&gm(r),o=e||n||i||s,a=o?x_(r.length,String):[],l=a.length;for(var u in r)(t||Ik.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Nc(u,l)))&&a.push(u);return a}var ym=Ok;function Rk(r,t){return function(e){return r(t(e))}}var vm=Rk;var Lk=vm(Object.keys,Object),C_=Lk;var Nk=Object.prototype,Bk=Nk.hasOwnProperty;function Fk(r){if(!kc(r))return C_(r);var t=[];for(var e in Object(r))Bk.call(r,e)&&e!="constructor"&&t.push(e);return t}var P_=Fk;function Uk(r){return mm(r)?ym(r):P_(r)}var Vc=Uk;function kk(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var D_=kk;var zk=Object.prototype,Gk=zk.hasOwnProperty;function Vk(r){if(!Ln(r))return D_(r);var t=kc(r),e=[];for(var n in r)n=="constructor"&&(t||!Gk.call(r,n))||e.push(n);return e}var I_=Vk;function Hk(r){return mm(r)?ym(r,!0):I_(r)}var Hc=Hk;var Wk=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jk=/^\w*$/;function qk(r,t){if(Wn(r))return!1;var e=typeof r;return e=="number"||e=="symbol"||e=="boolean"||r==null||Jo(r)?!0:jk.test(r)||!Wk.test(r)||t!=null&&r in Object(t)}var O_=qk;var Xk=Vr(Object,"create"),ho=Xk;function Yk(){this.__data__=ho?ho(null):{},this.size=0}var R_=Yk;function Qk(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}var L_=Qk;var Kk="__lodash_hash_undefined__",Zk=Object.prototype,Jk=Zk.hasOwnProperty;function $k(r){var t=this.__data__;if(ho){var e=t[r];return e===Kk?void 0:e}return Jk.call(t,r)?t[r]:void 0}var N_=$k;var ez=Object.prototype,tz=ez.hasOwnProperty;function nz(r){var t=this.__data__;return ho?t[r]!==void 0:tz.call(t,r)}var B_=nz;var rz="__lodash_hash_undefined__";function iz(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=ho&&t===void 0?rz:t,this}var F_=iz;function Wc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}Wc.prototype.clear=R_;Wc.prototype.delete=L_;Wc.prototype.get=N_;Wc.prototype.has=B_;Wc.prototype.set=F_;var vx=Wc;function sz(){this.__data__=[],this.size=0}var U_=sz;function oz(r,t){for(var e=r.length;e--;)if(Bc(r[e][0],t))return e;return-1}var $o=oz;var az=Array.prototype,lz=az.splice;function cz(r){var t=this.__data__,e=$o(t,r);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():lz.call(t,e,1),--this.size,!0}var k_=cz;function uz(r){var t=this.__data__,e=$o(t,r);return e<0?void 0:t[e][1]}var z_=uz;function dz(r){return $o(this.__data__,r)>-1}var G_=dz;function hz(r,t){var e=this.__data__,n=$o(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}var V_=hz;function jc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}jc.prototype.clear=U_;jc.prototype.delete=k_;jc.prototype.get=z_;jc.prototype.has=G_;jc.prototype.set=V_;var ea=jc;var fz=Vr(ln,"Map"),ta=fz;function pz(){this.size=0,this.__data__={hash:new vx,map:new(ta||ea),string:new vx}}var H_=pz;function mz(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}var W_=mz;function gz(r,t){var e=r.__data__;return W_(t)?e[typeof t=="string"?"string":"hash"]:e.map}var na=gz;function yz(r){var t=na(this,r).delete(r);return this.size-=t?1:0,t}var j_=yz;function vz(r){return na(this,r).get(r)}var q_=vz;function xz(r){return na(this,r).has(r)}var X_=xz;function bz(r,t){var e=na(this,r),n=e.size;return e.set(r,t),this.size+=e.size==n?0:1,this}var Y_=bz;function qc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}qc.prototype.clear=H_;qc.prototype.delete=j_;qc.prototype.get=q_;qc.prototype.has=X_;qc.prototype.set=Y_;var sl=qc;var wz="Expected a function";function xx(r,t){if(typeof r!="function"||t!=null&&typeof t!="function")throw new TypeError(wz);var e=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=e.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return e.cache=s.set(i,o)||s,o};return e.cache=new(xx.Cache||sl),e}xx.Cache=sl;var Q_=xx;var Sz=500;function Az(r){var t=Q_(r,function(n){return e.size===Sz&&e.clear(),n}),e=t.cache;return t}var K_=Az;var _z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Mz=/\\(\\)?/g,Ez=K_(function(r){var t=[];return r.charCodeAt(0)===46&&t.push(""),r.replace(_z,function(e,n,i,s){t.push(i?s.replace(Mz,"$1"):n||e)}),t}),Z_=Ez;function Tz(r){return r==null?"":$A(r)}var J_=Tz;function Cz(r,t){return Wn(r)?r:O_(r,t)?[r]:Z_(J_(r))}var bi=Cz;var Pz=1/0;function Dz(r){if(typeof r=="string"||Jo(r))return r;var t=r+"";return t=="0"&&1/r==-Pz?"-0":t}var ra=Dz;function Iz(r,t){t=bi(t,r);for(var e=0,n=t.length;r!=null&&e<n;)r=r[ra(t[e++])];return e&&e==n?r:void 0}var xm=Iz;function Oz(r,t){for(var e=-1,n=t.length,i=r.length;++e<n;)r[i+e]=t[e];return r}var Xc=Oz;var $_=rr?rr.isConcatSpreadable:void 0;function Rz(r){return Wn(r)||zc(r)||!!($_&&r&&r[$_])}var eM=Rz;function tM(r,t,e,n,i){var s=-1,o=r.length;for(e||(e=eM),i||(i=[]);++s<o;){var a=r[s];t>0&&e(a)?t>1?tM(a,t-1,e,n,i):Xc(i,a):n||(i[i.length]=a)}return i}var nM=tM;function Lz(r){var t=r==null?0:r.length;return t?nM(r,1):[]}var rM=Lz;function Nz(r){return m_(v_(r,void 0,rM),r+"")}var bm=Nz;var Bz=vm(Object.getPrototypeOf,Object),Yc=Bz;var Fz="[object Object]",Uz=Function.prototype,kz=Object.prototype,iM=Uz.toString,zz=kz.hasOwnProperty,Gz=iM.call(Object);function Vz(r){if(!mr(r)||ui(r)!=Fz)return!1;var t=Yc(r);if(t===null)return!0;var e=zz.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&iM.call(e)==Gz}var sM=Vz;function Hz(r,t,e){var n=-1,i=r.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+t];return s}var oM=Hz;function Wz(){this.__data__=new ea,this.size=0}var aM=Wz;function jz(r){var t=this.__data__,e=t.delete(r);return this.size=t.size,e}var lM=jz;function qz(r){return this.__data__.get(r)}var cM=qz;function Xz(r){return this.__data__.has(r)}var uM=Xz;var Yz=200;function Qz(r,t){var e=this.__data__;if(e instanceof ea){var n=e.__data__;if(!ta||n.length<Yz-1)return n.push([r,t]),this.size=++e.size,this;e=this.__data__=new sl(n)}return e.set(r,t),this.size=e.size,this}var dM=Qz;function Qc(r){var t=this.__data__=new ea(r);this.size=t.size}Qc.prototype.clear=aM;Qc.prototype.delete=lM;Qc.prototype.get=cM;Qc.prototype.has=uM;Qc.prototype.set=dM;var Kc=Qc;function Kz(r,t){return r&&xs(t,Vc(t),r)}var hM=Kz;function Zz(r,t){return r&&xs(t,Hc(t),r)}var fM=Zz;var yM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pM=yM&&typeof module=="object"&&module&&!module.nodeType&&module,Jz=pM&&pM.exports===yM,mM=Jz?ln.Buffer:void 0,gM=mM?mM.allocUnsafe:void 0;function $z(r,t){if(t)return r.slice();var e=r.length,n=gM?gM(e):new r.constructor(e);return r.copy(n),n}var vM=$z;function eG(r,t){for(var e=-1,n=r==null?0:r.length,i=0,s=[];++e<n;){var o=r[e];t(o,e,r)&&(s[i++]=o)}return s}var xM=eG;function tG(){return[]}var wm=tG;var nG=Object.prototype,rG=nG.propertyIsEnumerable,bM=Object.getOwnPropertySymbols,iG=bM?function(r){return r==null?[]:(r=Object(r),xM(bM(r),function(t){return rG.call(r,t)}))}:wm,Zc=iG;function sG(r,t){return xs(r,Zc(r),t)}var wM=sG;var oG=Object.getOwnPropertySymbols,aG=oG?function(r){for(var t=[];r;)Xc(t,Zc(r)),r=Yc(r);return t}:wm,Sm=aG;function lG(r,t){return xs(r,Sm(r),t)}var SM=lG;function cG(r,t,e){var n=t(r);return Wn(r)?n:Xc(n,e(r))}var Am=cG;function uG(r){return Am(r,Vc,Zc)}var Bh=uG;function dG(r){return Am(r,Hc,Sm)}var _m=dG;var hG=Vr(ln,"DataView"),Mm=hG;var fG=Vr(ln,"Promise"),Em=fG;var pG=Vr(ln,"Set"),Tm=pG;var AM="[object Map]",mG="[object Object]",_M="[object Promise]",MM="[object Set]",EM="[object WeakMap]",TM="[object DataView]",gG=co(Mm),yG=co(ta),vG=co(Em),xG=co(Tm),bG=co(fm),ol=ui;(Mm&&ol(new Mm(new ArrayBuffer(1)))!=TM||ta&&ol(new ta)!=AM||Em&&ol(Em.resolve())!=_M||Tm&&ol(new Tm)!=MM||fm&&ol(new fm)!=EM)&&(ol=function(r){var t=ui(r),e=t==mG?r.constructor:void 0,n=e?co(e):"";if(n)switch(n){case gG:return TM;case yG:return AM;case vG:return _M;case xG:return MM;case bG:return EM}return t});var fo=ol;var wG=Object.prototype,SG=wG.hasOwnProperty;function AG(r){var t=r.length,e=new r.constructor(t);return t&&typeof r[0]=="string"&&SG.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var CM=AG;var _G=ln.Uint8Array,Jc=_G;function MG(r){var t=new r.constructor(r.byteLength);return new Jc(t).set(new Jc(r)),t}var $c=MG;function EG(r,t){var e=t?$c(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var PM=EG;var TG=/\w*$/;function CG(r){var t=new r.constructor(r.source,TG.exec(r));return t.lastIndex=r.lastIndex,t}var DM=CG;var IM=rr?rr.prototype:void 0,OM=IM?IM.valueOf:void 0;function PG(r){return OM?Object(OM.call(r)):{}}var RM=PG;function DG(r,t){var e=t?$c(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var LM=DG;var IG="[object Boolean]",OG="[object Date]",RG="[object Map]",LG="[object Number]",NG="[object RegExp]",BG="[object Set]",FG="[object String]",UG="[object Symbol]",kG="[object ArrayBuffer]",zG="[object DataView]",GG="[object Float32Array]",VG="[object Float64Array]",HG="[object Int8Array]",WG="[object Int16Array]",jG="[object Int32Array]",qG="[object Uint8Array]",XG="[object Uint8ClampedArray]",YG="[object Uint16Array]",QG="[object Uint32Array]";function KG(r,t,e){var n=r.constructor;switch(t){case kG:return $c(r);case IG:case OG:return new n(+r);case zG:return PM(r,e);case GG:case VG:case HG:case WG:case jG:case qG:case XG:case YG:case QG:return LM(r,e);case RG:return new n;case LG:case FG:return new n(r);case NG:return DM(r);case BG:return new n;case UG:return RM(r)}}var NM=KG;function ZG(r){return typeof r.constructor=="function"&&!kc(r)?c_(Yc(r)):{}}var BM=ZG;var JG="[object Map]";function $G(r){return mr(r)&&fo(r)==JG}var FM=$G;var UM=uo&&uo.isMap,eV=UM?Gc(UM):FM,kM=eV;var tV="[object Set]";function nV(r){return mr(r)&&fo(r)==tV}var zM=nV;var GM=uo&&uo.isSet,rV=GM?Gc(GM):zM,VM=rV;var iV=1,sV=2,oV=4,HM="[object Arguments]",aV="[object Array]",lV="[object Boolean]",cV="[object Date]",uV="[object Error]",WM="[object Function]",dV="[object GeneratorFunction]",hV="[object Map]",fV="[object Number]",jM="[object Object]",pV="[object RegExp]",mV="[object Set]",gV="[object String]",yV="[object Symbol]",vV="[object WeakMap]",xV="[object ArrayBuffer]",bV="[object DataView]",wV="[object Float32Array]",SV="[object Float64Array]",AV="[object Int8Array]",_V="[object Int16Array]",MV="[object Int32Array]",EV="[object Uint8Array]",TV="[object Uint8ClampedArray]",CV="[object Uint16Array]",PV="[object Uint32Array]",jt={};jt[HM]=jt[aV]=jt[xV]=jt[bV]=jt[lV]=jt[cV]=jt[wV]=jt[SV]=jt[AV]=jt[_V]=jt[MV]=jt[hV]=jt[fV]=jt[jM]=jt[pV]=jt[mV]=jt[gV]=jt[yV]=jt[EV]=jt[TV]=jt[CV]=jt[PV]=!0;jt[uV]=jt[WM]=jt[vV]=!1;function Cm(r,t,e,n,i,s){var o,a=t&iV,l=t&sV,u=t&oV;if(e&&(o=i?e(r,n,i,s):e(r)),o!==void 0)return o;if(!Ln(r))return r;var c=Wn(r);if(c){if(o=CM(r),!a)return d_(r,o)}else{var d=fo(r),h=d==WM||d==dV;if(il(r))return vM(r,a);if(d==jM||d==HM||h&&!i){if(o=l||h?{}:BM(r),!a)return l?SM(r,fM(o,r)):wM(r,hM(o,r))}else{if(!jt[d])return i?r:{};o=NM(r,d,a)}}s||(s=new Kc);var f=s.get(r);if(f)return f;s.set(r,o),VM(r)?r.forEach(function(g){o.add(Cm(g,t,e,g,r,s))}):kM(r)&&r.forEach(function(g,y){o.set(y,Cm(g,t,e,y,r,s))});var m=u?l?_m:Bh:l?Hc:Vc,p=c?void 0:m(r);return g_(p||r,function(g,y){p&&(y=g,g=r[y]),Fc(o,y,Cm(g,t,e,y,r,s))}),o}var Pm=Cm;var DV=1,IV=4;function OV(r){return Pm(r,DV|IV)}var po=OV;var RV="__lodash_hash_undefined__";function LV(r){return this.__data__.set(r,RV),this}var qM=LV;function NV(r){return this.__data__.has(r)}var XM=NV;function Dm(r){var t=-1,e=r==null?0:r.length;for(this.__data__=new sl;++t<e;)this.add(r[t])}Dm.prototype.add=Dm.prototype.push=qM;Dm.prototype.has=XM;var YM=Dm;function BV(r,t){for(var e=-1,n=r==null?0:r.length;++e<n;)if(t(r[e],e,r))return!0;return!1}var QM=BV;function FV(r,t){return r.has(t)}var KM=FV;var UV=1,kV=2;function zV(r,t,e,n,i,s){var o=e&UV,a=r.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(r),c=s.get(t);if(u&&c)return u==t&&c==r;var d=-1,h=!0,f=e&kV?new YM:void 0;for(s.set(r,t),s.set(t,r);++d<a;){var m=r[d],p=t[d];if(n)var g=o?n(p,m,d,t,r,s):n(m,p,d,r,t,s);if(g!==void 0){if(g)continue;h=!1;break}if(f){if(!QM(t,function(y,v){if(!KM(f,v)&&(m===y||i(m,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(m===p||i(m,p,e,n,s))){h=!1;break}}return s.delete(r),s.delete(t),h}var Im=zV;function GV(r){var t=-1,e=Array(r.size);return r.forEach(function(n,i){e[++t]=[i,n]}),e}var ZM=GV;function VV(r){var t=-1,e=Array(r.size);return r.forEach(function(n){e[++t]=n}),e}var JM=VV;var HV=1,WV=2,jV="[object Boolean]",qV="[object Date]",XV="[object Error]",YV="[object Map]",QV="[object Number]",KV="[object RegExp]",ZV="[object Set]",JV="[object String]",$V="[object Symbol]",e4="[object ArrayBuffer]",t4="[object DataView]",$M=rr?rr.prototype:void 0,bx=$M?$M.valueOf:void 0;function n4(r,t,e,n,i,s,o){switch(e){case t4:if(r.byteLength!=t.byteLength||r.byteOffset!=t.byteOffset)return!1;r=r.buffer,t=t.buffer;case e4:return!(r.byteLength!=t.byteLength||!s(new Jc(r),new Jc(t)));case jV:case qV:case QV:return Bc(+r,+t);case XV:return r.name==t.name&&r.message==t.message;case KV:case JV:return r==t+"";case YV:var a=ZM;case ZV:var l=n&HV;if(a||(a=JM),r.size!=t.size&&!l)return!1;var u=o.get(r);if(u)return u==t;n|=WV,o.set(r,t);var c=Im(a(r),a(t),n,i,s,o);return o.delete(r),c;case $V:if(bx)return bx.call(r)==bx.call(t)}return!1}var eE=n4;var r4=1,i4=Object.prototype,s4=i4.hasOwnProperty;function o4(r,t,e,n,i,s){var o=e&r4,a=Bh(r),l=a.length,u=Bh(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:s4.call(t,h)))return!1}var f=s.get(r),m=s.get(t);if(f&&m)return f==t&&m==r;var p=!0;s.set(r,t),s.set(t,r);for(var g=o;++d<l;){h=a[d];var y=r[h],v=t[h];if(n)var x=o?n(v,y,h,t,r,s):n(y,v,h,r,t,s);if(!(x===void 0?y===v||i(y,v,e,n,s):x)){p=!1;break}g||(g=h=="constructor")}if(p&&!g){var w=r.constructor,S=t.constructor;w!=S&&"constructor"in r&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(p=!1)}return s.delete(r),s.delete(t),p}var tE=o4;var a4=1,nE="[object Arguments]",rE="[object Array]",Om="[object Object]",l4=Object.prototype,iE=l4.hasOwnProperty;function c4(r,t,e,n,i,s){var o=Wn(r),a=Wn(t),l=o?rE:fo(r),u=a?rE:fo(t);l=l==nE?Om:l,u=u==nE?Om:u;var c=l==Om,d=u==Om,h=l==u;if(h&&il(r)){if(!il(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new Kc),o||gm(r)?Im(r,t,e,n,i,s):eE(r,t,l,e,n,i,s);if(!(e&a4)){var f=c&&iE.call(r,"__wrapped__"),m=d&&iE.call(t,"__wrapped__");if(f||m){var p=f?r.value():r,g=m?t.value():t;return s||(s=new Kc),i(p,g,e,n,s)}}return h?(s||(s=new Kc),tE(r,t,e,n,i,s)):!1}var sE=c4;function oE(r,t,e,n,i){return r===t?!0:r==null||t==null||!mr(r)&&!mr(t)?r!==r&&t!==t:sE(r,t,e,n,oE,i)}var aE=oE;function u4(r,t){return r!=null&&t in Object(r)}var lE=u4;function d4(r,t,e){t=bi(t,r);for(var n=-1,i=t.length,s=!1;++n<i;){var o=ra(t[n]);if(!(s=r!=null&&e(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&Uc(i)&&Nc(o,i)&&(Wn(r)||zc(r)))}var cE=d4;function h4(r,t){return r!=null&&cE(r,t,lE)}var uE=h4;var f4=function(){return ln.Date.now()},Rm=f4;var p4="Expected a function",m4=Math.max,g4=Math.min;function y4(r,t,e){var n,i,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(p4);t=mx(t)||0,Ln(e)&&(c=!!e.leading,d="maxWait"in e,s=d?m4(mx(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(_){var M=n,b=i;return n=i=void 0,u=_,o=r.apply(b,M),o}function m(_){return u=_,a=setTimeout(y,t),c?f(_):o}function p(_){var M=_-l,b=_-u,E=t-M;return d?g4(E,s-b):E}function g(_){var M=_-l,b=_-u;return l===void 0||M>=t||M<0||d&&b>=s}function y(){var _=Rm();if(g(_))return v(_);a=setTimeout(y,p(_))}function v(_){return a=void 0,h&&n?f(_):(n=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function w(){return a===void 0?o:v(Rm())}function S(){var _=Rm(),M=g(_);if(n=arguments,i=this,l=_,M){if(a===void 0)return m(l);if(d)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return S.cancel=x,S.flush=w,S}var al=y4;function v4(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}var dE=v4;function x4(r,t){return t.length<2?r:xm(r,oM(t,0,-1))}var hE=x4;function b4(r,t){return aE(r,t)}var ll=b4;function w4(r,t){return t=bi(t,r),r=hE(r,t),r==null||delete r[ra(dE(t))]}var fE=w4;function S4(r){return sM(r)?void 0:r}var pE=S4;var A4=1,_4=2,M4=4,E4=bm(function(r,t){var e={};if(r==null)return e;var n=!1;t=um(t,function(s){return s=bi(s,r),n||(n=s.length>1),s}),xs(r,_m(r),e),n&&(e=Pm(e,A4|_4|M4,pE));for(var i=t.length;i--;)fE(e,t[i]);return e}),eu=E4;function T4(r,t,e,n){if(!Ln(r))return r;t=bi(t,r);for(var i=-1,s=t.length,o=s-1,a=r;a!=null&&++i<s;){var l=ra(t[i]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Ln(c)?c:Nc(t[i+1])?[]:{})}Fc(a,l,u),a=a[l]}return r}var mE=T4;function C4(r,t,e){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=xm(r,o);e(a,o)&&mE(s,bi(o,r),a)}return s}var gE=C4;function P4(r,t){return gE(r,t,function(e,n){return uE(r,n)})}var yE=P4;var D4=bm(function(r,t){return r==null?{}:yE(r,t)}),ia=D4;var I4="Expected a function";function O4(r,t,e){var n=!0,i=!0;if(typeof r!="function")throw new TypeError(I4);return Ln(e)&&(n="leading"in e?!!e.leading:n,i="trailing"in e?!!e.trailing:i),al(r,t,{leading:n,maxWait:t,trailing:i})}var wx=O4;function vE(r){for(let t of Object.keys(r))r[t]===void 0&&delete r[t];return r}function Hi(r,t){return Object.setPrototypeOf(r,t),r}var R4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),L4=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),N4=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||cl&&"ontouchend"in document,B4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,F4=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,U4=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(t)},k4=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},Iee=R4(),cl=L4(),Lm=N4(),xE=B4(),jn=F4(),Sx=U4(),Ax=Number(k4());function Nm(r){return Array.isArray(r)?r:[r]}function bE(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}function Fh(r){return cl?r.metaKey:r.ctrlKey}var ke=[],Fm={},Uh={},Bm={};function wE(r){ke.includes(r)||ke.push(r)}function tu(r){delete Fm[r.pointerId];for(let t=0;t<ke.length;t++)if(ke[t].pointerId===r.pointerId){ke.splice(t,1);break}}function SE(){ke.splice(0,ke.length)}function Um(r){if(r.pointerType!=="touch")return;let t=Fm[r.pointerId];t===void 0&&(t={x:0,y:0},Fm[r.pointerId]=t),t.x=r.pageX,t.y=r.pageY}function km(r){let t=r.pointerId===ke[0].pointerId?ke[1]:ke[0];return Fm[t.pointerId]}function AE(r){Uh[r.key]=!0,Bm[r.key]=Bm[r.key]===void 0?1:Bm[r.key]+1}function _E(r){if(cl&&Uh.Meta)for(let t in Uh)Uh[t]=!1;else Uh[r.key]=!1;Bm={}}function ME(r){r.addEventListener("pointerdown",wE,!0),r.addEventListener("pointerdown",Um,!0),r.addEventListener("pointermove",Um,!0),r.addEventListener("pointerup",tu,!0),r.addEventListener("pointercancel",tu,!0),r.addEventListener("pointerleave",tu,!0),window.addEventListener("keydown",AE,!0),window.addEventListener("keyup",_E,!0)}function EE(r){r.removeEventListener("pointerdown",wE,!0),r.removeEventListener("pointerdown",Um,!0),r.removeEventListener("pointermove",Um,!0),r.removeEventListener("pointerup",tu,!0),r.removeEventListener("pointercancel",tu,!0),r.removeEventListener("pointerleave",tu,!0),window.removeEventListener("keydown",AE,!0),window.removeEventListener("keyup",_E,!0)}var CE,PE=new Promise(r=>{CE=r}),TE=!1;async function DE(){if(TE)return;let t=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.381/build",[e,n]=await Promise.all([import("./navmesh.js"),fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});CE(s),TE=!0}var OE,RE=new Promise(r=>{OE=r}),IE=!1;async function LE(){if(IE)return;let r=await import("./physics.js");await r.init(),OE(r),IE=!0}var Ft=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,Ft.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let n=e[t.id],i;n===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,Ft.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:n}=t,i=e[n];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Ft.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:i}}}}return null}};function kh(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let t=Object.getOwnPropertyNames(r);for(let e of t){let n=r[e];n&&typeof n=="object"&&kh(n)}return Object.freeze(r)}function NE(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}var nu=class extends Error{};function zm(r){let t={...r};return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}function bs(r,t,e){if(r===void 0?t===void 0?(r=0,t=10):r=t-10:t===void 0&&(t=r+10),r>t){let s=r;r=t,t=s}let n=[],i=1/(e+1);for(let s=0;s<e;s++){let o=r+(t-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function ru(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function BE(){return typeof process<"u"}function FE(r,t){for(let e of r)t(e.id,e.data)!==!0&&FE(e.children,t)}function UE(r,t){if(t(r.id,r.data)!==!0)for(let e of r.children)UE(e,t)}var Zt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Zt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kh(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,n){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}isDescendantOf(e,n){for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,n){if(e===null)this.traverse(n);else{let i=this.get(e);i&&UE(i,n)}}traverse(e){FE(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let i=e,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,Zt.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:n}){if(this.get(e)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:n,fi:i,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:i,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:n,fi:i,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new nu("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,m)=>f.fi-m.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>NE(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(e){var n=e;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(e,n,i){return this.insertAfterHelper(e,this.previous(e,n),i)}insertAfterHelper(e,n,i){let s=this.childrenArray(e);if(n===null){if(s.length===0)return bs(0,i,i);{let o=s[0].fi;return bs(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return bs(l,l+i,i)}else return bs(o.fi,a.fi,i)}}};var iu;(t=>{function r(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let i=n.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=r})(iu||(iu={}));var We=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kh(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,We.prototype);let n=e;return BE()||n.fillCaches(),n}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:n,id:i,data:s}=e,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:n}=e,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:i}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===e)return n;n=i.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let i=this;if(e===null){if(i.length===0)return bs(0,n,n);{let s=i[0].fi;return bs(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return bs(a,a+n,n)}else return bs(s.fi,o.fi,n)}}};function su(r){return r&&typeof r=="object"&&r instanceof Jt}var Jt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,i=0,s={};for(;i<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[i]],n!==void 0&&!su(n))return null;i+=1}n=n?zm(n):new Jt;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;i>0;){if(Object.keys(n).length===0){let l=e[i-1];l&&(n=zm(l),delete n[t.path[i-1]])}else{let l=e[i-1];if(l){let u=zm(l);u[t.path[i-1]]=n,n=u}else{let u=new Jt;u[t.path[i-1]]=n,n=u}}i-=1}let o=Object.setPrototypeOf(n,Jt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},mo;(n=>{function r(i,s){return zh(i,s)??i}n.apply=r;function t(i,s){return Mx(i,s)}n.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=Lr.zoomOnce(l,a[o]),l===void 0)return s;if(!su(l))return;o+=1}if(l===void 0)return s;if(!!su(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=_x([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(mo||(mo={}));function _x(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=zh(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=_x(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return n}function z4(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=zh(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function zh(r,t){if(!su(t))return t;if(r instanceof Zt){let e=_x(r,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else{if(r instanceof We)return z4(r,t);if(Array.isArray(r)){let e=!1,n=r.map((i,s)=>{let o=zh(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else{if(r instanceof Jt)return Mx(r,t);if(r&&typeof r=="object"){let e={},n=!1;for(let[i,s]of Object.entries(r)){let o=zh(s,t[i]);n=n||o!==void 0,o===void 0&&(o=s),e[i]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e):void 0}}}}function Mx(r,t){if(r===void 0)return t;if(t===void 0)return r;if(!su(t))return t;if(!su(r))return mo.apply(r,t);let e=new Set;for(let i of Object.keys(r))e.add(i);for(let i of Object.keys(t))e.add(i);let n=new Jt;for(let i of e){let s=Mx(r===void 0?void 0:r[i],t===void 0?void 0:t[i]);n[i]=s}return n}function kE(r,t){let e={cur:[],result:[],len:0};return r=Gh(r,t,e)??r,[r,e.result]}function Gm(r,t){return r===null?null:(r.cur[r.len]=t,r.len+=1,r)}function Vm(r){r&&(r.len-=1)}function G4(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function zE(r,t,e){let n=!1,i=r.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Gh(s.data,t,Gm(e,o));Vm(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=zE(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function V4(r,t,e){let n=!1,i=r.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Gh(s.data,t,Gm(e,o));return Vm(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function Gh(r,t,e){if(r instanceof Zt){let n=zE(r,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof We)return V4(r,t,e);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=Gh(s,t,Gm(e,o));return Vm(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"&&!ru(r)){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=Gh(o,t,Gm(e,s));Vm(e),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=t[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");G4(e)}return n}else return}}var Hm;(t=>{function r(e,n){let i=Lr.zoom(n,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=r})(Hm||(Hm={}));var gr;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof Jt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof Zt||l instanceof We||l instanceof Ft?h=l.runOp(u):h=iu.runOp(l,u)),h!==void 0)if(h!==null){let p=h.data;for(let g=d.length-1;g>=0;g--){let y=c[g],v=d[g];if(v instanceof Zt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof We){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Ft){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Jt){let x={...v,[y]:p};p=Object.setPrototypeOf(x,Jt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=p;p=[...v],p[y]=x}else p={...v,[y]:p};else return null}return{data:p,actual:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],m;if(l instanceof Zt){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof We){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)d.push(l),l=m;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function i(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(gr||(gr={}));var Ex;(l=>{function r(){return[]}l.empty=r;function t(u,c){let d=[];for(let h of u){let[f,...m]=h.path;f===c&&d.push({...h,path:m})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(h=>!c.some(f=>gr.subsumed(h,f))),...c]}l.compress=i;function s(u,c){return u.every(d=>c.every(h=>gr.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],f=[];for(let m of c)try{if(m.type===3){let p=Lr.zoom(d,[...m.path,m.id]),g=gr.apply(d,{...m,type:2});if(g!==null){d=g.data;let[y,v]=kE(d,{[m.id]:p});d=y;for(let x of v){let w=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[w]:p}}),f.push({type:0,path:x,props:{[w]:m.id}})}f.push(g.reverse),h.push(g.actual)}}else{let p=gr.apply(d,m);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof nu)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(Ex||(Ex={}));var GE=Symbol(),H4=Symbol(),jm=Symbol(),ul=class{reportOp(t,e,n=[]){let i=this;if(e===null)return;i._current=e.data;let s=n;for(;!(i instanceof Wm);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[jm];n&&n(),delete this._children[t]}}}},Cx=class extends ul{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,iu.runOp(this._current,t),t.path)}},Px=class extends ul{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Ft.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},VE={get(r,t){if(t===jm)return()=>{r._parent=null};if(t===GE)return r._current;if(t===H4)return r;let{_current:e,_children:n}=r;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e[t],o=qm(r,t,s);return o!==s?(n===void 0&&(n={},r._children=n),n[t]=o,o):s},has(r,t){return t in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,t){let e=r._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},W4={...VE,set(r,t,e){let n={type:0,props:{[t]:ir(e)??e}};return r.deleteChildren(t),r.runOp(n),!0},deleteProperty(r,t){let e={type:0,props:{[t]:void 0}};return r.deleteChildren(t),r.runOp(e),!0}},j4={...VE,set(r,t,e){return e===void 0?this.deleteProperty(r,t):(r.deleteChildren(t),r.runOp({type:1,id:t,data:e})),!0},deleteProperty(r,t){return r.runOp({type:2,id:t}),!0}},ou=class extends ul{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[jm]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=qm(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,i,s){this.runOp({type:7,parent:t,fi:e,id:n,data:i,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}moveBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},au=class extends ul{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[jm]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),i,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id;if(t(this.data(i),i))return this.get(i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:n}=this,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=qm(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Tx(r,t,e){if(r.length>0){let n=r[r.length-1];if(n.type===0&&t.type===0&&Lr.equal(n.path,e)){Object.assign(n.props,t.props);return}}r.push({...t,path:e})}var Wm=class extends ul{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,n,i){Tx(this.ts,e,t),Tx(this.actual,n,t),Tx(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function qm(r,t,e){return e instanceof Zt?new ou(r,t,e):e instanceof We?new au(r,t,e):e instanceof Ft?new Proxy(new Px(r,t,e),j4):e!==null&&typeof e=="object"?ru(e)?e:new Proxy(new Cx(r,t,e),W4):e}function Dx(r){let t=new Wm(r);return[qm(t,"",r),t]}function lu(r,t){let[e,n]=Dx(r);return t(e),n.result()}function ir(r){return r instanceof ou||r instanceof au?r._current:r!==null&&typeof r=="object"?r[GE]:r}var Lr;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function t(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof Zt||s instanceof ou)&&typeof o=="string")return s.data(o);if((s instanceof We||s instanceof au)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=n})(Lr||(Lr={}));function HE(r,t){let e=[];if(t.length===r.length)for(var n=0;n<r.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}function Wi(r,t){let e=[];if(t.length<=r.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}var Xm=class{},Vh=class extends Xm{constructor(e){super();this.id=e}},Hh=class extends Xm{constructor(e){super();this.data=e}};var Ox;try{Ox=new TextDecoder}catch{}var Ie,oa,J=0;var ZE=[],Rx=ZE,Lx=0,Hr={},Ct,sa,wi=0,ws=0,di,go,Nr=[],Lt,WE={useRecords:!1,mapsAsObjects:!0},Wh=class{},Bx=new Wh;Bx.name="MessagePack 0xC1";var cu=!1,Ss=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Ie)return nT(()=>(Qm(),this?this.unpack(t,e):Ss.prototype.unpack.call(WE,t,e)));oa=e>-1?e:t.length,J=0,Lx=0,ws=0,sa=null,Rx=ZE,di=null,Ie=t;try{Lt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Ie=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ss){if(Hr=this,this.structures)return Ct=this.structures,Ym();(!Ct||Ct.length>0)&&(Ct=[])}else Hr=WE,(!Ct||Ct.length>0)&&(Ct=[]);return Ym()}unpackMultiple(t,e){let n,i=0;try{cu=!0;let s=t.length,o=this?this.unpack(t,s):Jm.unpack(t,s);if(e){for(e(o);J<s;)if(i=J,e(Ym())===!1)return}else{for(n=[o];J<s;)i=J,n.push(Ym());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{cu=!1,Qm()}}_mergeStructures(t,e){t=t||[];for(let n=0,i=t.length;n<i;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let i=t[n],s=e[n];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[n]=i),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ym(){try{if(!Hr.trusted&&!cu){let t=Ct.sharedLength||0;t<Ct.length&&(Ct.length=t)}let r=cn();if(J==oa)Ct.restoreStructures&&jE(),Ct=null,Ie=null,go&&(go=null);else if(J>oa){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!cu)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw Ct.restoreStructures&&jE(),Qm(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function jE(){for(let r in Ct.restoreStructures)Ct[r]=Ct.restoreStructures[r];Ct.restoreStructures=null}function cn(){let r=Ie[J++];if(r<160)if(r<128){if(r<64)return r;{let t=Ct[r&63]||Hr.getStructures&&JE()[r&63];return t?(t.read||(t.read=Fx(t,r&63)),t.read()):r}}else if(r<144)if(r-=128,Hr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[eT()]=cn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(cn(),cn());return t}else{r-=144;let t=new Array(r);for(let e=0;e<r;e++)t[e]=cn();return t}else if(r<192){let t=r-160;if(ws>=J)return sa.slice(J-wi,(J+=t)-wi);if(ws==0&&oa<140){let e=t<16?Ux(t):$E(t);if(e!=null)return e}return Nx(t)}else{let t;switch(r){case 192:return null;case 193:return di?(t=cn(),t>0?di[1].slice(di.position1,di.position1+=t):di[0].slice(di.position0,di.position0-=t)):Bx;case 194:return!1;case 195:return!0;case 196:return Ix(Ie[J++]);case 197:return t=Lt.getUint16(J),J+=2,Ix(t);case 198:return t=Lt.getUint32(J),J+=4,Ix(t);case 199:return dl(Ie[J++]);case 200:return t=Lt.getUint16(J),J+=2,dl(t);case 201:return t=Lt.getUint32(J),J+=4,dl(t);case 202:if(t=Lt.getFloat32(J),Hr.useFloat32>2){let e=Zm[(Ie[J]&127)<<1|Ie[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=Lt.getFloat64(J),J+=8,t;case 204:return Ie[J++];case 205:return t=Lt.getUint16(J),J+=2,t;case 206:return t=Lt.getUint32(J),J+=4,t;case 207:return Hr.int64AsNumber?(t=Lt.getUint32(J)*4294967296,t+=Lt.getUint32(J+4)):t=Lt.getBigUint64(J),J+=8,t;case 208:return Lt.getInt8(J++);case 209:return t=Lt.getInt16(J),J+=2,t;case 210:return t=Lt.getInt32(J),J+=4,t;case 211:return Hr.int64AsNumber?(t=Lt.getInt32(J)*4294967296,t+=Lt.getUint32(J+4)):t=Lt.getBigInt64(J),J+=8,t;case 212:if(t=Ie[J++],t==114)return KE(Ie[J++]&63);{let e=Nr[t];if(e)return e.read?(J++,e.read(cn())):e.noBuffer?(J++,e()):e(Ie.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=Ie[J],t==114?(J++,KE(Ie[J++]&63,Ie[J++])):dl(2);case 214:return dl(4);case 215:return dl(8);case 216:return dl(16);case 217:return t=Ie[J++],ws>=J?sa.slice(J-wi,(J+=t)-wi):X4(t);case 218:return t=Lt.getUint16(J),J+=2,ws>=J?sa.slice(J-wi,(J+=t)-wi):Y4(t);case 219:return t=Lt.getUint32(J),J+=4,ws>=J?sa.slice(J-wi,(J+=t)-wi):Q4(t);case 220:return t=Lt.getUint16(J),J+=2,XE(t);case 221:return t=Lt.getUint32(J),J+=4,XE(t);case 222:return t=Lt.getUint16(J),J+=2,YE(t);case 223:return t=Lt.getUint32(J),J+=4,YE(t);default:if(r>=224)return r-256;if(r===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+r)}}}var q4=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Fx(r,t){function e(){if(e.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>q4.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(cn);return r.highByte===0&&(r.read=qE(t,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=cn()}return n}return e.count=0,r.highByte===0?qE(t,e):e}var qE=(r,t)=>function(){let e=Ie[J++];if(e===0)return t();let n=r<32?-(r+(e<<5)):r+(e<<5),i=Ct[n]||JE()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=Fx(i,r)),i.read()};function JE(){let r=nT(()=>(Ie=null,Hr.getStructures()));return Ct=Hr._mergeStructures(r,Ct)}var Nx=Km,X4=Km,Y4=Km,Q4=Km;function Km(r){let t;if(r<16&&(t=Ux(r)))return t;if(r>64&&Ox)return Ox.decode(Ie.subarray(J,J+=r));let e=J+r,n=[];for(t="";J<e;){let i=Ie[J++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Ie[J++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Ie[J++]&63,o=Ie[J++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ie[J++]&63,o=Ie[J++]&63,a=Ie[J++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(t+=sr.apply(String,n),n.length=0)}return n.length>0&&(t+=sr.apply(String,n)),t}function XE(r){let t=new Array(r);for(let e=0;e<r;e++)t[e]=cn();return t}function YE(r){if(Hr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[eT()]=cn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(cn(),cn());return t}}var sr=String.fromCharCode;function $E(r){let t=J,e=new Array(r);for(let n=0;n<r;n++){let i=Ie[J++];if((i&128)>0){J=t;return}e[n]=i}return sr.apply(String,e)}function Ux(r){if(r<4)if(r<2){if(r===0)return"";{let t=Ie[J++];if((t&128)>1){J-=1;return}return sr(t)}}else{let t=Ie[J++],e=Ie[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(r<3)return sr(t,e);let n=Ie[J++];if((n&128)>0){J-=3;return}return sr(t,e,n)}else{let t=Ie[J++],e=Ie[J++],n=Ie[J++],i=Ie[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(i&128)>0){J-=4;return}if(r<6){if(r===4)return sr(t,e,n,i);{let s=Ie[J++];if((s&128)>0){J-=5;return}return sr(t,e,n,i,s)}}else if(r<8){let s=Ie[J++],o=Ie[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(r<7)return sr(t,e,n,i,s,o);let a=Ie[J++];if((a&128)>0){J-=7;return}return sr(t,e,n,i,s,o,a)}else{let s=Ie[J++],o=Ie[J++],a=Ie[J++],l=Ie[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(r<10){if(r===8)return sr(t,e,n,i,s,o,a,l);{let u=Ie[J++];if((u&128)>0){J-=9;return}return sr(t,e,n,i,s,o,a,l,u)}}else if(r<12){let u=Ie[J++],c=Ie[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(r<11)return sr(t,e,n,i,s,o,a,l,u,c);let d=Ie[J++];if((d&128)>0){J-=11;return}return sr(t,e,n,i,s,o,a,l,u,c,d)}else{let u=Ie[J++],c=Ie[J++],d=Ie[J++],h=Ie[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(r<14){if(r===12)return sr(t,e,n,i,s,o,a,l,u,c,d,h);{let f=Ie[J++];if((f&128)>0){J-=13;return}return sr(t,e,n,i,s,o,a,l,u,c,d,h,f)}}else{let f=Ie[J++],m=Ie[J++];if((f&128)>0||(m&128)>0){J-=14;return}if(r<15)return sr(t,e,n,i,s,o,a,l,u,c,d,h,f,m);let p=Ie[J++];if((p&128)>0){J-=15;return}return sr(t,e,n,i,s,o,a,l,u,c,d,h,f,m,p)}}}}}function Ix(r){return Hr.copyBuffers?Uint8Array.prototype.slice.call(Ie,J,J+=r):Ie.subarray(J,J+=r)}function dl(r){let t=Ie[J++];if(Nr[t])return Nr[t](Ie.subarray(J,J+=r));throw new Error("Unknown extension type "+t)}var QE=new Array(4096);function eT(){let r=Ie[J++];if(r>=160&&r<192){if(r=r-160,ws>=J)return sa.slice(J-wi,(J+=r)-wi);if(!(ws==0&&oa<180))return Nx(r)}else return J--,cn();let t=(r<<5^(r>1?Lt.getUint16(J):r>0?Ie[J]:0))&4095,e=QE[t],n=J,i=J+r-3,s,o=0;if(e&&e.bytes==r){for(;n<i;){if(s=Lt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Ie[n++],s!=e[o++]){n=1879048192;break}if(n===i)return J=n,e.string;i-=3,n=J}for(e=[],QE[t]=e,e.bytes=r;n<i;)s=Lt.getUint32(n),e.push(s),n+=4;for(i+=3;n<i;)s=Ie[n++],e.push(s);let a=r<16?Ux(r):$E(r);return a!=null?e.string=a:e.string=Nx(r)}var KE=(r,t)=>{var e=cn();let n=r;t!==void 0&&(r=r<32?-((t<<5)+r):(t<<5)+r,e.highByte=t);let i=Ct[r];return i&&i.isShared&&((Ct.restoreStructures||(Ct.restoreStructures=[]))[r]=i),Ct[r]=e,e.read=Fx(e,n),e.read()},tT=typeof self=="object"?self:global;Nr[0]=()=>{};Nr[0].noBuffer=!0;Nr[101]=()=>{let r=cn();return(tT[r[0]]||Error)(r[1])};Nr[105]=r=>{let t=Lt.getUint32(J-4);go||(go=new Map);let e=Ie[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let i={target:n};go.set(t,i);let s=cn();return i.used?Object.assign(n,s):(i.target=s,s)};Nr[112]=r=>{let t=Lt.getUint32(J-4),e=go.get(t);return e.used=!0,e.target};Nr[115]=()=>new Set(cn());var kx=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");Nr[116]=r=>{let t=r[0],e=kx[t];if(!e)throw new Error("Could not find typed array for code "+t);return new tT[e](Uint8Array.prototype.slice.call(r,1).buffer)};Nr[120]=()=>{let r=cn();return new RegExp(r[0],r[1])};Nr[98]=r=>{let t=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],e=J;J+=t-4,di=[cn(),cn()],di.position0=0,di.position1=0;let n=J;J=e;try{return cn()}finally{J=n}};Nr[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function nT(r){let t=oa,e=J,n=Lx,i=wi,s=ws,o=sa,a=Rx,l=go,u=di,c=new Uint8Array(Ie.slice(0,oa)),d=Ct,h=Ct.slice(0,Ct.length),f=Hr,m=cu,p=r();return oa=t,J=e,Lx=n,wi=i,ws=s,sa=o,Rx=a,go=l,di=u,Ie=c,cu=m,Ct=d,Ct.splice(0,Ct.length,...h),Hr=f,Lt=new DataView(Ie.buffer,Ie.byteOffset,Ie.byteLength),p}function Qm(){Ie=null,go=null,Ct=null}function rT(r){r.unpack?Nr[r.type]=r.unpack:Nr[r.type]=r}var Zm=new Array(147);for(let r=0;r<256;r++)Zm[r]=+("1e"+Math.floor(45.15-r*.30103));var Jm=new Ss({useRecords:!1}),K4=Jm.unpack,Z4=Jm.unpackMultiple,J4=Jm.unpack,$m={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},$4=new Float32Array(1),Vte=new Uint8Array($4.buffer,0,4);var eg;try{eg=new TextEncoder}catch{}var tg,Gx,ng=typeof Buffer<"u",zx=ng?Buffer.allocUnsafeSlow:Uint8Array,aT=ng?Buffer:Uint8Array,iT=ng?4294967296:2144337920,le,vn,ne=0,As,_s=null,eH=/[\u0080-\uFFFF]/,jh=Symbol("record-id"),hl=class extends Ss{constructor(t){super(t),this.offset=0;let e,n,i,s,o,a,l=0,u=aT.prototype.utf8Write?function(b,E,T){return le.utf8Write(b,E,T)}:eg&&eg.encodeInto?function(b,E){return eg.encodeInto(b,le.subarray(E)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=t.maxOwnStructures;m==null&&(m=h?32:64),d&&!t.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,y=f+m+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,w=0;this.pack=this.encode=function(b,E){if(le||(le=new zx(8192),vn=new DataView(le.buffer,0,8192),ne=0),As=le.length-10,As-ne<2048?(le=new zx(le.length),vn=new DataView(le.buffer,0,le.length),As=le.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(_s=["",""],le[ne++]=214,le[ne++]=98,_s.position=ne-n,ne+=4):_s=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let T=i.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let P=0;P<T;P++){let D=i[P];if(!D)continue;let C,O=i.transitions;for(let B=0,V=D.length;B<V;B++){let Y=D[B];C=O[Y],C||(C=O[Y]=Object.create(null)),O=C}O[jh]=P+64}l=T}d||(i.nextId=T+64)}s&&(s=!1),o=i||[];try{if(S(b),_s){vn.setUint32(_s.position+n,ne-_s.position-n);let T=_s;_s=null,S(T[0]),S(T[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>As&&M(ne),c.offset=ne;let T=nH(le.subarray(n,ne),a.idsToInsert);return a=null,T}return E&cT?(le.start=n,le.end=ne,le):le.subarray(n,ne)}finally{if(i){if(w<10&&w++,x>1e4)i.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let T=0,P=v.length;T<P;T++)v[T][jh]=0;v=[]}if(s&&c.saveStructures){let T=i.sharedLength||f;i.length>T&&(i=i.slice(0,T));let P=le.subarray(n,ne);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,P)}}E&cH&&(ne=n)}};let S=b=>{ne>As&&(le=M(ne));var E=typeof b,T;if(E==="string"){let P=b.length;if(_s&&P>=8&&P<4096){let O=eH.test(b);_s[O?0:1]+=b,le[ne++]=193,S(O?-P:P);return}let D;P<32?D=1:P<256?D=2:P<65536?D=3:D=5;let C=P*3;if(ne+C>As&&(le=M(ne+C)),P<64||!u){let O,B,V,Y=ne+D;for(O=0;O<P;O++)B=b.charCodeAt(O),B<128?le[Y++]=B:B<2048?(le[Y++]=B>>6|192,le[Y++]=B&63|128):(B&64512)===55296&&((V=b.charCodeAt(O+1))&64512)===56320?(B=65536+((B&1023)<<10)+(V&1023),O++,le[Y++]=B>>18|240,le[Y++]=B>>12&63|128,le[Y++]=B>>6&63|128,le[Y++]=B&63|128):(le[Y++]=B>>12|224,le[Y++]=B>>6&63|128,le[Y++]=B&63|128);T=Y-ne-D}else T=u(b,ne+D,C);T<32?le[ne++]=160|T:T<256?(D<2&&le.copyWithin(ne+2,ne+1,ne+1+T),le[ne++]=217,le[ne++]=T):T<65536?(D<3&&le.copyWithin(ne+3,ne+2,ne+2+T),le[ne++]=218,le[ne++]=T>>8,le[ne++]=T&255):(D<5&&le.copyWithin(ne+5,ne+3,ne+3+T),le[ne++]=219,vn.setUint32(ne,T),ne+=4),ne+=T}else if(E==="number")if(b>>>0===b)b<64?le[ne++]=b:b<256?(le[ne++]=204,le[ne++]=b):b<65536?(le[ne++]=205,le[ne++]=b>>8,le[ne++]=b&255):(le[ne++]=206,vn.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?le[ne++]=256+b:b>=-128?(le[ne++]=208,le[ne++]=b+256):b>=-32768?(le[ne++]=209,vn.setInt16(ne,b),ne+=2):(le[ne++]=210,vn.setInt32(ne,b),ne+=4);else{let P;if((P=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){le[ne++]=202,vn.setFloat32(ne,b);let D;if(P<4||(D=b*Zm[(le[ne]&127)<<1|le[ne+1]>>7])>>0===D){ne+=4;return}else ne--}le[ne++]=203,vn.setFloat64(ne,b),ne+=8}else if(E==="object")if(!b)le[ne++]=192;else{if(a){let D=a.get(b);if(D){if(!D.id){let C=a.idsToInsert||(a.idsToInsert=[]);D.id=C.push(D)}le[ne++]=214,le[ne++]=112,vn.setUint32(ne,D.id),ne+=4;return}else a.set(b,{offset:ne-n})}let P=b.constructor;if(P===Object)_(b,!0);else if(P===Array){T=b.length,T<16?le[ne++]=144|T:T<65536?(le[ne++]=220,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=221,vn.setUint32(ne,T),ne+=4);for(let D=0;D<T;D++)S(b[D])}else if(P===Map){T=b.size,T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,vn.setUint32(ne,T),ne+=4);for(let[D,C]of b)S(D),S(C)}else{for(let D=0,C=tg.length;D<C;D++){let O=Gx[D];if(b instanceof O){let B=tg[D];if(B.write){B.type&&(le[ne++]=212,le[ne++]=B.type,le[ne++]=0),S(B.write.call(this,b));return}let V=le,Y=vn,W=ne;le=null;let q;try{q=B.pack.call(this,b,j=>(le=V,V=null,ne+=j,ne>As&&M(ne),{target:le,targetView:vn,position:ne-j}),S)}finally{V&&(le=V,vn=Y,ne=W,As=le.length-10)}q&&(q.length+ne>As&&M(q.length+ne),ne=tH(q,le,ne,B.type));return}}_(b,!b.hasOwnProperty)}}else if(E==="boolean")le[ne++]=b?195:194;else if(E==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))le[ne++]=211,vn.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)le[ne++]=207,vn.setBigUint64(ne,b);else if(this.largeBigIntToFloat)le[ne++]=203,vn.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(E==="undefined")this.encodeUndefinedAsNil?le[ne++]=192:(le[ne++]=212,le[ne++]=0,le[ne++]=0);else if(E==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+E)},_=this.useRecords===!1?this.variableMapSize?b=>{let E=Object.keys(b),T=E.length;T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,vn.setUint32(ne,T),ne+=4);let P;for(let D=0;D<T;D++)S(P=E[D]),S(b[P])}:(b,E)=>{le[ne++]=222;let T=ne-n;ne+=2;let P=0;for(let D in b)(E||b.hasOwnProperty(D))&&(S(D),S(b[D]),P++);le[T+++n]=P>>8,le[T+n]=P&255}:b=>{let E=Object.keys(b),T,P=o.transitions||(o.transitions=Object.create(null)),D=0;for(let O=0,B=E.length;O<B;O++){let V=E[O];T=P[V],T||(T=P[V]=Object.create(null),D++),P=T}let C=P[jh];if(C)C>=96&&p?(le[ne++]=((C-=96)&31)+96,le[ne++]=C>>5):le[ne++]=C;else{C=o.nextId,C||(C=64),C<g&&this.shouldShareStructure&&!this.shouldShareStructure(E)?(C=o.nextOwnId,C<y||(C=g),o.nextOwnId=C+1):(C>=y&&(C=g),o.nextId=C+1);let O=E.highByte=C>=96&&p?C-96>>5:-1;P[jh]=C,o[C-64]=E,C<g?(E.isShared=!0,o.sharedLength=C-63,s=!0,O>=0?(le[ne++]=(C&31)+96,le[ne++]=O):le[ne++]=C):(O>=0?(le[ne++]=213,le[ne++]=114,le[ne++]=(C&31)+96,le[ne++]=O):(le[ne++]=212,le[ne++]=114,le[ne++]=C),D&&(x+=w*D),v.length>=m&&(v.shift()[jh]=0),v.push(P),S(E))}for(let O=0,B=E.length;O<B;O++)S(b[E[O]])},M=b=>{let E;if(b>16777216){if(b-n>iT)throw new Error("Packed buffer would be larger than maximum buffer size");E=Math.min(iT,Math.round(Math.max((b-n)*(b>67108864?1.25:2),4194304)/4096)*4096)}else E=(Math.max(b-n<<2,le.length-1)>>12)+1<<12;let T=new zx(E);return vn=new DataView(T.buffer,0,E),le.copy?le.copy(T,0,n,b):T.set(le.slice(n,b)),ne-=n,n=0,As=T.length-10,le=T}}useBuffer(t){le=t,vn=new DataView(le.buffer,le.byteOffset,le.byteLength),ne=0}};Gx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Wh];tg=[{pack(r,t,e){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,t,e){let n=Array.from(r),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(n)}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),e([r.name,r.message])}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),e([r.source,r.flags])}},{pack(r,t){this.structuredClone?sT(r,16,t):oT(ng?Buffer.from(r):new Uint8Array(r),t)}},{pack(r,t){let e=r.constructor;e!==aT&&this.structuredClone?sT(r,kx.indexOf(e.name),t):oT(r,t)}},{pack(r,t){let{target:e,position:n}=t(1);e[n]=193}}];function sT(r,t,e,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function oT(r,t){let e=r.byteLength;var n,i;if(e<256){var{target:n,position:i}=t(e+2);n[i++]=196,n[i++]=e}else if(e<65536){var{target:n,position:i}=t(e+3);n[i++]=197,n[i++]=e>>8,n[i++]=e&255}else{var{target:n,position:i,targetView:s}=t(e+5);n[i++]=198,s.setUint32(i,e),i+=4}n.set(r,i)}function tH(r,t,e,n){let i=r.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=n,t.set(r,e),e+=i,e}function nH(r,t){let e,n=t.length*6,i=r.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function aa(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");Gx.unshift(r.Class),tg.unshift(r)}rT(r)}var lT=new hl({useRecords:!1}),rH=lT.pack,iH=lT.pack;var{NEVER:sH,ALWAYS:oH,DECIMAL_ROUND:aH,DECIMAL_FIT:lH}=$m,cT=512,cH=1024;var uT=new hl({structuredClone:!0});aa({Class:Ft.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ft.prototype),r}});aa({Class:We.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,We.prototype),r}});aa({Class:Zt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Zt.prototype),r}});aa({Class:Vh.prototype.constructor,type:4,write(r){return r.id},read(r){return new Vh(r)}});aa({Class:Hh.prototype.constructor,type:5,write(r){return r.data},read(r){return new Hh(r)}});aa({Class:Jt.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Jt.prototype),r}});function uH(r){var t=0;if(r.length===0)return t;for(let e=0;e<r.length;e++){let n=r[e];t=(t<<5)-t+n,t=t&t}return t}function Vx(r){if(ru(r))return r;if(Array.isArray(r))return r.map(Vx);if(typeof r=="object"&&r!==null){let t={};for(let e of Object.keys(r).sort())t[e]=Vx(r[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else return r}var rg;(n=>{function r(i){return uT.pack(i)}n.serialize=r;function t(i){return uT.unpack(i)}n.deserialize=t;function e(i){return uH(r(Vx(i))).toString()}n.checksum=e})(rg||(rg={}));var yo={["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"]},dT;(e=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=r;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,toggle:!1,actions:new We}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new We}}e.defaultData=t})(dT||(dT={}));var ig;(e=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=r,e.valueDefaultData={type:"Literal",value:0}})(ig||(ig={}));var Hx;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:ig.propertyDefaultData(i),rOperand:{...ig.valueDefaultData}}}n.comparisonDefaultData=r;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=e})(Hx||(Hx={}));var hT;(e=>{function r(n){return n.type==="Conditional"}e.is=r;function t(n){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:Hx.distanceDefaultData(n)}}e.defaultData=t})(hT||(hT={}));var fT;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(fT||(fT={}));var sg;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new We})(sg||(sg={}));var og;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(og||(og={}));var pT;(e=>{function r(n){return n.type==="MouseHover"}e.is=r;function t(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=t})(pT||(pT={}));var mT;(e=>{function r(n){return n.type==="Scroll"}e.is=r;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new We}}e.defaultData=t})(mT||(mT={}));var gT;(e=>{function r(n){return n.type==="Start"}e.is=r;function t(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=t})(gT||(gT={}));var yT;(e=>{function r(n){return n.type==="Collision"}e.is=r;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new We}}e.defaultData=t})(yT||(yT={}));var fl;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}e.lerp=t})(fl||(fl={}));var Ms;(a=>{function r(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=r;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function i(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=i;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(Ms||(Ms={}));var qh;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}e.lerp=t})(qh||(qh={}));var la;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=t;function e(s){return s??i.identity}i.simplify=e;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}i.applyMatrix4=n})(la||(la={}));var Nn;(c=>{function r(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}c.isRGB=r,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function i(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=i;function s(d){return{r:d.r,g:d.g,b:d.b}}c.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=a;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}c.equals=l;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}c.lerp=u})(Nn||(Nn={}));var Mr;(a=>{a.white={...Nn.white,a:1},a.transparent={...Nn.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...Nn.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return Nn.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Mr||(Mr={}));var ag;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(ag||(ag={}));var vT;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(vT||(vT={}));var xT;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(xT||(xT={}));var vo;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(vo||(vo={}));var ji;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(ji||(ji={}));var pl;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(pl||(pl={}));var Es;(e=>{function r(n,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*i,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=r;function t(n,i){let s={...n};if(Wx.forEach(o=>{Object.assign(s,{[o]:i[o]??n[o]})}),s.radial={...n.radial},i.radial){let o=n.radial,a=i.radial;jx.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},i.linear){let o=n.linear,a=i.linear;qx.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},i.grid){let o=n.grid,a=i.grid;Xx.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},i.toObject){let o=n.toObject,a=i.toObject;Yx.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},i.randomnessObject){let o=n.randomnessObject,a=i.randomnessObject;Qx.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Es||(Es={}));var lg;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(lg||(lg={}));var Wx=["count"],jx=["radius","start","end","position","scale","rotation"],qx=["position","scale","rotation"],Xx=["count","size"],Yx=["count","position","scale","rotation"],Qx=["strength","scale","rotation","position","movement","seed","freqScale"];var ml;(e=>{let r={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(ml||(ml={}));var cg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(cg||(cg={}));var ug;(e=>{function r(n){return t(n)}e.defaultData=r;function t(n){if(n==="PointLight")return{type:n,color:Mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:Mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Mr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(ug||(ug={}));var Kx;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}e.equals=t})(Kx||(Kx={}));var Zx;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}e.equals=t})(Zx||(Zx={}));var dg;(t=>t.defaultData={...Zx.defaultData,...Kx.defaultData})(dg||(dg={}));var uu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(uu||(uu={}));var bT;(t=>{function r(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=r})(bT||(bT={}));function ST(r){return r.type!=="displace"}var wT;(t=>{function r(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=r})(wT||(wT={}));var hg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],AT=["wrapping","image","video"],Br;(i=>{function r(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}i.patch=r;function t(s,o){return s==="light"&&o?e(o):n(s)}i.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function n(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:uu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:Nn.fromHex(5526619)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Nn.fromHex(6710886),a:1},colorB:{...Nn.fromHex(6710886),a:1},colorC:{...Nn.fromHex(16777215),a:1},colorD:{...Nn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:Mr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Mr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Mr.fromHexAndA(0,1),contourColor:Mr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Nn.fromHex(0),a:1},colorB:{...Nn.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Br||(Br={}));var or;(l=>{function r(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=r;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${f}`,Array.isArray(f)?f.forEach(m=>c+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new We}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function i(u,c){return{...u,name:c}}l.withName=i;function s(u,c="layer1",d="layer2"){let h=new We;return h.push({fi:0,data:Br.defaultData("light",u),id:c}),h.push({fi:1,data:Br.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=Br.defaultData("texture");Object.assign(f.texture,{image:u});let m=new We;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Br.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=Br.defaultData("video");Object.assign(f.texture,{video:u});let m=new We;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Br.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerVideoTextureData=a})(or||(or={}));var du;(t=>{function r(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=r})(du||(du={}));var hu;(t=>{function r(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=r})(hu||(hu={}));var Jx={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var fg;(t=>{function r(e,n){let i={...e};return $x.forEach(s=>{Object.assign(i,{[s]:n[s]??e[s]})}),i}t.merge=r})(fg||(fg={}));var pg={shape:Jx,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},$x=["depth","offset","angle","twist","startScale","endScale"];var Xh;(e=>{function r(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=r;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(Xh||(Xh={}));var mg;(t=>{function r(e,n){let i={...e};return Object.assign(i,n),i.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,fg.merge(i.extrusion,n.extrusion))),i}t.merge=r})(mg||(mg={}));var ca;(t=>{function r(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:hu.defaultData(),extrusion:pg};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:du.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}t.defaultData=r})(ca||(ca={}));var eb=["width","height","depth"];var _T;(e=>{function r(n){return n==="Component"||n==="Instance"}e.isComponentRelated=r;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(_T||(_T={}));var fu;(i=>{i.identity={...ag.identity,hiddenMatrix:la.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function n(s,o){return vE({position:Ms.isEqual(s.position,o.position)?void 0:o.position,rotation:Ms.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Ms.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:la.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=n})(fu||(fu={}));var MT;(t=>t.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(MT||(MT={}));var hi;(t=>t.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...fu.identity,cloner:null})(hi||(hi={}));var ET;(t=>t.defaultData={type:"Empty",...hi.defaultData})(ET||(ET={}));var TT;(t=>t.defaultData={type:"Component",...hi.defaultData})(TT||(TT={}));var gl;(t=>t.defaultData={type:"Mesh",...hi.defaultData,...dg.defaultData})(gl||(gl={}));var pu;(t=>t.defaultData={...hi.defaultData,...fu.identity,...pl.defaultData})(pu||(pu={}));var gg;(t=>{function r(e){return{...hi.defaultData,...ug.defaultData(e)}}t.defaultData=r})(gg||(gg={}));var mu;(e=>{function r(n,i,s=0){for(;s<i.length;){let o=n?n[i[s]]:void 0;if(i.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=r;function t(n,i,s=0){let o=r(n,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(mu||(mu={}));var ua;(s=>{s.rootOverrideProps=["physics"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...hi.defaultData,...a,component:o,overrides:new Jt,physics:void 0,type:"Instance"}}s.ofComponent=n;function i(o){let a=fu.fromObject(o.data);return n(o.id,a)}s.fromComponentData=i})(ua||(ua={}));var yg;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:la.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...pl.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...hi.defaultData,...gl.defaultData,geometry:ca.defaultData("RectangleGeometry"),material:or.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...hi.defaultData,...gl.defaultData,geometry:ca.defaultData("BooleanGeometry"),material:or.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...hi.defaultData,...gl.defaultData,geometry:ca.defaultData("TextGeometry"),material:or.defaultTwoLayerData("phong","layer1","layer2")}))(yg||(yg={}));var xo;(i=>{function r(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Jt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Jt})))):ji.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=r;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=lu(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&Br.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=lu(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&Br.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,m]of Object.entries(h.layers)){let{texture:p,...g}=m;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...d,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",f],props:g,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...lg.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,m]of Object.entries(h))c(["materials",f],m);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}i.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,fu.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),ji.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:mg.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Es.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Es.merge(a.cloner,o.cloner)});else if(cg.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Nn.clone(l.color))}return a}i.patch=n})(xo||(xo={}));var Qh;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Nn.white,near:.1,far:2e3})(Qh||(Qh={}));var gu;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(gu||(gu={}));var bo;(t=>t.defaultData={orbitControls:gu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null,hdTransmission:!1})(bo||(bo={}));var tb;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(tb||(tb={}));var nb;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(nb||(nb={}));var yl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...tb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:nb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(yl||(yl={}));var Fr;(t=>t.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low",occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(Fr||(Fr={}));var CT;(o=>{o.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a={withLight:!0,withSquare:!0}){let l=new Zt,u=yg.defaultMeshObject;return a.withLight===!0&&l.push({fi:-1,data:{...gg.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),a.withSquare===!0&&l.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:u,children:[]}),l}o.defaultData={backgroundColor:Mr.fromHexAndA(2960946,1),postprocessing:ml.defaultData,fog:Qh.defaultData,objects:t(),environment:Fr.defaultData,publish:bo.defaultData,styles:yl.defaultData()},o.emptyData=function(a){return{backgroundColor:Mr.fromHexAndA(2960946,1),postprocessing:ml.defaultData,fog:Qh.defaultData,objects:a?t(a):new Zt,environment:Fr.defaultData,publish:bo.defaultData,styles:yl.defaultData()}};function i(a){return{...o.defaultData,objects:Hi(a,Zt.prototype)}}o.withObjs=i;function s(a,l){return i([{id:a,data:l,children:[],fi:0}])}o.withObj=s})(CT||(CT={}));var yu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(yu||(yu={}));var vg;(n=>{function r(){let i={};return i["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Hi(i,Ft.prototype)}n.defaultColors=r;function t(i){let s={};return i?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...yu.emptyImage,name:"AI generated image"}),Hi(s,Ft.prototype)}n.defaultImages=t;function e(){return{materials:new Ft,images:new Ft,videos:new Ft,colors:new Ft,audios:new Ft,fonts:new Ft,penumbraSize:[2,2,2]}}n.emptyData=e})(vg||(vg={}));var vu;(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 We,move:new We,jump:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Mr.fromHexAndA(3728051,1)}}))(vu||(vu={}));function PT(r){r.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,i=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...ia(ir(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...ir(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function xu(r,t){Object.values(r.shared.materials).forEach(e=>t(e))}function bu(r,t){r.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&t(i)}):"material"in n&&typeof n.material!="string"&&t(n.material)})}function hH(r){Object.assign(r.scene.publish,{orbitControls:{...gu.defaultData,...ir(r.scene.publish.orbitControls)}})}function fH(r){Object.assign(r.scene.publish.settings,{video:{...bo.defaultData.settings.video,...ir(r.scene.publish.settings.video)}})}function pH(r){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[i,s]of Object.entries(n))if((hg.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(AT.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((e,n)=>{n.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function mH(r){r.scene.publish.withBackground=!0}function gH(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function yH(r){r.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function vH(r){r.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function xH(r){r.scene.objects.traverse((t,e)=>{let n=r.scene.objects.unproxy().parent(t);if(n){let i=ir(r.scene.objects.data(n));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ir(e).booleanExclude!==!0)}})}function bH(r){r.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function wH(r){function t(n){Object.setPrototypeOf(n,Jt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Jt.prototype)}function e(n){Object.setPrototypeOf(n,Jt.prototype);for(let i in n)t(n[i])}r.scene.objects.traverse((n,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=ir(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=ir(l).layers;e(u),l.layers=u}})})}function DT(r){r.layers===void 0&&Object.assign(r,or.defaultTwoLayerData("lambert"))}function rb(r){!r.layers||r.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let n=[...t.steps];n.push(t.steps[9]);let i={...ir(t),colors:e,steps:n};Object.assign(t,i)}})}function SH(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function IT(r){r.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&rb(n)}):"material"in e&&typeof e.material!="string"&&rb(e.material)}),Object.values(r.shared.materials).forEach(t=>rb(t))}function AH(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function _H(r){r.shared.audios=Hi({},Ft.prototype)}function MH(r){r.shared.videos=Hi({},Ft.prototype)}function EH(r){let t=r.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:i})}})}function TH(r){Object.entries(ir(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(ir(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function CH(r){r.scene.publish.settings.web.preload=!1}function OT(r){r.layers&&r.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function RT(r){r.layers&&r.layers.forEach(t=>{ST(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function PH(r){r.shared.fonts=Hi({},Ft.prototype)}function DH(r){return r.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function IH(r){let t=[];r.scene.objects.traverse((e,n)=>{let i=n;if(i.type==="TextFrame"){let s=or.defaultTwoLayerData("phong"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=DH(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...hi.defaultData,...gl.defaultData,flatShading:!1,wireframe:!1,geometry:{...ca.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:ir(i.states),events:ir(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=ir(r.scene.objects).parent(e);r.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{r.scene.objects.delete(e)})}function OH(r){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((e,n)=>{n.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new We,move:new We,jump:new We}});else{let s=new We;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:He.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,ia(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:He.generateUUID(),data:u},{fi:1,id:He.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function RH(r){r.scene.objects.traverse((t,e)=>{function n(i,s){let o=new We,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...ia(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...ia(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:He.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function LT(r){let t=r.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Br.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function NT(r){xu(r,LT),bu(r,LT)}function LH(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function NH(r){r.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function BH(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=or.defaultTwoLayerData("phong"))})}function FH(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function UH(r){r.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function kH(r){r.scene.publish.mouseEventTarget===void 0&&(r.scene.publish.mouseEventTarget="canvas"),r.scene.publish.settings.web.hint===void 0&&(r.scene.publish.settings.web.hint=!1)}function zH(r){let{video:t}=r.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function GH(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function VH(r){let t=r.scene.environment.usePhysics;r.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function HH(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=vu.defaultDataThirdPerson.navmesh)})})}function WH(r){r.scene.styles||(r.scene.styles=yl.defaultData())}function BT(r){r.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function jH(r){r.scene.environment.ambientLight.occlusion===void 0&&(r.scene.environment.ambientLight.occlusion=!1),r.scene.environment.ambientLight.aoFullRes===void 0&&(r.scene.environment.ambientLight.aoFullRes=!1),r.scene.environment.ambientLight.radius===void 0&&(r.scene.environment.ambientLight.radius=256),r.scene.environment.ambientLight.bias===void 0&&(r.scene.environment.ambientLight.bias=.5),r.scene.environment.ambientLight.aoColor===void 0&&(r.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),bu(r,BT),xu(r,BT)}var FT=41;function UT(r){let t=r.schema??0;t!==FT&&(console.warn("updating from ",t,"to ",FT),t<1&&(bu(r,PT),xu(r,PT),r.schema=1),t<2&&(hH(r),r.schema=2),t<3&&(pH(r),r.schema=3),t<4&&(mH(r),r.schema=4),t<5&&(gH(r),r.schema=5),t<6&&(yH(r),r.schema=6),t<7&&(vH(r),r.schema=7),t<8&&(r.schema=8),t<9&&(IT(r),r.schema=9),t<10&&(SH(r),r.schema=10),t<11&&(AH(r),r.schema=11),t<12&&(IT(r),r.schema=12),t<13&&(_H(r),r.schema=13),t<14&&(EH(r),r.schema=14),t<15&&(TH(r),r.schema=15),t<16&&(CH(r),r.schema=16),t<17&&(bu(r,OT),xu(r,OT),r.schema=17),t<18&&(bu(r,DT),xu(r,DT),r.schema=18),t<19&&(fH(r),r.schema=19),t<20&&(PH(r),IH(r),r.schema=20),t<21&&(OH(r),RH(r),r.schema=21),t<22&&(NT(r),r.schema=22),t<23&&(LH(r),r.schema=23),t<24&&(NH(r),r.schema=24),(t<25||r.shared.videos===void 0)&&(MH(r),t<25&&(r.schema=25)),t<26&&(xH(r),r.schema=26),t<27&&(bH(r),r.schema=27),t<28&&(NT(r),r.schema=28),t<29&&(wH(r),r.schema=29),t<30&&(BH(r),r.schema=30),t<31&&(FH(r),r.schema=31),t<33&&(UH(r),r.schema=33),t<34&&(kH(r),r.schema=34),t<35&&(zH(r),r.schema=35),t<36&&(GH(r),r.schema=36),t<37&&(VH(r),r.schema=37),t<38&&(bu(r,RT),xu(r,RT),r.schema=38),t<39&&(HH(r),r.schema=39),t<40&&(WH(r),r.schema=40),t<41&&(jH(r),r.schema=41))}function Xi(r,t=!1){let e=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Me,u=0;for(let c=0;c<r.length;++c){let d=r[c],h=0;if(e!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in d.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(d.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in d.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,d=[];for(let h=0;h<r.length;++h){let f=r[h].index;for(let m=0;m<f.count;++m)d.push(f.getX(m)+c);c+=r[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=kT(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][h]);let m=kT(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(m)}}return l}function kT(r){let t,e,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Be(s,e,n)}var zT=Math.pow(2,-24);var vl=class{constructor(){}};function Si(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function ib(r){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>e&&(e=i,t=n)}return t}function sb(r,t){t.set(r)}function ob(r,t,e){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=t[s],e[s]=n<i?n:i,n=r[o],i=t[o],e[o]=n>i?n:i}}function Kh(r,t,e){for(let n=0;n<3;n++){let i=t[r+2*n],s=t[r+2*n+1],o=i-s,a=i+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Su(r){let t=r[3]-r[0],e=r[4]-r[1],n=r[5]-r[2];return 2*(t*e+e*n+n*t)}function YH(r,t){if(!r.index){let e=r.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new n(4*e)):i=new Uint16Array(new n(2*e)),r.setIndex(new Be(i,1));for(let s=0;s<e;s++)i[s]=s}}function QH(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let t=[],e=new Set;for(let i of r.groups)e.add(i.start),e.add(i.start+i.count);let n=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function lb(r,t,e,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let w=r[v+0],S=r[v+1],_=w-S,M=w+S;_<s&&(s=_),M>l&&(l=M),y&&w<d&&(d=w),y&&w>m&&(m=w);let b=r[v+2],E=r[v+3],T=b-E,P=b+E;T<o&&(o=T),P>u&&(u=P),y&&b<h&&(h=b),y&&b>p&&(p=b);let D=r[v+4],C=r[v+5],O=D-C,B=D+C;O<a&&(a=O),B>c&&(c=B),y&&D<f&&(f=D),y&&D>g&&(g=D)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(i[0]=d,i[1]=h,i[2]=f,i[3]=m,i[4]=p,i[5]=g)}function KH(r,t,e,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=r[c+0];h<i&&(i=h),h>a&&(a=h);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let m=r[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function ZH(r,t,e,n,i){let s=e,o=e+n-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var wo=32,JH=(r,t)=>r.candidate-t.candidate,da=new Array(wo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),xg=new Float32Array(6);function $H(r,t,e,n,i,s){let o=-1,a=0;if(s===0)o=ib(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=ib(r),o!==-1&&(a=e5(e,n,i,o));else if(s===2){let l=Su(r),u=1.25*i,c=n*6,d=(n+i)*6;for(let h=0;h<3;h++){let f=t[h],g=(t[h+3]-f)/wo;if(i<wo/4){let y=[...da];y.length=i;let v=0;for(let w=c;w<d;w+=6,v++){let S=y[v];S.candidate=e[w+2*h],S.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:b}=S;for(let E=0;E<3;E++)b[E]=1/0,b[E+3]=-1/0,M[E]=1/0,M[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;Kh(w,e,_)}y.sort(JH);let x=i;for(let w=0;w<x;w++){let S=y[w];for(;w+1<x&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),x--}for(let w=c;w<d;w+=6){let S=e[w+2*h];for(let _=0;_<x;_++){let M=y[_];S>=M.candidate?Kh(w,e,M.rightCacheBounds):(Kh(w,e,M.leftCacheBounds),M.count++)}}for(let w=0;w<x;w++){let S=y[w],_=S.count,M=i-S.count,b=S.leftCacheBounds,E=S.rightCacheBounds,T=0;_!==0&&(T=Su(b)/l);let P=0;M!==0&&(P=Su(E)/l);let D=1+1.25*(T*_+P*M);D<u&&(o=h,u=D,a=S.candidate)}}else{for(let x=0;x<wo;x++){let w=da[x];w.count=0,w.candidate=f+g+x*g;let S=w.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let x=c;x<d;x+=6){let _=~~((e[x+2*h]-f)/g);_>=wo&&(_=wo-1);let M=da[_];M.count++,Kh(x,e,M.bounds)}let y=da[wo-1];sb(y.bounds,y.rightCacheBounds);for(let x=wo-2;x>=0;x--){let w=da[x],S=da[x+1];ob(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;x<wo-1;x++){let w=da[x],S=w.count,_=w.bounds,b=da[x+1].rightCacheBounds;S!==0&&(v===0?sb(_,xg):ob(_,xg,xg)),v+=S;let E=0,T=0;v!==0&&(E=Su(xg)/l);let P=i-v;P!==0&&(T=Su(b)/l);let D=1+1.25*(E*v+T*P);D<u&&(o=h,u=D,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function e5(r,t,e,n){let i=0;for(let s=t,o=t+e;s<o;s++)i+=r[s*6+n*2];return i/e}function t5(r,t){let e=r.attributes.position,n=e.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=e.offset||0,l=3;e.isInterleavedBufferAttribute&&(l=e.data.stride);for(let u=0;u<s;u++){let c=u*3,d=u*6,h=i[c+0]*l+a,f=i[c+1]*l+a,m=i[c+2]*l+a;for(let p=0;p<3;p++){let g=n[h+p],y=n[f+p],v=n[m+p],x=g;y<x&&(x=y),v<x&&(x=v);let w=g;y>w&&(w=y),v>w&&(w=v);let S=(w-x)/2,_=p*2;o[d+_+0]=x+S,o[d+_+1]=S+(Math.abs(x)+S)*zT,x<t[p]&&(t[p]=x),w>t[p+3]&&(t[p+3]=w)}}return o}function n5(r,t){function e(y){h&&h(y/f)}function n(y,v,x,w=null,S=0){if(!m&&S>=l&&(m=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let _=$H(y.boundingData,w,o,v,x,d);if(_.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=ZH(a,o,v,x,_);if(M===v||M===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=_.axis;let b=new vl,E=v,T=M-v;y.left=b,b.boundingData=new Float32Array(6),lb(o,E,T,b.boundingData,s),n(b,E,T,s,S+1);let P=new vl,D=M,C=x-T;y.right=P,P.boundingData=new Float32Array(6),lb(o,D,C,P.boundingData,s),n(P,D,C,s,S+1)}return y}YH(r,t);let i=new Float32Array(6),s=new Float32Array(6),o=t5(r,i),a=r.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=r.index.count/3,m=!1,p=[],g=QH(r);if(g.length===1){let y=g[0],v=new vl;v.boundingData=i,KH(o,y.offset,y.count,s),n(v,y.offset,y.count,s),p.push(v)}else for(let y of g){let v=new vl;v.boundingData=new Float32Array(6),lb(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function HT(r,t){let e=n5(r,t),n,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,m=!!d.count,p=d.boundingData;for(let g=0;g<6;g++)n[h+g]=p[g];if(m){let g=d.offset,y=d.count;return i[h+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=d.left,y=d.right,v=d.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[h+6]=x/4,x=u(x,y),i[h+7]=v,x}}}var Wr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Wr.prototype.setFromBox=function(){let r=new A;return function(e,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let d=e.dot(r);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var Wie=function(){let r=new Wr;return function(e,n){let i=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let d=o[c],h=s[c];if(r.setFromPoints(h,a),d.isSeparated(r))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(r.setFromPoints(h,i),d.isSeparated(r))return!1}}}();var r5=function(){let r=new A,t=new A,e=new A;return function(i,s,o){let a=i.start,l=r,u=s.start,c=t;e.subVectors(a,u),r.subVectors(i.end,s.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),m=e.dot(l),g=l.dot(l)*f-h*h,y,v;g!==0?y=(d*h-m*f)/g:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),Zh=function(){let r=new F,t=new A,e=new A;return function(i,s,o,a){r5(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(i.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),WT=function(){let r=new A,t=new A,e=new yn,n=new Hn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var i5=1e-15;function Au(r){return Math.abs(r)<i5}var jr=class extends an{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Wr),this.points=[this.a,this.b,this.c],this.sphere=new Rn,this.plane=new yn,this.needsUpdate=!0}intersectsSphere(t){return WT(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,i);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,i);let f=s[3],m=o[3];f.subVectors(n,t),m.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};jr.prototype.closestPointToSegment=function(){let r=new A,t=new A,e=new Hn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),Zh(e,i,r,t),c=r.distanceToSquared(t),c<d&&(d=c,s&&s.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(d)}}();jr.prototype.intersectsTriangle=function(){let r=new jr,t=new Array(3),e=new Array(3),n=new Wr,i=new Wr,s=new A,o=new A,a=new A,l=new A,u=new Hn,c=new Hn,d=new Hn;return function(f,m=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,g=f.plane;if(Math.abs(p.normal.dot(g.normal))>1-1e-10){let y=this.satBounds,v=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let S=0;S<4;S++){let _=y[S],M=v[S];if(n.setFromPoints(M,e),_.isSeparated(n))return!1}let x=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){let _=x[S],M=w[S];if(n.setFromPoints(M,t),_.isSeparated(n))return!1}for(let S=0;S<4;S++){let _=v[S];for(let M=0;M<4;M++){let b=w[M];if(s.crossVectors(_,b),n.setFromPoints(s,t),i.setFromPoints(s,e),n.isSeparated(i))return!1}}return m&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let y=this.points,v=!1,x=0;for(let C=0;C<3;C++){let O=y[C],B=y[(C+1)%3];u.start.copy(O),u.end.copy(B),u.delta(o);let V=v?c.start:c.end,Y=Au(g.distanceToPoint(O));if(Au(g.normal.dot(o))&&Y){c.copy(u),x=2;break}if((g.intersectLine(u,V)||Y)&&!Au(V.distanceTo(B))){if(x++,v)break;v=!0}}if(x===1&&this.containsPoint(c.start))return m&&(m.start.copy(c.start),m.end.copy(c.start)),!0;if(x!==2)return!1;let w=f.points,S=!1,_=0;for(let C=0;C<3;C++){let O=w[C],B=w[(C+1)%3];u.start.copy(O),u.end.copy(B),u.delta(a);let V=S?d.start:d.end,Y=Au(p.distanceToPoint(O));if(Au(p.normal.dot(a))&&Y){d.copy(u),_=2;break}if((p.intersectLine(u,V)||Y)&&!Au(V.distanceTo(B))){if(_++,S)break;S=!0}}if(_===1&&this.containsPoint(d.start))return m&&(m.start.copy(d.start),m.end.copy(d.start)),!0;if(_!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let C=d.start;d.start=d.end,d.end=C}let M=c.start.dot(o),b=c.end.dot(o),E=d.start.dot(o),T=d.end.dot(o),P=b<E,D=M<T;return M!==T&&E!==b&&P===D?!1:(m&&(l.subVectors(c.start,d.start),l.dot(o)>0?m.start.copy(c.start):m.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?m.end.copy(c.end):m.end.copy(d.end)),!0)}}}();jr.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();jr.prototype.distanceToTriangle=function(){let r=new A,t=new A,e=["a","b","c"],n=new Hn,i=new Hn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],m=o[f];this.closestPointToPoint(m,r),h=m.distanceToSquared(r),h<c&&(c=h,a&&a.copy(r),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,r),h=p.distanceToSquared(r),h<c&&(c=h,a&&a.copy(p),l&&l.copy(r))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let m=0;m<3;m++){let p=e[m],g=e[(m+1)%3];i.set(o[p],o[g]),Zh(n,i,r,t);let y=r.distanceToSquared(t);y<c&&(c=y,a&&a.copy(r),l&&l.copy(t))}}return Math.sqrt(c)}}();var qr=class extends _t{constructor(...t){super(...t),this.isOrientedBox=!0,this.matrix=new ae,this.invMatrix=new ae,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Wr),this.alignedSatBounds=new Array(3).fill().map(()=>new Wr),this.needsUpdate=!1}set(t,e,n){super.set(t,e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){super.copy(t),this.matrix.copy(t.matrix),this.needsUpdate=!0}};qr.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=i[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=i[h];c.subVectors(a,f),d.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();qr.prototype.intersectsBox=function(){let r=new Wr;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,e),c.isSeparated(r))return!1}return!0}}();qr.prototype.intersectsTriangle=function(){let r=new jr,t=new Array(3),e=new Wr,n=new Wr,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let h=0;h<3;h++){let f=a[h],m=l[h];if(e.setFromPoints(m,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],m=c[h];if(e.setFromPoints(m,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let m=0;m<4;m++){let p=c[m];if(i.crossVectors(f,p),e.setFromPoints(i,t),n.setFromPoints(i,d),e.isSeparated(n))return!1}}return!0}}();qr.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();qr.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();qr.prototype.distanceToBox=function(){let r=["x","y","z"],t=new Array(12).fill().map(()=>new Hn),e=new Array(12).fill().map(()=>new Hn),n=new A,i=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,d=o.min,h=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(d,h);let v=y.distanceToSquared(i);if(v<m&&(m=v,l&&l.copy(y),u&&u.copy(i),v<c))return Math.sqrt(v)}let p=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,w=(g+2)%3,S=y<<x|v<<w,_=1<<g|y<<x|v<<w,M=f[S],b=f[_];t[p].set(M,b);let T=r[g],P=r[x],D=r[w],C=e[p],O=C.start,B=C.end;O[T]=d[T],O[P]=y?d[P]:h[P],O[D]=v?d[D]:h[P],B[T]=h[T],B[P]=y?d[P]:h[P],B[D]=v?d[D]:h[P],p++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?h.x:d.x,i.y=y?h.y:d.y,i.z=v?h.z:d.z,this.closestPointToPoint(i,n);let x=i.distanceToSquared(n);if(x<m&&(m=x,l&&l.copy(n),u&&u.copy(i),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Zh(y,x,n,i);let w=n.distanceToSquared(i);if(w<m&&(m=w,l&&l.copy(n),u&&u.copy(i),w<c))return Math.sqrt(w)}}return Math.sqrt(m)}}();var wg=new A,Sg=new A,Ag=new A,jT=new F,qT=new F,XT=new F,YT=new A;function s5(r,t,e,n,i,s){let o;return s===On?o=r.intersectTriangle(n,e,t,!0,i):o=r.intersectTriangle(t,e,n,s!==Ir,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function o5(r,t,e,n,i,s,o){wg.fromBufferAttribute(t,n),Sg.fromBufferAttribute(t,i),Ag.fromBufferAttribute(t,s);let a=s5(r,wg,Sg,Ag,YT,o);if(a){e&&(jT.fromBufferAttribute(e,n),qT.fromBufferAttribute(e,i),XT.fromBufferAttribute(e,s),a.uv=an.getUV(YT,wg,Sg,Ag,jT,qT,XT,new F));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};an.getNormal(wg,Sg,Ag,l.normal),a.face=l,a.faceIndex=n}return a}function ub(r,t,e,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=o5(e,r.attributes.position,r.attributes.uv,o,a,l,t);return u?(u.faceIndex=n,i&&i.push(u),u):null}function QT(r,t,e,n,i,s){for(let o=n,a=n+i;o<a;o++)ub(r,t,e,o,s)}function KT(r,t,e,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=ub(r,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function db(r,t,e){return r===null||(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r.distance<e.near||r.distance>e.far)?null:r}function Ai(r,t,e,n){let i=r.a,s=r.b,o=r.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function hb(r,t,e,n,i,s,o){let a=e.index,l=e.attributes.position;for(let u=r,c=t+r;u<c;u++)if(Ai(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var _u=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function So(r,t){return t[r+15]===65535}function xl(r,t){return t[r+6]}function Mu(r,t){return t[r+14]}function Eu(r){return r+8}function Tu(r,t){return t[r+6]}function ZT(r,t){return t[r+7]}var Cu=new _t,Mg=new A,l5=["x","y","z"];function Eg(r,t,e,n,i){let s=r*2,o=Pu,a=ha,l=fa;if(So(s,a)){let c=xl(r,l),d=Mu(s,a);QT(t,e,n,c,d,i)}else{let c=Eu(r);Cg(c,o,n,Mg)&&Eg(c,t,e,n,i);let d=Tu(r,l);Cg(d,o,n,Mg)&&Eg(d,t,e,n,i)}}function Tg(r,t,e,n){let i=r*2,s=Pu,o=ha,a=fa;if(So(i,o)){let u=xl(r,a),c=Mu(i,o);return KT(t,e,n,u,c)}else{let u=ZT(r,a),c=l5[u],h=n.direction[c]>=0,f,m;h?(f=Eu(r),m=Tu(r,a)):(f=Tu(r,a),m=Eu(r));let g=Cg(f,s,n,Mg)?Tg(f,t,e,n):null;if(g){let x=g.point[c];if(h?x<=s[m+u]:x>=s[m+u+3])return g}let v=Cg(m,s,n,Mg)?Tg(m,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var JT=function(){let r,t,e=[],n=new _u(()=>new _t);return function(...o){r=n.getPrimitive(),t=n.getPrimitive(),e.push(r,t);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],r=e[l-2]),a};function i(s,o,a,l,u=null,c=0,d=0){function h(x){let w=x*2,S=ha,_=fa;for(;!So(w,S);)x=Eu(x),w=x*2;return xl(x,_)}function f(x){let w=x*2,S=ha,_=fa;for(;!So(w,S);)x=Tu(x,_),w=x*2;return xl(x,_)+Mu(w,S)}let m=s*2,p=Pu,g=ha,y=fa;if(So(m,g)){let x=xl(s,y),w=Mu(m,g);return Si(s,p,r),l(x,w,!1,d,c+s,r)}else{let x=Eu(s),w=Tu(s,y),S=x,_=w,M,b,E,T;if(u&&(E=r,T=t,Si(S,p,E),Si(_,p,T),M=u(E),b=u(T),b<M)){S=w,_=x;let Y=M;M=b,b=Y,E=T}E||(E=r,Si(S,p,E));let P=So(S*2,g),D=a(E,P,M,d+1,c+S),C;if(D===2){let Y=h(S),q=f(S)-Y;C=l(Y,q,!0,d+1,c+S,E)}else C=D&&i(S,o,a,l,u,c,d+1);if(C)return!0;T=t,Si(_,p,T);let O=So(_*2,g),B=a(T,O,b,d+1,c+_),V;if(B===2){let Y=h(_),q=f(_)-Y;V=l(Y,q,!0,d+1,c+_,T)}else V=B&&i(_,o,a,l,u,c,d+1);return!!V}}}(),$T=function(){let r=new jr,t=new jr,e=new ae,n=new qr,i=new qr;return function s(o,a,l,u,c=null){let d=o*2,h=Pu,f=ha,m=fa;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),So(d,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,w=l.attributes.position,S=xl(o,m),_=Mu(d,f);if(e.copy(u).invert(),l.boundsTree)return Si(o,h,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>i.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let E=S*3,T=(_+S)*3;E<T;E+=3)if(Ai(t,E,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let M=S*3,b=_+S*3;M<b;M+=3){Ai(r,M,y,v),r.a.applyMatrix4(e),r.b.applyMatrix4(e),r.c.applyMatrix4(e),r.needsUpdate=!0;for(let E=0,T=x.count;E<T;E+=3)if(Ai(t,E,x,w),t.needsUpdate=!0,r.intersectsTriangle(t))return!0}}else{let g=o+8,y=m[o+6];return Si(g,h,Cu),!!(c.intersectsBox(Cu)&&s(g,a,l,u,c)||(Si(y,h,Cu),c.intersectsBox(Cu)&&s(y,a,l,u,c)))}}}();function Cg(r,t,e,n){return Si(r,t,Cu),e.intersectBox(Cu,n)}var fb=[],_g,Pu,ha,fa;function Du(r){_g&&fb.push(_g),_g=r,Pu=new Float32Array(r),ha=new Uint16Array(r),fa=new Uint32Array(r)}function Jh(){_g=null,Pu=null,ha=null,fa=null,fb.length&&Du(fb.pop())}var pb=Symbol("skip tree generation"),mb=new _t,gb=new _t,Iu=new ae,bl=new qr,$h=new qr,ef=new A,Pg=new A,c5=new A,u5=new A,d5=new A,eC=new _t,Ts=new _u(()=>new jr),un=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),un.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),un.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=t,o=new un(e,{...n,[pb]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Be(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[pb]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[pb]||(this._roots=HT(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new _t))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,i=e.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,d,h=0,f=this._roots;for(let p=0,g=f.length;p<g;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),d=new Float32Array(l),m(0,h),h+=l.byteLength;function m(p,g,y=!1){let v=p*2;if(c[v+15]===65535){let w=u[p+6],S=c[v+14],_=1/0,M=1/0,b=1/0,E=-1/0,T=-1/0,P=-1/0;for(let D=3*w,C=3*(w+S);D<C;D++){let O=n[D]*a+o,B=s[O+0],V=s[O+1],Y=s[O+2];B<_&&(_=B),B>E&&(E=B),V<M&&(M=V),V>T&&(T=V),Y<b&&(b=Y),Y>P&&(P=Y)}return d[p+0]!==_||d[p+1]!==M||d[p+2]!==b||d[p+3]!==E||d[p+4]!==T||d[p+5]!==P?(d[p+0]=_,d[p+1]=M,d[p+2]=b,d[p+3]=E,d[p+4]=T,d[p+5]=P,!0):!1}else{let w=p+8,S=u[p+6],_=w+g,M=S+g,b=y,E=!1,T=!1;t?b||(E=t.has(_),T=t.has(M),b=!E&&!T):(E=!0,T=!0);let P=b||E,D=b||T,C=!1;P&&(C=m(w,g,b));let O=!1;D&&(O=m(S,g,b));let B=C||O;if(B)for(let V=0;V<3;V++){let Y=w+V,W=S+V,q=d[Y],j=d[Y+3],X=d[W],L=d[W+3];d[p+V]=q<X?q:X,d[p+V+3]=j>L?j:L}return B}}}traverse(t,e=0){let n=this._roots[e],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=i[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=i[a+6],f=i[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=si){let n=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(Du(n[c]),Eg(0,i,h,t,s),Jh(),a){let m=l[c].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(t,e=si){let n=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;Du(n[c]);let f=Tg(0,i,h,t);Jh(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,i=!1;for(let s of this._roots)if(Du(s),i=$T(0,n,t,e),Jh(),i)break;return i}shapecast(t,e,n){let i=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,m,p,g)=>{let y=m*3;return h(f,y,y+1,y+2,p,g)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Ts.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,m,p,g,y)=>h(f,m,p,g,y)?!0:hb(f,m,i,u,p,g,s)}else l||(u?l=(h,f,m,p)=>hb(h,f,i,u,m,p,s):l=(h,f,m)=>m);let c=!1,d=0;for(let h of this._roots){if(Du(h),c=JT(0,i,a,l,o,d),Jh(),c)break;d+=h.byteLength}return Ts.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;Iu.copy(e).invert();let c=Ts.getPrimitive(),d=Ts.getPrimitive();if(s){let f=function(m,p,g,y,v,x,w,S){for(let _=g,M=g+y;_<M;_++){Ai(d,_*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let b=m,E=m+p;b<E;b++)if(Ai(c,b*3,o,a),c.needsUpdate=!0,s(c,d,b,_,v,x,w,S))return!0}return!1};if(i){let m=i;i=function(p,g,y,v,x,w,S,_){return m(p,g,y,v,x,w,S,_)?!0:f(p,g,y,v,x,w,S,_)}}else i=f}t.getBoundingBox(gb),gb.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>gb.intersectsBox(f),intersectsRange:(f,m,p,g,y,v)=>(mb.copy(v),mb.applyMatrix4(Iu),t.shapecast({intersectsBounds:x=>mb.intersectsBox(x),intersectsRange:(x,w,S,_,M)=>i(f,m,x,w,g,y,_,M)}))});return Ts.releasePrimitive(c),Ts.releasePrimitive(d),h}intersectsBox(t,e){return bl.set(t.min,t.max,e),bl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>bl.intersectsBox(n),intersectsTriangle:n=>bl.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),bl.set(t.boundingBox.min,t.boundingBox.max,e),bl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=Ts.getPrimitive(),f=Ts.getPrimitive(),m=Pg,p=c5,g=null,y=null;i&&(g=u5,y=d5);let v=1/0,x=null,w=null;return Iu.copy(e).invert(),$h.matrix.copy(Iu),this.shapecast({boundsTraverseOrder:S=>bl.distanceToBox(S),intersectsBounds:(S,_,M)=>M<v&&M<o?(_&&($h.min.copy(S.min),$h.max.copy(S.max),$h.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>$h.distanceToBox(M),intersectsBounds:(M,b,E)=>E<v&&E<o,intersectsRange:(M,b)=>{for(let E=M*3,T=(M+b)*3;E<T;E+=3){Ai(f,E,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let P=S*3,D=(S+_)*3;P<D;P+=3){Ai(h,P,u,l),h.needsUpdate=!0;let C=h.distanceToTriangle(f,m,g);if(C<v&&(p.copy(m),y&&y.copy(g),v=C,x=P/3,w=E/3),C<s)return!0}}}});{let M=d?d.count:c.count;for(let b=0,E=M;b<E;b+=3){Ai(f,b,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let T=S*3,P=(S+_)*3;T<P;T+=3){Ai(h,T,u,l),h.needsUpdate=!0;let D=h.distanceToTriangle(f,m,g);if(D<v&&(p.copy(m),y&&y.copy(g),v=D,x=T/3,w=b/3),D<s)return!0}}}}}),Ts.releasePrimitive(h),Ts.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(Iu),p.applyMatrix4(Iu),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(t,e={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(ef.copy(t).clamp(c.min,c.max),ef.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,ef);let h=t.distanceToSquared(ef);return h<a&&(Pg.copy(ef),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(Pg):e.point=Pg.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Si(0,new Float32Array(n),eC),t.union(eC)}),t}},tC=un.prototype.raycast;un.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,e,n,i]=r;return tC.call(this,n,t.material).forEach(o=>{o=db(o,t,e),o&&i.push(o)}),i}else return tC.apply(this,r)};var nC=un.prototype.raycastFirst;un.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,e,n]=r;return db(nC.call(this,n,t.material),t,e)}else return nC.apply(this,r)};var rC=un.prototype.closestPointToPoint;un.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let t=r[1],e={};return r[1]=e,rC.apply(this,r),t&&t.copy(e.point),e.distance}else return rC.apply(this,r)};var iC=un.prototype.closestPointToGeometry;un.prototype.closestPointToGeometry=function(...r){let t=r[2],e=r[3];if(t&&t.isVector3||e&&e.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,iC.apply(this,r),t&&t.copy(n.point),e&&e.copy(i.point).applyMatrix4(s),n.distance}else return iC.apply(this,r)};var sC=un.prototype.refit;un.prototype.refit=function(...r){let t=r[0],e=r[1];if(e&&(e instanceof Set||Array.isArray(e))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;e.forEach(i=>n.add(i)),t&&t.forEach(i=>n.add(i)),sC.call(this,n)}else sC.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let t=un.prototype[r];un.prototype[r]=function(...e){return(e[0]===null||e[0].isMesh)&&(e.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,e)}});var wd=fs(aC());var h5=.5*(Math.sqrt(3)-1),tf=(3-Math.sqrt(3))/6,f5=1/3,Cs=1/6,Use=(Math.sqrt(5)-1)/4,kse=(5-Math.sqrt(5))/20,nf=r=>Math.floor(r)|0,lC=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]),vb=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 Dg(r=Math.random){let t=uC(r),e=new Float64Array(t).map(i=>lC[i%12*2]),n=new Float64Array(t).map(i=>lC[i%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*h5,d=nf(s+c),h=nf(o+c),f=(d+h)*tf,m=d-f,p=h-f,g=s-m,y=o-p,v,x;g>y?(v=1,x=0):(v=0,x=1);let w=g-v+tf,S=y-x+tf,_=g-1+2*tf,M=y-1+2*tf,b=d&255,E=h&255,T=.5-g*g-y*y;if(T>=0){let C=b+t[E],O=e[C],B=n[C];T*=T,a=T*T*(O*g+B*y)}let P=.5-w*w-S*S;if(P>=0){let C=b+v+t[E+x],O=e[C],B=n[C];P*=P,l=P*P*(O*w+B*S)}let D=.5-_*_-M*M;if(D>=0){let C=b+1+t[E+1],O=e[C],B=n[C];D*=D,u=D*D*(O*_+B*M)}return 70*(a+l+u)}}function cC(r=Math.random){let t=uC(r),e=new Float64Array(t).map(s=>vb[s%12*3]),n=new Float64Array(t).map(s=>vb[s%12*3+1]),i=new Float64Array(t).map(s=>vb[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*f5,m=nf(o+f),p=nf(a+f),g=nf(l+f),y=(m+p+g)*Cs,v=m-y,x=p-y,w=g-y,S=o-v,_=a-x,M=l-w,b,E,T,P,D,C;S>=_?_>=M?(b=1,E=0,T=0,P=1,D=1,C=0):S>=M?(b=1,E=0,T=0,P=1,D=0,C=1):(b=0,E=0,T=1,P=1,D=0,C=1):_<M?(b=0,E=0,T=1,P=0,D=1,C=1):S<M?(b=0,E=1,T=0,P=0,D=1,C=1):(b=0,E=1,T=0,P=1,D=1,C=0);let O=S-b+Cs,B=_-E+Cs,V=M-T+Cs,Y=S-P+2*Cs,W=_-D+2*Cs,q=M-C+2*Cs,j=S-1+3*Cs,X=_-1+3*Cs,L=M-1+3*Cs,U=m&255,G=p&255,H=g&255,z=.6-S*S-_*_-M*M;if(z<0)u=0;else{let k=U+t[G+t[H]];z*=z,u=z*z*(e[k]*S+n[k]*_+i[k]*M)}let re=.6-O*O-B*B-V*V;if(re<0)c=0;else{let k=U+b+t[G+E+t[H+T]];re*=re,c=re*re*(e[k]*O+n[k]*B+i[k]*V)}let K=.6-Y*Y-W*W-q*q;if(K<0)d=0;else{let k=U+P+t[G+D+t[H+C]];K*=K,d=K*K*(e[k]*Y+n[k]*W+i[k]*q)}let Z=.6-j*j-X*X-L*L;if(Z<0)h=0;else{let k=U+1+t[G+1+t[H+1]];Z*=Z,h=Z*Z*(e[k]*j+n[k]*X+i[k]*L)}return 32*(u+c+d+h)}}function uC(r){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let i=n+~~(r()*(256-n)),s=e[n];e[n]=e[i],e[i]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var Yi=new an,Ig=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let s=1;Yi.a.fromBufferAttribute(t,i),Yi.b.fromBufferAttribute(t,i+1),Yi.c.fromBufferAttribute(t,i+2),s*=Yi.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let i=0;i<e.length;i++)n+=e[i],this.distribution[i]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*n);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,i=e.length-1,s=-1;for(;n<=i;){let o=Math.ceil((n+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:n=o+1}return s}sampleFace(t,e,n){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),Yi.a.fromBufferAttribute(this.positionAttribute,t*3),Yi.b.fromBufferAttribute(this.positionAttribute,t*3+1),Yi.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Yi.a,i).addScaledVector(Yi.b,s).addScaledVector(Yi.c,1-(i+s)),Yi.getNormal(n),this}};var hC=fs(xb()),p5=new ae,m5=new ae,g5=new ae,rf;(t=>{function r(e){return e&&e.__isSPEObject}t.is=r})(rf||(rf={}));var Ou=r=>class extends r{constructor(){super(...arguments);this.previousModelViewMatrix=new ae;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ae;this.matrixWorldRigid=new ae;this.shearScale=new ae;this.shearScaleInv=new ae}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof pt&&(n=n.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===n)return!0;i=i.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseObject(n,i=0){if(n(this,i)!==!0)for(let o of this.children)rf.is(o)&&o.traverseObject(n,i+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,i=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,hC.SVD)(i),l=p5.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=m5.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=g5.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,i){this.updateWorldMatrix(!0,!1);let s=new ae().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof ae?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),i!==void 0&&(this.children.pop(),this.children.splice(i,0,n)),this}copy(n,i=!1){return super.copy(n,i),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,i,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var bb=class extends Ou(pt){},y5=r=>r.type==="Mesh",dn=class extends bb{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let i=this.children[e];i?.object!==n&&(i&&this.remove(i),i=new dn(n),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=n.matrix,i.hiddenMatrix=n.hiddenMatrix),i.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return y5(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var wl=new A,Sl=new A,Ru=new ae,pC=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],v5=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],x5=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],fC=(r,t,e)=>{r.updateEntityBoxSize(wl,Sl),Ru.copy(t).multiply(r.matrixWorld),Sl.x===0&&Sl.y===0&&Sl.z===0?e.push(new A(wl.x,wl.y,wl.z).applyMatrix4(Ru)):pC.forEach(n=>{e.push(n.clone().multiply(Sl).add(wl).applyMatrix4(Ru))})},sf=class extends _t{constructor(){super(...arguments);this.matrix=new ae;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ae().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,n)}expandByObjectSize(e,n,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}fC(o,n,s)}}):fC(e,n,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Ru.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Sl).multiplyScalar(.5),this.getCenter(wl),Ru.copy(this.matrix).setPosition(wl),this.vertices=pC.map(e=>e.clone().multiply(Sl).applyMatrix4(Ru))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=v5.map(([e,n])=>new Hn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=x5.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Qi={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Sb=class extends bh{constructor(){super()}getPoints(t=12){let e=[],n,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?i[a]:i[a]-i[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let m=h[f];n&&n.equals(m)||(e.push(m),n=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Ab=.001;function _b(r,t,e){return t.clone().sub(r).cross(t.clone().sub(e)).length()<=Ab}function wb(r,t){let e=new A(...r.position),n=new A(...r.controlNext.position),i=new A(...t.controlPrevious.position),s=new A(...t.position);return _b(e,n,s)&&_b(e,i,s)}function Rg(r){let t=r.points.map(c=>new A(...c.data.position)),e=[r.points[0]],n=new A(...e[0].data.position);for(let c=0;c<r.points.length-1;c++)_b(n,t[c],t[c+1])||(e.push(r.points[c]),n=t[c]);e.push(r.points[r.points.length-1]);let i=r.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new A(...d.position),f=new A(...d.controlPrevious.position),m=new A(...d.controlNext.position),p={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!r.isClosed&&(c===0||c===o-1)){a[c]={...p,removedLength:0};continue}let g=i&&c==0?o-1:c-1,y=i&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,w=new A(...v.position),S=new A(...x.position),_=w.clone().sub(h).normalize(),M=S.clone().sub(h).normalize();Object.assign(p,{prevDir:_,nextDir:M});let b=wb(v,d),E=wb(d,x);if(!b||!E)a[c]={...p,removedLength:0};else{let T=_.clone().add(M).normalize(),P=T.clone().cross(_).length()/_.dot(T);a[c]={...p,tan:P,removedLength:d.roundness/P}}}for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],m=a[h];if(f.removedLength!==0||m.removedLength!==0){let p=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,p/2),m.removedLength=Math.min(m.removedLength,p/2)}}let l=[];for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],m=a[h],p=null;if(!wb(e[d].data,e[h].data))f.position.distanceTo(m.position)>Ab&&(p=new Ka(f.position,f.controlNext,m.controlPrevious,m.position));else{let g=f.position.clone(),y=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&y.add(m.prevDir.clone().setLength(m.removedLength))),g.distanceTo(y)>Ab&&(p=new Ka(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=p}for(let c=0;c<o;c++){let d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),m=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),p=d.tan*d.removedLength,g=d.prevDir.clone().add(d.nextDir).normalize(),y=f.clone().lerp(m,.5),v=f.distanceTo(m)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(v,2))).add(y),w=g.clone().multiplyScalar(-p).add(x),S=h.distanceTo(w)/h.distanceTo(y),_=d.prevDir.clone().multiplyScalar(S*h.distanceTo(f)).add(h),M=_.clone().lerp(w,2),b=f.clone().lerp(_,4/3),E=m.clone().lerp(M,4/3);l[2*c]=new Ka(f,b,E,m)}let u=new Sb;return l.forEach(c=>{c&&u.add(c)}),u}var St;(t=>{function r(e){return e&&e.__isEntity}t.is=r})(St||(St={}));var Ao=r=>St.is(r),b5={type:"completeState",isfromEntity:!0},Lg=r=>class extends Ou(r){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new sf;this._recursiveBBox=new sf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let i=this.children[n];if(St.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let n=this;for(;n.data.type!=="Instance";){let i=n.parent;if(St.is(i))n=i;else return}return n}forInstancesRec(n){this.instances.forEach(i=>{i.disposed||n(i),i.forInstancesRec(n)})}super_Entity(n,i){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)xo.toOps(this.data,o.data).forEach(l=>{let u=Hm.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,i)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=xo.patch(this.data,o),xo.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched),this.stateSelection=n,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(n,i){n.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Ao(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let i;return this.traverseEntity(s=>{s.uuid===n&&(i=s)}),i}traverseSortNextHelper(){let n=this.parent;if(n){let i=n.children,s=i.indexOf(this)+1;if(St.is(i[s]))return i[s];if(St.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&St.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let i=this;for(;n>0&&i!==null;)i=i.parent,n-=1;return i}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let i=this.parent;for(;i;){if(n===i)return!0;i=i.parent}return!1}countToAccestor(n){let i=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(n){for(let i of this.children)Ao(i)&&n(i)}traverseEntityAncestors(n){this.traverseAncestors(i=>{St.is(i)&&n(i)})}traverseEntity(n,i=0){if(n(this,i)!==!0)for(let o of this.children)Ao(o)&&o.traverseEntity(n,i+1)}traverseVisibleEntity(n){n(this);for(let i of this.children)Ao(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,i=!1){return super.copy(n,i),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Ao(n))}isAncestorOf(n){if(this.uuid===n)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===n&&(i=!0)}),i}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return eu(i,n)}updateTransformState(n){let i=!1;return n.position&&(this.position.fromArray(n.position),i=!0),n.rotation&&(this.rotation.fromArray(n.rotation),i=!0),n.scale&&(i=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??la.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)St.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{St.is(n)&&n.disposeRecursively()})}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return eu(i,n)}updateByOp(n,i,s,o){let a=this.data;this.data=i;let l=n,u=Wi(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=Lr.zoom(h,n.path.slice(2));if(f)for(let m in n.props)n.props[m]===void 0&&m in f&&(d[m]=f[m])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=Lr.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,xo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Wi(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(mo.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=Lr.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let m=n.props;if(f)for(let[p,g]of Object.entries(n.props))g===void 0&&(m===n.props&&(m={...n.props}),m[p]=f[p]);n={...n,props:m}}h.overrideData=mu.resolve(i.overrides,c),h.updateByOp(n,gr.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of ua.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of ua.rootOverrideProps)if(Wi(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=mo.filterOp(d.overrideData,c);h&&d.updateByOp(h,gr.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=mo.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=i:f=gr.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,i,s){if(this.dataPatched=i,n.path.length===0&&n.type===0)n.props.type!==void 0&&!ji.is(n.props.type)&&Qi.changeEntityProptotype(this,i,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){Qi.changeEntityProptotype(this,i,s);for(let o of this.children)St.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,i,s)}updateByPatchedOp(n,i,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Wi(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Wi(n.path,["cloner"])!==null){let o=gr.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=n.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data,c=Rg(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new ae;l.updateMatrixWorld();let m=new ae().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(m);let p={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ae().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(g).add(h),v=new ae().lookAt(h,y,new A(0,1,0)),x=new Wt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(b5)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,i){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,i),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof Qi.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,i){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Qi.Cloner(this,n),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,i.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var Ng=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},r.parameters),n=e.width/2,i=e.radiusTop??n,s=e.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=r.parameters,m;return d||f?m=new of(u,c,n,i,s,o,a,l*Math.PI/180,d,d,h,f):m=new Ja(u,c,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,e/t),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function pa(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function mC(r){return new F(r.y,-r.x)}var of=class extends Me{constructor(t,e,n,i,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],y=[],v=0,x=n/2,w=new A,S=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let _=new F(t,x),M=new F(e,-x),b=null,E=null,T=null,P=null,D=_.clone().sub(M),C=0,O=0,B=0;h>0&&(C=Math.min(t,e)*(1-h),O=t-C,B=e-C);let V=_.clone();V.x-=C;let Y=Math.PI-D.angle(),W=D.angle(),q=Math.tan(W/2),j=Math.tan(Y/2),X=q+j,L=h?X:j,U=h?X:q;if(u=Math.min(u,(t-O)/L,D.length()/X),c=Math.min(c,(e-B)/U,D.length()/X),u>0){let Z=u/q;b=_.clone().sub(new F(Z,u)),h&&(T=b.clone(),T.x-=C-X*u),_.sub(D.clone().setLength(Z))}if(c>0){let Z=c/j;E=M.clone().sub(new F(Z,-c)),M.add(D.clone().setLength(Z)),h&&(P=E.clone(),P.x-=C-X*c,V.sub(D.clone().setLength(Z)))}D=_.clone().sub(M);let G=D.length()<.5,H=[];for(let Z=0;Z<=i;Z++){let k=[],he=Z/i,fe=he*l+a,ce=new F(Math.sin(fe),Math.cos(fe));P&&E?(z(k,he,ce,Y,c,P,-1,!0),z(k,he,ce,W,c,E,-1,!1)):E?(re(k,ce,E.x,0,-1),z(k,he,ce,W,c,E,-1,!1)):o||re(k,ce,e,B,-1);let ye=mC(D).normalize();if(pa(ye,ce,w),!G)for(let Se=0;Se<=s;Se++){let ve=Se/s,Ee=D.clone().multiplyScalar(ve).add(M);pa(Ee,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}if(T&&b?(z(k,he,ce,Y,u,b,1,!1),z(k,he,ce,W,u,T,1,!0)):b?(z(k,he,ce,Y,u,b,1,!1),re(k,ce,b.x,0,1)):o||re(k,ce,t,O,1),h&&!G){let Se=mC(D).multiplyScalar(-1).normalize();pa(Se,ce,w);for(let ve=0;ve<=s;ve++){let Ee=ve/s,Te=D.clone().multiplyScalar(-Ee).add(V);pa(Te,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}}h&&!o&&k.push(k[0]),H.push(k)}for(let Z=0;Z<H.length-1;Z++)for(let k=0;k<H[0].length-1;k++){if(o&&h&&k==s)continue;let he=H[Z][k],fe=H[Z+1][k],ce=H[Z+1][k+1],ye=H[Z][k+1],Se=p[ce*3+0],ve=p[ce*3+2];m.push(he,fe,ye),(Se!=0||ve!=0)&&m.push(fe,ce,ye)}l<Math.PI*2&&(K(-1,H[0],a),K(1,H[H.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(y,2));function z(Z,k,he,fe,ce,ye,Se,ve){for(let Ee=0;Ee<d+1;Ee++){let Te=Ee/d,we=Se<0?Te:1-Te;ve&&(we-=1),we*=fe;let Ge=new F(Math.sin(we),Math.cos(we)*Se),gt=Ge.clone().multiplyScalar(ce).add(ye);pa(gt,he,S),p.push(S.x,S.y,S.z),pa(Ge,he,w),g.push(w.x,w.y,w.z),y.push(k,.5+S.y/n),Z.push(v++)}}function re(Z,k,he,fe,ce){let ye=new A,Se=new F,ve=[he,fe];ce<0&&ve.reverse();for(let Ee of ve)Se.set(Ee,x*ce),pa(Se,k,ye),p.push(ye.x,ye.y,ye.z),g.push(0,ce,0),y.push(.5,.5),Z.push(v++)}function K(Z,k,he){let fe=new F(Math.sin(he),Math.cos(he)),ce=new F(-Math.cos(he),Math.sin(he)),ye=new A,Se=Z<0?(Te,we,Ge)=>m.push(Te,we,Ge):(Te,we,Ge)=>m.push(Te,Ge,we),ve=new F((t+e+O+B)/4,0);pa(ve,fe,ye),p.push(ye.x,ye.y,ye.z),g.push(ce.x,0,ce.y),y.push(.5,.5);let Ee=v++;for(let Te of k){let we=p.slice(Te*3,Te*3+3);p.push(...we),g.push(ce.x,0,ce.y);let Ge=y.slice(Te*2,Te*2+2);y.push(...Ge),v++}for(let Te=Ee+1;Te<v-1;Te++)Se(Ee,Te,Te+1);Se(Ee,v-1,Ee+1)}}};var gC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=r.parameters,h;return u>0||c>0||l<360?h=new of(0,t/2,n,i,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new fc(t/2,n,i,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...r,type:"ConeGeometry"}})}};var yC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new er(t,e,n,i,s,o):u=new Eb(t,e,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},Mb=Math.PI/2,Eb=class extends Me{constructor(t=1,e=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,i,o,2),g("x","z","y",1,-1,t,n,-e,i,o,3),g("x","y","z",1,-1,t,e,n,i,s,4),g("x","y","z",-1,-1,t,e,-n,i,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,i,0),y("x","y","z",1,-1,1,t,e,n,i,1),y("x","y","z",-1,1,1,t,e,n,i,0),y("x","y","z",1,1,-1,t,e,n,i,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function g(x,w,S,_,M,b,E,T,P,D,C){let O=(b-2*a)/P,B=(E-2*a)/D,V=b/2-a,Y=E/2-a,W=T/2,q=P+1,j=D+1,X=0,L=0,U=new A;for(let G=0;G<j;G++){let H=G*B-Y;for(let z=0;z<q;z++){let re=z*O-V;U[x]=re*_,U[w]=H*M,U[S]=W,d.push(U.x,U.y,U.z),U[x]=0,U[w]=0,U[S]=T>0?1:-1,h.push(U.x,U.y,U.z),f.push(z/P),f.push(1-G/D),X+=1}}for(let G=0;G<D;G++)for(let H=0;H<P;H++){let z=m+H+q*G,re=m+H+q*(G+1),K=m+(H+1)+q*(G+1),Z=m+(H+1)+q*G;c.push(z,re,Z),c.push(re,K,Z),L+=6}u.addGroup(p,L,C),p+=L,m+=X}function y(x,w,S,_,M,b,E,T,P,D,C){let O=(E-2*a)/D,B=E/2-a,V=T/2-a,Y=P/2,W=D+1,q=0,j=0,X=new A,L=new A;for(let U=0;U<l+1;U++){let G=U/l*Mb,H=Math.sin(G)*a,z=(1-Math.cos(G))*a,re=Math.sin(G),K=Math.cos(G);X[w]=(V+H)*M,X[S]=(Y-z)*b,L[x]=0,L[w]=re*Math.sign(X[w]),L[S]=K*Math.sign(X[S]);for(let Z=0;Z<W;Z++){let k=Z*O-B;X[x]=k*_,d.push(X.x,X.y,X.z),h.push(L.x,L.y,L.z),f.push(Z/D),f.push(0),q+=1}}for(let U=0;U<l;U++)for(let G=0;G<D;G++){let H=m+G+W*U,z=m+G+W*(U+1),re=m+(G+1)+W*(U+1),K=m+(G+1)+W*U;c.push(H,z,K),c.push(z,re,K),j+=6}u.addGroup(p,j,C),p+=j,m+=q}function v(x,w,S){let _=new A,M=new A(t/2,e/2,n/2);M.subScalar(a);let b=[],E=x*w*S>0?(P,D,C)=>c.push(P,D,C):(P,D,C)=>c.push(P,C,D);for(let P=0;P<=l;P++){let D=[],C=Mb*(1-P/l),O=Math.cos(C),B=Math.sin(C),V=0;for(let Y=0;Y<=P;Y++){let W=Math.cos(V),q=Math.sin(V);_.x=O*W,_.y=B,_.z=O*q;let j=M.clone().addScaledVector(_,a);d.push(x*j.x,w*j.y,S*j.z),h.push(x*_.x,w*_.y,S*_.z),f.push(0,0),D.push(m++),V+=Mb/P}b.push(D)}let T=b.length-1;for(let P=0;P<T;P++){let D=b[P],C=b[P+1],O=D.length-1;E(D[0],C[1],C[0]);for(let B=1;B<=O;B++)E(D[B-1],D[B],C[B]),E(D[B],C[B+1],C[B])}}}};var ma=class extends Me{constructor(t=[],e=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new an,y=s*i,v=i-y,x=o+1,w=new A,S=(q,j)=>w.subVectors(q,j).normalize(),_=(q,j)=>Array(q).fill(void 0).map(j),M=_(t.length/3,(q,j)=>new A().fromArray(t,j*3).setLength(i)),b=[],E=1e6;for(let q=0;q<M.length;q++){let j=M[q],X=[],L,U,G,H=1e10,z=-1;for(;(z=e.indexOf(q,z+1))!=-1;){let k=z-z%3;L=e[k+(z+1)%3],U=e[k+(z+2)%3],G=j.distanceToSquared(M[L]),H=Math.min(H,G),X.push([L,U,G])}H+=1e-6;let re=[],K=0,Z=X.length;for(let k=0;k<Z;k++){[L,U,G]=X[K];let he=b[L]?.includes(q)==!0;G<=H&&re.push(L+ +he*E),K=X.findIndex(fe=>fe[0]==U)}b.push(re)}let T=[];{let q=0,j=0,X,L,U=f==3;for(let G=0;G<=o;G++){X=G*(G+1)/2,L=(G+1)*(G+2)/2;for(let H=0;H<o-G;H++)[q,j]=[X+H+G+2,L+H+G+3],T.push(X,L,...U?[j,X]:[q,L],j,q),[X,L]=[q,j];T.push(X,L,X+o+2)}}let P=m.clone(),D=m.clone(),C=m.clone(),O=m.clone(),B=m.clone(),V=[],Y=_(M.length,()=>_(f,()=>m.clone()));for(let q=0;q<M.length;q++){m.copy(M[q]).normalize(),P.copy(m).multiplyScalar(v);let j=b[q];for(let re=0;re<j.length;re++){let K=j[re],Z=j[(re+1)%f];g.setFromPointsAndIndices(M,q,K%E,Z%E),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(P,Y[q][re])}let X=[],L=[],U=[],G=new A;o==0&&[...Y[q]].reduce((re,K)=>re.add(K),G).multiplyScalar(1/f);for(let re=0;re<f;re++){let K=[],Z=(re-1+f)%f,k=Y[q][Z],he=Y[q][re];m.copy(k).sub(P),p.copy(he).sub(P);let fe=P.angleTo(m),ce=m.angleTo(p),ye=Math.cos(fe)*y;o==0?D.copy(G):D.copy(P).setLength(v+ye),L.push(ye);let Se=[D,k,he];for(let ve=0;ve<2;ve++){let Ee=Se[ve],Te=Se[ve+1];O.subVectors(Ee,P),B.subVectors(Te,P),C.crossVectors(O,B).normalize();for(let we=0;we<x;we++){let Ge=[fe,ce][ve]*we/x;m.copy(O).applyAxisAngle(C,Ge).add(P),X.push(m.clone()),ve&&(S(m,P),K.push([we==0?Ee:m.clone(),w.clone()]))}ve&&(S(Te,P),K.push([Te,w.clone()]))}U.push(K)}V.push(U);let H=2*x,z=2;for(let re=0;re<f;re++){let K=H*re,Z=H*((re+1)%f),k=[X[K]];for(let fe=1;fe<x;fe++){O=X[K+fe],B=X[Z+fe],k.push(O);for(let ce=1,ye=fe-z+1;ce<=ye;ce++)m.lerpVectors(O,B,ce/(ye+1)),m.sub(P).setLength(L[re]).add(P),k.push(m.clone());k.push(B)}for(let fe=0;fe<x;fe++)k.push(X[fe+x+K]);k.push(X[Z+x]);let he=T.map(fe=>k[fe]);a.push(...he.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...he.map(fe=>(S(fe,P),[w.x,w.y,w.z])).flat())}}let W=[];for(let q=0;q<b.length;q++)for(let j=0;j<f;j++){let X=b[q][j];if(X<E){let L=b[X].findIndex(H=>H%E==q),U=V[q][j],G=V[X][L];for(let H=0;H<x;H++){let z=U[H],re=G[x-H],K=U[H+1],Z=G[x-(H+1)];[z,re,K,K,re,Z].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),u.push(k[1].x,k[1].y,k[1].z)})}W.push(U[0][0],G[x][0],U[x][0],G[0][0])}}for(;W.length;){let q,j,X,L;[q,j]=W.splice(0,2);let U=[q];for(;q!=j;)U.push(j),X=W.indexOf(j),L=X%2,j=W.splice(X-L,2)[1-L];w.subVectors(U[0],U[1]).cross(m.subVectors(U[0],U[2])).normalize();let G=w.dot(U[0])<0;G&&w.negate();for(let H=1;H<=U.length-2;H++)[U[H+ +G],U[H+1-+G],U[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(w.x,w.y,w.z)})}}function d(){let h=new A;for(let M=0;M<a.length;M+=3){h.x=a[M+0],h.y=a[M+1],h.z=a[M+2];let b=S(h)/2/Math.PI+.5,E=_(h)/Math.PI+.5;l.push(b,1-E)}let f=new A,m=new A,p=new A,g=new A,y=new F,v=new F,x=new F,w=(M,b,E,T)=>{T<0&&M.x===1&&(l[b]=M.x-1),E.x===0&&E.z===0&&(l[b]=T/2/Math.PI+.5)};for(let M=0,b=0;M<a.length;M+=9,b+=6){f.set(a[M+0],a[M+1],a[M+2]),m.set(a[M+3],a[M+4],a[M+5]),p.set(a[M+6],a[M+7],a[M+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(m).add(p).divideScalar(3);let E=S(g);w(y,b+0,f,E),w(v,b+2,m,E),w(x,b+4,p,E)}for(let M=0;M<l.length;M+=6){let b=l[M+0],E=l[M+2],T=l[M+4],P=Math.max(b,E,T),D=Math.min(b,E,T);P>.9&&D<.1&&(b<.2&&(l[M+0]+=1),E<.2&&(l[M+2]+=1),T<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new ma(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var vC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new af(t*.5,s,o):new mc(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},af=class extends ma{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new af(t.radius,t.corner,t.cornerSides)}};var lf=1e-12,Lu=class{constructor(t){this.position=new F;this.startPosition=new F;this.uuid=He.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Lu(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Nu=class extends Lu{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Nu(this.parent).copy(this)}},Ki=class extends Lu{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Nu(this),new Nu(this))}static create(e,n){let i=new Ki(e,new F(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Ki(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new F,n=new F){let[i,s]=this.computeTangents();return i&&s&&(xC(i,e),xC(s,n)),[e,n]}computeTangent(e=new F){let[n,i]=this.computeTangents();return n&&i&&e.copy(n).add(i).normalize(),e}computeNormal(e=new F){let[n,i]=this.computeNormals();return e.copy(n).add(i).normalize(),e}};function xC(r,t=new F){let e=r.length();return t.set(-r.y/e,r.x/e)}var Cb=r=>r,Bu=new F,Bg=new F,w5=new F,S5=new F,A5=new F,_5=new F,wC=new A,SC=new A;function AC(r){let t=new F;t.addVectors(r.v0,Bu.subVectors(r.v1,r.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(r.v2,Bg.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new Sr(r.v0,t,e,r.v2)}function cf(r,t,e=Number.EPSILON){return Math.abs(r-t)<e}function M5(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function E5(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function Pb(r,t,e){let n=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function _C(r,t,e){return bC(r,t)&&bC(t,e)&&Tb(r.position,t.position,e.position)}function Tb(r,t,e){return Bu.copy(t).sub(r).cross(Bg.copy(e).sub(r))===0}function MC(r,t,e,n,i){let s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),o=(r.y+t.y)/2,a=(r.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(r.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function EC(r,t,e){let n=r.distanceTo(e),i=t.distanceTo(e);return n<i?t:r}function TC(r,t,e,n,i,s){let o=t.x-r.x,a=t.y-r.y,l=e.x-r.x,u=e.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return Pb(t,r,e)>Math.PI&&(c*=-1),cf(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),i.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[i,s]}function Db(r,t){return r.position.equals(r.controls[1].position)&&t.position.equals(t.controls[0].position)}function bC(r,t){return Tb(r.position,r.controls[1].position,t.position)&&Tb(r.position,t.controls[0].position,t.position)}function CC(r,t,e,n,i=.5){let s=Bu.subVectors(t,r).multiplyScalar(i).add(r),o=Bg.subVectors(e,t).multiplyScalar(i).add(t),a=w5.subVectors(n,e).multiplyScalar(i).add(e),l=s,u=S5.subVectors(o,s).multiplyScalar(i).add(s),c=A5.subVectors(a,o).multiplyScalar(i).add(o),d=a,h=_5.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function PC(r,t,e=12,n=!0){let i=SC.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=Cb(t[l]),c=Bu,d=ga(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof Sr||u instanceof ai||u instanceof Ar){if(u.getPoint(h/d,c),i.set(c.x,c.y,0),s!==void 0&&E5(s,i))continue;s===void 0&&(s=wC),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function DC(r,t,e,n=12,i=!0){let s=SC.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Cb(t[l]),d=Bu,h=ga(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof Sr||c instanceof ai||c instanceof Ar){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=wC:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function Ib(r,t=12,e=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=ga(o.roundedCurveCorner,t)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=ga(o.curveAfter,t)),n.push(a)}return r.length>0&&e&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=ga(r[0].roundedCurveCorner,t)*.5),n}function ga(r,t=12){return r&&r instanceof Qa?t*2:r&&(r instanceof Ar||r instanceof xh)?1:r&&r instanceof dc?t*r.points.length:t}function IC(r,t,e=12,n=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=Cb(t[o]),l=ga(a,e),u=Bu;for(let c=0;c<=l;c++)if(a instanceof Sr||a instanceof ai||a instanceof Ar){if(a.getPoint(c/l,u),i!==void 0&&M5(i,u,lf))continue;i===void 0&&(i=Bg),i.copy(u),r.push(u.x,u.y),s++}}return cf(r[0],r[r.length-2],lf)&&cf(r[1],r[r.length-1],lf)&&(r.pop(),r.pop()),n&&s>1&&!(cf(r[s-1],r[1],lf)&&cf(r[s-2],r[0],lf))&&(r.push(r[0],r[1]),s++),r}var Ob=new F,T5=new F,C5=new F,P5=new F,D5=new F,I5=new F,Mt=class extends ao{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new yn(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=He.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,i){let s=new Mt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Ki.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Mt.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let i=Ob.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,i=He.generateUUID()){let s;e instanceof F?s=e:s=new F(e,n);let o=new Ki(i,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(i=>i.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return PC(e,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Ib(this.points,e,!1),this.roundedCurveDivisions=Ib(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,i=12){return DC(e,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),IC(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=ga(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(e,n,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(Db(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(Ob.set(i.x,i.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){Db(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,n.curveAfter=i;let s=i.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(n,i)}if(this.points.length>2){let n=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],u=o.roundness,c=a&&l&&_C(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,m=o.roundedCurveAfter,p=d.getLength(),g=h.getLength(),y=Math.min(u,p*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/p,S=x/g,_=d.getPointAt(w,Ob),M=h.getPointAt(S,T5);this._subSplitCurve(d,f,w,_,void 0),this._subSplitCurve(h,m,S,void 0,M);let b;if(this.useCubicForRoundedCorners){let E=Pb(_,o.position,M)/2,T=Math.tan(E)*_.distanceTo(o.position),[P,D]=MC(_,M,T,C5,P5),C=EC(P,D,o.position),[O,B]=TC(C,_,M,T,D5,I5);b=new Sr(_.clone(),O.clone(),B.clone(),M.clone())}else b=new ai(_.clone(),o.position.clone(),M.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+n,0,b),n++}}}}_subSplitCurve(e,n,i,s,o){if(e instanceof Ar)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(i,0),c=CC(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let e=new Mt(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],d=e.points[s+5],h=e.points[s+6],f=new Ki(He.generateUUID(),new F(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new Mt;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof Sr&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof ai&&(s[a]=AC(s[a]));for(a=0,l=s.length;a<l;a++){let d=s[a],h=a>0?s[a-1]:null,f;d instanceof Sr?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Ar&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&n(f,h),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof Sr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof Ar&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(e.curves),e instanceof ao&&(this.shapeHoles=e.holes.map(s=>{let o=new Mt;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let i=this.getPointByUuid(e);i&&(n.position!==void 0&&i.position.fromArray(n.position),n.roundness!==void 0&&(i.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var Lb=Math.PI*2;function Rb({x:r,y:t},e,n,i,s){return{x:r*e+i,y:t*n+s}}function O5(r,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-i*e,y:i+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function OC(r,t,e,n){let i=r*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,r*e+t*n));return i*Math.acos(s)}function R5(r,t,e,n,i,s,o,a,l,u){let c=Math.pow(i,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),m=c*d-c*f-d*h;m<0&&(m=0),m/=c*f+d*h,m=Math.sqrt(m)*(l===u?-1:1);let p=m*i/s*a,g=m*-s/i*o,y=p+(r+e)/2,v=g+(t+n)/2,x=(o-p)/i,w=(a-g)/s,S=(-o-p)/i,_=(-a-g)/s,M=OC(1,0,x,w),b=OC(x,w,S,_);return!u&&b>0&&(b-=Lb),u&&b<0&&(b+=Lb),{centerx:y,centery:v,ang1:M,ang2:b}}function RC({px:r,py:t,cx:e,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(i*=Math.sqrt(d),s*=Math.sqrt(d));let h=R5(r,t,e,n,i,s,u,c,o,a),{ang1:f,ang2:m}=h,{centerx:p,centery:g}=h,y=Math.abs(m)/(Lb/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);m/=v;for(let x=0;x<v;x++)l.push(O5(f,m)),f+=m;return l.map(x=>{let{x:w,y:S}=Rb(x[0],i,s,p,g),{x:_,y:M}=Rb(x[1],i,s,p,g),{x:b,y:E}=Rb(x[2],i,s,p,g);return{x1:w,y1:S,x2:_,y2:M,x:b,y:E}})}var mt;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(mt||(mt={}));var sn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(sn||(sn={}));function $e(r,t){if(!r)throw t||"Assertion Failed!"}var je=function(){function r(){}return r.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},r.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},r.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},r.edgeGoesLeft=function(t){return r.vertLeq(t.Dst,t.Org)},r.edgeGoesRight=function(t){return r.vertLeq(t.Org,t.Dst)},r.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},r.edgeEval=function(t,e,n){$e(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-n.t)*(i/(i+s)):e.t-n.t+(n.t-t.t)*(s/(i+s)):0},r.edgeSign=function(t,e,n){$e(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?(e.t-n.t)*i+(e.t-t.t)*s:0},r.transEval=function(t,e,n){$e(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-n.s)*(i/(i+s)):e.s-n.s+(n.s-t.s)*(s/(i+s)):0},r.transSign=function(t,e,n){$e(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?(e.s-n.s)*i+(e.s-t.s)*s:0},r.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},r.interpolate=function(t,e,n,i){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+i)/2:e+(i-e)*(t/(t+n)):i+(e-i)*(n/(t+n))},r.intersect=function(t,e,n,i,s){var o,a,l;r.vertLeq(t,e)||(l=t,t=e,e=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.vertLeq(n,e)?r.vertLeq(e,i)?(o=r.edgeEval(t,n,e),a=r.edgeEval(n,e,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,e.s)):(o=r.edgeSign(t,n,e),a=-r.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+e.s)/2,r.transLeq(t,e)||(l=t,t=e,e=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.transLeq(n,e)?r.transLeq(e,i)?(o=r.transEval(t,n,e),a=r.transEval(n,e,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,e.t)):(o=r.transSign(t,n,e),a=-r.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+e.t)/2},r}(),uf=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Fg=function(){function r(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),r}(),Fu=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),LC=function(){function r(){var t=new Fu,e=new uf,n=new Fg(0),i=new Fg(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(t){var e=new Fg(0),n=new Fg(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return n.next=i,i.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},r.prototype.splice_=function(t,e){var n=t.Onext,i=e.Onext;n.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=n},r.prototype.makeVertex_=function(t,e,n){var i=t;$e(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},r.prototype.makeFace_=function(t,e,n){var i=t;$e(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=n.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},r.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},r.prototype.killVertex_=function(t,e){var n=t.anEdge,i=n;do i.Org=e,i=i.Onext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.killFace_=function(t,e){var n=t.anEdge,i=n;do i.Lface=e,i=i.Lnext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var t=new Fu,e=new Fu,n=new uf,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(t,e){var n=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new Fu;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new uf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},r.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!n){var i=new uf;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},r.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Fu;return this.makeVertex_(i,n,e.Org),e.Lface=n.Lface=t.Lface,e},r.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},r.prototype.connect=function(t,e){var n=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new uf;this.makeFace_(o,i,t.Lface)}return i},r.prototype.zapFace=function(t){var e=t.anEdge,n,i,s,o,a;i=e.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},r.prototype.mergeConvexFaces=function(t){var e,n,i,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&je.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&je.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=t,s=t;(i=s.next)!==t;s=i){$e(i.prev===s),l=i.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for($e(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){$e(o.prev===a),l=o.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for($e(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)$e(l.Sym.next===u.Sym),$e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Org!==null),$e(l.Dst!==null),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l);$e(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),NC=function(){function r(){this.handle=null}return r}(),BC=function(){function r(){this.key=null,this.node=0}return r}(),L5=function(){function r(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var n=0;n<t+1;n++)this.nodes[n]=new NC,this.handles[n]=new BC;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,$e(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[i].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new NC;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new BC}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},r.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,i=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(t){var e=this.nodes,n=this.handles,i;$e(t>=1&&t<=this.max&&n[t].key!==null),i=n[t].node,e[i].handle=e[this.size].handle,n[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[e[i>>1].handle].key,n[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},r}(),Nb=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),FC=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),N5=function(){function r(t,e){this.frame=t,this.leq=e,this.head=new FC,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(t){return this.insertBefore(this.head,t)},r.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},r.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new FC;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},r.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},r}(),B5=function(){function r(){}return r.regionBelow=function(t){return t.nodeUp.prev.key},r.regionAbove=function(t){return t.nodeUp.next.key},r.debugEvent=function(t){},r.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.edgeLeq=function(t,e,n){var i=t.event,s=e.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?je.vertLeq(s.Org,o.Org)?je.edgeSign(o.Dst,s.Org,o.Org)<=0:je.edgeSign(s.Dst,o.Org,s.Org)>=0:je.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return je.edgeSign(s.Dst,i,s.Org)>=0;var a=je.edgeEval(s.Dst,i,s.Org),l=je.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(t,e){e.fixUpperEdge&&$e(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},r.fixUpperEdge=function(t,e,n){$e(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},r.topLeftRegion=function(t,e){var n=e.eUp.Org,i;do e=r.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(i=t.mesh.connect(r.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;r.fixUpperEdge(t,e,i),e=r.regionAbove(e)}return e},r.topRightRegion=function(t){var e=t.eUp.Dst;do t=r.regionAbove(t);while(t.eUp.Dst===e);return t},r.addRegionBelow=function(t,e,n){var i=new Nb;return i.eUp=n,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(t,e){switch(t.windingRule){case mt.ODD:return(e&1)!==0;case mt.NONZERO:return e!==0;case mt.POSITIVE:return e>0;case mt.NEGATIVE:return e<0;case mt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(t,e){e.windingNumber=r.regionAbove(e).windingNumber+e.eUp.winding,e.inside=r.isWindingInside(t,e.windingNumber)},r.finishRegion=function(t,e){var n=e.eUp,i=n.Lface;i.inside=e.inside,i.anEdge=n,r.deleteRegion(t,e)},r.finishLeftRegions=function(t,e,n){for(var i,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),r.finishRegion(t,o),a=s.eUp,o=s}return a},r.addRightEdges=function(t,e,n,i,s,o){var a,l,u,c,d=!0;u=n;do $e(je.vertLeq(u.Org,u.Dst)),r.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(e).eUp.Rprev),l=e,c=s;a=r.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=r.isWindingInside(t,a.windingNumber),l.dirty=!0,!d&&r.checkForRightSplice(t,l)&&(r.addWinding(u,c),r.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,$e(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(t,l)},r.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},r.vertexWeights=function(t,e,n){var i=je.vertL1dist(e,t),s=je.vertL1dist(n,t),o=.5*s/(i+s),a=.5*i/(i+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},r.getIntersectData=function(t,e,n,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,r.vertexWeights(e,n,i),r.vertexWeights(e,s,o)},r.checkForRightSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp;if(je.vertLeq(i.Org,s.Org)){if(je.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;je.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=n.dirty=!0)}else{if(je.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o;if($e(!je.vertEq(i.Dst,s.Dst)),je.vertLeq(i.Dst,s.Dst)){if(je.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(je.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},r.checkForIntersect=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,d,h=new Fu,f,m;if($e(!je.vertEq(u,l)),$e(je.edgeSign(l,t.event,o)<=0),$e(je.edgeSign(u,t.event,a)>=0),$e(o!==t.event&&a!==t.event),$e(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(je.vertLeq(o,a)){if(je.edgeSign(u,o,a)>0)return!1}else if(je.edgeSign(l,a,o)<0)return!1;return r.debugEvent(t),je.intersect(l,o,u,a,h),$e(Math.min(o.t,l.t)<=h.t),$e(h.t<=Math.max(a.t,u.t)),$e(Math.min(u.s,l.s)<=h.s),$e(h.s<=Math.max(a.s,o.s)),je.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=je.vertLeq(o,a)?o:a,je.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),je.vertEq(h,o)||je.vertEq(h,a)?(r.checkForRightSplice(t,e),!1):!je.vertEq(l,t.event)&&je.edgeSign(l,t.event,h)>=0||!je.vertEq(u,t.event)&&je.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=r.topLeftRegion(t,e),i=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),n),r.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),n=e,e=r.topRightRegion(e),m=r.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(t,n,null),r.addRightEdges(t,e,s.Onext,i.Rprev,m,!0),!0):(je.edgeSign(l,t.event,h)>=0&&(r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),je.edgeSign(u,t.event,h)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=h.s,i.Org.t=h.t,i.Org.pqHandle=t.pq.insert(i.Org),r.getIntersectData(t,i.Org,o,l,a,u),r.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(t,e){for(var n=r.regionBelow(e),i,s;;){for(;n.dirty;)e=n,n=r.regionBelow(n);if(!e.dirty&&(n=e,e=r.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(r.deleteRegion(t,n),t.mesh.delete(s),n=r.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(r.checkForIntersect(t,e))return}else r.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n))}},r.connectRightVertex=function(t,e,n){var i,s=n.Onext,o=r.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(t,e),je.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=r.topLeftRegion(t,e),s=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),o),u=!0),je.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(t,o,null),u=!0),u){r.addRightEdges(t,e,n.Onext,s,s,!0);return}je.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(n.Lprev,i),r.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(t,e)},r.connectLeftDegenerate=function(t,e,n){var i,s,o,a,l;if(i=e.eUp,je.vertEq(i.Org,n)){$e(!1),r.spliceMergeVertices(t,i,n.anEdge);return}if(!je.vertEq(i.Dst,n)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,i),r.sweepEvent(t,n);return}$e(!1),e=r.topRightRegion(e),l=r.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&($e(s!==o),r.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),je.edgeGoesLeft(s)||(s=null),r.addRightEdges(t,e,o.Onext,a,s,!0)},r.connectLeftVertex=function(t,e){var n,i,s,o,a,l,u=new Nb;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,je.edgeSign(o.Dst,e,o.Org)===0){r.connectLeftDegenerate(t,n,e);return}if(s=je.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?r.fixUpperEdge(t,s,l):r.computeWinding(t,r.addRegionBelow(t,n,l)),r.sweepEvent(t,e)}else r.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},r.sweepEvent=function(t,e){t.event=e,r.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){r.connectLeftVertex(t,e);return}var i=r.topLeftRegion(t,n.activeRegion);$e(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(t,s,null);a.Onext===o?r.connectRightVertex(t,i,a):r.addRightEdges(t,i,a.Onext,o,o,!0)},r.addSentinel=function(t,e,n,i){var s=new Nb,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},r.initEdgeDict=function(t){t.dict=new N5(t,r.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;r.addSentinel(t,i,s,o),r.addSentinel(t,i,s,a)},r.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||($e(e.fixUpperEdge),$e(++n===1)),$e(e.windingNumber===0),r.deleteRegion(t,e)},r.removeDegenerateEdges=function(t){var e,n,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,i=e.Lnext,je.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(r.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===n||i===n.Sym)&&(n=n.next),t.mesh.delete(i)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},r.initPriorityQ=function(t){var e,n,i,s=0;for(i=t.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,e=t.pq=new L5(s,je.vertLeq),i=t.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=e.insert(n);return n!==i?!1:(e.init(),!0)},r.donePriorityQ=function(t){t.pq=null},r.removeDegenerateFaces=function(t,e){var n,i,s;for(n=e.fHead.next;n!==e.fHead;n=i)i=n.next,s=n.anEdge,$e(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),t.mesh.delete(s));return!0},r.computeInterior=function(t,e){e===void 0&&(e=!0);var n,i;if(r.removeDegenerateEdges(t),!r.initPriorityQ(t))return!1;for(r.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!je.vertEq(i,n));)i=t.pq.extractMin(),r.spliceMergeVertices(t,n.anEdge,i.anEdge);r.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,r.debugEvent(t),r.doneEdgeDict(t),r.donePriorityQ(t),r.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},r}(),F5=function(){function r(){this.mesh=new LC,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=mt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},r.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},r.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},r.prototype.computeNormal_=function(t){var e,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;e=p.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,m[g]=e,l[g]=s,f[g]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,m[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,n=m[v],i=f[v],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],e=p.next;e!==p;e=e.next)d[0]=e.coords[0]-i.coords[0],d[1]=e.coords[1]-i.coords[1],d[2]=e.coords[2]-i.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(e=n.next;e!==n;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,i,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},r.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.prototype.tessellateMonoRegion_=function(t,e){var n,i;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;je.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;je.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(je.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(je.edgeGoesLeft(i.Lnext)||je.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(je.edgeGoesRight(n.Lprev)||je.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},r.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},r.prototype.setWindingNumber_=function(t,e,n){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},r.prototype.outputPolymesh_=function(t,e,n,i){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===sn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*i;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],i>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===sn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var m=l;m<n;++m)this.elements[h++]=-1}}},r.prototype.outputContours_=function(t,e){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new LC),t<2&&(t=2),t>3&&(t=3);for(var n=null,i=0;i<e.length;i+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[i+0],n.Org.coords[1]=e[i+1],t>2?n.Org.coords[2]=e[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(t,e,n,i,s,o){if(t===void 0&&(t=mt.ODD),e===void 0&&(e=sn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),B5.computeInterior(this,o);var a=this.mesh;return e===sn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===sn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,n,i),!0},r}();function Zi(r){var t=r.windingRule,e=t===void 0?mt.ODD:t,n=r.elementType,i=n===void 0?sn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,d=r.contours,h=d===void 0?[]:d,f=r.strict,m=f===void 0?!0:f,p=r.debug,g=p===void 0?!1:p;if(!h&&m)throw new Error("Contours can't be empty");if(!!h){var y=new F5;r.edgeCreateCallback&&(y.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(y.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,i,o,l,c,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var hae=mt.ODD,fae=mt.NONZERO,pae=mt.POSITIVE,mae=mt.NEGATIVE,gae=mt.ABS_GEQ_TWO,yae=sn.POLYGONS,vae=sn.CONNECTED_POLYGONS,xae=sn.BOUNDARY_CONTOURS;var Ug=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*Ug.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let n=t*Ug.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let u=new Float32Array(i,o*s,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=e,n}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},df=Ug;df.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var hf={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Fb={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Ub={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},Bb=(r,t)=>([e,n])=>(n<e&&(n+=t),(r>=e?r:r+t)<=n),Uu=class extends Me{constructor(e,n,i=0,s=12,o=3,a=mt.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(M=>{let b=M.extractShapePointsToFlatArray([],s),E=[];for(let T=b.length-1;T>=1;T-=2){let P=b[T-1],D=b[T-0];E.push(P,D)}return E}),c;try{c=Zi({windingRule:a,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=hf}let d;try{d=Zi({windingRule:mt.ODD,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=Fb}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let M=0;M<d.elements.length;M++){let b=d.elements[M],E=M%2===0?c.vertexCount:0;c.elements.push(b+E)}for(let M=0;M<d.vertexIndices.length;M++){let b=d.vertexIndices[M],E=c.vertexCount;c.vertexIndices.push(b+E)}for(let M=0;M<d.vertices.length;M++){let b=d.vertices[M];c.vertices.push(b)}}let f=1/0,m=-1/0,p=1/0,g=-1/0;for(let M=0,b=c.vertexCount;M<b;M++){let E=M*2,T=c.vertices[E+0],P=c.vertices[E+1];T<f&&(f=T),T>m&&(m=T),P<p&&(p=P),P>g&&(g=P)}this._minX=f,this._minY=p,this._width=m-f,this._height=g-p,this._buffer=new df(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let M=c.elementCount-1;M>=0;M--){let b=M>=h,E=M*2,T=c.elements[E+0],P=c.elements[E+1],D=T+P,C={start:T,count:P,normals:[],continuous:[],concave:[]},O=T,B=D-1,V=T+1,Y=this._shape.roundedCurves.length;do{let X=O-T,L=c.vertices[B*2+0],U=c.vertices[B*2+1],G=c.vertices[O*2+0],H=c.vertices[O*2+1],z=c.vertices[V*2+0],re=c.vertices[V*2+1],K=G-L,Z=H-U,k=Math.sqrt(K*K+Z*Z);K/=k,Z/=k;let he=G-z,fe=H-re,ce=Math.sqrt(he*he+fe*fe);he/=ce,fe/=ce,C.normals[X*2+0]=-fe,C.normals[X*2+1]=he,C.concave[X]=K*fe-Z*he>0;let ye=c.vertexIndices[O];if(Array.isArray(ye))C.continuous[X]=!1;else{let[Se,ve]=this._shape.getCurveIndexFromVertexId(ye-1,!0);if(ve>0&&ve<1)C.continuous[X]=!0;else{let Ee=ve===1?Se+1:Se-1;Ee=(Ee+Y)%Y;let Te=ve===1?0:1,we=this._shape.roundedCurves[Se].getTangent(ve),Ge=this._shape.roundedCurves[Ee].getTangent(Te);C.continuous[X]=we.dot(Ge)>.95}}b&&(C.normals[X*2+0]*=-1,C.normals[X*2+1]*=-1),[B,O,V]=[O,V,V+1],V>=D&&(V-=P)}while(V!==T+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(T*2,D*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((X,L)=>[L,L]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(T*2,D*2)});for(let X=1;X<=this._bevelSegments;X++){let L=X/this._bevelSegments*Math.PI/2,U=(1-Math.cos(L))*this._bevelSize,G=[],H=[],z=[],re=[],K=0;for(let k=0;k<P;k++){let he=k*2,fe=(k-1+P)%P*2,ce=c.vertices[C.start*2+he+0],ye=c.vertices[C.start*2+he+1],Se=-C.normals[fe+0]*U,ve=-C.normals[fe+1]*U,Ee=-C.normals[he+0]*U,Te=-C.normals[he+1]*U;if(C.concave[k]||!C.concave[k]&&b){let we=Math.atan2(ve,Se),Ge=Math.atan2(Te,Ee);Ge>we&&(Ge-=Math.PI*2);let gt=Ge-we;if(C.continuous[k]||b){let R=we+gt/2,I=Math.cos(R)*U,ee=Math.sin(R)*U;G[2*K+0]=ce+I*(b?-1:1),G[2*K+1]=ye+ee*(b?-1:1),re[K]=k,K++}else{let R=Math.max(1,Math.floor(s/4*Math.abs(gt)/Math.PI));for(let I=0;I<=R;I++){let ee=we+gt*(I/R),me=Math.cos(ee)*U,xe=Math.sin(ee)*U;G[2*K+0]=ce+me,G[2*K+1]=ye+xe,re[K]=k,K++}}}else G[2*K+0]=ce+Se,G[2*K+1]=ye+ve,re[K]=k,H[k]=K,K++,G[2*K+0]=ce,G[2*K+1]=ye,re[K]=k,K++,G[2*K+0]=ce+Ee,G[2*K+1]=ye+Te,re[K]=k,z[k]=K,K++}let Z=Zi({windingRule:mt.POSITIVE,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[G],edgeCreateCallback:k=>{let fe=k.Org.idx,ce=re[fe],ye=re[(fe+1)%re.length];k.idx=[ce,ye],k.Sym.idx=[ye,ce]},vertexIdCallback:k=>{let he=k.Lprev.idx;return[he?he[1]:0,k.idx?k.idx[0]:0]}});if(!Z)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!Z.vertexCount)break;for(let k=0;k<Z.vertexIndices.length;k++){let[he,fe]=Z.vertexIndices[k];if(he===fe)continue;let ce=fe;fe<he&&(ce+=P);for(let ye=he;ye<ce;ye++){let Se=ye%P,ve=(ye+1)%P;if(!C.continuous[Se]||!C.continuous[ve]){Z.vertexIndices[k]=[he,Se],Z.vertexIndices.splice(k+1,0,[ve,fe]),Z.vertices.splice((k+1)*2,0,Z.vertices[k*2],Z.vertices[k*2+1]);break}}}W.push({bevelI:X,angle:L,size:U,boundary:Z,reverseMap:re,insetPoints:G})}let q=(X,L,U)=>{let G=0,H=X.boundary.vertexIndices.length;for(;G<H&&U(X.boundary.vertexIndices[L]);)L=(L+1)%H,G++;return G},j=y.length;for(let X=1;X<W.length;X++){let L=W[X-1],U=W[X],G=L.boundary.vertexIndices.length,H=U.boundary.vertexIndices.length;if(!G||!H)break;let z=C.concave.length,re=0,K=Bb(re,P);for(;!L.boundary.vertexIndices.filter(K).length||!U.boundary.vertexIndices.filter(K).length;)re++,K=Bb(re,P);let Z=L.boundary.vertexIndices.findIndex(K),k=U.boundary.vertexIndices.findIndex(K);do Z=(Z+1)%G;while(K(L.boundary.vertexIndices[Z]));do k=(k+1)%H;while(K(U.boundary.vertexIndices[k]));re=(re+1)%P;let he=re,fe=this._buildBevelVert(C,L,(Z-1+G)%G),ce=this._buildBevelVert(C,U,(k-1+H)%H),ye=fe,Se=ce,ve,Ee,Te=!1;do{K=Bb(re,P);let we=q(L,Z,K),Ge=q(U,k,K),gt=Te;if(Te=!1,we&&!Ge){for(let R=0;R<we;R++)ve=this._buildBevelVert(C,L,(Z+R)%G,R/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve;Te=!0}else if(!we&&Ge)for(let R=0;R<Ge;R++)Ee=this._buildBevelVert(C,U,(k+R)%H,R/(Ge-1)),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,Se.bottomN,Ee.bottomP),Se=Ee;else if(we&&Ge)if(ve=this._buildBevelVert(C,L,Z,0),Ee=this._buildBevelVert(C,U,k,0),gt?(y.push(ye.topN,Ee.topP,Se.topN),y.push(ye.topN,ve.topP,Ee.topP),y.push(Ee.bottomP,ye.bottomN,Se.bottomN),y.push(Ee.bottomP,ve.bottomP,ye.bottomN)):(y.push(Se.topN,ye.topN,ve.topP),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP)),ye=ve,Se=Ee,we===Ge)for(let R=1;R<we;R++)ve=this._buildBevelVert(C,L,(Z+R)%G,R/(we-1)),Ee=this._buildBevelVert(C,U,(k+R)%H,R/(Ge-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),ye=ve,Se=Ee;else if(we>Ge){let R=we/Ge,I=0;for(let ee=1;ee<we;ee++)ve=this._buildBevelVert(C,L,(Z+ee)%G,ee/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve,ee>(I+1)*R&&(I++,Ee=this._buildBevelVert(C,U,(k+I)%H,I/(Ge-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee)}else{let R=Ge/we,I=0;for(let ee=1;ee<Ge;ee++)Ee=this._buildBevelVert(C,U,(k+ee)%H,ee/(Ge-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee,ee>(I+1)*R&&(I++,ve=this._buildBevelVert(C,L,(Z+I)%G,I/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve)}Z=(Z+we)%G,k=(k+Ge)%H,re=(re+1)%z}while(re!==he)}if(this._depth>this._bevel*2&&this._buildWall(W,C,y),b){let X=[];for(let L=y.length-1;L>=j+2;L-=3){let U=y[L-2],G=y[L-1],H=y[L-0];X.push(H,G,U)}y.splice(j,y.length-j,...X)}if(b){let X=[];for(let L=W[W.length-1].boundary.vertices.length-1;L>=1;L-=2){let U=W[W.length-1].boundary.vertices[L-1],G=W[W.length-1].boundary.vertices[L-0];X.push(U,G)}v.push(X)}if(!b){let X=W[W.length-1],L;try{L=Zi({windingRule:W.length>1?mt.POSITIVE:mt.ODD,elementType:sn.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,...v]})}catch{L=Ub}if(!L)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let U=0;U<L.elementCount*3;U+=3){let G=this._buildSurfaceVert(L,L.elements[U+0]),H=this._buildSurfaceVert(L,L.elements[U+1]),z=this._buildSurfaceVert(L,L.elements[U+2]);y.push(G.top,H.top,z.top),y.push(z.bottom,H.bottom,G.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Be(Uint32Array.from(y),1),w=new Be(this._buffer.positions,3),S=new Be(this._buffer.normals,3),_=new Be(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,_.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",_),this.setIndex(x)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=e.vertices[n*2+0],o=e.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=l,this.vertexCache[i]=h,h}_buildBevelVert(e,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=e.continuous[c]&&e.continuous[u]):(u=a,c=(u-1+e.count)%e.count,h=e.concave[u]&&n.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=u*2,y=c*2,v=n.boundary.vertices[p+0],x=n.boundary.vertices[p+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,_=(x-this._minY)/this._height,M=e.normals[g+0],b=e.normals[g+1],E=e.normals[y+0],T=e.normals[y+1];if(h){let B=E-M,V=T-b;M=M+B*(1-s),b=b+V*(1-s);let Y=Math.sqrt(M*M+b*b);M/=Y,b/=Y}let P=this._buffer.get(d?2:4),D=P*3,C=P*2,O={i,fi:u,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1};return this._buffer.positions[D+0]=v,this._buffer.positions[D+1]=x,this._buffer.positions[D+2]=this._depth-w,this._buffer.normals[D+0]=M*f,this._buffer.normals[D+1]=b*f,this._buffer.normals[D+2]=m,this._buffer.uvs[C+0]=S,this._buffer.uvs[C+1]=_,this._buffer.positions[D+3]=v,this._buffer.positions[D+4]=x,this._buffer.positions[D+5]=w,this._buffer.normals[D+3]=M*f,this._buffer.normals[D+4]=b*f,this._buffer.normals[D+5]=-m,this._buffer.uvs[C+2]=_,this._buffer.uvs[C+3]=S,d||(P+=2,D+=6,C+=4,O.topP=P+0,O.bottomP=P+1,this._buffer.positions[D+0]=v,this._buffer.positions[D+1]=x,this._buffer.positions[D+2]=this._depth-w,this._buffer.normals[D+0]=E*f,this._buffer.normals[D+1]=T*f,this._buffer.normals[D+2]=m,this._buffer.uvs[C+0]=S,this._buffer.uvs[C+1]=_,this._buffer.positions[D+3]=v,this._buffer.positions[D+4]=x,this._buffer.positions[D+5]=w,this._buffer.normals[D+3]=E*f,this._buffer.normals[D+4]=T*f,this._buffer.normals[D+5]=-m,this._buffer.uvs[C+2]=_,this._buffer.uvs[C+3]=S),this.vertexCache[o]=O,O}clone(){let e=new Uu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=po(this.userData),e}};var ku=class extends Me{constructor(e,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=mt.ODD;this.elementType=sn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:mt.ODD,elementType:sn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=Zi({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=hf}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Be(new Float32Array(h*3),3),this._normalAttribute=new Be(new Float32Array(h*3),3),this._uvAttribute=new Be(new Float32Array(h*2),2),this._indexAttribute=new Be(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,y=-1/0;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1];M<m&&(m=M),M>p&&(p=M),b<g&&(g=b),b>y&&(y=b)}let v=p-m,x=y-g;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1],E=(M-m)/v,T=(b-g)/x;this._positionAttribute.setXYZ(w,M,b,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,E,T)}for(let w=0,S=f;w<S;w++){let _=w*3,M=a.elements[_+0],b=a.elements[_+1],E=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,b),this._indexAttribute.setX(_+2,E)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new ku(this._shape,this._curveSegments);return e.userData=po(this.userData),e}};var zu=class extends Uu{constructor(e,n,i=0,s=12,o=3,a=mt.ODD){super(e,n,i,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new zu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=po(this.userData),e}};var Xr=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:mt.ODD},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=r.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Mt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new Mt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update());let l=o??new Mt(n,i);return{parameters:Object.assign(e,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return t<=0?a=new ku(r.shape,i,{windingRule:o}):a=new zu(r.shape,t,e,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var kC=Math.PI*2,Vu=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=t*.5,d=e*.5,h=U5(u,c,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Xr.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function U5(r,t,e,n,i,s){if(n>=kC)return i>30||i%4===0?(z5(r,t,e,s),Math.round(i/4)):UC(r,n,i,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=RC({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?k5(r,o.x,o.y,u,i,t,e,s):UC(r,n,i,t,e,s)}function k5(r,t,e,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(Gu(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=r.points[u],f=Gu(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),r.addPoint(f)}return a>0?zC(r,s,o,a):r.addPoint(Gu(0,0)),l}function UC(r,t,e,n,i,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*i;r.addPoint(Gu(u,c))}return t<kC?s>0?zC(r,n,i,s):r.addPoint(Gu(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&GC(r,n,i,s)),1}function z5(r,t,e,n=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;r.addPoint(kg(i-t,s,i-t,s-l,i-t,s+l)),r.addPoint(kg(i,s+e,i-a,s+e,i+a,s+e)),r.addPoint(kg(i+t,s,i+t,s+l,i+t,s-l)),r.addPoint(kg(i,s-e,i+a,s-e,i-a,s-e)),n>0&&GC(r,t,e,n)}function Gu(r,t){return new Ki(He.generateUUID(),new F(r,t))}function kg(r,t,e,n,i,s){let o=Gu(r,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(i,s),o}function zC(r,t,e,n){VC(r,t,e,n).forEach(s=>r.addPoint(s))}function GC(r,t,e,n){let i=VC(r,t,e,n),s=new Mt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function VC(r,t,e,n){let i=n*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new F(i/t,s/e),a=r.points.map(l=>{let u=l.clone();return u.uuid=He.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var HC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(r){let{width:t,height:e,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=r.parameters,h=new ff(!1,t,e,n,i,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...r,type:"HelixGeometry"}})}},kb=new vs([0,0,0],1),ff=class extends Me{constructor(t=!0,e=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let m=()=>new A,p=new A,g=m(),y=m(),v=m(),x,w,S,_,M,b,E,T,P=m(),D=m(),C=m(),O=m(),B=m(),V=m(),Y=m(),W=m(),q=n-2*l+.001,j=q/o,X=Math.ceil(a*o),L=X+1,U=q/X,G=-q/2,H=c+1,z=2*Math.PI/c,re=Math.PI/2/h,K=.01,Z=Math.min((1-d/100)*l,l-K),k=l-Z,he=0,fe=2,ce=h*fe+fe,ye=H*ce/fe,Se=ye+H*L,ve=H*(L+ce),[Ee,Te,we]=[3,3,2].map(Re=>Array(ve*Re).fill(0)),Ge=[],gt=s-l;function R(Re,De){let Ue=Math.PI/2;b=De*U,T=2*Math.PI*(b%j)/j+Ue,b+=G,E=Math.sin(T)*gt,M=Math.cos(T)*gt,t?Re.set(M,E,b):Re.set(M,b,E)}R(p,-1e-10),R(g,0),P.copy(p),R(p,1);let I=p.distanceTo(g),ee=f?0:k+Z,me=I*X+2*ee,xe=Z,Ce=me-ee;for(let Re=0;Re<=X;Re++){R(y,Re),W.subVectors(y,P).normalize(),P.copy(y),V.copy(y).setComponent(+t+1,0).normalize(),Y.crossVectors(W,V).normalize();let De=Re===0,Ue=Re===X,Ye=De?3*Math.PI/2:re,yt=De?xe:Ce,zt=De?H:Se,En=De?0:ve-H,Q=W.clone().multiplyScalar(De?-k:k).add(y),se=W.clone().multiplyScalar(De?-1:1).normalize();for(let ge=0;ge<H;ge++){let Le=ge*z;if(D.addVectors(p.copy(V).multiplyScalar(l*Math.cos(Le)),g.copy(Y).multiplyScalar(l*Math.sin(Le))),C.copy(D).normalize(),De||Ue){f||(he=En+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=Q.getComponent(Oe),Te[he*3+Oe]=se.getComponent(Oe)}),we[he*2]=+Ue,we[he*2+1]=ge/c),g.copy(C).multiplyScalar(Z),v.addVectors(y,g);for(let Oe=0;Oe<h;Oe++){let vt=Oe*re+Ye;O.addVectors(p.copy(W).multiplyScalar(k*Math.sin(vt)),g.copy(C).multiplyScalar(k*Math.cos(vt))),B.copy(O).normalize(),g.addVectors(v,O),O.normalize(),he=zt+Oe*H+ge,[0,1,2].forEach(pn=>{Ee[he*3+pn]=g.getComponent(pn),Te[he*3+pn]=B.getComponent(pn)});let Tn=+De+Math.sin(vt);we[he*2]=(yt+k*Tn)/me,we[he*2+1]=ge/c}}g.addVectors(y,D),he=ye+Re*H+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=g.getComponent(Oe),Te[he*3+Oe]=C.getComponent(Oe)}),we[he*2]=(ee+Re*I)/me,we[he*2+1]=ge/c}}let Ve=L+2*h+fe,Pe=1,[de,Xe]=[+f,Ve-1];for(let Re=de;Re<=Xe-1;Re++){let De=f&&Re===Xe-1;for(let Ue=0;Ue<H-1;Ue++)x=Re*H+Ue,w=x+1,S=(De?Ue:x)+H,_=(De?Ue+1:w)+H,Re===0?Ge.push(w,_,S):Re===Ve-2?Ge.push(x,w,S):Ge.push(x,w,S,w,_,S)}this.setIndex(Ge),this.setAttribute("position",new Ae(Ee,3)),this.setAttribute("normal",new Ae(Te,3)),this.setAttribute("uv",new Ae(we,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,i=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let h=0;h<t.radialSegments;h++)s=c*n+h,o=s+1,a=(d?h:s)+n,l=(d?h+1:o)+n,i[u++]=s,i[u++]=o,i[u++]=a,i[u++]=o,i[u++]=l,i[u++]=a;return i.length=u,kb.array=i,kb.count=i.length,kb}};var WC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new pf(t*.5,s,o):new yc(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},pf=class extends ma{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new pf(t.radius,t.corner,t.cornerSides)}};var jC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{points:t,segments:e,verticalSegments:n}=r.parameters,i=new ao;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new hc(i.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var Ps=new ae,zb=new pt,zg=new A,ya=class extends Ht{constructor(){super(),this.uuid=He.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new Kt().getNormalMatrix(t);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(t);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Ps.makeRotationX(t),this.applyMatrix4(Ps),this}rotateY(t){return Ps.makeRotationY(t),this.applyMatrix4(Ps),this}rotateZ(t){return Ps.makeRotationZ(t),this.applyMatrix4(Ps),this}translate(t,e,n){return Ps.makeTranslation(t,e,n),this.applyMatrix4(Ps),this}scale(t,e,n){return Ps.makeScale(t,e,n),this.applyMatrix4(Ps),this}lookAt(t){return zb.lookAt(t),zb.updateMatrix(),this.applyMatrix4(zb.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,i=t.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Ne().fromBufferAttribute(a,h));function c(h,f,m,p){let g=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[m].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],v=new Hu(h,f,m,y,g,p);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new F().fromBufferAttribute(l,h),new F().fromBufferAttribute(l,f),new F().fromBufferAttribute(l,m)]),u!==void 0&&e.faceVertexUvs[1].push([new F().fromBufferAttribute(u,h),new F().fromBufferAttribute(u,f),new F().fromBufferAttribute(u,m)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],m=f.start,p=f.count;for(let g=m,y=m+p;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zg).negate(),this.translate(zg.x,zg.y,zg.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,i=new ae;return i.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)e[n]=new A;if(t){let n=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)e[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let t=new ya;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let i=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _t),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rn),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let i,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(i=new Kt().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let m=u[h],p,g,y=m.vertexNormals,v=m.vertexColors,x=new Hu(m.a+s,m.b+s,m.c+s);x.normal.copy(m.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let w=0,S=y.length;w<S;w++)p=y[w].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),x.vertexNormals.push(p);x.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)g=v[w],x.vertexColors.push(g.clone());x.materialIndex=m.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++)v.push(y[x].clone());this.faceVertexUvs[h].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},n=[],i=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let i=t[e];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(i[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(t[p]=m[p]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];e.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,y=!1,v=this.faceVertexUvs[0][m]!==void 0,x=p.normal.length()>0,w=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,M=0;if(M=c(M,0,0),M=c(M,1,g),M=c(M,2,y),M=c(M,3,v),M=c(M,4,x),M=c(M,5,w),M=c(M,6,S),M=c(M,7,_),n.push(M),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let b=this.faceVertexUvs[0][m];n.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&n.push(d(p.normal)),w){let b=p.vertexNormals;n.push(d(b[0]),d(b[1]),d(b[2]))}if(S&&n.push(h(p.color)),_){let b=p.vertexColors;n.push(h(b[0]),h(b[1]),h(b[2]))}}function c(m,p,g){return g?m|1<<p:m&~(1<<p)}function d(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function h(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(m.x,m.y)),u[p]}return t.data={},t.data.vertices=e,t.data.normals=i,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new ya().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let i=t.faces;for(let h=0,f=i.length;h<f;h++)this.faces.push(i[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++){let S=y[x];v.push(S.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let m={};if(m.name=s[h].name,s[h].vertices!==void 0){m.vertices=[];for(let p=0,g=s[h].vertices.length;p<g;p++)m.vertices.push(s[h].vertices[p].clone())}if(s[h].normals!==void 0){m.normals=[];for(let p=0,g=s[h].normals.length;p<g;p++)m.normals.push(s[h].normals[p].clone())}this.morphTargets.push(m)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let m={};if(o[h].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[h].vertexNormals.length;p<g;p++){let y=o[h].vertexNormals[p],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),m.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[h].faceNormals.length;p<g;p++)m.faceNormals.push(o[h].faceNormals[p].clone())}this.morphNormals.push(m)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Gb().fromGeometry(this),e=new Me,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Gg.call(new Be(n,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",Gg.call(new Be(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",qC.call(new Be(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",XC.call(new Be(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",XC.call(new Be(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new Ae(u.data.length*3,3);c.name=u.name,s.push(Gg.call(c,u.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new Ae(t.skinIndices.length*4,4);e.setAttribute("skinIndex",YC.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Ae(t.skinWeights.length*4,4);e.setAttribute("skinWeight",YC.call(i,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Me,n=t.geometry;if(t.isPoints||t.isLine){let i=new Ae(n.vertices.length*3,3),s=new Ae(n.colors.length*3,3);if(e.setAttribute("position",Gg.call(i,n.vertices)),e.setAttribute("color",qC.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Ae(n.lineDistances.length,1);e.setAttribute("lineDistance",G5.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};ya.prototype.isGeometry=!0;var Gb=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],n,i,s,o=t.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,e.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,i=t.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,m=t.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][y];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new F,new F,new F))}if(o===!0){let S=i[1][y];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new F,new F,new F))}for(let S=0;S<l;S++){let _=a[S].vertices;u[S].data.push(_[v.a],_[v.b],_[v.c])}for(let S=0;S<d;S++){let _=c[S].vertexNormals[y];h[S].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Hu=class{constructor(t,e,n,i,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Ne,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function G5(r){return this.array.set(r),this}function qC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Ne),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function XC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new F),t[e++]=s.x,t[e++]=s.y}return this}function Gg(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function YC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Ze),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var V5=["a","b","c"];function H5(r,t){switch(t){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function Vb(r,t,e){let n=Math.min(r,t),i=Math.max(r,t),s=n+"_"+i;return e.get(s)}function Hb(r,t,e,n,i,s){let o=Math.min(r,t),a=Math.max(r,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[t].edges.push(u)}function W5(r,t,e,n){let i,s,o;for(i=0,s=r.length;i<s;i++)e[i]={edges:[]};for(i=0,s=t.length;i<s;i++)o=t[i],Hb(o.a,o.b,r,n,o,e),Hb(o.b,o.c,r,n,o,e),Hb(o.c,o.a,r,n,o,e)}function Vg(r,t,e,n,i){r.push(new Hu(t,e,n,void 0,void 0,i))}function Wu(r,t){return Math.abs(t-r)/2+Math.min(r,t)}function Hg(r,t,e,n){r.push([t.clone(),e.clone(),n.clone()])}var Wg=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Me?t=new ya().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,i,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;W5(l,u,h,f);let m=[],p,g,y,v,x,w,S;for(let K of Array.from(f.keys())){for(g=f.get(K),y=new A,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[H5(v,V5[a])],!(p!==g.a&&p!==g.b));a++);p&&e.add(p)}e.multiplyScalar(w),y.add(e),g.newEdge=m.length,m.push(y)}let _,M,b,E,T,P,D,C=[];for(i=0,s=l.length;i<s;i++){for(P=l[i],T=h[i].edges,n=T.length,n==3?_=3/16:n>3&&(_=3/(8*n)),M=1-n*Number(_),b=_,n<=2&&(n==2?(M=3/4,b=1/8):n==1||n==0),D=P.clone().multiplyScalar(M),e.set(0,0,0),o=0;o<n;o++)E=T[o],p=E.a!==P?E.a:E.b,e.add(p);e.multiplyScalar(Number(b)),D.add(e),C.push(D)}let O=C.concat(m),B=C.length,V,Y,W,q=[],j=[],X,L,U,G,H=new F,z=new F,re=new F;for(i=0,s=u.length;i<s;i++)v=u[i],V=Number(Vb(v.a,v.b,f).newEdge)+B,Y=Number(Vb(v.b,v.c,f).newEdge)+B,W=Number(Vb(v.c,v.a,f).newEdge)+B,Vg(q,V,Y,W,v.materialIndex),Vg(q,v.a,V,W,v.materialIndex),Vg(q,v.b,Y,V,v.materialIndex),Vg(q,v.c,W,Y,v.materialIndex),d&&(X=c[i],L=X[0],U=X[1],G=X[2],H.set(Wu(L.x,U.x),Wu(L.y,U.y)),z.set(Wu(U.x,G.x),Wu(U.y,G.y)),re.set(Wu(L.x,G.x),Wu(L.y,G.y)),Hg(j,H,z,re),Hg(j,L,H,re),Hg(j,U,z,H),Hg(j,G,re,z));t.vertices=O,t.faces=q,d&&(t.faceVertexUvs[0]=j)}};var qn=new A,QC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=r.geometry??t?.geometry??new Me().copy(new er(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(qn),n={width:qn.x,height:qn.y,depth:qn.z,subdivisions:0}):n=t.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(r){let{width:t,height:e,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Me().copy(new er(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(qn)):qn.set(o.width,o.height,o.depth),(t!==qn.x||e!==qn.y||n!==qn.z)&&s.scale(qn.x===0?1:t/qn.x,qn.y===0?1:e/qn.y,qn.z===0?1:n/qn.z);let a=s.originalGeometry;try{i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Wg(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,t,e){new Sc(e).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(qn);let o=100/qn.x;Object.assign(s.parameters,{width:100,height:qn.y*o,depth:qn.z*o}),t(this.build(s))})}};var jg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,y=d+Math.sin(g)*u,v=h+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Xr.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var KC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new jb(t*.5,e,i,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function mf(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function Wb(r,t,e,n,i,s){let o=t.clone().sub(r),a=e.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function j5(r,t,e){let n=r.clone().sub(t),i=e.clone().sub(t);return n.projectOnVector(i),n.add(t)}var jb=class extends Me{constructor(t=.5,e=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,m=Math.PI/n,p=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),w=new A(0,f,0),S=new F(t,-f),_=new F(p,-f),M=new F(0,w.y).sub(_),b=new F(0,w.y).sub(S),E=new F(M.y,-M.x).normalize(),T=new F(b.y,-b.x).normalize(),D=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,D);let C;{let j=new A(E.x,E.y,0),X=new A(Math.cos(g)*j.x,j.y,Math.sin(g)*j.x);C=j.angleTo(X)}let O=o/Math.tan((Math.PI-M.angle())/2),B=o/Math.tan((Math.PI-C)/2),V=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let j=h++,X=[],L=S.clone(),U=O/Math.cos(Math.PI/n);L.x-=U;for(let G=0;G<n;G++){let H=G/n*Math.PI*2+m,z=new F(Math.sin(H),Math.cos(H));mf(L,z,V),u.push(V.x,V.y,V.z),c.push(0,-1,0),d.push(0,0),X.push(h++)}for(let G=0;G<X.length;G++)l.push(X[G],j,X[(G+1)%X.length])}let Y=[];{let j=new A,X=new A,L=new A,U=new A,G=new A,H=new A;for(let z=0;z<n;z++){let re=z/n*Math.PI*2+m,K=(z+.5)/n*Math.PI*2+m,Z=(z+1)/n*Math.PI*2+m,k=new F(Math.sin(re),Math.cos(re)),he=new F(Math.sin(K),Math.cos(K)),fe=new F(Math.sin(Z),Math.cos(Z));mf(S,k,X),mf(S,fe,L),mf(E,he,j),Wb(w,X,L,B,B,U),u.push(U.x,U.y,U.z),Wb(X,w,L,B,O,G),u.push(G.x,G.y,G.z),Wb(L,X,w,O,B,H),u.push(H.x,H.y,H.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),d.push(0,0),d.push(0,0),d.push(0,0);let ce=h++,ye=h++,Se=h++;if(l.push(ce,ye,Se),o>0){{let Te=X.clone().add(L).multiplyScalar(.5),we=w.clone().sub(Te).normalize(),gt=x.clone().sub(Te).normalize().add(we).normalize().multiplyScalar(-1),R=H.clone().sub(G);W(Te,R,gt,M.angle())}let ve,Ee;{let Te=new A;mf(T,fe,Te);let we=H.clone().add(U).multiplyScalar(.5);we=j5(we,L,w);let Ge=H.clone().sub(U);[ve,Ee]=W(we,Ge,Te,C,U.y)}{let Te=ve,we=Te.clone().setY(0).normalize(),Ge=new A(0,-1,0),gt=we.clone().cross(Ge);q(Te,we,Ge,gt)}Y.concat(Ee);{let Te=M.angle(),we=Math.PI-Te,Ge=w.clone();Ge.y-=o/Math.sin(Te-Math.PI/2);let gt=new A,R=[];for(let ee=0;ee<a;ee++){let me=[],xe=Math.PI/2-we*ee/a,Ce=Math.cos(xe),Ve=Math.sin(xe),Pe=K;for(let de=0;de<=ee;de++){let Xe=Math.cos(Pe),Re=Math.sin(Pe);j.x=Ce*Re,j.y=Ve,j.z=Ce*Xe,gt.copy(Ge).addScaledVector(j,o),u.push(gt.x,gt.y,gt.z),c.push(j.x,j.y,j.z),d.push(0,0),me.push(h++),Pe+=Math.PI*2/ee/n}R.push(me)}Ee.reverse(),R.push(Ee);let I=R.length-1;for(let ee=0;ee<I;ee++){let me=R[ee],xe=R[ee+1],Ce=me.length-1;l.push(xe[1],me[0],xe[0]);for(let Ve=1;Ve<=Ce;Ve++)l.push(me[Ve],me[Ve-1],xe[Ve]),l.push(xe[Ve+1],me[Ve],xe[Ve])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(d,2));function W(j,X,L,U,G){let H=-U/2,z=(Math.PI-U)/2,re=X.clone().normalize().cross(L);j.addScaledVector(L,-o/Math.sin(z));let K=new A,Z=new A,k=1,he=h,fe=[];for(let ce=0;ce<=a;ce++){let ye=H+ce/a*U;Z.set(0,0,0),Z.addScaledVector(re,Math.sin(ye)),Z.addScaledVector(L,Math.cos(ye));for(let Se=0;Se<=k;Se++){let ve=Se/k-.5;if(K.copy(j),K.addScaledVector(X,ve),K.addScaledVector(Z,o),G!=null){let Ee=Math.max(0,K.y-G);K.addScaledVector(X,-Ee/X.y)}u.push(K.x,K.y,K.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),Se===0&&fe.push(h),h++}}for(let ce=0;ce<a;ce++)for(let ye=0;ye<k;ye++){let Se=he+ye+(k+1)*ce,ve=Se+(k+1),Ee=ve+1,Te=Se+1;l.push(Se,ve,Te),l.push(ve,Ee,Te)}return[j.clone().addScaledVector(X,.5),fe]}function q(j,X,L,U){let G=Math.PI/2,H=b.angle()-G,z=[],re=new A,K=new A;for(let k=0;k<=a;k++){let he=[],fe=k/a;for(let ce=0;ce<=k;ce++){let Se=((k?ce/k:0)-.5)*v,ve=Math.cos(Se),Ee=Math.sin(Se),Te=Math.atan(Math.tan(H)*ve),we=(G+Te)*fe,Ge=Math.cos(we),gt=Math.sin(we);re.set(0,0,0),re.addScaledVector(X,gt*ve),re.addScaledVector(L,Ge),re.addScaledVector(U,gt*Ee),K.copy(j).addScaledVector(re,o),u.push(K.x,K.y,K.z),c.push(re.x,re.y,re.z),d.push(0,0),he.push(h++)}z.push(he)}let Z=z.length-1;for(let k=0;k<Z;k++){let he=z[k],fe=z[k+1],ce=he.length-1;l.push(he[0],fe[1],fe[0]);for(let ye=1;ye<=ce;ye++)l.push(he[ye-1],he[ye],fe[ye]),l.push(he[ye],fe[ye+1],fe[ye])}}}};var qg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(r){let t=r.shape,{width:e,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(w,S,_){return S>e&&_>n?Math.min(w*e/S,w*n/_):S>e?w*e/S:_>n?w*n/_:w}let f=[];f[0]=i[0]===0?0:h(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:h(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:h(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:h(i[3],i[3]+i[0],i[3]+i[2]);let m=c.x,p=d.x,g=d.y,y=c.y;t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let v=!0;for(let w=0,S=t.points.length;w<S;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Xr.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...r,type:"RectangleGeometry"}})}};var ZC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t=100,height:e=t,depth:n=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new el(.5*t,i,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var JC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(r){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new oo(t,e,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var $C=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new qb(t,e,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},qb=class extends Me{constructor(t=1,e=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let d=[],h=Math.PI/2,f=(K=0,Z=0,k=0)=>new A(K,Z,k),m=f(),p=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,w=+y,[S,_,M]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(K,Z=!1)=>Math.sin(K-Math.PI/(1+ +Z)),E=(K,Z=!1)=>Math.cos(K-Math.PI/(1+ +Z));M.y=Math.sin(i)*e-g;let T=Math.cos(i)*e-v,P=S.z-c;i<=h?(M.z=Math.min(T,P),M.z==P&&(M.y-=(T-P)/Math.tan(h-i))):_.z=Math.min(_.z-T-v,S.z-c),m.subVectors(S,_),p.subVectors(M,_);let D=Math.min(m.length(),p.length())*s/100,C=D*Math.tan(i/2),O=D/Math.cos(i/2),B=m.clone().normalize().add(p.normalize()).setLength(O).add(_);m.set(0,b(i,!0),E(i,!0)),d.push([M,m.clone()]);let V=(Math.PI-i)/o;for(let K=0;K<=o;K++){let Z=h+i+K*V;m.set(0,Math.sin(Z)*C,Math.cos(Z)*C),m.add(B),p.set(0,b(Z),E(Z)),d.push([m.clone(),p.clone()])}d.push([S,f(0,1,0)]);let Y=Math.sin(V/2)*C*2,W=d.length-1,q=d[0][0].distanceTo(d[1][0]),j=d[W-1][0].distanceTo(d[W][0]),X=q+Y*o+j;d[0].push(1);for(let K=0;K<=o;K++)d[K+1].push(1-(q+K*Y)/X);d[W].push(0);let[L,U,G]=d[0],H,z,re;for(let K=1;K<d.length;K++)[H,z,re]=d[K],a.push(x,L.y,L.z,x,H.y,H.z,w,L.y,L.z,w,L.y,L.z,x,H.y,H.z,w,H.y,H.z),l.push(0,U.y,U.z,0,z.y,z.z,0,U.y,U.z,0,U.y,U.z,0,z.y,z.z,0,z.y,z.z),u.push(0,G,0,re,1,G,1,G,0,re,1,re),[L,U,G]=[H,z,re];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var Xg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,d=t*.5,h=e*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let w=0;w<i;w++){let S=p*w,_=f+Math.sin(S)*d,M=m+Math.cos(S)*h;c.addPoint(c.createPoint(_,M))}}else for(let w=0;w<i;w++){let S=f+Math.cos(g)*d,_=m+Math.sin(g)*h;c.addPoint(c.createPoint(S,_)),g+=p,S=f+Math.cos(g)*y,_=m+Math.sin(g)*v,w<=i,c.addPoint(c.createPoint(S,_)),g+=p}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let x=Xr.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...r,type:"StarGeometry"}})}};var eP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e}=r.parameters,n=new oo(t,e);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var tP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:i,depth:s})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=q5(t,e,n,t*.5,o,s,0,0,i,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function q5(r,t,e,n,i,s,o,a,l,u,c){return[t,e]=[e,t],o=t/2,i/=2*Math.PI,i==1&&(u=0),new ff(!0,r,t,e,n,i,s,o,a,l,u,c)}var nP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(r){let{width:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=t*.5;a!==e&&(a-=e);let l=new vc(a,e,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var rP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t=100,height:e,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=Xr.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...r,type:"TriangleGeometry"}})}};function iP(r,t){let e=2*Math.PI;return(r%e+e)%e===(t%e+e)%e}function X5(r,t,e){let n=[new A,new A,new A],i=[new A,new A,new A];return r.extractBasis(n[0],n[1],n[2]),t.extractBasis(i[0],i[1],i[2]),n.forEach((s,o)=>{let a=i[o],l=He.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ae().makeBasis(n[0],n[1],n[2])}var sP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Vu.create({parameters:Jx}).userData.shape;return{path:r.path??hu.defaultData(),parameters:Object.assign(e,{width:n,height:i,depth:s,extrusion:{...pg,...e.extrusion}}),shapeData:o}}static build(r){if(r.path.points.length>=2){let e=new Xb(r);return Object.assign(e,{userData:{...r,type:"PathGeometry"}})}else return Object.assign(new Me,{userData:{...r,type:"PathGeometry"}})}},Xb=class extends Me{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)||!iP(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:i,offset:s}=this.inputs.parameters.extrusion,o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((i+s)*o):Math.ceil(Math.min(1,i+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let D=0;D<u;D++){let C=this.inputs.path.isClosed?(D+a)%e.length:Math.min(D+a,e.length-1);c.push(e[C].clone()),d.push(n[C].clone())}let h=(D,C,O)=>{c[D]=c[D].clone().lerp(c[C],O),d[D]=X5(d[D],d[C],O)},f=0,m=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(m||s===0)&&(f=m,h(0,1,f));let p=0,g=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&g&&(p=g,h(c.length-1,c.length-2,1-p)),i===0){let D=c.length-1;c[D].copy(c[0]),d[D].copy(d[0])}this._applyPathModifiers(d,f,p);let{regions:y,infos:v,vertices:x}=this._computeShapePoints(5),w=0,S=0;v.sort((D,C)=>D.start-C.start),v.forEach(D=>{D.verticesStart=w,D.verticesCount=D.continuous.reduce((C,O,B)=>C+(B===0||!O?2:1),0),S+=D.verticesCount,w=S});let _=S*u,M,b=0;if(this._isOpenEnded()){try{M=Zi({windingRule:mt.ODD,elementType:sn.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{M=Ub}b=M.vertexCount}let E=_+2*b,T={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},P=[];v.forEach(D=>{this._extrudeRegion(D,x,d,c,T,P,this._isGeometryClosed()&&!this._isOpenEnded())}),M&&(this._closeEnd(M,_,P,T,d[0],c[0],!1),this._closeEnd(M,_+b,P,T,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Be(T.positions,3)),this.setAttribute("normal",new Be(T.normals,3)),this.setAttribute("uv",new Be(T.uvs,2)),this.setIndex(P)}_extractPathPoints(){let n=Rg(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let i=[n[0]];return n.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let n=[],i=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let g=0;g<i;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===i-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let w=y.clone().sub(v).normalize(),S=x.clone().sub(y).normalize(),_=w.clone().add(S).normalize();l.copy(_),g===0&&(_.equals(c)||_.clone().negate().equals(c))&&c.set(0,0,1);let M=c.clone().cross(_).normalize(),b=_.clone().cross(M).normalize();c.copy(b),u.copy(M),g===0&&(o.copy(b),a.copy(_));let E=new ae().makeBasis(M,b,_);n.push(E)}let d=s?a:l,h=s?o:new A(0,1,0),f=d.clone().cross(u).normalize(),m=Math.acos(h.dot(f));if(isNaN(m))return n;let p=h.clone().cross(f);d.dot(p)>0&&(m*=-1);for(let g=1;g<n.length;g++){let y=new ae().makeRotationZ(m*g/n.length);n[g].multiply(y)}return n}_applyPathModifiers(e,n,i){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new ae,d=new ae;return e.forEach((h,f)=>{let m=f===0?0:f===s-1?1:(f-n)/(s-(i===0?0:1)-(n+(1-i)));c.makeRotationZ(He.lerp(o,o+a,m));let p=He.lerp(l,u,m);d.makeScale(p,p,p),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=mt.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(p=>{let g=p.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],w=g[v-0];y.push(x,w)}return y}),a;try{a=Zi({windingRule:n,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=hf}let l;try{l=Zi({windingRule:mt.ODD,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=Fb}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let g=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let p=0;p<l.vertexIndices.length;p++){let g=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let p=0;p<l.vertices.length;p++){let g=l.vertices[p];a.vertices.push(g)}}let c=1/0,d=-1/0,h=1/0,f=-1/0;for(let p=0,g=a.vertexCount;p<g;p++){let y=p*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>d&&(d=v),x<h&&(h=x),x>f&&(f=x)}let m=[];for(let p=a.elementCount-1;p>=0;p--){let g=p>=u,y=p*2,v=a.elements[y+0],x=a.elements[y+1],w=v+x,S={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let _=v,M=w-1,b=v+1,E=i.roundedCurves.length;do{let T=_-v,P=a.vertices[M*2+0],D=a.vertices[M*2+1],C=a.vertices[_*2+0],O=a.vertices[_*2+1],B=a.vertices[b*2+0],V=a.vertices[b*2+1],Y=C-P,W=O-D,q=Math.sqrt(Y*Y+W*W);Y/=q,W/=q;let j=C-B,X=O-V,L=Math.sqrt(j*j+X*X);j/=L,X/=L,S.normals[T*2+0]=-X,S.normals[T*2+1]=j;let U=a.vertexIndices[_];if(Array.isArray(U))S.continuous[T]=!1;else{let[G,H]=i.getCurveIndexFromVertexId(U-1,!0);if(H>0&&H<1)S.continuous[T]=!0;else{let z=H===1?G+1:G-1;z=(z+E)%E;let re=H===1?0:1,K=i.roundedCurves[G].getTangent(H),Z=i.roundedCurves[z].getTangent(re);S.continuous[T]=K.dot(Z)>.95}}g&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[M,_,b]=[_,b,b+1],b>=w&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:m,vertices:a.vertices}}_insertVertex(e,n,i,s,o){let a=n*2,l=n*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,n,i,s,o,a,l){let u=new A,c=new A,d=new A,h=new A,f=new F;i.forEach((p,g)=>{let y=s[g],v=e.verticesStart*i.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let w=(e.start+x)*2;if(u.set(n[w+0],n[w+1],0),d.copy(u).applyMatrix4(p).add(y),e.continuous[x])h.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let S=x==0?(e.start+e.count-1)*2:w-2;c.set(n[S+0],n[S+1],0),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(p).normalize(),f.set(x===0?1:x/e.count,g/(i.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(i.length-1));else{let S=x===e.count-1?e.start*2:w+2;c.set(n[S+0],n[S+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(p).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let m=i.length-1;for(let p=0;p<m;p++){let g=e.verticesStart*i.length+e.verticesCount*p,y=e.verticesStart*i.length+e.verticesCount*(p+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let w=x===e.count-1?0:v+1,S=g+v,_=g+w,M=y+w,b=y+v;e.isHole?a.push(S,M,_,S,b,M):a.push(S,_,M,S,M,b),v++}}}_closeEnd(e,n,i,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),d=new A,h=new F;for(let m=0;m<u;m++){let p=2*m;d.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+m,d,c,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let p=3*m,g=f[p+0]+n,y=f[p+(l?1:2)]+n,v=f[p+(l?2:1)]+n;i.push(g,y,v)}}};function oP(){let r=new Me;return r.setAttribute("position",new Be(new Float32Array([]),3)),r.setIndex(new Be(new Uint16Array([]),1)),r}var Y5=oP().attributes,Q5=12,K5=1,ju=class extends Me{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,Y5),this.userData={parameters:e,type:"TextGeometry"};let i=n.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let i=n.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=Z5(e,n,d),{shapes:f,charWidths:m,charCoords:p}=n.generateShapes(h,e),g=i*.5,y=s*.5,v=f.map(S=>new Mt().fromShape(S));this.vectorShapes=v;let x=v.map(S=>Xr.create({shape:S,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?mt.NONZERO:mt.ODD,subdivisions:this.isLowResolution&&o>0?K5:Q5}})),w=x.length?Xi(x):oP();w.translate(-g,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,_])=>{this.setAttribute(S,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Hi(new Me,ju.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function Z5(r,t,e){e=e??r.text;let n=[""],i="";for(let s of e)i+=s,s===" "||s===`
3138
+ }`;function PB(r,t,e){let n=new yh,i=new F,s=new F,o=new Ze,a=new vh({depthPacking:J0}),l=new T0,u={},c=e.maxTextureSize,d={[si]:On,[On]:si,[Ir]:Ir},h=new ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:TB,fragmentShader:CB}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new Me;m.setAttribute("position",new Be(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new In(m,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=im,this.render=function(w,S,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let M=r.getRenderTarget(),b=r.getActiveCubeFace(),E=r.getActiveMipmapLevel(),T=r.state;T.setBlending(Dt),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let P=0,D=w.length;P<D;P++){let C=w[P],O=C.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",C,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);let B=O.getFrameExtents();if(i.multiply(B),s.copy(O.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/B.x),i.x=s.x*B.x,O.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/B.y),i.y=s.y*B.y,O.mapSize.y=s.y)),O.map===null){let Y=this.type!==ah?{minFilter:Pt,magFilter:Pt}:{};O.map=new st(i.x,i.y,Y),O.map.texture.name=C.name+".shadowMap",O.camera.updateProjectionMatrix()}r.setRenderTarget(O.map),r.clear();let V=O.getViewportCount();for(let Y=0;Y<V;Y++){let W=O.getViewport(Y);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),T.viewport(o),O.updateMatrices(C,Y),n=O.getFrustum(),x(S,_,O.camera,C,this.type)}O.isPointLightShadow!==!0&&this.type===ah&&y(O,_),O.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(M,b,E)};function y(w,S){let _=t.update(p);h.defines.VSM_SAMPLES!==w.blurSamples&&(h.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new st(i.x,i.y)),h.uniforms.shadow_pass.value=w.map.texture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(S,null,_,h,p,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(S,null,_,f,p,null)}function v(w,S,_,M,b,E){let T=null,P=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(P!==void 0)T=P;else if(T=_.isPointLight===!0?l:a,r.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let D=T.uuid,C=S.uuid,O=u[D];O===void 0&&(O={},u[D]=O);let B=O[C];B===void 0&&(B=T.clone(),O[C]=B),T=B}return T.visible=S.visible,T.wireframe=S.wireframe,E===ah?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:d[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,_.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(_.matrixWorld),T.nearDistance=M,T.farDistance=b),T}function x(w,S,_,M,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===ah)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let P=t.update(w),D=w.material;if(Array.isArray(D)){let C=P.groups;for(let O=0,B=C.length;O<B;O++){let V=C[O],Y=D[V.materialIndex];if(Y&&Y.visible){let W=v(w,Y,M,_.near,_.far,b);r.renderBufferDirect(_,null,P,W,w,V)}}}else if(D.visible){let C=v(w,D,M,_.near,_.far,b);r.renderBufferDirect(_,null,P,C,w,null)}}let T=w.children;for(let P=0,D=T.length;P<D;P++)x(T[P],S,_,M,b)}}function DB(r,t,e){let n=e.isWebGL2;function i(){let Q=!1,se=new Ze,ge=null,Le=new Ze(0,0,0,0);return{setMask:function(Oe){ge!==Oe&&!Q&&(r.colorMask(Oe,Oe,Oe,Oe),ge=Oe)},setLocked:function(Oe){Q=Oe},setClear:function(Oe,vt,Tn,pn,Oa){Oa===!0&&(Oe*=pn,vt*=pn,Tn*=pn),se.set(Oe,vt,Tn,pn),Le.equals(se)===!1&&(r.clearColor(Oe,vt,Tn,pn),Le.copy(se))},reset:function(){Q=!1,ge=null,Le.set(-1,0,0,0)}}}function s(){let Q=!1,se=null,ge=null,Le=null;return{setTest:function(Oe){Oe?re(2929):K(2929)},setMask:function(Oe){se!==Oe&&!Q&&(r.depthMask(Oe),se=Oe)},setFunc:function(Oe){if(ge!==Oe){switch(Oe){case oO:r.depthFunc(512);break;case aO:r.depthFunc(519);break;case lO:r.depthFunc(513);break;case h0:r.depthFunc(515);break;case cO:r.depthFunc(514);break;case uO:r.depthFunc(518);break;case dO:r.depthFunc(516);break;case hO:r.depthFunc(517);break;default:r.depthFunc(515)}ge=Oe}},setLocked:function(Oe){Q=Oe},setClear:function(Oe){Le!==Oe&&(r.clearDepth(Oe),Le=Oe)},reset:function(){Q=!1,se=null,ge=null,Le=null}}}function o(){let Q=!1,se=null,ge=null,Le=null,Oe=null,vt=null,Tn=null,pn=null,Oa=null;return{setTest:function(Qt){Q||(Qt?re(2960):K(2960))},setMask:function(Qt){se!==Qt&&!Q&&(r.stencilMask(Qt),se=Qt)},setFunc:function(Qt,Qs,pi){(ge!==Qt||Le!==Qs||Oe!==pi)&&(r.stencilFunc(Qt,Qs,pi),ge=Qt,Le=Qs,Oe=pi)},setOp:function(Qt,Qs,pi){(vt!==Qt||Tn!==Qs||pn!==pi)&&(r.stencilOp(Qt,Qs,pi),vt=Qt,Tn=Qs,pn=pi)},setLocked:function(Qt){Q=Qt},setClear:function(Qt){Oa!==Qt&&(r.clearStencil(Qt),Oa=Qt)},reset:function(){Q=!1,se=null,ge=null,Le=null,Oe=null,vt=null,Tn=null,pn=null,Oa=null}}}let a=new i,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,P=null,D=null,C=null,O=null,B=r.getParameter(35661),V=!1,Y=0,W=r.getParameter(7938);W.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(W)[1]),V=Y>=1):W.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),V=Y>=2);let q=null,j={},X=r.getParameter(3088),L=r.getParameter(2978),U=new Ze().fromArray(X),G=new Ze().fromArray(L);function H(Q,se,ge){let Le=new Uint8Array(4),Oe=r.createTexture();r.bindTexture(Q,Oe),r.texParameteri(Q,10241,9728),r.texParameteri(Q,10240,9728);for(let vt=0;vt<ge;vt++)r.texImage2D(se+vt,0,6408,1,1,0,6408,5121,Le);return Oe}let z={};z[3553]=H(3553,3553,1),z[34067]=H(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(h0),ve(!1),Ee(XS),re(2884),ye(Dt);function re(Q){h[Q]!==!0&&(r.enable(Q),h[Q]=!0)}function K(Q){h[Q]!==!1&&(r.disable(Q),h[Q]=!1)}function Z(Q,se){return f[Q]!==se?(r.bindFramebuffer(Q,se),f[Q]=se,n&&(Q===36009&&(f[36160]=se),Q===36160&&(f[36009]=se)),!0):!1}function k(Q,se){let ge=p,Le=!1;if(Q)if(ge=m.get(se),ge===void 0&&(ge=[],m.set(se,ge)),Q.isWebGLMultipleRenderTargets){let Oe=Q.texture;if(ge.length!==Oe.length||ge[0]!==36064){for(let vt=0,Tn=Oe.length;vt<Tn;vt++)ge[vt]=36064+vt;ge.length=Oe.length,Le=!0}}else ge[0]!==36064&&(ge[0]=36064,Le=!0);else ge[0]!==1029&&(ge[0]=1029,Le=!0);Le&&(e.isWebGL2?r.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function he(Q){return g!==Q?(r.useProgram(Q),g=Q,!0):!1}let fe={[rc]:32774,[QI]:32778,[KI]:32779};if(n)fe[ZS]=32775,fe[JS]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(fe[ZS]=Q.MIN_EXT,fe[JS]=Q.MAX_EXT)}let ce={[ZI]:0,[JI]:1,[$I]:768,[MA]:770,[sO]:776,[rO]:774,[tO]:772,[eO]:769,[EA]:771,[iO]:775,[nO]:773};function ye(Q,se,ge,Le,Oe,vt,Tn,pn){if(Q===Dt){y===!0&&(K(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Q!==YI){if(Q!==v||pn!==E){if((x!==rc||_!==rc)&&(r.blendEquation(32774),x=rc,_=rc),pn)switch(Q){case oc:r.blendFuncSeparate(1,771,1,771);break;case YS:r.blendFunc(1,1);break;case QS:r.blendFuncSeparate(0,769,0,1);break;case KS:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case oc:r.blendFuncSeparate(770,771,1,771);break;case YS:r.blendFunc(770,1);break;case QS:r.blendFuncSeparate(0,769,0,1);break;case KS:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}w=null,S=null,M=null,b=null,v=Q,E=pn}return}Oe=Oe||se,vt=vt||ge,Tn=Tn||Le,(se!==x||Oe!==_)&&(r.blendEquationSeparate(fe[se],fe[Oe]),x=se,_=Oe),(ge!==w||Le!==S||vt!==M||Tn!==b)&&(r.blendFuncSeparate(ce[ge],ce[Le],ce[vt],ce[Tn]),w=ge,S=Le,M=vt,b=Tn),v=Q,E=!1}function Se(Q,se){Q.side===Ir?K(2884):re(2884);let ge=Q.side===On;se&&(ge=!ge),ve(ge),Q.blending===oc&&Q.transparent===!1?ye(Dt):ye(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let Le=Q.stencilWrite;u.setTest(Le),Le&&(u.setMask(Q.stencilWriteMask),u.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),u.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),we(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?re(32926):K(32926)}function ve(Q){T!==Q&&(Q?r.frontFace(2304):r.frontFace(2305),T=Q)}function Ee(Q){Q!==qI?(re(2884),Q!==P&&(Q===XS?r.cullFace(1029):Q===XI?r.cullFace(1028):r.cullFace(1032))):K(2884),P=Q}function Te(Q){Q!==D&&(V&&r.lineWidth(Q),D=Q)}function we(Q,se,ge){Q?(re(32823),(C!==se||O!==ge)&&(r.polygonOffset(se,ge),C=se,O=ge)):K(32823)}function Ge(Q){Q?re(3089):K(3089)}function gt(Q){Q===void 0&&(Q=33984+B-1),q!==Q&&(r.activeTexture(Q),q=Q)}function R(Q,se,ge){ge===void 0&&(q===null?ge=33984+B-1:ge=q);let Le=j[ge];Le===void 0&&(Le={type:void 0,texture:void 0},j[ge]=Le),(Le.type!==Q||Le.texture!==se)&&(q!==ge&&(r.activeTexture(ge),q=ge),r.bindTexture(Q,se||z[Q]),Le.type=Q,Le.texture=se)}function I(){let Q=j[q];Q!==void 0&&Q.type!==void 0&&(r.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ee(){try{r.compressedTexImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function me(){try{r.compressedTexImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function xe(){try{r.texSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ce(){try{r.texSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ve(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Pe(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function de(){try{r.texStorage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Xe(){try{r.texStorage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Re(){try{r.texImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function De(){try{r.texImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ue(Q){U.equals(Q)===!1&&(r.scissor(Q.x,Q.y,Q.z,Q.w),U.copy(Q))}function Ye(Q){G.equals(Q)===!1&&(r.viewport(Q.x,Q.y,Q.z,Q.w),G.copy(Q))}function yt(Q,se){let ge=d.get(se);ge===void 0&&(ge=new WeakMap,d.set(se,ge));let Le=ge.get(Q);Le===void 0&&(Le=r.getUniformBlockIndex(se,Q.name),ge.set(Q,Le))}function zt(Q,se){let Le=d.get(se).get(Q);c.get(se)!==Le&&(r.uniformBlockBinding(se,Le,Q.__bindingPointIndex),c.set(se,Le))}function En(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},q=null,j={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,P=null,D=null,C=null,O=null,U.set(0,0,r.canvas.width,r.canvas.height),G.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:re,disable:K,bindFramebuffer:Z,drawBuffers:k,useProgram:he,setBlending:ye,setMaterial:Se,setFlipSided:ve,setCullFace:Ee,setLineWidth:Te,setPolygonOffset:we,setScissorTest:Ge,activeTexture:gt,bindTexture:R,unbindTexture:I,compressedTexImage2D:ee,compressedTexImage3D:me,texImage2D:Re,texImage3D:De,updateUBOMapping:yt,uniformBlockBinding:zt,texStorage2D:de,texStorage3D:Xe,texSubImage2D:xe,texSubImage3D:Ce,compressedTexSubImage2D:Ve,compressedTexSubImage3D:Pe,scissor:Ue,viewport:Ye,reset:En}}function IB(r,t,e,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,d=i.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,I){return y?new OffscreenCanvas(R,I):Fp("canvas")}function x(R,I,ee,me){let xe=1;if((R.width>me||R.height>me)&&(xe=me/Math.max(R.width,R.height)),xe<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ce=I?Bp:Math.floor,Ve=Ce(xe*R.width),Pe=Ce(xe*R.height);p===void 0&&(p=v(Ve,Pe));let de=ee?v(Ve,Pe):p;return de.width=Ve,de.height=Pe,de.getContext("2d").drawImage(R,0,0,Ve,Pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Ve+"x"+Pe+")."),de}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function w(R){return v0(R.width)&&v0(R.height)}function S(R){return a?!1:R.wrapS!==Gt||R.wrapT!==Gt||R.minFilter!==Pt&&R.minFilter!==qe}function _(R,I){return R.generateMipmaps&&I&&R.minFilter!==Pt&&R.minFilter!==qe}function M(R){r.generateMipmap(R)}function b(R,I,ee,me,xe=!1){if(a===!1)return I;if(R!==null){if(r[R]!==void 0)return r[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ce=I;return I===6403&&(ee===5126&&(Ce=33326),ee===5131&&(Ce=33325),ee===5121&&(Ce=33321)),I===33319&&(ee===5126&&(Ce=33328),ee===5131&&(Ce=33327),ee===5121&&(Ce=33323)),I===6408&&(ee===5126&&(Ce=34836),ee===5131&&(Ce=34842),ee===5121&&(Ce=me===Qe&&xe===!1?35907:32856),ee===32819&&(Ce=32854),ee===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&t.get("EXT_color_buffer_float"),Ce}function E(R,I,ee){return _(R,ee)===!0||R.isFramebufferTexture&&R.minFilter!==Pt&&R.minFilter!==qe?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function T(R){return R===Pt||R===$S||R===Pv?9728:9729}function P(R){let I=R.target;I.removeEventListener("dispose",P),C(I),I.isVideoTexture&&m.delete(I)}function D(R){let I=R.target;I.removeEventListener("dispose",D),B(I)}function C(R){let I=n.get(R);if(I.__webglInit===void 0)return;let ee=R.source,me=g.get(ee);if(me){let xe=me[I.__cacheKey];xe.usedTimes--,xe.usedTimes===0&&O(R),Object.keys(me).length===0&&g.delete(ee)}n.remove(R)}function O(R){let I=n.get(R);r.deleteTexture(I.__webglTexture);let ee=R.source,me=g.get(ee);delete me[I.__cacheKey],o.memory.textures--}function B(R){let I=R.texture,ee=n.get(R),me=n.get(I);if(me.__webglTexture!==void 0&&(r.deleteTexture(me.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++)r.deleteFramebuffer(ee.__webglFramebuffer[xe]),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer[xe]);else{if(r.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let xe=0;xe<ee.__webglColorRenderbuffer.length;xe++)ee.__webglColorRenderbuffer[xe]&&r.deleteRenderbuffer(ee.__webglColorRenderbuffer[xe]);ee.__webglDepthRenderbuffer&&r.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let xe=0,Ce=I.length;xe<Ce;xe++){let Ve=n.get(I[xe]);Ve.__webglTexture&&(r.deleteTexture(Ve.__webglTexture),o.memory.textures--),n.remove(I[xe])}n.remove(I),n.remove(R)}let V=0;function Y(){V=0}function W(){let R=V;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),V+=1,R}function q(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.wrapR||0),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function j(R,I){let ee=n.get(R);if(R.isVideoTexture&&Ge(R),R.isRenderTargetTexture===!1&&R.version>0&&ee.__version!==R.version){let me=R.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(ee,R,I);return}}e.bindTexture(3553,ee.__webglTexture,33984+I)}function X(R,I){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,I);return}e.bindTexture(35866,ee.__webglTexture,33984+I)}function L(R,I){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,I);return}e.bindTexture(32879,ee.__webglTexture,33984+I)}function U(R,I){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){Z(ee,R,I);return}e.bindTexture(34067,ee.__webglTexture,33984+I)}let G={[Bi]:10497,[Gt]:33071,[m0]:33648},H={[Pt]:9728,[$S]:9984,[Pv]:9986,[qe]:9729,[bO]:9985,[Ha]:9987};function z(R,I,ee){if(ee?(r.texParameteri(R,10242,G[I.wrapS]),r.texParameteri(R,10243,G[I.wrapT]),(R===32879||R===35866)&&r.texParameteri(R,32882,G[I.wrapR]),r.texParameteri(R,10240,H[I.magFilter]),r.texParameteri(R,10241,H[I.minFilter])):(r.texParameteri(R,10242,33071),r.texParameteri(R,10243,33071),(R===32879||R===35866)&&r.texParameteri(R,32882,33071),(I.wrapS!==Gt||I.wrapT!==Gt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(R,10240,T(I.magFilter)),r.texParameteri(R,10241,T(I.minFilter)),I.minFilter!==Pt&&I.minFilter!==qe&&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 me=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===Pt||I.minFilter!==Pv&&I.minFilter!==Ha||I.type===wr&&t.has("OES_texture_float_linear")===!1||a===!1&&I.type===Wa&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||n.get(I).__currentAnisotropy)&&(r.texParameterf(R,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy)}}function re(R,I){let ee=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",P));let me=I.source,xe=g.get(me);xe===void 0&&(xe={},g.set(me,xe));let Ce=q(I);if(Ce!==R.__cacheKey){xe[Ce]===void 0&&(xe[Ce]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),xe[Ce].usedTimes++;let Ve=xe[R.__cacheKey];Ve!==void 0&&(xe[R.__cacheKey].usedTimes--,Ve.usedTimes===0&&O(I)),R.__cacheKey=Ce,R.__webglTexture=xe[Ce].texture}return ee}function K(R,I,ee){let me=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(me=35866),I.isData3DTexture&&(me=32879);let xe=re(R,I),Ce=I.source;e.bindTexture(me,R.__webglTexture,33984+ee);let Ve=n.get(Ce);if(Ce.version!==Ve.__version||xe===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Pe=S(I)&&w(I.image)===!1,de=x(I.image,Pe,!1,c);de=gt(I,de);let Xe=w(de)||a,Re=s.convert(I.format,I.encoding),De=s.convert(I.type),Ue=b(I.internalFormat,Re,De,I.encoding,I.isVideoTexture);z(me,I,Xe);let Ye,yt=I.mipmaps,zt=a&&I.isVideoTexture!==!0,En=Ve.__version===void 0||xe===!0,Q=E(I,de,Xe);if(I.isDepthTexture)Ue=6402,a?I.type===wr?Ue=36012:I.type===ro?Ue=33190:I.type===Vo?Ue=35056:Ue=33189:I.type===wr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Ga&&Ue===6402&&I.type!==PA&&I.type!==ro&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=ro,De=s.convert(I.type)),I.format===jo&&Ue===6402&&(Ue=34041,I.type!==Vo&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Vo,De=s.convert(I.type))),En&&(zt?e.texStorage2D(3553,1,Ue,de.width,de.height):e.texImage2D(3553,0,Ue,de.width,de.height,0,Re,De,null));else if(I.isDataTexture)if(yt.length>0&&Xe){zt&&En&&e.texStorage2D(3553,Q,Ue,yt[0].width,yt[0].height);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],zt?e.texSubImage2D(3553,se,0,0,Ye.width,Ye.height,Re,De,Ye.data):e.texImage2D(3553,se,Ue,Ye.width,Ye.height,0,Re,De,Ye.data);I.generateMipmaps=!1}else zt?(En&&e.texStorage2D(3553,Q,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,de.width,de.height,Re,De,de.data)):e.texImage2D(3553,0,Ue,de.width,de.height,0,Re,De,de.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){zt&&En&&e.texStorage3D(35866,Q,Ue,yt[0].width,yt[0].height,de.depth);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],I.format!==gi?Re!==null?zt?e.compressedTexSubImage3D(35866,se,0,0,0,Ye.width,Ye.height,de.depth,Re,Ye.data,0,0):e.compressedTexImage3D(35866,se,Ue,Ye.width,Ye.height,de.depth,0,Ye.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?e.texSubImage3D(35866,se,0,0,0,Ye.width,Ye.height,de.depth,Re,De,Ye.data):e.texImage3D(35866,se,Ue,Ye.width,Ye.height,de.depth,0,Re,De,Ye.data)}else{zt&&En&&e.texStorage2D(3553,Q,Ue,yt[0].width,yt[0].height);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],I.format!==gi?Re!==null?zt?e.compressedTexSubImage2D(3553,se,0,0,Ye.width,Ye.height,Re,Ye.data):e.compressedTexImage2D(3553,se,Ue,Ye.width,Ye.height,0,Ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?e.texSubImage2D(3553,se,0,0,Ye.width,Ye.height,Re,De,Ye.data):e.texImage2D(3553,se,Ue,Ye.width,Ye.height,0,Re,De,Ye.data)}else if(I.isDataArrayTexture)zt?(En&&e.texStorage3D(35866,Q,Ue,de.width,de.height,de.depth),e.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Re,De,de.data)):e.texImage3D(35866,0,Ue,de.width,de.height,de.depth,0,Re,De,de.data);else if(I.isData3DTexture)zt?(En&&e.texStorage3D(32879,Q,Ue,de.width,de.height,de.depth),e.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Re,De,de.data)):e.texImage3D(32879,0,Ue,de.width,de.height,de.depth,0,Re,De,de.data);else if(I.isFramebufferTexture){if(En)if(zt)e.texStorage2D(3553,Q,Ue,de.width,de.height);else{let se=de.width,ge=de.height;for(let Le=0;Le<Q;Le++)e.texImage2D(3553,Le,Ue,se,ge,0,Re,De,null),se>>=1,ge>>=1}}else if(yt.length>0&&Xe){zt&&En&&e.texStorage2D(3553,Q,Ue,yt[0].width,yt[0].height);for(let se=0,ge=yt.length;se<ge;se++)Ye=yt[se],zt?e.texSubImage2D(3553,se,0,0,Re,De,Ye):e.texImage2D(3553,se,Ue,Re,De,Ye);I.generateMipmaps=!1}else zt?(En&&e.texStorage2D(3553,Q,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,Re,De,de)):e.texImage2D(3553,0,Ue,Re,De,de);_(I,Xe)&&M(me),Ve.__version=Ce.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function Z(R,I,ee){if(I.image.length!==6)return;let me=re(R,I),xe=I.source;e.bindTexture(34067,R.__webglTexture,33984+ee);let Ce=n.get(xe);if(xe.version!==Ce.__version||me===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Ve=I.isCompressedTexture||I.image[0].isCompressedTexture,Pe=I.image[0]&&I.image[0].isDataTexture,de=[];for(let se=0;se<6;se++)!Ve&&!Pe?de[se]=x(I.image[se],!1,!0,u):de[se]=Pe?I.image[se].image:I.image[se],de[se]=gt(I,de[se]);let Xe=de[0],Re=w(Xe)||a,De=s.convert(I.format,I.encoding),Ue=s.convert(I.type),Ye=b(I.internalFormat,De,Ue,I.encoding),yt=a&&I.isVideoTexture!==!0,zt=Ce.__version===void 0||me===!0,En=E(I,Xe,Re);z(34067,I,Re);let Q;if(Ve){yt&&zt&&e.texStorage2D(34067,En,Ye,Xe.width,Xe.height);for(let se=0;se<6;se++){Q=de[se].mipmaps;for(let ge=0;ge<Q.length;ge++){let Le=Q[ge];I.format!==gi?De!==null?yt?e.compressedTexSubImage2D(34069+se,ge,0,0,Le.width,Le.height,De,Le.data):e.compressedTexImage2D(34069+se,ge,Ye,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):yt?e.texSubImage2D(34069+se,ge,0,0,Le.width,Le.height,De,Ue,Le.data):e.texImage2D(34069+se,ge,Ye,Le.width,Le.height,0,De,Ue,Le.data)}}}else{Q=I.mipmaps,yt&&zt&&(Q.length>0&&En++,e.texStorage2D(34067,En,Ye,de[0].width,de[0].height));for(let se=0;se<6;se++)if(Pe){yt?e.texSubImage2D(34069+se,0,0,0,de[se].width,de[se].height,De,Ue,de[se].data):e.texImage2D(34069+se,0,Ye,de[se].width,de[se].height,0,De,Ue,de[se].data);for(let ge=0;ge<Q.length;ge++){let Oe=Q[ge].image[se].image;yt?e.texSubImage2D(34069+se,ge+1,0,0,Oe.width,Oe.height,De,Ue,Oe.data):e.texImage2D(34069+se,ge+1,Ye,Oe.width,Oe.height,0,De,Ue,Oe.data)}}else{yt?e.texSubImage2D(34069+se,0,0,0,De,Ue,de[se]):e.texImage2D(34069+se,0,Ye,De,Ue,de[se]);for(let ge=0;ge<Q.length;ge++){let Le=Q[ge];yt?e.texSubImage2D(34069+se,ge+1,0,0,De,Ue,Le.image[se]):e.texImage2D(34069+se,ge+1,Ye,De,Ue,Le.image[se])}}}_(I,Re)&&M(34067),Ce.__version=xe.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function k(R,I,ee,me,xe){let Ce=s.convert(ee.format,ee.encoding),Ve=s.convert(ee.type),Pe=b(ee.internalFormat,Ce,Ve,ee.encoding);n.get(I).__hasExternalTextures||(xe===32879||xe===35866?e.texImage3D(xe,0,Pe,I.width,I.height,I.depth,0,Ce,Ve,null):e.texImage2D(xe,0,Pe,I.width,I.height,0,Ce,Ve,null)),e.bindFramebuffer(36160,R),we(I)?h.framebufferTexture2DMultisampleEXT(36160,me,xe,n.get(ee).__webglTexture,0,Te(I)):(xe===3553||xe>=34069&&xe<=34074)&&r.framebufferTexture2D(36160,me,xe,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function he(R,I,ee){if(r.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let me=33189;if(ee||we(I)){let xe=I.depthTexture;xe&&xe.isDepthTexture&&(xe.type===wr?me=36012:xe.type===ro&&(me=33190));let Ce=Te(I);we(I)?h.renderbufferStorageMultisampleEXT(36161,Ce,me,I.width,I.height):r.renderbufferStorageMultisample(36161,Ce,me,I.width,I.height)}else r.renderbufferStorage(36161,me,I.width,I.height);r.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let me=Te(I);ee&&we(I)===!1?r.renderbufferStorageMultisample(36161,me,35056,I.width,I.height):we(I)?h.renderbufferStorageMultisampleEXT(36161,me,35056,I.width,I.height):r.renderbufferStorage(36161,34041,I.width,I.height),r.framebufferRenderbuffer(36160,33306,36161,R)}else{let me=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let xe=0;xe<me.length;xe++){let Ce=me[xe],Ve=s.convert(Ce.format,Ce.encoding),Pe=s.convert(Ce.type),de=b(Ce.internalFormat,Ve,Pe,Ce.encoding),Xe=Te(I);ee&&we(I)===!1?r.renderbufferStorageMultisample(36161,Xe,de,I.width,I.height):we(I)?h.renderbufferStorageMultisampleEXT(36161,Xe,de,I.width,I.height):r.renderbufferStorage(36161,de,I.width,I.height)}}r.bindRenderbuffer(36161,null)}function fe(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),j(I.depthTexture,0);let me=n.get(I.depthTexture).__webglTexture,xe=Te(I);if(I.depthTexture.format===Ga)we(I)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,me,0,xe):r.framebufferTexture2D(36160,36096,3553,me,0);else if(I.depthTexture.format===jo)we(I)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,me,0,xe):r.framebufferTexture2D(36160,33306,3553,me,0);else throw new Error("Unknown depthTexture format")}function ce(R){let I=n.get(R),ee=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");fe(I.__webglFramebuffer,R)}else if(ee){I.__webglDepthbuffer=[];for(let me=0;me<6;me++)e.bindFramebuffer(36160,I.__webglFramebuffer[me]),I.__webglDepthbuffer[me]=r.createRenderbuffer(),he(I.__webglDepthbuffer[me],R,!1)}else e.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=r.createRenderbuffer(),he(I.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function ye(R,I,ee){let me=n.get(R);I!==void 0&&k(me.__webglFramebuffer,R,R.texture,36064,3553),ee!==void 0&&ce(R)}function Se(R){let I=R.texture,ee=n.get(R),me=n.get(I);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=r.createTexture()),me.__version=I.version,o.memory.textures++);let xe=R.isWebGLCubeRenderTarget===!0,Ce=R.isWebGLMultipleRenderTargets===!0,Ve=w(R)||a;if(xe){ee.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)ee.__webglFramebuffer[Pe]=r.createFramebuffer()}else{if(ee.__webglFramebuffer=r.createFramebuffer(),Ce)if(i.drawBuffers){let Pe=R.texture;for(let de=0,Xe=Pe.length;de<Xe;de++){let Re=n.get(Pe[de]);Re.__webglTexture===void 0&&(Re.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&we(R)===!1){let Pe=Ce?I:[I];ee.__webglMultisampledFramebuffer=r.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let de=0;de<Pe.length;de++){let Xe=Pe[de];ee.__webglColorRenderbuffer[de]=r.createRenderbuffer(),r.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[de]);let Re=s.convert(Xe.format,Xe.encoding),De=s.convert(Xe.type),Ue=b(Xe.internalFormat,Re,De,Xe.encoding,R.isXRRenderTarget===!0),Ye=Te(R);r.renderbufferStorageMultisample(36161,Ye,Ue,R.width,R.height),r.framebufferRenderbuffer(36160,36064+de,36161,ee.__webglColorRenderbuffer[de])}r.bindRenderbuffer(36161,null),R.depthBuffer&&(ee.__webglDepthRenderbuffer=r.createRenderbuffer(),he(ee.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(xe){e.bindTexture(34067,me.__webglTexture),z(34067,I,Ve);for(let Pe=0;Pe<6;Pe++)k(ee.__webglFramebuffer[Pe],R,I,36064,34069+Pe);_(I,Ve)&&M(34067),e.unbindTexture()}else if(Ce){let Pe=R.texture;for(let de=0,Xe=Pe.length;de<Xe;de++){let Re=Pe[de],De=n.get(Re);e.bindTexture(3553,De.__webglTexture),z(3553,Re,Ve),k(ee.__webglFramebuffer,R,Re,36064+de,3553),_(Re,Ve)&&M(3553)}e.unbindTexture()}else{let Pe=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?Pe=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Pe,me.__webglTexture),z(Pe,I,Ve),k(ee.__webglFramebuffer,R,I,36064,Pe),_(I,Ve)&&M(Pe),e.unbindTexture()}R.depthBuffer&&ce(R)}function ve(R){let I=w(R)||a,ee=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let me=0,xe=ee.length;me<xe;me++){let Ce=ee[me];if(_(Ce,I)){let Ve=R.isWebGLCubeRenderTarget?34067:3553,Pe=n.get(Ce).__webglTexture;e.bindTexture(Ve,Pe),M(Ve),e.unbindTexture()}}}function Ee(R){if(a&&R.samples>0&&we(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ee=R.width,me=R.height,xe=16384,Ce=[],Ve=R.stencilBuffer?33306:36096,Pe=n.get(R),de=R.isWebGLMultipleRenderTargets===!0;if(de)for(let Xe=0;Xe<I.length;Xe++)e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Xe,36161,null),e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Xe,3553,null,0);e.bindFramebuffer(36008,Pe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Pe.__webglFramebuffer);for(let Xe=0;Xe<I.length;Xe++){Ce.push(36064+Xe),R.depthBuffer&&Ce.push(Ve);let Re=Pe.__ignoreDepthValues!==void 0?Pe.__ignoreDepthValues:!1;if(Re===!1&&(R.depthBuffer&&(xe|=256),R.stencilBuffer&&(xe|=1024)),de&&r.framebufferRenderbuffer(36008,36064,36161,Pe.__webglColorRenderbuffer[Xe]),Re===!0&&(r.invalidateFramebuffer(36008,[Ve]),r.invalidateFramebuffer(36009,[Ve])),de){let De=n.get(I[Xe]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,De,0)}r.blitFramebuffer(0,0,ee,me,0,0,ee,me,xe,9728),f&&r.invalidateFramebuffer(36008,Ce)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),de)for(let Xe=0;Xe<I.length;Xe++){e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Xe,36161,Pe.__webglColorRenderbuffer[Xe]);let Re=n.get(I[Xe]).__webglTexture;e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Xe,3553,Re,0)}e.bindFramebuffer(36009,Pe.__webglMultisampledFramebuffer)}}function Te(R){return Math.min(d,R.samples)}function we(R){let I=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ge(R){let I=o.render.frame;m.get(R)!==I&&(m.set(R,I),R.update())}function gt(R,I){let ee=R.encoding,me=R.format,xe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===y0||ee!==oi&&(ee===Qe?a===!1?t.has("EXT_sRGB")===!0&&me===gi?(R.format=y0,R.minFilter=qe,R.generateMipmaps=!1):I=Up.sRGBToLinear(I):(me!==gi||xe!==qt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ee)),I}this.allocateTextureUnit=W,this.resetTextureUnits=Y,this.setTexture2D=j,this.setTexture2DArray=X,this.setTexture3D=L,this.setTextureCube=U,this.rebindTextures=ye,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=ve,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=ce,this.setupFrameBufferTexture=k,this.useMultisampledRTT=we}function OB(r,t,e){let n=e.isWebGL2;function i(s,o=null){let a;if(s===qt)return 5121;if(s===_O)return 32819;if(s===MO)return 32820;if(s===wO)return 5120;if(s===SO)return 5122;if(s===PA)return 5123;if(s===AO)return 5124;if(s===ro)return 5125;if(s===wr)return 5126;if(s===Wa)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===EO)return 6406;if(s===gi)return 6408;if(s===TO)return 6409;if(s===CO)return 6410;if(s===Ga)return 6402;if(s===jo)return 34041;if(s===y0)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===PO)return 6403;if(s===DO)return 36244;if(s===Z0)return 33319;if(s===IO)return 33320;if(s===OO)return 36249;if(s===Dv||s===Iv||s===Ov||s===Rv)if(o===Qe)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Dv)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Iv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Ov)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Rv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Dv)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Iv)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ov)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Rv)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===e1||s===t1||s===n1||s===r1)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===e1)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===t1)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===n1)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===r1)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===RO)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===i1||s===s1)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===i1)return o===Qe?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===s1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===o1||s===a1||s===l1||s===c1||s===u1||s===d1||s===h1||s===f1||s===p1||s===m1||s===g1||s===y1||s===v1||s===x1)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===o1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===a1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===l1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===c1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===u1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===d1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===h1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===f1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===p1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===m1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===g1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===y1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===v1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===x1)return o===Qe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Lv)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Lv)return o===Qe?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===LO||s===b1||s===w1||s===S1)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Lv)return a.COMPRESSED_RED_RGTC1_EXT;if(s===b1)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===w1)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===S1)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Vo?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var C0=class extends gn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},gs=class extends pt{constructor(){super(),this.isGroup=!0,this.type="Group"}},RB={type:"move"},dh=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new gs,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 gs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new gs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let p of t.hand.values()){let g=e.getJointPose(p,n),y=this._getHandJoint(u,p);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,m=.005;u.inputState.pinching&&h>f+m?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=f-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(RB)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new gs;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},yi=class extends Vt{constructor(t,e,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Ga,c!==Ga&&c!==jo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Ga&&(n=ro),n===void 0&&c===jo&&(n=Vo),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Pt,this.minFilter=l!==void 0?l:Pt,this.flipY=!1,this.generateMipmaps=!1}},P0=class extends Ht{constructor(t,e){super();let n=this,i=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,m=null,p=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,_=new gn;_.layers.enable(1),_.viewport=new Ze;let M=new gn;M.layers.enable(2),M.viewport=new Ze;let b=[_,M],E=new C0;E.layers.enable(1),E.layers.enable(2);let T=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(L){let U=v[L];return U===void 0&&(U=new dh,v[L]=U),U.getTargetRaySpace()},this.getControllerGrip=function(L){let U=v[L];return U===void 0&&(U=new dh,v[L]=U),U.getGripSpace()},this.getHand=function(L){let U=v[L];return U===void 0&&(U=new dh,v[L]=U),U.getHandSpace()};function D(L){let U=x.indexOf(L.inputSource);if(U===-1)return;let G=v[U];G!==void 0&&G.dispatchEvent({type:L.type,data:L.inputSource})}function C(){i.removeEventListener("select",D),i.removeEventListener("selectstart",D),i.removeEventListener("selectend",D),i.removeEventListener("squeeze",D),i.removeEventListener("squeezestart",D),i.removeEventListener("squeezeend",D),i.removeEventListener("end",C),i.removeEventListener("inputsourceschange",O);for(let L=0;L<v.length;L++){let U=x[L];U!==null&&(x[L]=null,v[L].disconnect(U))}T=null,P=null,t.setRenderTarget(g),f=null,h=null,d=null,i=null,y=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(L){s=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(L){a=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(L){u=L},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(L){if(i=L,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",D),i.addEventListener("selectstart",D),i.addEventListener("selectend",D),i.addEventListener("squeeze",D),i.addEventListener("squeezestart",D),i.addEventListener("squeezeend",D),i.addEventListener("end",C),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let U={antialias:i.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,U),i.updateRenderState({baseLayer:f}),y=new st(f.framebufferWidth,f.framebufferHeight,{format:gi,type:qt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let U=null,G=null,H=null;p.depth&&(H=p.stencil?35056:33190,U=p.stencil?jo:Ga,G=p.stencil?Vo:ro);let z={colorFormat:32856,depthFormat:H,scaleFactor:s};d=new XRWebGLBinding(i,e),h=d.createProjectionLayer(z),i.updateRenderState({layers:[h]}),y=new st(h.textureWidth,h.textureHeight,{format:gi,type:qt,depthTexture:new yi(h.textureWidth,h.textureHeight,G,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let re=t.properties.get(y);re.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await i.requestReferenceSpace(a),X.setContext(i),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function O(L){for(let U=0;U<L.removed.length;U++){let G=L.removed[U],H=x.indexOf(G);H>=0&&(x[H]=null,v[H].disconnect(G))}for(let U=0;U<L.added.length;U++){let G=L.added[U],H=x.indexOf(G);if(H===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(G),H=re;break}else if(x[re]===null){x[re]=G,H=re;break}if(H===-1)break}let z=v[H];z&&z.connect(G)}}let B=new A,V=new A;function Y(L,U,G){B.setFromMatrixPosition(U.matrixWorld),V.setFromMatrixPosition(G.matrixWorld);let H=B.distanceTo(V),z=U.projectionMatrix.elements,re=G.projectionMatrix.elements,K=z[14]/(z[10]-1),Z=z[14]/(z[10]+1),k=(z[9]+1)/z[5],he=(z[9]-1)/z[5],fe=(z[8]-1)/z[0],ce=(re[8]+1)/re[0],ye=K*fe,Se=K*ce,ve=H/(-fe+ce),Ee=ve*-fe;U.matrixWorld.decompose(L.position,L.quaternion,L.scale),L.translateX(Ee),L.translateZ(ve),L.matrixWorld.compose(L.position,L.quaternion,L.scale),L.matrixWorldInverse.copy(L.matrixWorld).invert();let Te=K+ve,we=Z+ve,Ge=ye-Ee,gt=Se+(H-Ee),R=k*Z/we*Te,I=he*Z/we*Te;L.projectionMatrix.makePerspective(Ge,gt,R,I,Te,we)}function W(L,U){U===null?L.matrixWorld.copy(L.matrix):L.matrixWorld.multiplyMatrices(U.matrixWorld,L.matrix),L.matrixWorldInverse.copy(L.matrixWorld).invert()}this.updateCamera=function(L){if(i===null)return;E.near=M.near=_.near=L.near,E.far=M.far=_.far=L.far,(T!==E.near||P!==E.far)&&(i.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,P=E.far);let U=L.parent,G=E.cameras;W(E,U);for(let z=0;z<G.length;z++)W(G[z],U);E.matrixWorld.decompose(E.position,E.quaternion,E.scale),L.matrix.copy(E.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);let H=L.children;for(let z=0,re=H.length;z<re;z++)H[z].updateMatrixWorld(!0);G.length===2?Y(E,_,M):E.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(L){l=L,h!==null&&(h.fixedFoveation=L),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=L)},this.getPlanes=function(){return w};let q=null;function j(L,U){if(c=U.getViewerPose(u||o),m=U,c!==null){let G=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let H=!1;G.length!==E.cameras.length&&(E.cameras.length=0,H=!0);for(let z=0;z<G.length;z++){let re=G[z],K=null;if(f!==null)K=f.getViewport(re);else{let k=d.getViewSubImage(h,re);K=k.viewport,z===0&&(t.setRenderTargetTextures(y,k.colorTexture,h.ignoreDepthValues?void 0:k.depthStencilTexture),t.setRenderTarget(y))}let Z=b[z];Z===void 0&&(Z=new gn,Z.layers.enable(z),Z.viewport=new Ze,b[z]=Z),Z.matrix.fromArray(re.transform.matrix),Z.projectionMatrix.fromArray(re.projectionMatrix),Z.viewport.set(K.x,K.y,K.width,K.height),z===0&&E.matrix.copy(Z.matrix),H===!0&&E.cameras.push(Z)}}for(let G=0;G<v.length;G++){let H=x[G],z=v[G];H!==null&&z!==void 0&&z.update(H,U,u||o)}if(q&&q(L,U),U.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:U.detectedPlanes});let G=null;for(let H of w)U.detectedPlanes.has(H)||(G===null&&(G=[]),G.push(H));if(G!==null)for(let H of G)w.delete(H),S.delete(H),n.dispatchEvent({type:"planeremoved",data:H});for(let H of U.detectedPlanes)if(!w.has(H))w.add(H),S.set(H,U.lastChangedTime),n.dispatchEvent({type:"planeadded",data:H});else{let z=S.get(H);H.lastChangedTime>z&&(S.set(H,H.lastChangedTime),n.dispatchEvent({type:"planechanged",data:H}))}}m=null}let X=new RA;X.setAnimationLoop(j),this.setAnimationLoop=function(L){q=L},this.dispose=function(){}}};function LB(r,t){function e(p,g){g.color.getRGB(p.fogColor.value,OA(r)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),c(p,g)):g.isMeshPhongMaterial?(i(p,g),u(p,g)):g.isMeshStandardMaterial?(i(p,g),d(p,g),g.isMeshPhysicalMaterial&&h(p,g,x)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,y,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===On&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===On&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let w=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uv2Transform.value.copy(x.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,y,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function c(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function d(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function h(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===On&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function NB(r,t,e,n){let i={},s={},o=[],a=e.isWebGL2?r.getParameter(35375):0;function l(v,x){let w=x.program;n.uniformBlockBinding(v,w)}function u(v,x){let w=i[v.id];w===void 0&&(m(v),w=c(v),i[v.id]=w,v.addEventListener("dispose",g));let S=x.program;n.updateUBOMapping(v,S);let _=t.render.frame;s[v.id]!==_&&(h(v),s[v.id]=_)}function c(v){let x=d();v.__bindingPointIndex=x;let w=r.createBuffer(),S=v.__size,_=v.usage;return r.bindBuffer(35345,w),r.bufferData(35345,S,_),r.bindBuffer(35345,null),r.bindBufferBase(35345,x,w),w}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let x=i[v.id],w=v.uniforms,S=v.__cache;r.bindBuffer(35345,x);for(let _=0,M=w.length;_<M;_++){let b=w[_];if(f(b,_,S)===!0){let E=b.__offset,T=Array.isArray(b.value)?b.value:[b.value],P=0;for(let D=0;D<T.length;D++){let C=T[D],O=p(C);typeof C=="number"?(b.__data[0]=C,r.bufferSubData(35345,E+P,b.__data)):C.isMatrix3?(b.__data[0]=C.elements[0],b.__data[1]=C.elements[1],b.__data[2]=C.elements[2],b.__data[3]=C.elements[0],b.__data[4]=C.elements[3],b.__data[5]=C.elements[4],b.__data[6]=C.elements[5],b.__data[7]=C.elements[0],b.__data[8]=C.elements[6],b.__data[9]=C.elements[7],b.__data[10]=C.elements[8],b.__data[11]=C.elements[0]):(C.toArray(b.__data,P),P+=O.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(35345,E,b.__data)}}r.bindBuffer(35345,null)}function f(v,x,w){let S=v.value;if(w[x]===void 0){if(typeof S=="number")w[x]=S;else{let _=Array.isArray(S)?S:[S],M=[];for(let b=0;b<_.length;b++)M.push(_[b].clone());w[x]=M}return!0}else if(typeof S=="number"){if(w[x]!==S)return w[x]=S,!0}else{let _=Array.isArray(w[x])?w[x]:[w[x]],M=Array.isArray(S)?S:[S];for(let b=0;b<_.length;b++){let E=_[b];if(E.equals(M[b])===!1)return E.copy(M[b]),!0}}return!1}function m(v){let x=v.uniforms,w=0,S=16,_=0;for(let M=0,b=x.length;M<b;M++){let E=x[M],T={boundary:0,storage:0},P=Array.isArray(E.value)?E.value:[E.value];for(let D=0,C=P.length;D<C;D++){let O=P[D],B=p(O);T.boundary+=B.boundary,T.storage+=B.storage}if(E.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=w,M>0){_=w%S;let D=S-_;_!==0&&D-T.boundary<0&&(w+=S-_,E.__offset=w)}w+=T.storage}return _=w%S,_>0&&(w+=S-_),v.__size=w,v.__cache={},this}function p(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)r.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:u,dispose:y}}function BB(){let r=Fp("canvas");return r.style.display="block",r}function tx(r={}){this.isWebGLRenderer=!0;let t=r.canvas!==void 0?r.canvas:BB(),e=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let d=null,h=null,f=[],m=[];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=oi,this.physicallyCorrectLights=!1,this.toneMapping=so,this.toneMappingExposure=1;let p=this,g=!1,y=0,v=0,x=null,w=-1,S=null,_=new Ze,M=new Ze,b=null,E=t.width,T=t.height,P=1,D=null,C=null,O=new Ze(0,0,E,T),B=new Ze(0,0,E,T),V=!1,Y=new yh,W=!1,q=!1,j=null,X=new ae,L=new F,U=new A,G={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function H(){return x===null?P:1}let z=e;function re(N,te){for(let oe=0;oe<N.length;oe++){let $=N[oe],ue=t.getContext($,te);if(ue!==null)return ue}return null}try{let N={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${lo}`),t.addEventListener("webglcontextlost",Ue,!1),t.addEventListener("webglcontextrestored",Ye,!1),t.addEventListener("webglcontextcreationerror",yt,!1),z===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),z=re(te,N),z===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let K,Z,k,he,fe,ce,ye,Se,ve,Ee,Te,we,Ge,gt,R,I,ee,me,xe,Ce,Ve,Pe,de,Xe;function Re(){K=new rN(z),Z=new Z3(z,K,r),K.init(Z),Pe=new OB(z,K,Z),k=new DB(z,K,Z),he=new oN,fe=new vB,ce=new IB(z,K,k,fe,Z,Pe,he),ye=new $3(p),Se=new nN(p),ve=new mR(z,Z),de=new Q3(z,K,ve,Z),Ee=new iN(z,ve,he,de),Te=new uN(z,Ee,ve,he),xe=new cN(z,Z,ce),I=new J3(fe),we=new yB(p,ye,Se,K,Z,de,I),Ge=new LB(p,fe),gt=new bB,R=new EB(K,Z),me=new Y3(p,ye,Se,k,Te,c,o),ee=new PB(p,Te,Z),Xe=new NB(z,he,Z,k),Ce=new K3(z,K,he,Z),Ve=new sN(z,K,he,Z),he.programs=we.programs,p.capabilities=Z,p.extensions=K,p.properties=fe,p.renderLists=gt,p.shadowMap=ee,p.state=k,p.info=he}Re();let De=new P0(p,z);this.xr=De,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let N=K.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=K.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(N){N!==void 0&&(P=N,this.setSize(E,T,!1))},this.getSize=function(N){return N.set(E,T)},this.setSize=function(N,te,oe){if(De.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=N,T=te,t.width=Math.floor(N*P),t.height=Math.floor(te*P),oe!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(E*P,T*P).floor()},this.setDrawingBufferSize=function(N,te,oe){E=N,T=te,P=oe,t.width=Math.floor(N*oe),t.height=Math.floor(te*oe),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(_)},this.getViewport=function(N){return N.copy(O)},this.setViewport=function(N,te,oe,$){N.isVector4?O.set(N.x,N.y,N.z,N.w):O.set(N,te,oe,$),k.viewport(_.copy(O).multiplyScalar(P).floor())},this.getScissor=function(N){return N.copy(B)},this.setScissor=function(N,te,oe,$){N.isVector4?B.set(N.x,N.y,N.z,N.w):B.set(N,te,oe,$),k.scissor(M.copy(B).multiplyScalar(P).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(N){k.setScissorTest(V=N)},this.setOpaqueSort=function(N){D=N},this.setTransparentSort=function(N){C=N},this.getClearColor=function(N){return N.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(N=!0,te=!0,oe=!0){let $=0;N&&($|=16384),te&&($|=256),oe&&($|=1024),z.clear($)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ue,!1),t.removeEventListener("webglcontextrestored",Ye,!1),t.removeEventListener("webglcontextcreationerror",yt,!1),gt.dispose(),R.dispose(),fe.dispose(),ye.dispose(),Se.dispose(),Te.dispose(),de.dispose(),Xe.dispose(),we.dispose(),De.dispose(),De.removeEventListener("sessionstart",Le),De.removeEventListener("sessionend",Oe),j&&(j.dispose(),j=null),vt.stop()};function Ue(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Ye(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=he.autoReset,te=ee.enabled,oe=ee.autoUpdate,$=ee.needsUpdate,ue=ee.type;Re(),he.autoReset=N,ee.enabled=te,ee.autoUpdate=oe,ee.needsUpdate=$,ee.type=ue}function yt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function zt(N){let te=N.target;te.removeEventListener("dispose",zt),En(te)}function En(N){Q(N),fe.remove(N)}function Q(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(oe){we.releaseProgram(oe)}),N.isShaderMaterial&&we.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,oe,$,ue,tt){te===null&&(te=G);let at=ue.isMesh&&ue.matrixWorld.determinant()<0,ct=BI(N,te,oe,$,ue);k.setMaterial($,at);let ft=oe.index,Tt=1;$.wireframe===!0&&(ft=Ee.getWireframeAttribute(oe),Tt=2);let xt=oe.drawRange,bt=oe.attributes.position,Cn=xt.start*Tt,ti=(xt.start+xt.count)*Tt;tt!==null&&(Cn=Math.max(Cn,tt.start*Tt),ti=Math.min(ti,(tt.start+tt.count)*Tt)),ft!==null?(Cn=Math.max(Cn,0),ti=Math.min(ti,ft.count)):bt!=null&&(Cn=Math.max(Cn,0),ti=Math.min(ti,bt.count));let Ks=ti-Cn;if(Ks<0||Ks===1/0)return;de.setup(ue,$,ct,oe,ft);let Ra,Pn=Ce;if(ft!==null&&(Ra=ve.get(ft),Pn=Ve,Pn.setIndex(Ra)),ue.isMesh)$.wireframe===!0?(k.setLineWidth($.wireframeLinewidth*H()),Pn.setMode(1)):Pn.setMode(4);else if(ue.isLine){let wt=$.linewidth;wt===void 0&&(wt=1),k.setLineWidth(wt*H()),ue.isLineSegments?Pn.setMode(1):ue.isLineLoop?Pn.setMode(2):Pn.setMode(3)}else ue.isPoints?Pn.setMode(0):ue.isSprite&&Pn.setMode(4);if(ue.isInstancedMesh)Pn.renderInstances(Cn,Ks,ue.count);else if(oe.isInstancedBufferGeometry){let wt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Mv=Math.min(oe.instanceCount,wt);Pn.renderInstances(Cn,Ks,Mv)}else Pn.render(Cn,Ks)},this.compile=function(N,te){function oe($,ue,tt){$.transparent===!0&&$.side===Ir&&$.forceSinglePass===!1?($.side=On,$.needsUpdate=!0,pi($,ue,tt),$.side=si,$.needsUpdate=!0,pi($,ue,tt),$.side=Ir):pi($,ue,tt)}h=R.get(N),h.init(),m.push(h),N.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),N.traverse(function($){let ue=$.material;if(ue)if(Array.isArray(ue))for(let tt=0;tt<ue.length;tt++){let at=ue[tt];oe(at,N,$)}else oe(ue,N,$)}),m.pop(),h=null};let se=null;function ge(N){se&&se(N)}function Le(){vt.stop()}function Oe(){vt.start()}let vt=new RA;vt.setAnimationLoop(ge),typeof self<"u"&&vt.setContext(self),this.setAnimationLoop=function(N){se=N,De.setAnimationLoop(N),N===null?vt.stop():vt.start()},De.addEventListener("sessionstart",Le),De.addEventListener("sessionend",Oe),this.render=function(N,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),De.enabled===!0&&De.isPresenting===!0&&(De.cameraAutoUpdate===!0&&De.updateCamera(te),te=De.getCamera()),N.isScene===!0&&N.onBeforeRender(p,N,te,x),h=R.get(N,m.length),h.init(),m.push(h),X.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),Y.setFromProjectionMatrix(X),q=this.localClippingEnabled,W=I.init(this.clippingPlanes,q),d=gt.get(N,f.length),d.init(),f.push(d),Tn(N,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(D,C),W===!0&&I.beginShadows();let oe=h.state.shadowsArray;if(ee.render(oe,N,te),W===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(d,N),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let ue=0,tt=$.length;ue<tt;ue++){let at=$[ue];pn(d,N,at,at.viewport)}}else pn(d,N,te);x!==null&&(ce.updateMultisampleRenderTarget(x),ce.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(p,N,te),de.resetDefaultState(),w=-1,S=null,m.pop(),m.length>0?h=m[m.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function Tn(N,te,oe,$){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)oe=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||Y.intersectsSprite(N)){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),ct=N.material;ct.visible&&d.push(N,at,ct,oe,U.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==he.render.frame&&(N.skeleton.update(),N.skeleton.frame=he.render.frame),!N.frustumCulled||Y.intersectsObject(N))){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),ct=N.material;if(Array.isArray(ct)){let ft=at.groups;for(let Tt=0,xt=ft.length;Tt<xt;Tt++){let bt=ft[Tt],Cn=ct[bt.materialIndex];Cn&&Cn.visible&&d.push(N,at,Cn,oe,U.z,bt)}}else ct.visible&&d.push(N,at,ct,oe,U.z,null)}}let tt=N.children;for(let at=0,ct=tt.length;at<ct;at++)Tn(tt[at],te,oe,$)}function pn(N,te,oe,$){let ue=N.opaque,tt=N.transmissive,at=N.transparent;h.setupLightsView(oe),W===!0&&I.setGlobalState(p.clippingPlanes,oe),tt.length>0&&Oa(ue,te,oe),$&&k.viewport(_.copy($)),ue.length>0&&Qt(ue,te,oe),tt.length>0&&Qt(tt,te,oe),at.length>0&&Qt(at,te,oe),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function Oa(N,te,oe){let $=Z.isWebGL2;j===null&&(j=new st(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?Wa:qt,minFilter:Ha,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(L),$?j.setSize(L.x,L.y):j.setSize(Bp(L.x),Bp(L.y));let ue=p.getRenderTarget();p.setRenderTarget(j),p.clear();let tt=p.toneMapping;p.toneMapping=so,Qt(N,te,oe),p.toneMapping=tt,ce.updateMultisampleRenderTarget(j),ce.updateRenderTargetMipmap(j),p.setRenderTarget(ue)}function Qt(N,te,oe){let $=te.isScene===!0?te.overrideMaterial:null;for(let ue=0,tt=N.length;ue<tt;ue++){let at=N[ue],ct=at.object,ft=at.geometry,Tt=$===null?at.material:$,xt=at.group;ct.layers.test(oe.layers)&&Qs(ct,te,oe,ft,Tt,xt)}}function Qs(N,te,oe,$,ue,tt){N.onBeforeRender(p,te,oe,$,ue,tt),N.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),ue.onBeforeRender(p,te,oe,$,N,tt),ue.transparent===!0&&ue.side===Ir&&ue.forceSinglePass===!1?(ue.side=On,ue.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ue,N,tt),ue.side=si,ue.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ue,N,tt),ue.side=Ir):p.renderBufferDirect(oe,te,$,ue,N,tt),N.onAfterRender(p,te,oe,$,ue,tt)}function pi(N,te,oe){te.isScene!==!0&&(te=G);let $=fe.get(N),ue=h.state.lights,tt=h.state.shadowsArray,at=ue.state.version,ct=we.getParameters(N,ue.state,tt,te,oe),ft=we.getProgramCacheKey(ct),Tt=$.programs;$.environment=N.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(N.isMeshStandardMaterial?Se:ye).get(N.envMap||$.environment),Tt===void 0&&(N.addEventListener("dispose",zt),Tt=new Map,$.programs=Tt);let xt=Tt.get(ft);if(xt!==void 0){if($.currentProgram===xt&&$.lightsStateVersion===at)return VS(N,ct),xt}else ct.uniforms=we.getUniforms(N),N.onBuild(oe,ct,p),N.onBeforeCompile(ct,p),xt=we.acquireProgram(ct,ft),Tt.set(ft,xt),$.uniforms=ct.uniforms;let bt=$.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(bt.clippingPlanes=I.uniform),VS(N,ct),$.needsLights=UI(N),$.lightsStateVersion=at,$.needsLights&&(bt.ambientLightColor.value=ue.state.ambient,bt.lightProbe.value=ue.state.probe,bt.directionalLights.value=ue.state.directional,bt.directionalLightShadows.value=ue.state.directionalShadow,bt.spotLights.value=ue.state.spot,bt.spotLightShadows.value=ue.state.spotShadow,bt.rectAreaLights.value=ue.state.rectArea,bt.ltc_1.value=ue.state.rectAreaLTC1,bt.ltc_2.value=ue.state.rectAreaLTC2,bt.pointLights.value=ue.state.point,bt.pointLightShadows.value=ue.state.pointShadow,bt.hemisphereLights.value=ue.state.hemi,bt.directionalShadowMap.value=ue.state.directionalShadowMap,bt.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,bt.spotShadowMap.value=ue.state.spotShadowMap,bt.spotLightMatrix.value=ue.state.spotLightMatrix,bt.spotLightMap.value=ue.state.spotLightMap,bt.pointShadowMap.value=ue.state.pointShadowMap,bt.pointShadowMatrix.value=ue.state.pointShadowMatrix);let Cn=xt.getUniforms(),ti=ac.seqWithValue(Cn.seq,bt);return $.currentProgram=xt,$.uniformsList=ti,xt}function VS(N,te){let oe=fe.get(N);oe.outputEncoding=te.outputEncoding,oe.instancing=te.instancing,oe.skinning=te.skinning,oe.morphTargets=te.morphTargets,oe.morphNormals=te.morphNormals,oe.morphColors=te.morphColors,oe.morphTargetsCount=te.morphTargetsCount,oe.numClippingPlanes=te.numClippingPlanes,oe.numIntersection=te.numClipIntersection,oe.vertexAlphas=te.vertexAlphas,oe.vertexTangents=te.vertexTangents,oe.toneMapping=te.toneMapping}function BI(N,te,oe,$,ue){te.isScene!==!0&&(te=G),ce.resetTextureUnits();let tt=te.fog,at=$.isMeshStandardMaterial?te.environment:null,ct=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:oi,ft=($.isMeshStandardMaterial?Se:ye).get($.envMap||at),Tt=$.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,xt=!!$.normalMap&&!!oe.attributes.tangent,bt=!!oe.morphAttributes.position,Cn=!!oe.morphAttributes.normal,ti=!!oe.morphAttributes.color,Ks=$.toneMapped?p.toneMapping:so,Ra=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,Pn=Ra!==void 0?Ra.length:0,wt=fe.get($),Mv=h.state.lights;if(W===!0&&(q===!0||N!==S)){let ni=N===S&&$.id===w;I.setState($,N,ni)}let Jn=!1;$.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==Mv.state.version||wt.outputEncoding!==ct||ue.isInstancedMesh&&wt.instancing===!1||!ue.isInstancedMesh&&wt.instancing===!0||ue.isSkinnedMesh&&wt.skinning===!1||!ue.isSkinnedMesh&&wt.skinning===!0||wt.envMap!==ft||$.fog===!0&&wt.fog!==tt||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==I.numPlanes||wt.numIntersection!==I.numIntersection)||wt.vertexAlphas!==Tt||wt.vertexTangents!==xt||wt.morphTargets!==bt||wt.morphNormals!==Cn||wt.morphColors!==ti||wt.toneMapping!==Ks||Z.isWebGL2===!0&&wt.morphTargetsCount!==Pn)&&(Jn=!0):(Jn=!0,wt.__version=$.version);let La=wt.currentProgram;Jn===!0&&(La=pi($,te,ue));let HS=!1,Jd=!1,Ev=!1,pr=La.getUniforms(),Na=wt.uniforms;if(k.useProgram(La.program)&&(HS=!0,Jd=!0,Ev=!0),$.id!==w&&(w=$.id,Jd=!0),HS||S!==N){if(pr.setValue(z,"projectionMatrix",N.projectionMatrix),Z.logarithmicDepthBuffer&&pr.setValue(z,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),S!==N&&(S=N,Jd=!0,Ev=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let ni=pr.map.cameraPosition;ni!==void 0&&ni.setValue(z,U.setFromMatrixPosition(N.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&pr.setValue(z,"isOrthographic",N.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||ue.isSkinnedMesh)&&pr.setValue(z,"viewMatrix",N.matrixWorldInverse)}if(ue.isSkinnedMesh){pr.setOptional(z,ue,"bindMatrix"),pr.setOptional(z,ue,"bindMatrixInverse");let ni=ue.skeleton;ni&&(Z.floatVertexTextures?(ni.boneTexture===null&&ni.computeBoneTexture(),pr.setValue(z,"boneTexture",ni.boneTexture,ce),pr.setValue(z,"boneTextureSize",ni.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 Tv=oe.morphAttributes;if((Tv.position!==void 0||Tv.normal!==void 0||Tv.color!==void 0&&Z.isWebGL2===!0)&&xe.update(ue,oe,$,La),(Jd||wt.receiveShadow!==ue.receiveShadow)&&(wt.receiveShadow=ue.receiveShadow,pr.setValue(z,"receiveShadow",ue.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(Na.envMap.value=ft,Na.flipEnvMap.value=ft.isCubeTexture&&ft.isRenderTargetTexture===!1?-1:1),Jd&&(pr.setValue(z,"toneMappingExposure",p.toneMappingExposure),wt.needsLights&&FI(Na,Ev),tt&&$.fog===!0&&Ge.refreshFogUniforms(Na,tt),Ge.refreshMaterialUniforms(Na,$,P,T,j),ac.upload(z,wt.uniformsList,Na,ce)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(ac.upload(z,wt.uniformsList,Na,ce),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&pr.setValue(z,"center",ue.center),pr.setValue(z,"modelViewMatrix",ue.modelViewMatrix),pr.setValue(z,"normalMatrix",ue.normalMatrix),pr.setValue(z,"modelMatrix",ue.matrixWorld),ue.previousModelViewMatrix&&pr.setValue(z,"previousModelViewMatrix",ue.previousModelViewMatrix),N.previousProjectionMatrix&&pr.setValue(z,"previousProjectionMatrix",N.previousProjectionMatrix),$.isShaderMaterial||$.isRawShaderMaterial){let ni=$.uniformsGroups;for(let Cv=0,kI=ni.length;Cv<kI;Cv++)if(Z.isWebGL2){let WS=ni[Cv];Xe.update(WS,La),Xe.bind(WS,La)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return La}function FI(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function UI(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,oe){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=oe;let $=fe.get(N);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=oe===void 0,$.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let oe=fe.get(N);oe.__webglFramebuffer=te,oe.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,oe=0){x=N,y=te,v=oe;let $=!0,ue=null,tt=!1,at=!1;if(N){let ft=fe.get(N);ft.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),$=!1):ft.__webglFramebuffer===void 0?ce.setupRenderTarget(N):ft.__hasExternalTextures&&ce.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let Tt=N.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(at=!0);let xt=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(ue=xt[te],tt=!0):Z.isWebGL2&&N.samples>0&&ce.useMultisampledRTT(N)===!1?ue=fe.get(N).__webglMultisampledFramebuffer:ue=xt,_.copy(N.viewport),M.copy(N.scissor),b=N.scissorTest}else _.copy(O).multiplyScalar(P).floor(),M.copy(B).multiplyScalar(P).floor(),b=V;if(k.bindFramebuffer(36160,ue)&&Z.drawBuffers&&$&&k.drawBuffers(N,ue),k.viewport(_),k.scissor(M),k.setScissorTest(b),tt){let ft=fe.get(N.texture);z.framebufferTexture2D(36160,36064,34069+te,ft.__webglTexture,oe)}else if(at){let ft=fe.get(N.texture),Tt=te||0;z.framebufferTextureLayer(36160,36064,ft.__webglTexture,oe||0,Tt)}w=-1},this.readRenderTargetPixels=function(N,te,oe,$,ue,tt,at){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ct=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&at!==void 0&&(ct=ct[at]),ct){k.bindFramebuffer(36160,ct);try{let ft=N.texture,Tt=ft.format,xt=ft.type;if(Tt!==gi&&Pe.convert(Tt)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let bt=xt===Wa&&(K.has("EXT_color_buffer_half_float")||Z.isWebGL2&&K.has("EXT_color_buffer_float"));if(xt!==qt&&Pe.convert(xt)!==z.getParameter(35738)&&!(xt===wr&&(Z.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!bt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-$&&oe>=0&&oe<=N.height-ue&&z.readPixels(te,oe,$,ue,Pe.convert(Tt),Pe.convert(xt),tt)}finally{let ft=x!==null?fe.get(x).__webglFramebuffer:null;k.bindFramebuffer(36160,ft)}}},this.copyFramebufferToTexture=function(N,te,oe=0){let $=Math.pow(2,-oe),ue=Math.floor(te.image.width*$),tt=Math.floor(te.image.height*$);ce.setTexture2D(te,0),z.copyTexSubImage2D(3553,oe,0,0,N.x,N.y,ue,tt),k.unbindTexture()},this.copyTextureToTexture=function(N,te,oe,$=0){let ue=te.image.width,tt=te.image.height,at=Pe.convert(oe.format),ct=Pe.convert(oe.type);ce.setTexture2D(oe,0),z.pixelStorei(37440,oe.flipY),z.pixelStorei(37441,oe.premultiplyAlpha),z.pixelStorei(3317,oe.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,$,N.x,N.y,ue,tt,at,ct,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,$,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,at,te.mipmaps[0].data):z.texSubImage2D(3553,$,N.x,N.y,at,ct,te.image),$===0&&oe.generateMipmaps&&z.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(N,te,oe,$,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let tt=N.max.x-N.min.x+1,at=N.max.y-N.min.y+1,ct=N.max.z-N.min.z+1,ft=Pe.convert($.format),Tt=Pe.convert($.type),xt;if($.isData3DTexture)ce.setTexture3D($,0),xt=32879;else if($.isDataArrayTexture)ce.setTexture2DArray($,0),xt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,$.flipY),z.pixelStorei(37441,$.premultiplyAlpha),z.pixelStorei(3317,$.unpackAlignment);let bt=z.getParameter(3314),Cn=z.getParameter(32878),ti=z.getParameter(3316),Ks=z.getParameter(3315),Ra=z.getParameter(32877),Pn=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;z.pixelStorei(3314,Pn.width),z.pixelStorei(32878,Pn.height),z.pixelStorei(3316,N.min.x),z.pixelStorei(3315,N.min.y),z.pixelStorei(32877,N.min.z),oe.isDataTexture||oe.isData3DTexture?z.texSubImage3D(xt,ue,te.x,te.y,te.z,tt,at,ct,ft,Tt,Pn.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(xt,ue,te.x,te.y,te.z,tt,at,ct,ft,Pn.data)):z.texSubImage3D(xt,ue,te.x,te.y,te.z,tt,at,ct,ft,Tt,Pn),z.pixelStorei(3314,bt),z.pixelStorei(32878,Cn),z.pixelStorei(3316,ti),z.pixelStorei(3315,Ks),z.pixelStorei(32877,Ra),ue===0&&$.generateMipmaps&&z.generateMipmap(xt),k.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ce.setTextureCube(N,0):N.isData3DTexture?ce.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ce.setTexture2DArray(N,0):ce.setTexture2D(N,0),k.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,k.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var D0=class extends tx{};D0.prototype.isWebGL1Renderer=!0;var uc=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ne(t),this.near=e,this.far=n}clone(){return new uc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Or=class extends pt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},jp=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=g0,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ys()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ys()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ys()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Pr=new A,Xa=class{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Pr.fromBufferAttribute(this,e),Pr.applyMatrix4(t),this.setXYZ(e,Pr.x,Pr.y,Pr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Pr.fromBufferAttribute(this,e),Pr.applyNormalMatrix(t),this.setXYZ(e,Pr.x,Pr.y,Pr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Pr.fromBufferAttribute(this,e),Pr.transformDirection(t),this.setXYZ(e,Pr.x,Pr.y,Pr.z);return this}setX(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Ut(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=io(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=io(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=io(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=io(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ut(e,this.array),n=Ut(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ut(e,this.array),n=Ut(n,this.array),i=Ut(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ut(e,this.array),n=Ut(n,this.array),i=Ut(i,this.array),s=Ut(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Be(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Xa(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var qo=class extends Vt{constructor(t=null,e=1,n=1,i,s,o,a,l,u=Pt,c=Pt,d,h){super(null,o,a,l,u,c,i,s,d,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var qp=class extends Be{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var vi=class extends ja{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ne(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},sA=new A,oA=new A,aA=new ae,o0=new Fi,Mp=new Rn,Ya=class extends pt{constructor(t=new Me,e=new vi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let i=1,s=e.count;i<s;i++)sA.fromBufferAttribute(e,i-1),oA.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=sA.distanceTo(oA);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Mp.copy(n.boundingSphere),Mp.applyMatrix4(i),Mp.radius+=s,t.ray.intersectsSphere(Mp)===!1)return;aA.copy(i).invert(),o0.copy(t.ray).applyMatrix4(aA);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let y=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){let S=m.getX(x),_=m.getX(x+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,_),o0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(h);b<t.near||b>t.far||e.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),o0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let _=t.ray.origin.distanceTo(h);_<t.near||_>t.far||e.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},lA=new A,cA=new A,Xo=class extends Ya{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,s=e.count;i<s;i+=2)lA.fromBufferAttribute(e,i),cA.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+lA.distanceTo(cA);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Xp=class extends Vt{constructor(t,e,n,i,s,o,a,l,u){super(t,e,n,i,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:qe,this.magFilter=s!==void 0?s:qe,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var xi=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],h=n[i+1]-c,f=(o-c)/h;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new F:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,i=[],s=[],o=[],a=new A,l=new ae;for(let f=0;f<=t;f++){let m=f/t;i[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),d=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(zn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(zn(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Qa=class extends xi{constructor(t=0,e=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new F,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},I0=class extends Qa{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function nx(){let r=0,t=0,e=0,n=0;function i(s,o,a,l){r=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,i(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return r+t*s+e*o+n*a}}}var Ep=new A,a0=new nx,l0=new nx,c0=new nx,O0=class extends xi{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new A){let n=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=i[(a-1)%s]:(Ep.subVectors(i[0],i[1]).add(i[0]),u=Ep);let d=i[a%s],h=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Ep.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Ep),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(c),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),a0.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,m,p,g),l0.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,m,p,g),c0.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(a0.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),l0.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),c0.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(a0.calc(l),l0.calc(l),c0.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new A().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function uA(r,t,e,n,i){let s=(n-t)*.5,o=(i-e)*.5,a=r*r,l=r*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*r+e}function FB(r,t){let e=1-r;return e*e*t}function UB(r,t){return 2*(1-r)*r*t}function kB(r,t){return r*r*t}function hh(r,t,e,n){return FB(r,t)+UB(r,e)+kB(r,n)}function zB(r,t){let e=1-r;return e*e*e*t}function GB(r,t){let e=1-r;return 3*e*e*r*t}function VB(r,t){return 3*(1-r)*r*r*t}function HB(r,t){return r*r*r*t}function fh(r,t,e,n,i){return zB(r,t)+GB(r,e)+VB(r,n)+HB(r,i)}var Sr=class extends xi{constructor(t=new F,e=new F,n=new F,i=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(fh(t,i.x,s.x,o.x,a.x),fh(t,i.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Ka=class extends xi{constructor(t=new A,e=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(fh(t,i.x,s.x,o.x,a.x),fh(t,i.y,s.y,o.y,a.y),fh(t,i.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Ar=class extends xi{constructor(t=new F,e=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new F){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new F;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},xh=class extends xi{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},ai=class extends xi{constructor(t=new F,e=new F,n=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(hh(t,i.x,s.x,o.x),hh(t,i.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},R0=class extends xi{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(hh(t,i.x,s.x,o.x),hh(t,i.y,s.y,o.y),hh(t,i.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},dc=class extends xi{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new F){let n=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],d=i[o>i.length-3?i.length-1:o+2];return n.set(uA(a,l.x,u.x,c.x,d.x),uA(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new F().fromArray(i))}return this}},WB=Object.freeze({__proto__:null,ArcCurve:I0,CatmullRomCurve3:O0,CubicBezierCurve:Sr,CubicBezierCurve3:Ka,EllipseCurve:Qa,LineCurve:Ar,LineCurve3:xh,QuadraticBezierCurve:ai,QuadraticBezierCurve3:R0,SplineCurve:dc}),bh=class extends xi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ar(e,t))}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(e.push(c),n=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(new WB[i.type]().fromJSON(i))}return this}},Za=class extends bh{constructor(t){super(),this.type="Path",this.currentPoint=new F,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Ar(this.currentPoint.clone(),new F(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let s=new ai(this.currentPoint.clone(),new F(t,e),new F(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,o){let a=new Sr(this.currentPoint.clone(),new F(t,e),new F(n,i),new F(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new dc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,i,s,o),this}absarc(t,e,n,i,s,o){return this.absellipse(t,e,n,n,i,s,o),this}ellipse(t,e,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,i,s,o,a,l),this}absellipse(t,e,n,i,s,o,a,l){let u=new Qa(t,e,n,i,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},hc=class extends Me{constructor(t=[new F(0,-.5),new F(.5,0),new F(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=zn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new F,f=new A,m=new A,p=new A,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let v=0;v<=e;v++){let x=n+v*c*i,w=Math.sin(x),S=Math.cos(x);for(let _=0;_<=t.length-1;_++){d.x=t[_].x*w,d.y=t[_].y,d.z=t[_].x*S,o.push(d.x,d.y,d.z),h.x=v/e,h.y=_/(t.length-1),a.push(h.x,h.y);let M=l[3*_+0]*w,b=l[3*_+1],E=l[3*_+0]*S;u.push(M,b,E)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let w=x+v*t.length,S=w,_=w+t.length,M=w+t.length+1,b=w+1;s.push(S,_,b),s.push(M,b,_)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(u,3))}static fromJSON(t){return new hc(t.points,t.segments,t.phiStart,t.phiLength)}};var Ja=class extends Me{constructor(t=1,e=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],d=[],h=[],f=[],m=0,p=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function v(){let w=new A,S=new A,_=0,M=(e-t)/n;for(let b=0;b<=s;b++){let E=[],T=b/s,P=T*(e-t)+t;for(let D=0;D<=i;D++){let C=D/i,O=C*l+a,B=Math.sin(O),V=Math.cos(O);S.x=P*B,S.y=-T*n+g,S.z=P*V,d.push(S.x,S.y,S.z),w.set(B,M,V).normalize(),h.push(w.x,w.y,w.z),f.push(C,1-T),E.push(m++)}p.push(E)}for(let b=0;b<i;b++)for(let E=0;E<s;E++){let T=p[E][b],P=p[E+1][b],D=p[E+1][b+1],C=p[E][b+1];c.push(T,P,C),c.push(P,D,C),_+=6}u.addGroup(y,_,0),y+=_}function x(w){let S=m,_=new F,M=new A,b=0,E=w===!0?t:e,T=w===!0?1:-1;for(let D=1;D<=i;D++)d.push(0,g*T,0),h.push(0,T,0),f.push(.5,.5),m++;let P=m;for(let D=0;D<=i;D++){let O=D/i*l+a,B=Math.cos(O),V=Math.sin(O);M.x=E*V,M.y=g*T,M.z=E*B,d.push(M.x,M.y,M.z),h.push(0,T,0),_.x=B*.5+.5,_.y=V*.5*T+.5,f.push(_.x,_.y),m++}for(let D=0;D<i;D++){let C=S+D,O=P+D;w===!0?c.push(O,O+1,C):c.push(O+1,O,C),b+=3}u.addGroup(y,b,w===!0?1:2),y+=b}}static fromJSON(t){return new Ja(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},fc=class extends Ja{constructor(t=1,e=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new fc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},pc=class extends Me{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,w=new A,S=new A;for(let _=0;_<e.length;_+=3)f(e[_+0],x),f(e[_+1],w),f(e[_+2],S),l(x,w,S,v)}function l(v,x,w,S){let _=S+1,M=[];for(let b=0;b<=_;b++){M[b]=[];let E=v.clone().lerp(w,b/_),T=x.clone().lerp(w,b/_),P=_-b;for(let D=0;D<=P;D++)D===0&&b===_?M[b][D]=E:M[b][D]=E.clone().lerp(T,D/P)}for(let b=0;b<_;b++)for(let E=0;E<2*(_-b)-1;E++){let T=Math.floor(E/2);E%2===0?(h(M[b][T+1]),h(M[b+1][T]),h(M[b][T])):(h(M[b][T+1]),h(M[b+1][T+1]),h(M[b+1][T]))}}function u(v){let x=new A;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,S=y(v)/Math.PI+.5;o.push(w,1-S)}m(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],S=o[v+4],_=Math.max(x,w,S),M=Math.min(x,w,S);_>.9&&M<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function m(){let v=new A,x=new A,w=new A,S=new A,_=new F,M=new F,b=new F;for(let E=0,T=0;E<s.length;E+=9,T+=6){v.set(s[E+0],s[E+1],s[E+2]),x.set(s[E+3],s[E+4],s[E+5]),w.set(s[E+6],s[E+7],s[E+8]),_.set(o[T+0],o[T+1]),M.set(o[T+2],o[T+3]),b.set(o[T+4],o[T+5]),S.copy(v).add(x).add(w).divideScalar(3);let P=g(S);p(_,T+0,v,P),p(M,T+2,x,P),p(b,T+4,w,P)}}function p(v,x,w,S){S<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new pc(t.vertices,t.indices,t.radius,t.details)}},mc=class extends pc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new mc(t.radius,t.detail)}};var ao=class extends Za{constructor(t){super(t),this.uuid=ys(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(new Za().fromJSON(i))}return this}},jB={triangulate:function(r,t,e=2){let n=t&&t.length,i=n?t[0]*e:r.length,s=UA(r,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=KB(r,t,s,e)),r.length>80*e){a=u=r[0],l=c=r[1];for(let m=e;m<i;m+=e)d=r[m],h=r[m+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return wh(s,o,e,a,l,f,0),o}};function UA(r,t,e,n,i){let s,o;if(i===aF(r,t,e,n)>0)for(s=t;s<e;s+=n)o=dA(s,r[s],r[s+1],o);else for(s=e-n;s>=t;s-=n)o=dA(s,r[s],r[s+1],o);return o&&om(o,o.next)&&(Ah(o),o=o.next),o}function $a(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(om(e,e.next)||rn(e.prev,e,e.next)===0)){if(Ah(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function wh(r,t,e,n,i,s,o){if(!r)return;!o&&s&&tF(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?XB(r,n,i,s):qB(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),Ah(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=YB($a(r),t,e),wh(r,t,e,n,i,s,2)):o===2&&QB(r,t,e,n,i,s):wh($a(r),t,e,n,i,s,1);break}}}function qB(r){let t=r.prev,e=r,n=r.next;if(rn(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=i<s?i<o?i:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=i>s?i>o?i:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,m=n.next;for(;m!==t;){if(m.x>=c&&m.x<=h&&m.y>=d&&m.y<=f&&sc(i,a,s,l,o,u,m.x,m.y)&&rn(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function XB(r,t,e,n){let i=r.prev,s=r,o=r.next;if(rn(i,s,o)>=0)return!1;let a=i.x,l=s.x,u=o.x,c=i.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,m=c<d?c<h?c:h:d<h?d:h,p=a>l?a>u?a:u:l>u?l:u,g=c>d?c>h?c:h:d>h?d:h,y=L0(f,m,t,e,n),v=L0(p,g,t,e,n),x=r.prevZ,w=r.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&sc(a,c,l,d,u,h,x.x,x.y)&&rn(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==i&&w!==o&&sc(a,c,l,d,u,h,w.x,w.y)&&rn(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&sc(a,c,l,d,u,h,x.x,x.y)&&rn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==i&&w!==o&&sc(a,c,l,d,u,h,w.x,w.y)&&rn(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function YB(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!om(i,s)&&kA(i,n,n.next,s)&&Sh(i,s)&&Sh(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Ah(n),Ah(n.next),n=r=s),n=n.next}while(n!==r);return $a(n)}function QB(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&iF(o,a)){let l=zA(o,a);o=$a(o,o.next),l=$a(l,l.next),wh(o,t,e,n,i,s,0),wh(l,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function KB(r,t,e,n){let i=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:r.length,u=UA(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(rF(u));for(i.sort(ZB),s=0;s<i.length;s++)e=JB(i[s],e);return e}function ZB(r,t){return r.x-t.x}function JB(r,t){let e=$B(r,t);if(!e)return t;let n=zA(e,r);return $a(n,n.next),$a(e,e.next)}function $B(r,t){let e=t,n=-1/0,i,s=r.x,o=r.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,i=e.x<e.next.x?e:e.next,h===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,u=i.y,c=1/0,d;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&sc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),Sh(e,r)&&(d<c||d===c&&(e.x>i.x||e.x===i.x&&eF(i,e)))&&(i=e,c=d)),e=e.next;while(e!==a);return i}function eF(r,t){return rn(r.prev,r,t.prev)<0&&rn(t.next,r,r.next)<0}function tF(r,t,e,n){let i=r;do i.z===0&&(i.z=L0(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,nF(i)}function nF(r){let t,e,n,i,s,o,a,l,u=1;do{for(e=r,r=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,u*=2}while(o>1);return r}function L0(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function rF(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function sc(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function iF(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!sF(r,t)&&(Sh(r,t)&&Sh(t,r)&&oF(r,t)&&(rn(r.prev,r,t.prev)||rn(r,t.prev,t))||om(r,t)&&rn(r.prev,r,r.next)>0&&rn(t.prev,t,t.next)>0)}function rn(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function om(r,t){return r.x===t.x&&r.y===t.y}function kA(r,t,e,n){let i=Cp(rn(r,t,e)),s=Cp(rn(r,t,n)),o=Cp(rn(e,n,r)),a=Cp(rn(e,n,t));return!!(i!==s&&o!==a||i===0&&Tp(r,e,t)||s===0&&Tp(r,n,t)||o===0&&Tp(e,r,n)||a===0&&Tp(e,t,n))}function Tp(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Cp(r){return r>0?1:r<0?-1:0}function sF(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&kA(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Sh(r,t){return rn(r.prev,r,r.next)<0?rn(r,t,r.next)>=0&&rn(r,r.prev,t)>=0:rn(r,t,r.prev)<0||rn(r,r.next,t)<0}function oF(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function zA(r,t){let e=new N0(r.i,r.x,r.y),n=new N0(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function dA(r,t,e,n){let i=new N0(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ah(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function N0(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function aF(r,t,e,n){let i=0;for(let s=t,o=e-n;s<e;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var gc=class{static area(t){let e=t.length,n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return gc.area(t)<0}static triangulateShape(t,e){let n=[],i=[],s=[];hA(t),fA(n,t);let o=t.length;e.forEach(hA);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,fA(n,e[l]);let a=jB.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function hA(r){let t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function fA(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}var yc=class extends pc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new yc(t.radius,t.detail)}};var el=class extends Me{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],d=new A,h=new A,f=[],m=[],p=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,w=0;y==0&&o==0?w=.5/e:y==n&&l==Math.PI&&(w=-.5/e);for(let S=0;S<=e;S++){let _=S/e;d.x=-t*Math.cos(i+_*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(i+_*s)*Math.sin(o+x*a),m.push(d.x,d.y,d.z),h.copy(d).normalize(),p.push(h.x,h.y,h.z),g.push(_+w,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],w=c[y][v],S=c[y+1][v],_=c[y+1][v+1];(y!==0||o>0)&&f.push(x,w,_),(y!==n-1||l<Math.PI)&&f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(t){return new el(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var vc=class extends Me{constructor(t=1,e=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],d=new A,h=new A,f=new A,m=new A,p=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let w=x/n*s*Math.PI*2;v(w,s,o,t,f),v(w+.01,s,o,t,m),g.subVectors(m,f),y.addVectors(m,f),p.crossVectors(g,y),y.crossVectors(p,g),p.normalize(),y.normalize();for(let S=0;S<=i;++S){let _=S/i*Math.PI*2,M=-e*Math.cos(_),b=e*Math.sin(_);d.x=f.x+(M*y.x+b*p.x),d.y=f.y+(M*y.y+b*p.y),d.z=f.z+(M*y.z+b*p.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(S/i)}}for(let x=1;x<=n;x++)for(let w=1;w<=i;w++){let S=(i+1)*(x-1)+(w-1),_=(i+1)*x+(w-1),M=(i+1)*x+w,b=(i+1)*(x-1)+w;a.push(S,_,b),a.push(_,M,b)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(c,2));function v(x,w,S,_,M){let b=Math.cos(x),E=Math.sin(x),T=S/w*x,P=Math.cos(T);M.x=_*(2+P)*.5*b,M.y=_*(2+P)*E*.5,M.z=_*Math.sin(T)*.5}}static fromJSON(t){return new vc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Go(r,t,e){return GA(r)?new r.constructor(r.subarray(t,e!==void 0?e:r.length)):r.slice(t,e)}function Pp(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function GA(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var xc=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{e:{let o;t:{r:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break e}o=e.length;break t}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=e[--n-1],t>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},B0=class extends xc{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:A1,endingEnd:A1}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case _1:s=t,a=2*e-n;break;case M1:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case _1:o=t,l=2*n-e;break;case M1:o=1,l=n+i[1]-i[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(n-e)/(i-e),p=m*m,g=p*m,y=-h*g+2*h*p-h*m,v=(1+h)*g+(-1.5-2*h)*p+(-.5+h)*m+1,x=(-1-f)*g+(1.5+f)*p+.5*m,w=f*g-f*p;for(let S=0;S!==a;++S)s[S]=y*o[c+S]+v*o[u+S]+x*o[l+S]+w*o[d+S];return s}},F0=class extends xc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(i-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},U0=class extends xc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},zi=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Pp(e,this.TimeBufferType),this.values=Pp(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Pp(t.times,Array),values:Pp(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new U0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new F0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new B0(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Lp:e=this.InterpolantFactoryMethodDiscrete;break;case Np:e=this.InterpolantFactoryMethodLinear;break;case Nv:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Lp;case this.InterpolantFactoryMethodLinear:return Np;case this.InterpolantFactoryMethodSmooth:return Nv}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Go(n,s,o),this.values=Go(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&GA(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Go(this.times),e=Go(this.values),n=this.getValueSize(),i=this.getInterpolation()===Nv,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(i)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let m=0;m!==n;++m){let p=e[d+m];if(p!==e[h+m]||p!==e[f+m]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Go(t,0,o),this.values=Go(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=Go(this.times,0),e=Go(this.values,0),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};zi.prototype.TimeBufferType=Float32Array;zi.prototype.ValueBufferType=Float32Array;zi.prototype.DefaultInterpolation=Np;var tl=class extends zi{};tl.prototype.ValueTypeName="bool";tl.prototype.ValueBufferType=Array;tl.prototype.DefaultInterpolation=Lp;tl.prototype.InterpolantFactoryMethodLinear=void 0;tl.prototype.InterpolantFactoryMethodSmooth=void 0;var k0=class extends zi{};k0.prototype.ValueTypeName="color";var z0=class extends zi{};z0.prototype.ValueTypeName="number";var G0=class extends xc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e),u=t*a;for(let c=u+a;u!==c;u+=4)Je.slerpFlat(s,0,o,u-a,o,u,l);return s}},_h=class extends zi{InterpolantFactoryMethodLinear(t){return new G0(this.times,this.values,this.getValueSize(),t)}};_h.prototype.ValueTypeName="quaternion";_h.prototype.DefaultInterpolation=Np;_h.prototype.InterpolantFactoryMethodSmooth=void 0;var nl=class extends zi{};nl.prototype.ValueTypeName="string";nl.prototype.ValueBufferType=Array;nl.prototype.DefaultInterpolation=Lp;nl.prototype.InterpolantFactoryMethodLinear=void 0;nl.prototype.InterpolantFactoryMethodSmooth=void 0;var V0=class extends zi{};V0.prototype.ValueTypeName="vector";var pA={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(this.files[r]=t)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Mh=class{constructor(t,e,n){let i=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],m=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return m}return null}}},lF=new Mh,bc=class{constructor(t){this.manager=t!==void 0?t:lF,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},no={},H0=class extends Error{constructor(t,e){super(t),this.response=e}},wc=class extends bc{constructor(t){super(t)}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=pA.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(no[t]!==void 0){no[t].push({onLoad:e,onProgress:n,onError:i});return}no[t]=[],no[t].push({onLoad:e,onProgress:n,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=no[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,m=f!==0,p=0,g=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:w})=>{if(x)y.close();else{p+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let _=0,M=c.length;_<M;_++){let b=c[_];b.onProgress&&b.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw new H0(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(m=>f.decode(m))}}}).then(u=>{pA.add(t,u);let c=no[t];delete no[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=no[t];if(c===void 0)throw this.manager.itemError(t),u;delete no[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Yo=class extends pt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ne(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Yp=class extends Yo{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ne(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},u0=new ae,mA=new A,gA=new A,Eh=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new ae,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yh,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;mA.setFromMatrixPosition(t.matrixWorld),e.position.copy(mA),gA.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(gA),e.updateMatrixWorld(),u0.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(u0),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(u0)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},W0=class extends Eh{constructor(){super(new gn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=mh*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Qp=class extends Yo{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(pt.DEFAULT_UP),this.updateMatrix(),this.target=new pt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new W0}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},yA=new ae,oh=new A,d0=new A,j0=class extends Eh{constructor(){super(new gn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),oh.setFromMatrixPosition(t.matrixWorld),n.position.copy(oh),d0.copy(n.position),d0.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(d0),n.updateMatrixWorld(),i.makeTranslation(-oh.x,-oh.y,-oh.z),yA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yA)}},Kp=class extends Yo{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new j0}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},q0=class extends Eh{constructor(){super(new qa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Zp=class extends Yo{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(pt.DEFAULT_UP),this.updateMatrix(),this.target=new pt,this.shadow=new q0}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var X0=class extends Me{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Sc=class extends bc{constructor(t){super(t)}load(t,e,n,i){let s=this,o=new wc(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){let e={},n={};function i(f,m){if(e[m]!==void 0)return e[m];let g=f.interleavedBuffers[m],y=s(f,g.buffer),v=op(g.type,y),x=new jp(v,g.stride);return x.uuid=g.uuid,e[m]=x,x}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],y=new Uint32Array(g).buffer;return n[m]=y,y}let o=t.isInstancedBufferGeometry?new X0:new Me,a=t.data.index;if(a!==void 0){let f=op(a.type,a.array);o.setIndex(new Be(f,1))}let l=t.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(t.data,m.data);p=new Xa(g,m.itemSize,m.offset,m.normalized)}else{let g=op(m.type,m.array),y=m.isInstancedBufferAttribute?qp:Be;p=new y(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let u=t.data.morphAttributes;if(u)for(let f in u){let m=u[f],p=[];for(let g=0,y=m.length;g<y;g++){let v=m[g],x;if(v.isInterleavedBufferAttribute){let w=i(t.data,v.data);x=new Xa(w,v.itemSize,v.offset,v.normalized)}else{let w=op(v.type,v.array);x=new Be(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),p.push(x)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,m=d.length;f!==m;++f){let p=d[f];o.addGroup(p.start,p.count,p.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Rn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Jp=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vA(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=vA();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function vA(){return(typeof performance>"u"?Date:performance).now()}var rx="\\[\\]\\.:\\/",cF=new RegExp("["+rx+"]","g"),ix="[^"+rx+"]",uF="[^"+rx.replace("\\.","")+"]",dF=/((?:WC+[\/:])*)/.source.replace("WC",ix),hF=/(WCOD+)?/.source.replace("WCOD",uF),fF=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ix),pF=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ix),mF=new RegExp("^"+dF+hF+fF+pF+"$"),gF=["material","materials","bones","map"],Y0=class{constructor(t,e,n){let i=n||Rt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Rt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Rt.parseTrackName(e),this.node=Rt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Rt.Composite(t,e,n):new Rt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(cF,"")}static parseTrackName(t){let e=mF.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);gF.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=Rt.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[i];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Rt.Composite=Y0;Rt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Rt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Rt.prototype.GetterByBindingType=[Rt.prototype._getValue_direct,Rt.prototype._getValue_array,Rt.prototype._getValue_arrayElement,Rt.prototype._getValue_toArray];Rt.prototype.SetterByBindingTypeAndVersioning=[[Rt.prototype._setValue_direct,Rt.prototype._setValue_direct_setNeedsUpdate,Rt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_array,Rt.prototype._setValue_array_setNeedsUpdate,Rt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_arrayElement,Rt.prototype._setValue_arrayElement_setNeedsUpdate,Rt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_fromArray,Rt.prototype._setValue_fromArray_setNeedsUpdate,Rt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Oq=new Float32Array(1);var ie=class{constructor(t){this.value=t}clone(){return new ie(this.value.clone===void 0?this.value:this.value.clone())}};var Ac=class{constructor(t,e,n=0,i=1/0){this.ray=new Fi(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new gh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return Q0(t,this,n,e),n.sort(xA),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)Q0(t[i],this,n,e);return n.sort(xA),n}};function xA(r,t){return r.distance-t.distance}function Q0(r,t,e,n){if(r.layers.test(t.layers)&&r.raycast(t,e),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Q0(i[s],t,e,!0)}}var Th=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(zn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var bA=new F,$p=class{constructor(t=new F(1/0,1/0),e=new F(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=bA.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return bA.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},wA=new A,Dp=new A,Hn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){wA.subVectors(t,this.start),Dp.subVectors(this.end,this.start);let n=Dp.dot(Dp),s=Dp.dot(wA)/n;return e&&(s=zn(s,0,1)),s}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},SA=new A,em=class extends pt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Me,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Ae(i,3));let s=new vi({fog:!1,toneMapped:!1});this.cone=new Xo(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),SA.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(SA),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var tm=class extends In{constructor(t,e,n){let i=new el(e,4,2),s=new Ui({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var AA=new A,Ip=new A,_A=new A,nm=class extends pt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Me;i.setAttribute("position",new Ae([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new vi({fog:!1,toneMapped:!1});this.lightPlane=new Ya(i,s),this.add(this.lightPlane),i=new Me,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new Ya(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),AA.setFromMatrixPosition(this.light.matrixWorld),Ip.setFromMatrixPosition(this.light.target.matrixWorld),_A.subVectors(Ip,AA),this.lightPlane.lookAt(Ip),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(Ip),this.targetLine.scale.z=_A.length()}},Op=new A,on=new ki,Qo=class extends Xo{constructor(t){let e=new Me,n=new vi({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}e.setAttribute("position",new Ae(i,3)),e.setAttribute("color",new Ae(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Ne(16755200),c=new Ne(16711680),d=new Ne(43775),h=new Ne(16777215),f=new Ne(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,i=1;on.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mn("c",e,t,on,0,0,-1),mn("t",e,t,on,0,0,1),mn("n1",e,t,on,-n,-i,-1),mn("n2",e,t,on,n,-i,-1),mn("n3",e,t,on,-n,i,-1),mn("n4",e,t,on,n,i,-1),mn("f1",e,t,on,-n,-i,1),mn("f2",e,t,on,n,-i,1),mn("f3",e,t,on,-n,i,1),mn("f4",e,t,on,n,i,1),mn("u1",e,t,on,n*.7,i*1.1,-1),mn("u2",e,t,on,-n*.7,i*1.1,-1),mn("u3",e,t,on,0,i*2,-1),mn("cf1",e,t,on,-n,0,1),mn("cf2",e,t,on,n,0,1),mn("cf3",e,t,on,0,-i,1),mn("cf4",e,t,on,0,i,1),mn("cn1",e,t,on,-n,0,-1),mn("cn2",e,t,on,n,0,-1),mn("cn3",e,t,on,0,-i,-1),mn("cn4",e,t,on,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mn(r,t,e,n,i,s,o){Op.set(i,s,o).unproject(n);let a=t[r];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Op.x,Op.y,Op.z)}}var Ko=class extends Xo{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Me;s.setIndex(new Be(n,1)),s.setAttribute("position",new Ae(i,3)),super(s,new vi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var rm=class extends Xo{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Me;i.setAttribute("position",new Ae(e,3)),i.setAttribute("color",new Ae(n,3));let s=new vi({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){let i=new Ne,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:lo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=lo);var Ec=".",Ch=Symbol("target"),sx=Symbol("unsubscribe");function Ph(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function VA(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var ci=Array.isArray;function rl(r){return typeof r=="symbol"}var yF={after:(r,t)=>ci(r)?r.slice(t.length):t===""?r:r.slice(t.length+1),concat:(r,t)=>ci(r)?(r=[...r],t&&r.push(t),r):t&&t.toString!==void 0?(r!==""&&(r+=Ec),rl(t)?r+t.toString():r+t):r,initial:r=>{if(ci(r))return r.slice(0,-1);if(r==="")return r;let t=r.lastIndexOf(Ec);return t===-1?"":r.slice(0,t)},last:r=>{if(ci(r))return r[r.length-1]||"";if(r==="")return r;let t=r.lastIndexOf(Ec);return t===-1?r:r.slice(t+1)},walk:(r,t)=>{if(ci(r))for(let e of r)t(e);else if(r!==""){let e=0,n=r.indexOf(Ec);if(n===-1)t(r);else for(;e<r.length;)n===-1&&(n=r.length),t(r.slice(e,n)),e=n+1,n=r.indexOf(Ec,e)}},get(r,t){return this.walk(t,e=>{r&&(r=r[e])}),r}},Rr=yF;function ox(r){return typeof r=="object"&&typeof r.next=="function"}function ax(r,t,e,n,i){let s=r.next;if(t.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],n),o.value[1]=i(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[Ch].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,n)),o};return r}function am(r,t,e){return r.isUnsubscribed||t.ignoreSymbols&&rl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Dh=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),i=n[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),n[e]=i),i}getProxy(t,e,n,i){if(this.isUnsubscribed)return t;let s=t[i],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,n):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Rr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,i,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,i):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let i=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Tc(r){return toString.call(r)==="[object Object]"}function Cc(){return!0}function Zo(r,t){return r.length!==t.length||r.some((e,n)=>t[n]!==e)}var lm=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var vF=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),lx={push:Cc,pop:Cc,shift:Cc,unshift:Cc,copyWithin:Zo,reverse:Zo,sort:Zo,splice:Zo,flat:Zo,fill:Zo},HA=new Set([...lm,...vF,...Object.keys(lx)]);function Pc(r,t){if(r.size!==t.size)return!0;for(let e of r)if(!t.has(e))return!0;return!1}var cx=["keys","values","entries"],ux=new Set(["has","toString"]),dx={add:Pc,clear:Pc,delete:Pc,forEach:Pc},WA=new Set([...ux,...Object.keys(dx),...cx]);function Dc(r,t){if(r.size!==t.size)return!0;let e;for(let[n,i]of r)if(e=t.get(n),e!==i||e===void 0&&!t.has(n))return!0;return!1}var xF=new Set([...ux,"get"]),hx={set:Dc,clear:Dc,delete:Dc,forEach:Dc},jA=new Set([...xF,...Object.keys(hx),...cx]);var nr=class{constructor(t,e,n,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return lm.has(t)}_shallowClone(t){let e=t;if(Tc(t))e={...t};else if(ci(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,i]of t.entries())e.set(n,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,i){return t?(ci(i)?this._onIsChanged=lx[e]:i instanceof Set?this._onIsChanged=dx[e]:i instanceof Map&&(this._onIsChanged=hx[e]),i):n}update(t,e,n){let i=Rr.after(t,this._path);if(e!=="length"){let s=this.clone;Rr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],Rr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Ic=class extends nr{static isHandledMethod(t){return HA.has(t)}};var Ih=class extends nr{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Oc=class extends nr{static isHandledMethod(t){return WA.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var Rc=class extends nr{static isHandledMethod(t){return jA.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var Oh=class extends nr{constructor(t,e,n,i){super(void 0,e,n,i),this._arg1=n[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var Rh=class extends nr{constructor(t,e,n,i){super(void 0,e,n,i),this._weakKey=n[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Vi=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Tc(t)||ci(t)||Ph(t)}static isHandledMethod(t,e){return Tc(t)?nr.isHandledMethod(e):ci(t)?Ic.isHandledMethod(e):t instanceof Set?Oc.isHandledMethod(e):t instanceof Map?Rc.isHandledMethod(e):Ph(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let i=nr;ci(t)?i=Ic:t instanceof Date?i=Ih:t instanceof Set?i=Oc:t instanceof Map?i=Rc:t instanceof WeakSet?i=Oh:t instanceof WeakMap&&(i=Rh),this._stack.push(new i(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:i}=t,s=Vi.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var bF={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},fx=(r,t,e={})=>{e={...bF,...e};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new Dh(i),u=typeof e.onValidate=="function",c=new Vi(u),d=(v,x,w,S,_)=>!u||c.isCloning||e.onValidate(Rr.concat(l.getPath(v),x),w,S,_)===!0,h=(v,x,w,S)=>{!am(l,e,x)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,_)=>{c.isCloning?c.update(v,x,S):t(Rr.concat(v,x),w,S,_)},m=v=>v&&(v[n]||v),p=(v,x,w,S)=>VA(v)||w==="constructor"||s&&!Vi.isHandledMethod(x,w)||am(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,r)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,Rr.concat(S,w),g,n)),g={get(v,x,w){if(rl(x)){if(x===n||x===Ch)return v;if(x===sx&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Ph(v)?Reflect.get(v,x):Reflect.get(v,x,w);return p(S,v,x)},set(v,x,w,S){w=m(w);let _=v[n]||v,M=_[x];if(i(M,w)&&x in v)return!0;let b=d(v,x,w,M);return b&&l.setProperty(_,x,w,S,M)?(h(v,x,v[x],M),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];d(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&h(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=d(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(h(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&Vi.isHandledType(S)){let _=Rr.initial(l.getPath(v)),M=Vi.isHandledMethod(S,v.name);c.start(S,_,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),M?w.map(P=>m(P)):w),E=c.isChanged(S,i),T=c.stop();if(Vi.isHandledType(b)&&M&&(x instanceof Map&&v.name==="get"&&(_=Rr.concat(_,w[0])),b=l.getProxy(b,_,g)),E){let P={name:v.name,args:w,result:b},D=c.isCloning?Rr.initial(_):_,C=c.isCloning?Rr.last(_):"";d(Rr.get(r,D),C,S,T,P)?f(D,C,S,T,P):c.undo(S)}return(x instanceof Map||x instanceof Set)&&ox(b)?ax(b,v,x,_,p):b}return Reflect.apply(v,x,w)}},y=l.getProxy(r,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};fx.target=r=>r&&r[Ch]||r;fx.unsubscribe=r=>r[sx]||r;var px=fx;var wF=typeof global=="object"&&global&&global.Object===Object&&global,cm=wF;var SF=typeof self=="object"&&self&&self.Object===Object&&self,AF=cm||SF||Function("return this")(),ln=AF;var _F=ln.Symbol,rr=_F;var qA=Object.prototype,MF=qA.hasOwnProperty,EF=qA.toString,Lh=rr?rr.toStringTag:void 0;function TF(r){var t=MF.call(r,Lh),e=r[Lh];try{r[Lh]=void 0;var n=!0}catch{}var i=EF.call(r);return n&&(t?r[Lh]=e:delete r[Lh]),i}var XA=TF;var CF=Object.prototype,PF=CF.toString;function DF(r){return PF.call(r)}var YA=DF;var IF="[object Null]",OF="[object Undefined]",QA=rr?rr.toStringTag:void 0;function RF(r){return r==null?r===void 0?OF:IF:QA&&QA in Object(r)?XA(r):YA(r)}var ui=RF;function LF(r){return r!=null&&typeof r=="object"}var mr=LF;var NF="[object Symbol]";function BF(r){return typeof r=="symbol"||mr(r)&&ui(r)==NF}var Jo=BF;function FF(r,t){for(var e=-1,n=r==null?0:r.length,i=Array(n);++e<n;)i[e]=t(r[e],e,r);return i}var um=FF;var UF=Array.isArray,Wn=UF;var kF=1/0,KA=rr?rr.prototype:void 0,ZA=KA?KA.toString:void 0;function JA(r){if(typeof r=="string")return r;if(Wn(r))return um(r,JA)+"";if(Jo(r))return ZA?ZA.call(r):"";var t=r+"";return t=="0"&&1/r==-kF?"-0":t}var $A=JA;var zF=/\s/;function GF(r){for(var t=r.length;t--&&zF.test(r.charAt(t)););return t}var e_=GF;var VF=/^\s+/;function HF(r){return r&&r.slice(0,e_(r)+1).replace(VF,"")}var t_=HF;function WF(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var Ln=WF;var n_=0/0,jF=/^[-+]0x[0-9a-f]+$/i,qF=/^0b[01]+$/i,XF=/^0o[0-7]+$/i,YF=parseInt;function QF(r){if(typeof r=="number")return r;if(Jo(r))return n_;if(Ln(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=Ln(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=t_(r);var e=qF.test(r);return e||XF.test(r)?YF(r.slice(2),e?2:8):jF.test(r)?n_:+r}var mx=QF;function KF(r){return r}var r_=KF;var ZF="[object AsyncFunction]",JF="[object Function]",$F="[object GeneratorFunction]",eU="[object Proxy]";function tU(r){if(!Ln(r))return!1;var t=ui(r);return t==JF||t==$F||t==ZF||t==eU}var dm=tU;var nU=ln["__core-js_shared__"],hm=nU;var i_=function(){var r=/[^.]+$/.exec(hm&&hm.keys&&hm.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function rU(r){return!!i_&&i_ in r}var s_=rU;var iU=Function.prototype,sU=iU.toString;function oU(r){if(r!=null){try{return sU.call(r)}catch{}try{return r+""}catch{}}return""}var co=oU;var aU=/[\\^$.*+?()[\]{}|]/g,lU=/^\[object .+?Constructor\]$/,cU=Function.prototype,uU=Object.prototype,dU=cU.toString,hU=uU.hasOwnProperty,fU=RegExp("^"+dU.call(hU).replace(aU,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pU(r){if(!Ln(r)||s_(r))return!1;var t=dm(r)?fU:lU;return t.test(co(r))}var o_=pU;function mU(r,t){return r?.[t]}var a_=mU;function gU(r,t){var e=a_(r,t);return o_(e)?e:void 0}var Vr=gU;var yU=Vr(ln,"WeakMap"),fm=yU;var l_=Object.create,vU=function(){function r(){}return function(t){if(!Ln(t))return{};if(l_)return l_(t);r.prototype=t;var e=new r;return r.prototype=void 0,e}}(),c_=vU;function xU(r,t,e){switch(e.length){case 0:return r.call(t);case 1:return r.call(t,e[0]);case 2:return r.call(t,e[0],e[1]);case 3:return r.call(t,e[0],e[1],e[2])}return r.apply(t,e)}var u_=xU;function bU(r,t){var e=-1,n=r.length;for(t||(t=Array(n));++e<n;)t[e]=r[e];return t}var d_=bU;var wU=800,SU=16,AU=Date.now;function _U(r){var t=0,e=0;return function(){var n=AU(),i=SU-(n-e);if(e=n,i>0){if(++t>=wU)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var h_=_U;function MU(r){return function(){return r}}var f_=MU;var EU=function(){try{var r=Vr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Lc=EU;var TU=Lc?function(r,t){return Lc(r,"toString",{configurable:!0,enumerable:!1,value:f_(t),writable:!0})}:r_,p_=TU;var CU=h_(p_),m_=CU;function PU(r,t){for(var e=-1,n=r==null?0:r.length;++e<n&&t(r[e],e,r)!==!1;);return r}var g_=PU;var DU=9007199254740991,IU=/^(?:0|[1-9]\d*)$/;function OU(r,t){var e=typeof r;return t=t??DU,!!t&&(e=="number"||e!="symbol"&&IU.test(r))&&r>-1&&r%1==0&&r<t}var Nc=OU;function RU(r,t,e){t=="__proto__"&&Lc?Lc(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e}var pm=RU;function LU(r,t){return r===t||r!==r&&t!==t}var Bc=LU;var NU=Object.prototype,BU=NU.hasOwnProperty;function FU(r,t,e){var n=r[t];(!(BU.call(r,t)&&Bc(n,e))||e===void 0&&!(t in r))&&pm(r,t,e)}var Fc=FU;function UU(r,t,e,n){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],r[a],a,e,r):void 0;l===void 0&&(l=r[a]),i?pm(e,a,l):Fc(e,a,l)}return e}var xs=UU;var y_=Math.max;function kU(r,t,e){return t=y_(t===void 0?r.length-1:t,0),function(){for(var n=arguments,i=-1,s=y_(n.length-t,0),o=Array(s);++i<s;)o[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=e(o),u_(r,this,a)}}var v_=kU;var zU=9007199254740991;function GU(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=zU}var Uc=GU;function VU(r){return r!=null&&Uc(r.length)&&!dm(r)}var mm=VU;var HU=Object.prototype;function WU(r){var t=r&&r.constructor,e=typeof t=="function"&&t.prototype||HU;return r===e}var kc=WU;function jU(r,t){for(var e=-1,n=Array(r);++e<r;)n[e]=t(e);return n}var x_=jU;var qU="[object Arguments]";function XU(r){return mr(r)&&ui(r)==qU}var gx=XU;var b_=Object.prototype,YU=b_.hasOwnProperty,QU=b_.propertyIsEnumerable,KU=gx(function(){return arguments}())?gx:function(r){return mr(r)&&YU.call(r,"callee")&&!QU.call(r,"callee")},zc=KU;function ZU(){return!1}var w_=ZU;var __=typeof exports=="object"&&exports&&!exports.nodeType&&exports,S_=__&&typeof module=="object"&&module&&!module.nodeType&&module,JU=S_&&S_.exports===__,A_=JU?ln.Buffer:void 0,$U=A_?A_.isBuffer:void 0,ek=$U||w_,il=ek;var tk="[object Arguments]",nk="[object Array]",rk="[object Boolean]",ik="[object Date]",sk="[object Error]",ok="[object Function]",ak="[object Map]",lk="[object Number]",ck="[object Object]",uk="[object RegExp]",dk="[object Set]",hk="[object String]",fk="[object WeakMap]",pk="[object ArrayBuffer]",mk="[object DataView]",gk="[object Float32Array]",yk="[object Float64Array]",vk="[object Int8Array]",xk="[object Int16Array]",bk="[object Int32Array]",wk="[object Uint8Array]",Sk="[object Uint8ClampedArray]",Ak="[object Uint16Array]",_k="[object Uint32Array]",Xt={};Xt[gk]=Xt[yk]=Xt[vk]=Xt[xk]=Xt[bk]=Xt[wk]=Xt[Sk]=Xt[Ak]=Xt[_k]=!0;Xt[tk]=Xt[nk]=Xt[pk]=Xt[rk]=Xt[mk]=Xt[ik]=Xt[sk]=Xt[ok]=Xt[ak]=Xt[lk]=Xt[ck]=Xt[uk]=Xt[dk]=Xt[hk]=Xt[fk]=!1;function Mk(r){return mr(r)&&Uc(r.length)&&!!Xt[ui(r)]}var M_=Mk;function Ek(r){return function(t){return r(t)}}var Gc=Ek;var E_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Nh=E_&&typeof module=="object"&&module&&!module.nodeType&&module,Tk=Nh&&Nh.exports===E_,yx=Tk&&cm.process,Ck=function(){try{var r=Nh&&Nh.require&&Nh.require("util").types;return r||yx&&yx.binding&&yx.binding("util")}catch{}}(),uo=Ck;var T_=uo&&uo.isTypedArray,Pk=T_?Gc(T_):M_,gm=Pk;var Dk=Object.prototype,Ik=Dk.hasOwnProperty;function Ok(r,t){var e=Wn(r),n=!e&&zc(r),i=!e&&!n&&il(r),s=!e&&!n&&!i&&gm(r),o=e||n||i||s,a=o?x_(r.length,String):[],l=a.length;for(var u in r)(t||Ik.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Nc(u,l)))&&a.push(u);return a}var ym=Ok;function Rk(r,t){return function(e){return r(t(e))}}var vm=Rk;var Lk=vm(Object.keys,Object),C_=Lk;var Nk=Object.prototype,Bk=Nk.hasOwnProperty;function Fk(r){if(!kc(r))return C_(r);var t=[];for(var e in Object(r))Bk.call(r,e)&&e!="constructor"&&t.push(e);return t}var P_=Fk;function Uk(r){return mm(r)?ym(r):P_(r)}var Vc=Uk;function kk(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var D_=kk;var zk=Object.prototype,Gk=zk.hasOwnProperty;function Vk(r){if(!Ln(r))return D_(r);var t=kc(r),e=[];for(var n in r)n=="constructor"&&(t||!Gk.call(r,n))||e.push(n);return e}var I_=Vk;function Hk(r){return mm(r)?ym(r,!0):I_(r)}var Hc=Hk;var Wk=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jk=/^\w*$/;function qk(r,t){if(Wn(r))return!1;var e=typeof r;return e=="number"||e=="symbol"||e=="boolean"||r==null||Jo(r)?!0:jk.test(r)||!Wk.test(r)||t!=null&&r in Object(t)}var O_=qk;var Xk=Vr(Object,"create"),ho=Xk;function Yk(){this.__data__=ho?ho(null):{},this.size=0}var R_=Yk;function Qk(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}var L_=Qk;var Kk="__lodash_hash_undefined__",Zk=Object.prototype,Jk=Zk.hasOwnProperty;function $k(r){var t=this.__data__;if(ho){var e=t[r];return e===Kk?void 0:e}return Jk.call(t,r)?t[r]:void 0}var N_=$k;var ez=Object.prototype,tz=ez.hasOwnProperty;function nz(r){var t=this.__data__;return ho?t[r]!==void 0:tz.call(t,r)}var B_=nz;var rz="__lodash_hash_undefined__";function iz(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=ho&&t===void 0?rz:t,this}var F_=iz;function Wc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}Wc.prototype.clear=R_;Wc.prototype.delete=L_;Wc.prototype.get=N_;Wc.prototype.has=B_;Wc.prototype.set=F_;var vx=Wc;function sz(){this.__data__=[],this.size=0}var U_=sz;function oz(r,t){for(var e=r.length;e--;)if(Bc(r[e][0],t))return e;return-1}var $o=oz;var az=Array.prototype,lz=az.splice;function cz(r){var t=this.__data__,e=$o(t,r);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():lz.call(t,e,1),--this.size,!0}var k_=cz;function uz(r){var t=this.__data__,e=$o(t,r);return e<0?void 0:t[e][1]}var z_=uz;function dz(r){return $o(this.__data__,r)>-1}var G_=dz;function hz(r,t){var e=this.__data__,n=$o(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}var V_=hz;function jc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}jc.prototype.clear=U_;jc.prototype.delete=k_;jc.prototype.get=z_;jc.prototype.has=G_;jc.prototype.set=V_;var ea=jc;var fz=Vr(ln,"Map"),ta=fz;function pz(){this.size=0,this.__data__={hash:new vx,map:new(ta||ea),string:new vx}}var H_=pz;function mz(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}var W_=mz;function gz(r,t){var e=r.__data__;return W_(t)?e[typeof t=="string"?"string":"hash"]:e.map}var na=gz;function yz(r){var t=na(this,r).delete(r);return this.size-=t?1:0,t}var j_=yz;function vz(r){return na(this,r).get(r)}var q_=vz;function xz(r){return na(this,r).has(r)}var X_=xz;function bz(r,t){var e=na(this,r),n=e.size;return e.set(r,t),this.size+=e.size==n?0:1,this}var Y_=bz;function qc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}qc.prototype.clear=H_;qc.prototype.delete=j_;qc.prototype.get=q_;qc.prototype.has=X_;qc.prototype.set=Y_;var sl=qc;var wz="Expected a function";function xx(r,t){if(typeof r!="function"||t!=null&&typeof t!="function")throw new TypeError(wz);var e=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=e.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return e.cache=s.set(i,o)||s,o};return e.cache=new(xx.Cache||sl),e}xx.Cache=sl;var Q_=xx;var Sz=500;function Az(r){var t=Q_(r,function(n){return e.size===Sz&&e.clear(),n}),e=t.cache;return t}var K_=Az;var _z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Mz=/\\(\\)?/g,Ez=K_(function(r){var t=[];return r.charCodeAt(0)===46&&t.push(""),r.replace(_z,function(e,n,i,s){t.push(i?s.replace(Mz,"$1"):n||e)}),t}),Z_=Ez;function Tz(r){return r==null?"":$A(r)}var J_=Tz;function Cz(r,t){return Wn(r)?r:O_(r,t)?[r]:Z_(J_(r))}var bi=Cz;var Pz=1/0;function Dz(r){if(typeof r=="string"||Jo(r))return r;var t=r+"";return t=="0"&&1/r==-Pz?"-0":t}var ra=Dz;function Iz(r,t){t=bi(t,r);for(var e=0,n=t.length;r!=null&&e<n;)r=r[ra(t[e++])];return e&&e==n?r:void 0}var xm=Iz;function Oz(r,t){for(var e=-1,n=t.length,i=r.length;++e<n;)r[i+e]=t[e];return r}var Xc=Oz;var $_=rr?rr.isConcatSpreadable:void 0;function Rz(r){return Wn(r)||zc(r)||!!($_&&r&&r[$_])}var eM=Rz;function tM(r,t,e,n,i){var s=-1,o=r.length;for(e||(e=eM),i||(i=[]);++s<o;){var a=r[s];t>0&&e(a)?t>1?tM(a,t-1,e,n,i):Xc(i,a):n||(i[i.length]=a)}return i}var nM=tM;function Lz(r){var t=r==null?0:r.length;return t?nM(r,1):[]}var rM=Lz;function Nz(r){return m_(v_(r,void 0,rM),r+"")}var bm=Nz;var Bz=vm(Object.getPrototypeOf,Object),Yc=Bz;var Fz="[object Object]",Uz=Function.prototype,kz=Object.prototype,iM=Uz.toString,zz=kz.hasOwnProperty,Gz=iM.call(Object);function Vz(r){if(!mr(r)||ui(r)!=Fz)return!1;var t=Yc(r);if(t===null)return!0;var e=zz.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&iM.call(e)==Gz}var sM=Vz;function Hz(r,t,e){var n=-1,i=r.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+t];return s}var oM=Hz;function Wz(){this.__data__=new ea,this.size=0}var aM=Wz;function jz(r){var t=this.__data__,e=t.delete(r);return this.size=t.size,e}var lM=jz;function qz(r){return this.__data__.get(r)}var cM=qz;function Xz(r){return this.__data__.has(r)}var uM=Xz;var Yz=200;function Qz(r,t){var e=this.__data__;if(e instanceof ea){var n=e.__data__;if(!ta||n.length<Yz-1)return n.push([r,t]),this.size=++e.size,this;e=this.__data__=new sl(n)}return e.set(r,t),this.size=e.size,this}var dM=Qz;function Qc(r){var t=this.__data__=new ea(r);this.size=t.size}Qc.prototype.clear=aM;Qc.prototype.delete=lM;Qc.prototype.get=cM;Qc.prototype.has=uM;Qc.prototype.set=dM;var Kc=Qc;function Kz(r,t){return r&&xs(t,Vc(t),r)}var hM=Kz;function Zz(r,t){return r&&xs(t,Hc(t),r)}var fM=Zz;var yM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pM=yM&&typeof module=="object"&&module&&!module.nodeType&&module,Jz=pM&&pM.exports===yM,mM=Jz?ln.Buffer:void 0,gM=mM?mM.allocUnsafe:void 0;function $z(r,t){if(t)return r.slice();var e=r.length,n=gM?gM(e):new r.constructor(e);return r.copy(n),n}var vM=$z;function eG(r,t){for(var e=-1,n=r==null?0:r.length,i=0,s=[];++e<n;){var o=r[e];t(o,e,r)&&(s[i++]=o)}return s}var xM=eG;function tG(){return[]}var wm=tG;var nG=Object.prototype,rG=nG.propertyIsEnumerable,bM=Object.getOwnPropertySymbols,iG=bM?function(r){return r==null?[]:(r=Object(r),xM(bM(r),function(t){return rG.call(r,t)}))}:wm,Zc=iG;function sG(r,t){return xs(r,Zc(r),t)}var wM=sG;var oG=Object.getOwnPropertySymbols,aG=oG?function(r){for(var t=[];r;)Xc(t,Zc(r)),r=Yc(r);return t}:wm,Sm=aG;function lG(r,t){return xs(r,Sm(r),t)}var SM=lG;function cG(r,t,e){var n=t(r);return Wn(r)?n:Xc(n,e(r))}var Am=cG;function uG(r){return Am(r,Vc,Zc)}var Bh=uG;function dG(r){return Am(r,Hc,Sm)}var _m=dG;var hG=Vr(ln,"DataView"),Mm=hG;var fG=Vr(ln,"Promise"),Em=fG;var pG=Vr(ln,"Set"),Tm=pG;var AM="[object Map]",mG="[object Object]",_M="[object Promise]",MM="[object Set]",EM="[object WeakMap]",TM="[object DataView]",gG=co(Mm),yG=co(ta),vG=co(Em),xG=co(Tm),bG=co(fm),ol=ui;(Mm&&ol(new Mm(new ArrayBuffer(1)))!=TM||ta&&ol(new ta)!=AM||Em&&ol(Em.resolve())!=_M||Tm&&ol(new Tm)!=MM||fm&&ol(new fm)!=EM)&&(ol=function(r){var t=ui(r),e=t==mG?r.constructor:void 0,n=e?co(e):"";if(n)switch(n){case gG:return TM;case yG:return AM;case vG:return _M;case xG:return MM;case bG:return EM}return t});var fo=ol;var wG=Object.prototype,SG=wG.hasOwnProperty;function AG(r){var t=r.length,e=new r.constructor(t);return t&&typeof r[0]=="string"&&SG.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var CM=AG;var _G=ln.Uint8Array,Jc=_G;function MG(r){var t=new r.constructor(r.byteLength);return new Jc(t).set(new Jc(r)),t}var $c=MG;function EG(r,t){var e=t?$c(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var PM=EG;var TG=/\w*$/;function CG(r){var t=new r.constructor(r.source,TG.exec(r));return t.lastIndex=r.lastIndex,t}var DM=CG;var IM=rr?rr.prototype:void 0,OM=IM?IM.valueOf:void 0;function PG(r){return OM?Object(OM.call(r)):{}}var RM=PG;function DG(r,t){var e=t?$c(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var LM=DG;var IG="[object Boolean]",OG="[object Date]",RG="[object Map]",LG="[object Number]",NG="[object RegExp]",BG="[object Set]",FG="[object String]",UG="[object Symbol]",kG="[object ArrayBuffer]",zG="[object DataView]",GG="[object Float32Array]",VG="[object Float64Array]",HG="[object Int8Array]",WG="[object Int16Array]",jG="[object Int32Array]",qG="[object Uint8Array]",XG="[object Uint8ClampedArray]",YG="[object Uint16Array]",QG="[object Uint32Array]";function KG(r,t,e){var n=r.constructor;switch(t){case kG:return $c(r);case IG:case OG:return new n(+r);case zG:return PM(r,e);case GG:case VG:case HG:case WG:case jG:case qG:case XG:case YG:case QG:return LM(r,e);case RG:return new n;case LG:case FG:return new n(r);case NG:return DM(r);case BG:return new n;case UG:return RM(r)}}var NM=KG;function ZG(r){return typeof r.constructor=="function"&&!kc(r)?c_(Yc(r)):{}}var BM=ZG;var JG="[object Map]";function $G(r){return mr(r)&&fo(r)==JG}var FM=$G;var UM=uo&&uo.isMap,eV=UM?Gc(UM):FM,kM=eV;var tV="[object Set]";function nV(r){return mr(r)&&fo(r)==tV}var zM=nV;var GM=uo&&uo.isSet,rV=GM?Gc(GM):zM,VM=rV;var iV=1,sV=2,oV=4,HM="[object Arguments]",aV="[object Array]",lV="[object Boolean]",cV="[object Date]",uV="[object Error]",WM="[object Function]",dV="[object GeneratorFunction]",hV="[object Map]",fV="[object Number]",jM="[object Object]",pV="[object RegExp]",mV="[object Set]",gV="[object String]",yV="[object Symbol]",vV="[object WeakMap]",xV="[object ArrayBuffer]",bV="[object DataView]",wV="[object Float32Array]",SV="[object Float64Array]",AV="[object Int8Array]",_V="[object Int16Array]",MV="[object Int32Array]",EV="[object Uint8Array]",TV="[object Uint8ClampedArray]",CV="[object Uint16Array]",PV="[object Uint32Array]",jt={};jt[HM]=jt[aV]=jt[xV]=jt[bV]=jt[lV]=jt[cV]=jt[wV]=jt[SV]=jt[AV]=jt[_V]=jt[MV]=jt[hV]=jt[fV]=jt[jM]=jt[pV]=jt[mV]=jt[gV]=jt[yV]=jt[EV]=jt[TV]=jt[CV]=jt[PV]=!0;jt[uV]=jt[WM]=jt[vV]=!1;function Cm(r,t,e,n,i,s){var o,a=t&iV,l=t&sV,u=t&oV;if(e&&(o=i?e(r,n,i,s):e(r)),o!==void 0)return o;if(!Ln(r))return r;var c=Wn(r);if(c){if(o=CM(r),!a)return d_(r,o)}else{var d=fo(r),h=d==WM||d==dV;if(il(r))return vM(r,a);if(d==jM||d==HM||h&&!i){if(o=l||h?{}:BM(r),!a)return l?SM(r,fM(o,r)):wM(r,hM(o,r))}else{if(!jt[d])return i?r:{};o=NM(r,d,a)}}s||(s=new Kc);var f=s.get(r);if(f)return f;s.set(r,o),VM(r)?r.forEach(function(g){o.add(Cm(g,t,e,g,r,s))}):kM(r)&&r.forEach(function(g,y){o.set(y,Cm(g,t,e,y,r,s))});var m=u?l?_m:Bh:l?Hc:Vc,p=c?void 0:m(r);return g_(p||r,function(g,y){p&&(y=g,g=r[y]),Fc(o,y,Cm(g,t,e,y,r,s))}),o}var Pm=Cm;var DV=1,IV=4;function OV(r){return Pm(r,DV|IV)}var po=OV;var RV="__lodash_hash_undefined__";function LV(r){return this.__data__.set(r,RV),this}var qM=LV;function NV(r){return this.__data__.has(r)}var XM=NV;function Dm(r){var t=-1,e=r==null?0:r.length;for(this.__data__=new sl;++t<e;)this.add(r[t])}Dm.prototype.add=Dm.prototype.push=qM;Dm.prototype.has=XM;var YM=Dm;function BV(r,t){for(var e=-1,n=r==null?0:r.length;++e<n;)if(t(r[e],e,r))return!0;return!1}var QM=BV;function FV(r,t){return r.has(t)}var KM=FV;var UV=1,kV=2;function zV(r,t,e,n,i,s){var o=e&UV,a=r.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(r),c=s.get(t);if(u&&c)return u==t&&c==r;var d=-1,h=!0,f=e&kV?new YM:void 0;for(s.set(r,t),s.set(t,r);++d<a;){var m=r[d],p=t[d];if(n)var g=o?n(p,m,d,t,r,s):n(m,p,d,r,t,s);if(g!==void 0){if(g)continue;h=!1;break}if(f){if(!QM(t,function(y,v){if(!KM(f,v)&&(m===y||i(m,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(m===p||i(m,p,e,n,s))){h=!1;break}}return s.delete(r),s.delete(t),h}var Im=zV;function GV(r){var t=-1,e=Array(r.size);return r.forEach(function(n,i){e[++t]=[i,n]}),e}var ZM=GV;function VV(r){var t=-1,e=Array(r.size);return r.forEach(function(n){e[++t]=n}),e}var JM=VV;var HV=1,WV=2,jV="[object Boolean]",qV="[object Date]",XV="[object Error]",YV="[object Map]",QV="[object Number]",KV="[object RegExp]",ZV="[object Set]",JV="[object String]",$V="[object Symbol]",e4="[object ArrayBuffer]",t4="[object DataView]",$M=rr?rr.prototype:void 0,bx=$M?$M.valueOf:void 0;function n4(r,t,e,n,i,s,o){switch(e){case t4:if(r.byteLength!=t.byteLength||r.byteOffset!=t.byteOffset)return!1;r=r.buffer,t=t.buffer;case e4:return!(r.byteLength!=t.byteLength||!s(new Jc(r),new Jc(t)));case jV:case qV:case QV:return Bc(+r,+t);case XV:return r.name==t.name&&r.message==t.message;case KV:case JV:return r==t+"";case YV:var a=ZM;case ZV:var l=n&HV;if(a||(a=JM),r.size!=t.size&&!l)return!1;var u=o.get(r);if(u)return u==t;n|=WV,o.set(r,t);var c=Im(a(r),a(t),n,i,s,o);return o.delete(r),c;case $V:if(bx)return bx.call(r)==bx.call(t)}return!1}var eE=n4;var r4=1,i4=Object.prototype,s4=i4.hasOwnProperty;function o4(r,t,e,n,i,s){var o=e&r4,a=Bh(r),l=a.length,u=Bh(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:s4.call(t,h)))return!1}var f=s.get(r),m=s.get(t);if(f&&m)return f==t&&m==r;var p=!0;s.set(r,t),s.set(t,r);for(var g=o;++d<l;){h=a[d];var y=r[h],v=t[h];if(n)var x=o?n(v,y,h,t,r,s):n(y,v,h,r,t,s);if(!(x===void 0?y===v||i(y,v,e,n,s):x)){p=!1;break}g||(g=h=="constructor")}if(p&&!g){var w=r.constructor,S=t.constructor;w!=S&&"constructor"in r&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(p=!1)}return s.delete(r),s.delete(t),p}var tE=o4;var a4=1,nE="[object Arguments]",rE="[object Array]",Om="[object Object]",l4=Object.prototype,iE=l4.hasOwnProperty;function c4(r,t,e,n,i,s){var o=Wn(r),a=Wn(t),l=o?rE:fo(r),u=a?rE:fo(t);l=l==nE?Om:l,u=u==nE?Om:u;var c=l==Om,d=u==Om,h=l==u;if(h&&il(r)){if(!il(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new Kc),o||gm(r)?Im(r,t,e,n,i,s):eE(r,t,l,e,n,i,s);if(!(e&a4)){var f=c&&iE.call(r,"__wrapped__"),m=d&&iE.call(t,"__wrapped__");if(f||m){var p=f?r.value():r,g=m?t.value():t;return s||(s=new Kc),i(p,g,e,n,s)}}return h?(s||(s=new Kc),tE(r,t,e,n,i,s)):!1}var sE=c4;function oE(r,t,e,n,i){return r===t?!0:r==null||t==null||!mr(r)&&!mr(t)?r!==r&&t!==t:sE(r,t,e,n,oE,i)}var aE=oE;function u4(r,t){return r!=null&&t in Object(r)}var lE=u4;function d4(r,t,e){t=bi(t,r);for(var n=-1,i=t.length,s=!1;++n<i;){var o=ra(t[n]);if(!(s=r!=null&&e(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&Uc(i)&&Nc(o,i)&&(Wn(r)||zc(r)))}var cE=d4;function h4(r,t){return r!=null&&cE(r,t,lE)}var uE=h4;var f4=function(){return ln.Date.now()},Rm=f4;var p4="Expected a function",m4=Math.max,g4=Math.min;function y4(r,t,e){var n,i,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(p4);t=mx(t)||0,Ln(e)&&(c=!!e.leading,d="maxWait"in e,s=d?m4(mx(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(_){var M=n,b=i;return n=i=void 0,u=_,o=r.apply(b,M),o}function m(_){return u=_,a=setTimeout(y,t),c?f(_):o}function p(_){var M=_-l,b=_-u,E=t-M;return d?g4(E,s-b):E}function g(_){var M=_-l,b=_-u;return l===void 0||M>=t||M<0||d&&b>=s}function y(){var _=Rm();if(g(_))return v(_);a=setTimeout(y,p(_))}function v(_){return a=void 0,h&&n?f(_):(n=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function w(){return a===void 0?o:v(Rm())}function S(){var _=Rm(),M=g(_);if(n=arguments,i=this,l=_,M){if(a===void 0)return m(l);if(d)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return S.cancel=x,S.flush=w,S}var al=y4;function v4(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}var dE=v4;function x4(r,t){return t.length<2?r:xm(r,oM(t,0,-1))}var hE=x4;function b4(r,t){return aE(r,t)}var ll=b4;function w4(r,t){return t=bi(t,r),r=hE(r,t),r==null||delete r[ra(dE(t))]}var fE=w4;function S4(r){return sM(r)?void 0:r}var pE=S4;var A4=1,_4=2,M4=4,E4=bm(function(r,t){var e={};if(r==null)return e;var n=!1;t=um(t,function(s){return s=bi(s,r),n||(n=s.length>1),s}),xs(r,_m(r),e),n&&(e=Pm(e,A4|_4|M4,pE));for(var i=t.length;i--;)fE(e,t[i]);return e}),eu=E4;function T4(r,t,e,n){if(!Ln(r))return r;t=bi(t,r);for(var i=-1,s=t.length,o=s-1,a=r;a!=null&&++i<s;){var l=ra(t[i]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Ln(c)?c:Nc(t[i+1])?[]:{})}Fc(a,l,u),a=a[l]}return r}var mE=T4;function C4(r,t,e){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=xm(r,o);e(a,o)&&mE(s,bi(o,r),a)}return s}var gE=C4;function P4(r,t){return gE(r,t,function(e,n){return uE(r,n)})}var yE=P4;var D4=bm(function(r,t){return r==null?{}:yE(r,t)}),ia=D4;var I4="Expected a function";function O4(r,t,e){var n=!0,i=!0;if(typeof r!="function")throw new TypeError(I4);return Ln(e)&&(n="leading"in e?!!e.leading:n,i="trailing"in e?!!e.trailing:i),al(r,t,{leading:n,maxWait:t,trailing:i})}var wx=O4;function vE(r){for(let t of Object.keys(r))r[t]===void 0&&delete r[t];return r}function Hi(r,t){return Object.setPrototypeOf(r,t),r}var R4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),L4=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),N4=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||cl&&"ontouchend"in document,B4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,F4=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,U4=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(t)},k4=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},Iee=R4(),cl=L4(),Lm=N4(),xE=B4(),jn=F4(),Sx=U4(),Ax=Number(k4());function Nm(r){return Array.isArray(r)?r:[r]}function bE(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}function Fh(r){return cl?r.metaKey:r.ctrlKey}var ke=[],Fm={},Uh={},Bm={};function wE(r){ke.includes(r)||ke.push(r)}function tu(r){delete Fm[r.pointerId];for(let t=0;t<ke.length;t++)if(ke[t].pointerId===r.pointerId){ke.splice(t,1);break}}function SE(){ke.splice(0,ke.length)}function Um(r){if(r.pointerType!=="touch")return;let t=Fm[r.pointerId];t===void 0&&(t={x:0,y:0},Fm[r.pointerId]=t),t.x=r.pageX,t.y=r.pageY}function km(r){let t=r.pointerId===ke[0].pointerId?ke[1]:ke[0];return Fm[t.pointerId]}function AE(r){Uh[r.key]=!0,Bm[r.key]=Bm[r.key]===void 0?1:Bm[r.key]+1}function _E(r){if(cl&&Uh.Meta)for(let t in Uh)Uh[t]=!1;else Uh[r.key]=!1;Bm={}}function ME(r){r.addEventListener("pointerdown",wE,!0),r.addEventListener("pointerdown",Um,!0),r.addEventListener("pointermove",Um,!0),r.addEventListener("pointerup",tu,!0),r.addEventListener("pointercancel",tu,!0),r.addEventListener("pointerleave",tu,!0),window.addEventListener("keydown",AE,!0),window.addEventListener("keyup",_E,!0)}function EE(r){r.removeEventListener("pointerdown",wE,!0),r.removeEventListener("pointerdown",Um,!0),r.removeEventListener("pointermove",Um,!0),r.removeEventListener("pointerup",tu,!0),r.removeEventListener("pointercancel",tu,!0),r.removeEventListener("pointerleave",tu,!0),window.removeEventListener("keydown",AE,!0),window.removeEventListener("keyup",_E,!0)}var CE,PE=new Promise(r=>{CE=r}),TE=!1;async function DE(){if(TE)return;let t=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.382/build",[e,n]=await Promise.all([import("./navmesh.js"),fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});CE(s),TE=!0}var OE,RE=new Promise(r=>{OE=r}),IE=!1;async function LE(){if(IE)return;let r=await import("./physics.js");await r.init(),OE(r),IE=!0}var Ft=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,Ft.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let n=e[t.id],i;n===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,Ft.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:n}=t,i=e[n];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Ft.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:i}}}}return null}};function kh(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let t=Object.getOwnPropertyNames(r);for(let e of t){let n=r[e];n&&typeof n=="object"&&kh(n)}return Object.freeze(r)}function NE(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}var nu=class extends Error{};function zm(r){let t={...r};return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}function bs(r,t,e){if(r===void 0?t===void 0?(r=0,t=10):r=t-10:t===void 0&&(t=r+10),r>t){let s=r;r=t,t=s}let n=[],i=1/(e+1);for(let s=0;s<e;s++){let o=r+(t-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function ru(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function BE(){return typeof process<"u"}function FE(r,t){for(let e of r)t(e.id,e.data)!==!0&&FE(e.children,t)}function UE(r,t){if(t(r.id,r.data)!==!0)for(let e of r.children)UE(e,t)}var Zt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Zt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kh(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,n){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}isDescendantOf(e,n){for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,n){if(e===null)this.traverse(n);else{let i=this.get(e);i&&UE(i,n)}}traverse(e){FE(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let i=e,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,Zt.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:n}){if(this.get(e)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:n,fi:i,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:i,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:n,fi:i,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new nu("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,m)=>f.fi-m.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>NE(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(e){var n=e;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(e,n,i){return this.insertAfterHelper(e,this.previous(e,n),i)}insertAfterHelper(e,n,i){let s=this.childrenArray(e);if(n===null){if(s.length===0)return bs(0,i,i);{let o=s[0].fi;return bs(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return bs(l,l+i,i)}else return bs(o.fi,a.fi,i)}}};var iu;(t=>{function r(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let i=n.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=r})(iu||(iu={}));var We=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kh(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,We.prototype);let n=e;return BE()||n.fillCaches(),n}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:n,id:i,data:s}=e,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:n}=e,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:i}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===e)return n;n=i.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let i=this;if(e===null){if(i.length===0)return bs(0,n,n);{let s=i[0].fi;return bs(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return bs(a,a+n,n)}else return bs(s.fi,o.fi,n)}}};function su(r){return r&&typeof r=="object"&&r instanceof Jt}var Jt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,i=0,s={};for(;i<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[i]],n!==void 0&&!su(n))return null;i+=1}n=n?zm(n):new Jt;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;i>0;){if(Object.keys(n).length===0){let l=e[i-1];l&&(n=zm(l),delete n[t.path[i-1]])}else{let l=e[i-1];if(l){let u=zm(l);u[t.path[i-1]]=n,n=u}else{let u=new Jt;u[t.path[i-1]]=n,n=u}}i-=1}let o=Object.setPrototypeOf(n,Jt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},mo;(n=>{function r(i,s){return zh(i,s)??i}n.apply=r;function t(i,s){return Mx(i,s)}n.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=Lr.zoomOnce(l,a[o]),l===void 0)return s;if(!su(l))return;o+=1}if(l===void 0)return s;if(!!su(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=_x([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(mo||(mo={}));function _x(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=zh(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=_x(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return n}function z4(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=zh(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function zh(r,t){if(!su(t))return t;if(r instanceof Zt){let e=_x(r,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else{if(r instanceof We)return z4(r,t);if(Array.isArray(r)){let e=!1,n=r.map((i,s)=>{let o=zh(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else{if(r instanceof Jt)return Mx(r,t);if(r&&typeof r=="object"){let e={},n=!1;for(let[i,s]of Object.entries(r)){let o=zh(s,t[i]);n=n||o!==void 0,o===void 0&&(o=s),e[i]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e):void 0}}}}function Mx(r,t){if(r===void 0)return t;if(t===void 0)return r;if(!su(t))return t;if(!su(r))return mo.apply(r,t);let e=new Set;for(let i of Object.keys(r))e.add(i);for(let i of Object.keys(t))e.add(i);let n=new Jt;for(let i of e){let s=Mx(r===void 0?void 0:r[i],t===void 0?void 0:t[i]);n[i]=s}return n}function kE(r,t){let e={cur:[],result:[],len:0};return r=Gh(r,t,e)??r,[r,e.result]}function Gm(r,t){return r===null?null:(r.cur[r.len]=t,r.len+=1,r)}function Vm(r){r&&(r.len-=1)}function G4(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function zE(r,t,e){let n=!1,i=r.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Gh(s.data,t,Gm(e,o));Vm(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=zE(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function V4(r,t,e){let n=!1,i=r.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Gh(s.data,t,Gm(e,o));return Vm(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function Gh(r,t,e){if(r instanceof Zt){let n=zE(r,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof We)return V4(r,t,e);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=Gh(s,t,Gm(e,o));return Vm(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"&&!ru(r)){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=Gh(o,t,Gm(e,s));Vm(e),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=t[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");G4(e)}return n}else return}}var Hm;(t=>{function r(e,n){let i=Lr.zoom(n,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=r})(Hm||(Hm={}));var gr;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof Jt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof Zt||l instanceof We||l instanceof Ft?h=l.runOp(u):h=iu.runOp(l,u)),h!==void 0)if(h!==null){let p=h.data;for(let g=d.length-1;g>=0;g--){let y=c[g],v=d[g];if(v instanceof Zt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof We){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Ft){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Jt){let x={...v,[y]:p};p=Object.setPrototypeOf(x,Jt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=p;p=[...v],p[y]=x}else p={...v,[y]:p};else return null}return{data:p,actual:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],m;if(l instanceof Zt){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof We){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)d.push(l),l=m;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function i(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(gr||(gr={}));var Ex;(l=>{function r(){return[]}l.empty=r;function t(u,c){let d=[];for(let h of u){let[f,...m]=h.path;f===c&&d.push({...h,path:m})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(h=>!c.some(f=>gr.subsumed(h,f))),...c]}l.compress=i;function s(u,c){return u.every(d=>c.every(h=>gr.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],f=[];for(let m of c)try{if(m.type===3){let p=Lr.zoom(d,[...m.path,m.id]),g=gr.apply(d,{...m,type:2});if(g!==null){d=g.data;let[y,v]=kE(d,{[m.id]:p});d=y;for(let x of v){let w=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[w]:p}}),f.push({type:0,path:x,props:{[w]:m.id}})}f.push(g.reverse),h.push(g.actual)}}else{let p=gr.apply(d,m);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof nu)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(Ex||(Ex={}));var GE=Symbol(),H4=Symbol(),jm=Symbol(),ul=class{reportOp(t,e,n=[]){let i=this;if(e===null)return;i._current=e.data;let s=n;for(;!(i instanceof Wm);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[jm];n&&n(),delete this._children[t]}}}},Cx=class extends ul{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,iu.runOp(this._current,t),t.path)}},Px=class extends ul{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Ft.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},VE={get(r,t){if(t===jm)return()=>{r._parent=null};if(t===GE)return r._current;if(t===H4)return r;let{_current:e,_children:n}=r;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e[t],o=qm(r,t,s);return o!==s?(n===void 0&&(n={},r._children=n),n[t]=o,o):s},has(r,t){return t in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,t){let e=r._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},W4={...VE,set(r,t,e){let n={type:0,props:{[t]:ir(e)??e}};return r.deleteChildren(t),r.runOp(n),!0},deleteProperty(r,t){let e={type:0,props:{[t]:void 0}};return r.deleteChildren(t),r.runOp(e),!0}},j4={...VE,set(r,t,e){return e===void 0?this.deleteProperty(r,t):(r.deleteChildren(t),r.runOp({type:1,id:t,data:e})),!0},deleteProperty(r,t){return r.runOp({type:2,id:t}),!0}},ou=class extends ul{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[jm]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=qm(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,i,s){this.runOp({type:7,parent:t,fi:e,id:n,data:i,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}moveBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},au=class extends ul{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[jm]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),i,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id;if(t(this.data(i),i))return this.get(i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:n}=this,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=qm(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Tx(r,t,e){if(r.length>0){let n=r[r.length-1];if(n.type===0&&t.type===0&&Lr.equal(n.path,e)){Object.assign(n.props,t.props);return}}r.push({...t,path:e})}var Wm=class extends ul{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,n,i){Tx(this.ts,e,t),Tx(this.actual,n,t),Tx(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function qm(r,t,e){return e instanceof Zt?new ou(r,t,e):e instanceof We?new au(r,t,e):e instanceof Ft?new Proxy(new Px(r,t,e),j4):e!==null&&typeof e=="object"?ru(e)?e:new Proxy(new Cx(r,t,e),W4):e}function Dx(r){let t=new Wm(r);return[qm(t,"",r),t]}function lu(r,t){let[e,n]=Dx(r);return t(e),n.result()}function ir(r){return r instanceof ou||r instanceof au?r._current:r!==null&&typeof r=="object"?r[GE]:r}var Lr;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function t(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof Zt||s instanceof ou)&&typeof o=="string")return s.data(o);if((s instanceof We||s instanceof au)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=n})(Lr||(Lr={}));function HE(r,t){let e=[];if(t.length===r.length)for(var n=0;n<r.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}function Wi(r,t){let e=[];if(t.length<=r.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}var Xm=class{},Vh=class extends Xm{constructor(e){super();this.id=e}},Hh=class extends Xm{constructor(e){super();this.data=e}};var Ox;try{Ox=new TextDecoder}catch{}var Ie,oa,J=0;var ZE=[],Rx=ZE,Lx=0,Hr={},Ct,sa,wi=0,ws=0,di,go,Nr=[],Lt,WE={useRecords:!1,mapsAsObjects:!0},Wh=class{},Bx=new Wh;Bx.name="MessagePack 0xC1";var cu=!1,Ss=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Ie)return nT(()=>(Qm(),this?this.unpack(t,e):Ss.prototype.unpack.call(WE,t,e)));oa=e>-1?e:t.length,J=0,Lx=0,ws=0,sa=null,Rx=ZE,di=null,Ie=t;try{Lt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Ie=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ss){if(Hr=this,this.structures)return Ct=this.structures,Ym();(!Ct||Ct.length>0)&&(Ct=[])}else Hr=WE,(!Ct||Ct.length>0)&&(Ct=[]);return Ym()}unpackMultiple(t,e){let n,i=0;try{cu=!0;let s=t.length,o=this?this.unpack(t,s):Jm.unpack(t,s);if(e){for(e(o);J<s;)if(i=J,e(Ym())===!1)return}else{for(n=[o];J<s;)i=J,n.push(Ym());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{cu=!1,Qm()}}_mergeStructures(t,e){t=t||[];for(let n=0,i=t.length;n<i;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let i=t[n],s=e[n];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[n]=i),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ym(){try{if(!Hr.trusted&&!cu){let t=Ct.sharedLength||0;t<Ct.length&&(Ct.length=t)}let r=cn();if(J==oa)Ct.restoreStructures&&jE(),Ct=null,Ie=null,go&&(go=null);else if(J>oa){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!cu)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw Ct.restoreStructures&&jE(),Qm(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function jE(){for(let r in Ct.restoreStructures)Ct[r]=Ct.restoreStructures[r];Ct.restoreStructures=null}function cn(){let r=Ie[J++];if(r<160)if(r<128){if(r<64)return r;{let t=Ct[r&63]||Hr.getStructures&&JE()[r&63];return t?(t.read||(t.read=Fx(t,r&63)),t.read()):r}}else if(r<144)if(r-=128,Hr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[eT()]=cn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(cn(),cn());return t}else{r-=144;let t=new Array(r);for(let e=0;e<r;e++)t[e]=cn();return t}else if(r<192){let t=r-160;if(ws>=J)return sa.slice(J-wi,(J+=t)-wi);if(ws==0&&oa<140){let e=t<16?Ux(t):$E(t);if(e!=null)return e}return Nx(t)}else{let t;switch(r){case 192:return null;case 193:return di?(t=cn(),t>0?di[1].slice(di.position1,di.position1+=t):di[0].slice(di.position0,di.position0-=t)):Bx;case 194:return!1;case 195:return!0;case 196:return Ix(Ie[J++]);case 197:return t=Lt.getUint16(J),J+=2,Ix(t);case 198:return t=Lt.getUint32(J),J+=4,Ix(t);case 199:return dl(Ie[J++]);case 200:return t=Lt.getUint16(J),J+=2,dl(t);case 201:return t=Lt.getUint32(J),J+=4,dl(t);case 202:if(t=Lt.getFloat32(J),Hr.useFloat32>2){let e=Zm[(Ie[J]&127)<<1|Ie[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=Lt.getFloat64(J),J+=8,t;case 204:return Ie[J++];case 205:return t=Lt.getUint16(J),J+=2,t;case 206:return t=Lt.getUint32(J),J+=4,t;case 207:return Hr.int64AsNumber?(t=Lt.getUint32(J)*4294967296,t+=Lt.getUint32(J+4)):t=Lt.getBigUint64(J),J+=8,t;case 208:return Lt.getInt8(J++);case 209:return t=Lt.getInt16(J),J+=2,t;case 210:return t=Lt.getInt32(J),J+=4,t;case 211:return Hr.int64AsNumber?(t=Lt.getInt32(J)*4294967296,t+=Lt.getUint32(J+4)):t=Lt.getBigInt64(J),J+=8,t;case 212:if(t=Ie[J++],t==114)return KE(Ie[J++]&63);{let e=Nr[t];if(e)return e.read?(J++,e.read(cn())):e.noBuffer?(J++,e()):e(Ie.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=Ie[J],t==114?(J++,KE(Ie[J++]&63,Ie[J++])):dl(2);case 214:return dl(4);case 215:return dl(8);case 216:return dl(16);case 217:return t=Ie[J++],ws>=J?sa.slice(J-wi,(J+=t)-wi):X4(t);case 218:return t=Lt.getUint16(J),J+=2,ws>=J?sa.slice(J-wi,(J+=t)-wi):Y4(t);case 219:return t=Lt.getUint32(J),J+=4,ws>=J?sa.slice(J-wi,(J+=t)-wi):Q4(t);case 220:return t=Lt.getUint16(J),J+=2,XE(t);case 221:return t=Lt.getUint32(J),J+=4,XE(t);case 222:return t=Lt.getUint16(J),J+=2,YE(t);case 223:return t=Lt.getUint32(J),J+=4,YE(t);default:if(r>=224)return r-256;if(r===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+r)}}}var q4=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Fx(r,t){function e(){if(e.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>q4.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(cn);return r.highByte===0&&(r.read=qE(t,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=cn()}return n}return e.count=0,r.highByte===0?qE(t,e):e}var qE=(r,t)=>function(){let e=Ie[J++];if(e===0)return t();let n=r<32?-(r+(e<<5)):r+(e<<5),i=Ct[n]||JE()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=Fx(i,r)),i.read()};function JE(){let r=nT(()=>(Ie=null,Hr.getStructures()));return Ct=Hr._mergeStructures(r,Ct)}var Nx=Km,X4=Km,Y4=Km,Q4=Km;function Km(r){let t;if(r<16&&(t=Ux(r)))return t;if(r>64&&Ox)return Ox.decode(Ie.subarray(J,J+=r));let e=J+r,n=[];for(t="";J<e;){let i=Ie[J++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Ie[J++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Ie[J++]&63,o=Ie[J++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ie[J++]&63,o=Ie[J++]&63,a=Ie[J++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(t+=sr.apply(String,n),n.length=0)}return n.length>0&&(t+=sr.apply(String,n)),t}function XE(r){let t=new Array(r);for(let e=0;e<r;e++)t[e]=cn();return t}function YE(r){if(Hr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[eT()]=cn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(cn(),cn());return t}}var sr=String.fromCharCode;function $E(r){let t=J,e=new Array(r);for(let n=0;n<r;n++){let i=Ie[J++];if((i&128)>0){J=t;return}e[n]=i}return sr.apply(String,e)}function Ux(r){if(r<4)if(r<2){if(r===0)return"";{let t=Ie[J++];if((t&128)>1){J-=1;return}return sr(t)}}else{let t=Ie[J++],e=Ie[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(r<3)return sr(t,e);let n=Ie[J++];if((n&128)>0){J-=3;return}return sr(t,e,n)}else{let t=Ie[J++],e=Ie[J++],n=Ie[J++],i=Ie[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(i&128)>0){J-=4;return}if(r<6){if(r===4)return sr(t,e,n,i);{let s=Ie[J++];if((s&128)>0){J-=5;return}return sr(t,e,n,i,s)}}else if(r<8){let s=Ie[J++],o=Ie[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(r<7)return sr(t,e,n,i,s,o);let a=Ie[J++];if((a&128)>0){J-=7;return}return sr(t,e,n,i,s,o,a)}else{let s=Ie[J++],o=Ie[J++],a=Ie[J++],l=Ie[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(r<10){if(r===8)return sr(t,e,n,i,s,o,a,l);{let u=Ie[J++];if((u&128)>0){J-=9;return}return sr(t,e,n,i,s,o,a,l,u)}}else if(r<12){let u=Ie[J++],c=Ie[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(r<11)return sr(t,e,n,i,s,o,a,l,u,c);let d=Ie[J++];if((d&128)>0){J-=11;return}return sr(t,e,n,i,s,o,a,l,u,c,d)}else{let u=Ie[J++],c=Ie[J++],d=Ie[J++],h=Ie[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(r<14){if(r===12)return sr(t,e,n,i,s,o,a,l,u,c,d,h);{let f=Ie[J++];if((f&128)>0){J-=13;return}return sr(t,e,n,i,s,o,a,l,u,c,d,h,f)}}else{let f=Ie[J++],m=Ie[J++];if((f&128)>0||(m&128)>0){J-=14;return}if(r<15)return sr(t,e,n,i,s,o,a,l,u,c,d,h,f,m);let p=Ie[J++];if((p&128)>0){J-=15;return}return sr(t,e,n,i,s,o,a,l,u,c,d,h,f,m,p)}}}}}function Ix(r){return Hr.copyBuffers?Uint8Array.prototype.slice.call(Ie,J,J+=r):Ie.subarray(J,J+=r)}function dl(r){let t=Ie[J++];if(Nr[t])return Nr[t](Ie.subarray(J,J+=r));throw new Error("Unknown extension type "+t)}var QE=new Array(4096);function eT(){let r=Ie[J++];if(r>=160&&r<192){if(r=r-160,ws>=J)return sa.slice(J-wi,(J+=r)-wi);if(!(ws==0&&oa<180))return Nx(r)}else return J--,cn();let t=(r<<5^(r>1?Lt.getUint16(J):r>0?Ie[J]:0))&4095,e=QE[t],n=J,i=J+r-3,s,o=0;if(e&&e.bytes==r){for(;n<i;){if(s=Lt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Ie[n++],s!=e[o++]){n=1879048192;break}if(n===i)return J=n,e.string;i-=3,n=J}for(e=[],QE[t]=e,e.bytes=r;n<i;)s=Lt.getUint32(n),e.push(s),n+=4;for(i+=3;n<i;)s=Ie[n++],e.push(s);let a=r<16?Ux(r):$E(r);return a!=null?e.string=a:e.string=Nx(r)}var KE=(r,t)=>{var e=cn();let n=r;t!==void 0&&(r=r<32?-((t<<5)+r):(t<<5)+r,e.highByte=t);let i=Ct[r];return i&&i.isShared&&((Ct.restoreStructures||(Ct.restoreStructures=[]))[r]=i),Ct[r]=e,e.read=Fx(e,n),e.read()},tT=typeof self=="object"?self:global;Nr[0]=()=>{};Nr[0].noBuffer=!0;Nr[101]=()=>{let r=cn();return(tT[r[0]]||Error)(r[1])};Nr[105]=r=>{let t=Lt.getUint32(J-4);go||(go=new Map);let e=Ie[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let i={target:n};go.set(t,i);let s=cn();return i.used?Object.assign(n,s):(i.target=s,s)};Nr[112]=r=>{let t=Lt.getUint32(J-4),e=go.get(t);return e.used=!0,e.target};Nr[115]=()=>new Set(cn());var kx=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");Nr[116]=r=>{let t=r[0],e=kx[t];if(!e)throw new Error("Could not find typed array for code "+t);return new tT[e](Uint8Array.prototype.slice.call(r,1).buffer)};Nr[120]=()=>{let r=cn();return new RegExp(r[0],r[1])};Nr[98]=r=>{let t=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],e=J;J+=t-4,di=[cn(),cn()],di.position0=0,di.position1=0;let n=J;J=e;try{return cn()}finally{J=n}};Nr[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function nT(r){let t=oa,e=J,n=Lx,i=wi,s=ws,o=sa,a=Rx,l=go,u=di,c=new Uint8Array(Ie.slice(0,oa)),d=Ct,h=Ct.slice(0,Ct.length),f=Hr,m=cu,p=r();return oa=t,J=e,Lx=n,wi=i,ws=s,sa=o,Rx=a,go=l,di=u,Ie=c,cu=m,Ct=d,Ct.splice(0,Ct.length,...h),Hr=f,Lt=new DataView(Ie.buffer,Ie.byteOffset,Ie.byteLength),p}function Qm(){Ie=null,go=null,Ct=null}function rT(r){r.unpack?Nr[r.type]=r.unpack:Nr[r.type]=r}var Zm=new Array(147);for(let r=0;r<256;r++)Zm[r]=+("1e"+Math.floor(45.15-r*.30103));var Jm=new Ss({useRecords:!1}),K4=Jm.unpack,Z4=Jm.unpackMultiple,J4=Jm.unpack,$m={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},$4=new Float32Array(1),Vte=new Uint8Array($4.buffer,0,4);var eg;try{eg=new TextEncoder}catch{}var tg,Gx,ng=typeof Buffer<"u",zx=ng?Buffer.allocUnsafeSlow:Uint8Array,aT=ng?Buffer:Uint8Array,iT=ng?4294967296:2144337920,le,vn,ne=0,As,_s=null,eH=/[\u0080-\uFFFF]/,jh=Symbol("record-id"),hl=class extends Ss{constructor(t){super(t),this.offset=0;let e,n,i,s,o,a,l=0,u=aT.prototype.utf8Write?function(b,E,T){return le.utf8Write(b,E,T)}:eg&&eg.encodeInto?function(b,E){return eg.encodeInto(b,le.subarray(E)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=t.maxOwnStructures;m==null&&(m=h?32:64),d&&!t.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,y=f+m+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,w=0;this.pack=this.encode=function(b,E){if(le||(le=new zx(8192),vn=new DataView(le.buffer,0,8192),ne=0),As=le.length-10,As-ne<2048?(le=new zx(le.length),vn=new DataView(le.buffer,0,le.length),As=le.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(_s=["",""],le[ne++]=214,le[ne++]=98,_s.position=ne-n,ne+=4):_s=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let T=i.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let P=0;P<T;P++){let D=i[P];if(!D)continue;let C,O=i.transitions;for(let B=0,V=D.length;B<V;B++){let Y=D[B];C=O[Y],C||(C=O[Y]=Object.create(null)),O=C}O[jh]=P+64}l=T}d||(i.nextId=T+64)}s&&(s=!1),o=i||[];try{if(S(b),_s){vn.setUint32(_s.position+n,ne-_s.position-n);let T=_s;_s=null,S(T[0]),S(T[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>As&&M(ne),c.offset=ne;let T=nH(le.subarray(n,ne),a.idsToInsert);return a=null,T}return E&cT?(le.start=n,le.end=ne,le):le.subarray(n,ne)}finally{if(i){if(w<10&&w++,x>1e4)i.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let T=0,P=v.length;T<P;T++)v[T][jh]=0;v=[]}if(s&&c.saveStructures){let T=i.sharedLength||f;i.length>T&&(i=i.slice(0,T));let P=le.subarray(n,ne);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,P)}}E&cH&&(ne=n)}};let S=b=>{ne>As&&(le=M(ne));var E=typeof b,T;if(E==="string"){let P=b.length;if(_s&&P>=8&&P<4096){let O=eH.test(b);_s[O?0:1]+=b,le[ne++]=193,S(O?-P:P);return}let D;P<32?D=1:P<256?D=2:P<65536?D=3:D=5;let C=P*3;if(ne+C>As&&(le=M(ne+C)),P<64||!u){let O,B,V,Y=ne+D;for(O=0;O<P;O++)B=b.charCodeAt(O),B<128?le[Y++]=B:B<2048?(le[Y++]=B>>6|192,le[Y++]=B&63|128):(B&64512)===55296&&((V=b.charCodeAt(O+1))&64512)===56320?(B=65536+((B&1023)<<10)+(V&1023),O++,le[Y++]=B>>18|240,le[Y++]=B>>12&63|128,le[Y++]=B>>6&63|128,le[Y++]=B&63|128):(le[Y++]=B>>12|224,le[Y++]=B>>6&63|128,le[Y++]=B&63|128);T=Y-ne-D}else T=u(b,ne+D,C);T<32?le[ne++]=160|T:T<256?(D<2&&le.copyWithin(ne+2,ne+1,ne+1+T),le[ne++]=217,le[ne++]=T):T<65536?(D<3&&le.copyWithin(ne+3,ne+2,ne+2+T),le[ne++]=218,le[ne++]=T>>8,le[ne++]=T&255):(D<5&&le.copyWithin(ne+5,ne+3,ne+3+T),le[ne++]=219,vn.setUint32(ne,T),ne+=4),ne+=T}else if(E==="number")if(b>>>0===b)b<64?le[ne++]=b:b<256?(le[ne++]=204,le[ne++]=b):b<65536?(le[ne++]=205,le[ne++]=b>>8,le[ne++]=b&255):(le[ne++]=206,vn.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?le[ne++]=256+b:b>=-128?(le[ne++]=208,le[ne++]=b+256):b>=-32768?(le[ne++]=209,vn.setInt16(ne,b),ne+=2):(le[ne++]=210,vn.setInt32(ne,b),ne+=4);else{let P;if((P=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){le[ne++]=202,vn.setFloat32(ne,b);let D;if(P<4||(D=b*Zm[(le[ne]&127)<<1|le[ne+1]>>7])>>0===D){ne+=4;return}else ne--}le[ne++]=203,vn.setFloat64(ne,b),ne+=8}else if(E==="object")if(!b)le[ne++]=192;else{if(a){let D=a.get(b);if(D){if(!D.id){let C=a.idsToInsert||(a.idsToInsert=[]);D.id=C.push(D)}le[ne++]=214,le[ne++]=112,vn.setUint32(ne,D.id),ne+=4;return}else a.set(b,{offset:ne-n})}let P=b.constructor;if(P===Object)_(b,!0);else if(P===Array){T=b.length,T<16?le[ne++]=144|T:T<65536?(le[ne++]=220,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=221,vn.setUint32(ne,T),ne+=4);for(let D=0;D<T;D++)S(b[D])}else if(P===Map){T=b.size,T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,vn.setUint32(ne,T),ne+=4);for(let[D,C]of b)S(D),S(C)}else{for(let D=0,C=tg.length;D<C;D++){let O=Gx[D];if(b instanceof O){let B=tg[D];if(B.write){B.type&&(le[ne++]=212,le[ne++]=B.type,le[ne++]=0),S(B.write.call(this,b));return}let V=le,Y=vn,W=ne;le=null;let q;try{q=B.pack.call(this,b,j=>(le=V,V=null,ne+=j,ne>As&&M(ne),{target:le,targetView:vn,position:ne-j}),S)}finally{V&&(le=V,vn=Y,ne=W,As=le.length-10)}q&&(q.length+ne>As&&M(q.length+ne),ne=tH(q,le,ne,B.type));return}}_(b,!b.hasOwnProperty)}}else if(E==="boolean")le[ne++]=b?195:194;else if(E==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))le[ne++]=211,vn.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)le[ne++]=207,vn.setBigUint64(ne,b);else if(this.largeBigIntToFloat)le[ne++]=203,vn.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(E==="undefined")this.encodeUndefinedAsNil?le[ne++]=192:(le[ne++]=212,le[ne++]=0,le[ne++]=0);else if(E==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+E)},_=this.useRecords===!1?this.variableMapSize?b=>{let E=Object.keys(b),T=E.length;T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,vn.setUint32(ne,T),ne+=4);let P;for(let D=0;D<T;D++)S(P=E[D]),S(b[P])}:(b,E)=>{le[ne++]=222;let T=ne-n;ne+=2;let P=0;for(let D in b)(E||b.hasOwnProperty(D))&&(S(D),S(b[D]),P++);le[T+++n]=P>>8,le[T+n]=P&255}:b=>{let E=Object.keys(b),T,P=o.transitions||(o.transitions=Object.create(null)),D=0;for(let O=0,B=E.length;O<B;O++){let V=E[O];T=P[V],T||(T=P[V]=Object.create(null),D++),P=T}let C=P[jh];if(C)C>=96&&p?(le[ne++]=((C-=96)&31)+96,le[ne++]=C>>5):le[ne++]=C;else{C=o.nextId,C||(C=64),C<g&&this.shouldShareStructure&&!this.shouldShareStructure(E)?(C=o.nextOwnId,C<y||(C=g),o.nextOwnId=C+1):(C>=y&&(C=g),o.nextId=C+1);let O=E.highByte=C>=96&&p?C-96>>5:-1;P[jh]=C,o[C-64]=E,C<g?(E.isShared=!0,o.sharedLength=C-63,s=!0,O>=0?(le[ne++]=(C&31)+96,le[ne++]=O):le[ne++]=C):(O>=0?(le[ne++]=213,le[ne++]=114,le[ne++]=(C&31)+96,le[ne++]=O):(le[ne++]=212,le[ne++]=114,le[ne++]=C),D&&(x+=w*D),v.length>=m&&(v.shift()[jh]=0),v.push(P),S(E))}for(let O=0,B=E.length;O<B;O++)S(b[E[O]])},M=b=>{let E;if(b>16777216){if(b-n>iT)throw new Error("Packed buffer would be larger than maximum buffer size");E=Math.min(iT,Math.round(Math.max((b-n)*(b>67108864?1.25:2),4194304)/4096)*4096)}else E=(Math.max(b-n<<2,le.length-1)>>12)+1<<12;let T=new zx(E);return vn=new DataView(T.buffer,0,E),le.copy?le.copy(T,0,n,b):T.set(le.slice(n,b)),ne-=n,n=0,As=T.length-10,le=T}}useBuffer(t){le=t,vn=new DataView(le.buffer,le.byteOffset,le.byteLength),ne=0}};Gx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Wh];tg=[{pack(r,t,e){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,t,e){let n=Array.from(r),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(n)}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),e([r.name,r.message])}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),e([r.source,r.flags])}},{pack(r,t){this.structuredClone?sT(r,16,t):oT(ng?Buffer.from(r):new Uint8Array(r),t)}},{pack(r,t){let e=r.constructor;e!==aT&&this.structuredClone?sT(r,kx.indexOf(e.name),t):oT(r,t)}},{pack(r,t){let{target:e,position:n}=t(1);e[n]=193}}];function sT(r,t,e,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function oT(r,t){let e=r.byteLength;var n,i;if(e<256){var{target:n,position:i}=t(e+2);n[i++]=196,n[i++]=e}else if(e<65536){var{target:n,position:i}=t(e+3);n[i++]=197,n[i++]=e>>8,n[i++]=e&255}else{var{target:n,position:i,targetView:s}=t(e+5);n[i++]=198,s.setUint32(i,e),i+=4}n.set(r,i)}function tH(r,t,e,n){let i=r.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=n,t.set(r,e),e+=i,e}function nH(r,t){let e,n=t.length*6,i=r.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function aa(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");Gx.unshift(r.Class),tg.unshift(r)}rT(r)}var lT=new hl({useRecords:!1}),rH=lT.pack,iH=lT.pack;var{NEVER:sH,ALWAYS:oH,DECIMAL_ROUND:aH,DECIMAL_FIT:lH}=$m,cT=512,cH=1024;var uT=new hl({structuredClone:!0});aa({Class:Ft.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ft.prototype),r}});aa({Class:We.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,We.prototype),r}});aa({Class:Zt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Zt.prototype),r}});aa({Class:Vh.prototype.constructor,type:4,write(r){return r.id},read(r){return new Vh(r)}});aa({Class:Hh.prototype.constructor,type:5,write(r){return r.data},read(r){return new Hh(r)}});aa({Class:Jt.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Jt.prototype),r}});function uH(r){var t=0;if(r.length===0)return t;for(let e=0;e<r.length;e++){let n=r[e];t=(t<<5)-t+n,t=t&t}return t}function Vx(r){if(ru(r))return r;if(Array.isArray(r))return r.map(Vx);if(typeof r=="object"&&r!==null){let t={};for(let e of Object.keys(r).sort())t[e]=Vx(r[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else return r}var rg;(n=>{function r(i){return uT.pack(i)}n.serialize=r;function t(i){return uT.unpack(i)}n.deserialize=t;function e(i){return uH(r(Vx(i))).toString()}n.checksum=e})(rg||(rg={}));var yo={["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"]},dT;(e=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=r;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,toggle:!1,actions:new We}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new We}}e.defaultData=t})(dT||(dT={}));var ig;(e=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=r,e.valueDefaultData={type:"Literal",value:0}})(ig||(ig={}));var Hx;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:ig.propertyDefaultData(i),rOperand:{...ig.valueDefaultData}}}n.comparisonDefaultData=r;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=e})(Hx||(Hx={}));var hT;(e=>{function r(n){return n.type==="Conditional"}e.is=r;function t(n){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:Hx.distanceDefaultData(n)}}e.defaultData=t})(hT||(hT={}));var fT;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(fT||(fT={}));var sg;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new We})(sg||(sg={}));var og;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(og||(og={}));var pT;(e=>{function r(n){return n.type==="MouseHover"}e.is=r;function t(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=t})(pT||(pT={}));var mT;(e=>{function r(n){return n.type==="Scroll"}e.is=r;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new We}}e.defaultData=t})(mT||(mT={}));var gT;(e=>{function r(n){return n.type==="Start"}e.is=r;function t(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=t})(gT||(gT={}));var yT;(e=>{function r(n){return n.type==="Collision"}e.is=r;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new We}}e.defaultData=t})(yT||(yT={}));var fl;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}e.lerp=t})(fl||(fl={}));var Ms;(a=>{function r(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=r;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function i(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=i;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(Ms||(Ms={}));var qh;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}e.lerp=t})(qh||(qh={}));var la;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=t;function e(s){return s??i.identity}i.simplify=e;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}i.applyMatrix4=n})(la||(la={}));var Nn;(c=>{function r(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}c.isRGB=r,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function i(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=i;function s(d){return{r:d.r,g:d.g,b:d.b}}c.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=a;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}c.equals=l;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}c.lerp=u})(Nn||(Nn={}));var Mr;(a=>{a.white={...Nn.white,a:1},a.transparent={...Nn.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...Nn.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return Nn.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Mr||(Mr={}));var ag;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(ag||(ag={}));var vT;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(vT||(vT={}));var xT;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(xT||(xT={}));var vo;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(vo||(vo={}));var ji;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(ji||(ji={}));var pl;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(pl||(pl={}));var Es;(e=>{function r(n,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*i,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=r;function t(n,i){let s={...n};if(Wx.forEach(o=>{Object.assign(s,{[o]:i[o]??n[o]})}),s.radial={...n.radial},i.radial){let o=n.radial,a=i.radial;jx.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},i.linear){let o=n.linear,a=i.linear;qx.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},i.grid){let o=n.grid,a=i.grid;Xx.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},i.toObject){let o=n.toObject,a=i.toObject;Yx.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},i.randomnessObject){let o=n.randomnessObject,a=i.randomnessObject;Qx.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Es||(Es={}));var lg;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(lg||(lg={}));var Wx=["count"],jx=["radius","start","end","position","scale","rotation"],qx=["position","scale","rotation"],Xx=["count","size"],Yx=["count","position","scale","rotation"],Qx=["strength","scale","rotation","position","movement","seed","freqScale"];var ml;(e=>{let r={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(ml||(ml={}));var cg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(cg||(cg={}));var ug;(e=>{function r(n){return t(n)}e.defaultData=r;function t(n){if(n==="PointLight")return{type:n,color:Mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:Mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Mr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(ug||(ug={}));var Kx;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}e.equals=t})(Kx||(Kx={}));var Zx;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}e.equals=t})(Zx||(Zx={}));var dg;(t=>t.defaultData={...Zx.defaultData,...Kx.defaultData})(dg||(dg={}));var uu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(uu||(uu={}));var bT;(t=>{function r(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=r})(bT||(bT={}));function ST(r){return r.type!=="displace"}var wT;(t=>{function r(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=r})(wT||(wT={}));var hg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],AT=["wrapping","image","video"],Br;(i=>{function r(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}i.patch=r;function t(s,o){return s==="light"&&o?e(o):n(s)}i.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function n(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:uu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:Nn.fromHex(5526619)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Nn.fromHex(6710886),a:1},colorB:{...Nn.fromHex(6710886),a:1},colorC:{...Nn.fromHex(16777215),a:1},colorD:{...Nn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:Mr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Mr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Mr.fromHexAndA(0,1),contourColor:Mr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Nn.fromHex(0),a:1},colorB:{...Nn.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Br||(Br={}));var or;(l=>{function r(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=r;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${f}`,Array.isArray(f)?f.forEach(m=>c+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new We}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function i(u,c){return{...u,name:c}}l.withName=i;function s(u,c="layer1",d="layer2"){let h=new We;return h.push({fi:0,data:Br.defaultData("light",u),id:c}),h.push({fi:1,data:Br.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=Br.defaultData("texture");Object.assign(f.texture,{image:u});let m=new We;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Br.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=Br.defaultData("video");Object.assign(f.texture,{video:u});let m=new We;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Br.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerVideoTextureData=a})(or||(or={}));var du;(t=>{function r(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=r})(du||(du={}));var hu;(t=>{function r(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=r})(hu||(hu={}));var Jx={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var fg;(t=>{function r(e,n){let i={...e};return $x.forEach(s=>{Object.assign(i,{[s]:n[s]??e[s]})}),i}t.merge=r})(fg||(fg={}));var pg={shape:Jx,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},$x=["depth","offset","angle","twist","startScale","endScale"];var Xh;(e=>{function r(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=r;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(Xh||(Xh={}));var mg;(t=>{function r(e,n){let i={...e};return Object.assign(i,n),i.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,fg.merge(i.extrusion,n.extrusion))),i}t.merge=r})(mg||(mg={}));var ca;(t=>{function r(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:hu.defaultData(),extrusion:pg};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:du.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}t.defaultData=r})(ca||(ca={}));var eb=["width","height","depth"];var _T;(e=>{function r(n){return n==="Component"||n==="Instance"}e.isComponentRelated=r;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(_T||(_T={}));var fu;(i=>{i.identity={...ag.identity,hiddenMatrix:la.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function n(s,o){return vE({position:Ms.isEqual(s.position,o.position)?void 0:o.position,rotation:Ms.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Ms.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:la.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=n})(fu||(fu={}));var MT;(t=>t.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(MT||(MT={}));var hi;(t=>t.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...fu.identity,cloner:null})(hi||(hi={}));var ET;(t=>t.defaultData={type:"Empty",...hi.defaultData})(ET||(ET={}));var TT;(t=>t.defaultData={type:"Component",...hi.defaultData})(TT||(TT={}));var gl;(t=>t.defaultData={type:"Mesh",...hi.defaultData,...dg.defaultData})(gl||(gl={}));var pu;(t=>t.defaultData={...hi.defaultData,...fu.identity,...pl.defaultData})(pu||(pu={}));var gg;(t=>{function r(e){return{...hi.defaultData,...ug.defaultData(e)}}t.defaultData=r})(gg||(gg={}));var mu;(e=>{function r(n,i,s=0){for(;s<i.length;){let o=n?n[i[s]]:void 0;if(i.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=r;function t(n,i,s=0){let o=r(n,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(mu||(mu={}));var ua;(s=>{s.rootOverrideProps=["physics"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...hi.defaultData,...a,component:o,overrides:new Jt,physics:void 0,type:"Instance"}}s.ofComponent=n;function i(o){let a=fu.fromObject(o.data);return n(o.id,a)}s.fromComponentData=i})(ua||(ua={}));var yg;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:la.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...pl.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...hi.defaultData,...gl.defaultData,geometry:ca.defaultData("RectangleGeometry"),material:or.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...hi.defaultData,...gl.defaultData,geometry:ca.defaultData("BooleanGeometry"),material:or.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...hi.defaultData,...gl.defaultData,geometry:ca.defaultData("TextGeometry"),material:or.defaultTwoLayerData("phong","layer1","layer2")}))(yg||(yg={}));var xo;(i=>{function r(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Jt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Jt})))):ji.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=r;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=lu(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&Br.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=lu(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&Br.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,m]of Object.entries(h.layers)){let{texture:p,...g}=m;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...d,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",f],props:g,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...lg.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,m]of Object.entries(h))c(["materials",f],m);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}i.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,fu.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),ji.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:mg.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Es.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Es.merge(a.cloner,o.cloner)});else if(cg.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Nn.clone(l.color))}return a}i.patch=n})(xo||(xo={}));var Qh;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Nn.white,near:.1,far:2e3})(Qh||(Qh={}));var gu;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(gu||(gu={}));var bo;(t=>t.defaultData={orbitControls:gu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null,hdTransmission:!1})(bo||(bo={}));var tb;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(tb||(tb={}));var nb;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(nb||(nb={}));var yl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...tb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:nb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(yl||(yl={}));var Fr;(t=>t.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low",occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(Fr||(Fr={}));var CT;(o=>{o.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a={withLight:!0,withSquare:!0}){let l=new Zt,u=yg.defaultMeshObject;return a.withLight===!0&&l.push({fi:-1,data:{...gg.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),a.withSquare===!0&&l.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:u,children:[]}),l}o.defaultData={backgroundColor:Mr.fromHexAndA(2960946,1),postprocessing:ml.defaultData,fog:Qh.defaultData,objects:t(),environment:Fr.defaultData,publish:bo.defaultData,styles:yl.defaultData()},o.emptyData=function(a){return{backgroundColor:Mr.fromHexAndA(2960946,1),postprocessing:ml.defaultData,fog:Qh.defaultData,objects:a?t(a):new Zt,environment:Fr.defaultData,publish:bo.defaultData,styles:yl.defaultData()}};function i(a){return{...o.defaultData,objects:Hi(a,Zt.prototype)}}o.withObjs=i;function s(a,l){return i([{id:a,data:l,children:[],fi:0}])}o.withObj=s})(CT||(CT={}));var yu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(yu||(yu={}));var vg;(n=>{function r(){let i={};return i["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Hi(i,Ft.prototype)}n.defaultColors=r;function t(i){let s={};return i?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...yu.emptyImage,name:"AI generated image"}),Hi(s,Ft.prototype)}n.defaultImages=t;function e(){return{materials:new Ft,images:new Ft,videos:new Ft,colors:new Ft,audios:new Ft,fonts:new Ft,penumbraSize:[2,2,2]}}n.emptyData=e})(vg||(vg={}));var vu;(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 We,move:new We,jump:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Mr.fromHexAndA(3728051,1)}}))(vu||(vu={}));function PT(r){r.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,i=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...ia(ir(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...ir(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function xu(r,t){Object.values(r.shared.materials).forEach(e=>t(e))}function bu(r,t){r.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&t(i)}):"material"in n&&typeof n.material!="string"&&t(n.material)})}function hH(r){Object.assign(r.scene.publish,{orbitControls:{...gu.defaultData,...ir(r.scene.publish.orbitControls)}})}function fH(r){Object.assign(r.scene.publish.settings,{video:{...bo.defaultData.settings.video,...ir(r.scene.publish.settings.video)}})}function pH(r){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[i,s]of Object.entries(n))if((hg.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(AT.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((e,n)=>{n.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function mH(r){r.scene.publish.withBackground=!0}function gH(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function yH(r){r.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function vH(r){r.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function xH(r){r.scene.objects.traverse((t,e)=>{let n=r.scene.objects.unproxy().parent(t);if(n){let i=ir(r.scene.objects.data(n));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ir(e).booleanExclude!==!0)}})}function bH(r){r.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function wH(r){function t(n){Object.setPrototypeOf(n,Jt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Jt.prototype)}function e(n){Object.setPrototypeOf(n,Jt.prototype);for(let i in n)t(n[i])}r.scene.objects.traverse((n,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=ir(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=ir(l).layers;e(u),l.layers=u}})})}function DT(r){r.layers===void 0&&Object.assign(r,or.defaultTwoLayerData("lambert"))}function rb(r){!r.layers||r.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let n=[...t.steps];n.push(t.steps[9]);let i={...ir(t),colors:e,steps:n};Object.assign(t,i)}})}function SH(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function IT(r){r.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&rb(n)}):"material"in e&&typeof e.material!="string"&&rb(e.material)}),Object.values(r.shared.materials).forEach(t=>rb(t))}function AH(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function _H(r){r.shared.audios=Hi({},Ft.prototype)}function MH(r){r.shared.videos=Hi({},Ft.prototype)}function EH(r){let t=r.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:i})}})}function TH(r){Object.entries(ir(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(ir(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function CH(r){r.scene.publish.settings.web.preload=!1}function OT(r){r.layers&&r.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function RT(r){r.layers&&r.layers.forEach(t=>{ST(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function PH(r){r.shared.fonts=Hi({},Ft.prototype)}function DH(r){return r.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function IH(r){let t=[];r.scene.objects.traverse((e,n)=>{let i=n;if(i.type==="TextFrame"){let s=or.defaultTwoLayerData("phong"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=DH(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...hi.defaultData,...gl.defaultData,flatShading:!1,wireframe:!1,geometry:{...ca.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:ir(i.states),events:ir(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=ir(r.scene.objects).parent(e);r.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{r.scene.objects.delete(e)})}function OH(r){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((e,n)=>{n.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new We,move:new We,jump:new We}});else{let s=new We;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:He.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,ia(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:He.generateUUID(),data:u},{fi:1,id:He.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function RH(r){r.scene.objects.traverse((t,e)=>{function n(i,s){let o=new We,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...ia(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...ia(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:He.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function LT(r){let t=r.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Br.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function NT(r){xu(r,LT),bu(r,LT)}function LH(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function NH(r){r.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function BH(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=or.defaultTwoLayerData("phong"))})}function FH(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function UH(r){r.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function kH(r){r.scene.publish.mouseEventTarget===void 0&&(r.scene.publish.mouseEventTarget="canvas"),r.scene.publish.settings.web.hint===void 0&&(r.scene.publish.settings.web.hint=!1)}function zH(r){let{video:t}=r.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function GH(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function VH(r){let t=r.scene.environment.usePhysics;r.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function HH(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=vu.defaultDataThirdPerson.navmesh)})})}function WH(r){r.scene.styles||(r.scene.styles=yl.defaultData())}function BT(r){r.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function jH(r){r.scene.environment.ambientLight.occlusion===void 0&&(r.scene.environment.ambientLight.occlusion=!1),r.scene.environment.ambientLight.aoFullRes===void 0&&(r.scene.environment.ambientLight.aoFullRes=!1),r.scene.environment.ambientLight.radius===void 0&&(r.scene.environment.ambientLight.radius=256),r.scene.environment.ambientLight.bias===void 0&&(r.scene.environment.ambientLight.bias=.5),r.scene.environment.ambientLight.aoColor===void 0&&(r.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),bu(r,BT),xu(r,BT)}var FT=41;function UT(r){let t=r.schema??0;t!==FT&&(console.warn("updating from ",t,"to ",FT),t<1&&(bu(r,PT),xu(r,PT),r.schema=1),t<2&&(hH(r),r.schema=2),t<3&&(pH(r),r.schema=3),t<4&&(mH(r),r.schema=4),t<5&&(gH(r),r.schema=5),t<6&&(yH(r),r.schema=6),t<7&&(vH(r),r.schema=7),t<8&&(r.schema=8),t<9&&(IT(r),r.schema=9),t<10&&(SH(r),r.schema=10),t<11&&(AH(r),r.schema=11),t<12&&(IT(r),r.schema=12),t<13&&(_H(r),r.schema=13),t<14&&(EH(r),r.schema=14),t<15&&(TH(r),r.schema=15),t<16&&(CH(r),r.schema=16),t<17&&(bu(r,OT),xu(r,OT),r.schema=17),t<18&&(bu(r,DT),xu(r,DT),r.schema=18),t<19&&(fH(r),r.schema=19),t<20&&(PH(r),IH(r),r.schema=20),t<21&&(OH(r),RH(r),r.schema=21),t<22&&(NT(r),r.schema=22),t<23&&(LH(r),r.schema=23),t<24&&(NH(r),r.schema=24),(t<25||r.shared.videos===void 0)&&(MH(r),t<25&&(r.schema=25)),t<26&&(xH(r),r.schema=26),t<27&&(bH(r),r.schema=27),t<28&&(NT(r),r.schema=28),t<29&&(wH(r),r.schema=29),t<30&&(BH(r),r.schema=30),t<31&&(FH(r),r.schema=31),t<33&&(UH(r),r.schema=33),t<34&&(kH(r),r.schema=34),t<35&&(zH(r),r.schema=35),t<36&&(GH(r),r.schema=36),t<37&&(VH(r),r.schema=37),t<38&&(bu(r,RT),xu(r,RT),r.schema=38),t<39&&(HH(r),r.schema=39),t<40&&(WH(r),r.schema=40),t<41&&(jH(r),r.schema=41))}function Xi(r,t=!1){let e=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Me,u=0;for(let c=0;c<r.length;++c){let d=r[c],h=0;if(e!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in d.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(d.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in d.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,d=[];for(let h=0;h<r.length;++h){let f=r[h].index;for(let m=0;m<f.count;++m)d.push(f.getX(m)+c);c+=r[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=kT(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][h]);let m=kT(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(m)}}return l}function kT(r){let t,e,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Be(s,e,n)}var zT=Math.pow(2,-24);var vl=class{constructor(){}};function Si(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function ib(r){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>e&&(e=i,t=n)}return t}function sb(r,t){t.set(r)}function ob(r,t,e){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=t[s],e[s]=n<i?n:i,n=r[o],i=t[o],e[o]=n>i?n:i}}function Kh(r,t,e){for(let n=0;n<3;n++){let i=t[r+2*n],s=t[r+2*n+1],o=i-s,a=i+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Su(r){let t=r[3]-r[0],e=r[4]-r[1],n=r[5]-r[2];return 2*(t*e+e*n+n*t)}function YH(r,t){if(!r.index){let e=r.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new n(4*e)):i=new Uint16Array(new n(2*e)),r.setIndex(new Be(i,1));for(let s=0;s<e;s++)i[s]=s}}function QH(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let t=[],e=new Set;for(let i of r.groups)e.add(i.start),e.add(i.start+i.count);let n=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function lb(r,t,e,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let w=r[v+0],S=r[v+1],_=w-S,M=w+S;_<s&&(s=_),M>l&&(l=M),y&&w<d&&(d=w),y&&w>m&&(m=w);let b=r[v+2],E=r[v+3],T=b-E,P=b+E;T<o&&(o=T),P>u&&(u=P),y&&b<h&&(h=b),y&&b>p&&(p=b);let D=r[v+4],C=r[v+5],O=D-C,B=D+C;O<a&&(a=O),B>c&&(c=B),y&&D<f&&(f=D),y&&D>g&&(g=D)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(i[0]=d,i[1]=h,i[2]=f,i[3]=m,i[4]=p,i[5]=g)}function KH(r,t,e,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=r[c+0];h<i&&(i=h),h>a&&(a=h);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let m=r[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function ZH(r,t,e,n,i){let s=e,o=e+n-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var wo=32,JH=(r,t)=>r.candidate-t.candidate,da=new Array(wo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),xg=new Float32Array(6);function $H(r,t,e,n,i,s){let o=-1,a=0;if(s===0)o=ib(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=ib(r),o!==-1&&(a=e5(e,n,i,o));else if(s===2){let l=Su(r),u=1.25*i,c=n*6,d=(n+i)*6;for(let h=0;h<3;h++){let f=t[h],g=(t[h+3]-f)/wo;if(i<wo/4){let y=[...da];y.length=i;let v=0;for(let w=c;w<d;w+=6,v++){let S=y[v];S.candidate=e[w+2*h],S.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:b}=S;for(let E=0;E<3;E++)b[E]=1/0,b[E+3]=-1/0,M[E]=1/0,M[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;Kh(w,e,_)}y.sort(JH);let x=i;for(let w=0;w<x;w++){let S=y[w];for(;w+1<x&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),x--}for(let w=c;w<d;w+=6){let S=e[w+2*h];for(let _=0;_<x;_++){let M=y[_];S>=M.candidate?Kh(w,e,M.rightCacheBounds):(Kh(w,e,M.leftCacheBounds),M.count++)}}for(let w=0;w<x;w++){let S=y[w],_=S.count,M=i-S.count,b=S.leftCacheBounds,E=S.rightCacheBounds,T=0;_!==0&&(T=Su(b)/l);let P=0;M!==0&&(P=Su(E)/l);let D=1+1.25*(T*_+P*M);D<u&&(o=h,u=D,a=S.candidate)}}else{for(let x=0;x<wo;x++){let w=da[x];w.count=0,w.candidate=f+g+x*g;let S=w.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let x=c;x<d;x+=6){let _=~~((e[x+2*h]-f)/g);_>=wo&&(_=wo-1);let M=da[_];M.count++,Kh(x,e,M.bounds)}let y=da[wo-1];sb(y.bounds,y.rightCacheBounds);for(let x=wo-2;x>=0;x--){let w=da[x],S=da[x+1];ob(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;x<wo-1;x++){let w=da[x],S=w.count,_=w.bounds,b=da[x+1].rightCacheBounds;S!==0&&(v===0?sb(_,xg):ob(_,xg,xg)),v+=S;let E=0,T=0;v!==0&&(E=Su(xg)/l);let P=i-v;P!==0&&(T=Su(b)/l);let D=1+1.25*(E*v+T*P);D<u&&(o=h,u=D,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function e5(r,t,e,n){let i=0;for(let s=t,o=t+e;s<o;s++)i+=r[s*6+n*2];return i/e}function t5(r,t){let e=r.attributes.position,n=e.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=e.offset||0,l=3;e.isInterleavedBufferAttribute&&(l=e.data.stride);for(let u=0;u<s;u++){let c=u*3,d=u*6,h=i[c+0]*l+a,f=i[c+1]*l+a,m=i[c+2]*l+a;for(let p=0;p<3;p++){let g=n[h+p],y=n[f+p],v=n[m+p],x=g;y<x&&(x=y),v<x&&(x=v);let w=g;y>w&&(w=y),v>w&&(w=v);let S=(w-x)/2,_=p*2;o[d+_+0]=x+S,o[d+_+1]=S+(Math.abs(x)+S)*zT,x<t[p]&&(t[p]=x),w>t[p+3]&&(t[p+3]=w)}}return o}function n5(r,t){function e(y){h&&h(y/f)}function n(y,v,x,w=null,S=0){if(!m&&S>=l&&(m=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let _=$H(y.boundingData,w,o,v,x,d);if(_.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=ZH(a,o,v,x,_);if(M===v||M===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=_.axis;let b=new vl,E=v,T=M-v;y.left=b,b.boundingData=new Float32Array(6),lb(o,E,T,b.boundingData,s),n(b,E,T,s,S+1);let P=new vl,D=M,C=x-T;y.right=P,P.boundingData=new Float32Array(6),lb(o,D,C,P.boundingData,s),n(P,D,C,s,S+1)}return y}YH(r,t);let i=new Float32Array(6),s=new Float32Array(6),o=t5(r,i),a=r.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=r.index.count/3,m=!1,p=[],g=QH(r);if(g.length===1){let y=g[0],v=new vl;v.boundingData=i,KH(o,y.offset,y.count,s),n(v,y.offset,y.count,s),p.push(v)}else for(let y of g){let v=new vl;v.boundingData=new Float32Array(6),lb(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function HT(r,t){let e=n5(r,t),n,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,m=!!d.count,p=d.boundingData;for(let g=0;g<6;g++)n[h+g]=p[g];if(m){let g=d.offset,y=d.count;return i[h+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=d.left,y=d.right,v=d.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[h+6]=x/4,x=u(x,y),i[h+7]=v,x}}}var Wr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Wr.prototype.setFromBox=function(){let r=new A;return function(e,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let d=e.dot(r);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var Wie=function(){let r=new Wr;return function(e,n){let i=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let d=o[c],h=s[c];if(r.setFromPoints(h,a),d.isSeparated(r))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(r.setFromPoints(h,i),d.isSeparated(r))return!1}}}();var r5=function(){let r=new A,t=new A,e=new A;return function(i,s,o){let a=i.start,l=r,u=s.start,c=t;e.subVectors(a,u),r.subVectors(i.end,s.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),m=e.dot(l),g=l.dot(l)*f-h*h,y,v;g!==0?y=(d*h-m*f)/g:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),Zh=function(){let r=new F,t=new A,e=new A;return function(i,s,o,a){r5(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(i.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),WT=function(){let r=new A,t=new A,e=new yn,n=new Hn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var i5=1e-15;function Au(r){return Math.abs(r)<i5}var jr=class extends an{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Wr),this.points=[this.a,this.b,this.c],this.sphere=new Rn,this.plane=new yn,this.needsUpdate=!0}intersectsSphere(t){return WT(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,i);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,i);let f=s[3],m=o[3];f.subVectors(n,t),m.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};jr.prototype.closestPointToSegment=function(){let r=new A,t=new A,e=new Hn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),Zh(e,i,r,t),c=r.distanceToSquared(t),c<d&&(d=c,s&&s.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(d)}}();jr.prototype.intersectsTriangle=function(){let r=new jr,t=new Array(3),e=new Array(3),n=new Wr,i=new Wr,s=new A,o=new A,a=new A,l=new A,u=new Hn,c=new Hn,d=new Hn;return function(f,m=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,g=f.plane;if(Math.abs(p.normal.dot(g.normal))>1-1e-10){let y=this.satBounds,v=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let S=0;S<4;S++){let _=y[S],M=v[S];if(n.setFromPoints(M,e),_.isSeparated(n))return!1}let x=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){let _=x[S],M=w[S];if(n.setFromPoints(M,t),_.isSeparated(n))return!1}for(let S=0;S<4;S++){let _=v[S];for(let M=0;M<4;M++){let b=w[M];if(s.crossVectors(_,b),n.setFromPoints(s,t),i.setFromPoints(s,e),n.isSeparated(i))return!1}}return m&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let y=this.points,v=!1,x=0;for(let C=0;C<3;C++){let O=y[C],B=y[(C+1)%3];u.start.copy(O),u.end.copy(B),u.delta(o);let V=v?c.start:c.end,Y=Au(g.distanceToPoint(O));if(Au(g.normal.dot(o))&&Y){c.copy(u),x=2;break}if((g.intersectLine(u,V)||Y)&&!Au(V.distanceTo(B))){if(x++,v)break;v=!0}}if(x===1&&this.containsPoint(c.start))return m&&(m.start.copy(c.start),m.end.copy(c.start)),!0;if(x!==2)return!1;let w=f.points,S=!1,_=0;for(let C=0;C<3;C++){let O=w[C],B=w[(C+1)%3];u.start.copy(O),u.end.copy(B),u.delta(a);let V=S?d.start:d.end,Y=Au(p.distanceToPoint(O));if(Au(p.normal.dot(a))&&Y){d.copy(u),_=2;break}if((p.intersectLine(u,V)||Y)&&!Au(V.distanceTo(B))){if(_++,S)break;S=!0}}if(_===1&&this.containsPoint(d.start))return m&&(m.start.copy(d.start),m.end.copy(d.start)),!0;if(_!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let C=d.start;d.start=d.end,d.end=C}let M=c.start.dot(o),b=c.end.dot(o),E=d.start.dot(o),T=d.end.dot(o),P=b<E,D=M<T;return M!==T&&E!==b&&P===D?!1:(m&&(l.subVectors(c.start,d.start),l.dot(o)>0?m.start.copy(c.start):m.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?m.end.copy(c.end):m.end.copy(d.end)),!0)}}}();jr.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();jr.prototype.distanceToTriangle=function(){let r=new A,t=new A,e=["a","b","c"],n=new Hn,i=new Hn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],m=o[f];this.closestPointToPoint(m,r),h=m.distanceToSquared(r),h<c&&(c=h,a&&a.copy(r),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,r),h=p.distanceToSquared(r),h<c&&(c=h,a&&a.copy(p),l&&l.copy(r))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let m=0;m<3;m++){let p=e[m],g=e[(m+1)%3];i.set(o[p],o[g]),Zh(n,i,r,t);let y=r.distanceToSquared(t);y<c&&(c=y,a&&a.copy(r),l&&l.copy(t))}}return Math.sqrt(c)}}();var qr=class extends _t{constructor(...t){super(...t),this.isOrientedBox=!0,this.matrix=new ae,this.invMatrix=new ae,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Wr),this.alignedSatBounds=new Array(3).fill().map(()=>new Wr),this.needsUpdate=!1}set(t,e,n){super.set(t,e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){super.copy(t),this.matrix.copy(t.matrix),this.needsUpdate=!0}};qr.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=i[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=i[h];c.subVectors(a,f),d.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();qr.prototype.intersectsBox=function(){let r=new Wr;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,e),c.isSeparated(r))return!1}return!0}}();qr.prototype.intersectsTriangle=function(){let r=new jr,t=new Array(3),e=new Wr,n=new Wr,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let h=0;h<3;h++){let f=a[h],m=l[h];if(e.setFromPoints(m,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],m=c[h];if(e.setFromPoints(m,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let m=0;m<4;m++){let p=c[m];if(i.crossVectors(f,p),e.setFromPoints(i,t),n.setFromPoints(i,d),e.isSeparated(n))return!1}}return!0}}();qr.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();qr.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();qr.prototype.distanceToBox=function(){let r=["x","y","z"],t=new Array(12).fill().map(()=>new Hn),e=new Array(12).fill().map(()=>new Hn),n=new A,i=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,d=o.min,h=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(d,h);let v=y.distanceToSquared(i);if(v<m&&(m=v,l&&l.copy(y),u&&u.copy(i),v<c))return Math.sqrt(v)}let p=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,w=(g+2)%3,S=y<<x|v<<w,_=1<<g|y<<x|v<<w,M=f[S],b=f[_];t[p].set(M,b);let T=r[g],P=r[x],D=r[w],C=e[p],O=C.start,B=C.end;O[T]=d[T],O[P]=y?d[P]:h[P],O[D]=v?d[D]:h[P],B[T]=h[T],B[P]=y?d[P]:h[P],B[D]=v?d[D]:h[P],p++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?h.x:d.x,i.y=y?h.y:d.y,i.z=v?h.z:d.z,this.closestPointToPoint(i,n);let x=i.distanceToSquared(n);if(x<m&&(m=x,l&&l.copy(n),u&&u.copy(i),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Zh(y,x,n,i);let w=n.distanceToSquared(i);if(w<m&&(m=w,l&&l.copy(n),u&&u.copy(i),w<c))return Math.sqrt(w)}}return Math.sqrt(m)}}();var wg=new A,Sg=new A,Ag=new A,jT=new F,qT=new F,XT=new F,YT=new A;function s5(r,t,e,n,i,s){let o;return s===On?o=r.intersectTriangle(n,e,t,!0,i):o=r.intersectTriangle(t,e,n,s!==Ir,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function o5(r,t,e,n,i,s,o){wg.fromBufferAttribute(t,n),Sg.fromBufferAttribute(t,i),Ag.fromBufferAttribute(t,s);let a=s5(r,wg,Sg,Ag,YT,o);if(a){e&&(jT.fromBufferAttribute(e,n),qT.fromBufferAttribute(e,i),XT.fromBufferAttribute(e,s),a.uv=an.getUV(YT,wg,Sg,Ag,jT,qT,XT,new F));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};an.getNormal(wg,Sg,Ag,l.normal),a.face=l,a.faceIndex=n}return a}function ub(r,t,e,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=o5(e,r.attributes.position,r.attributes.uv,o,a,l,t);return u?(u.faceIndex=n,i&&i.push(u),u):null}function QT(r,t,e,n,i,s){for(let o=n,a=n+i;o<a;o++)ub(r,t,e,o,s)}function KT(r,t,e,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=ub(r,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function db(r,t,e){return r===null||(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r.distance<e.near||r.distance>e.far)?null:r}function Ai(r,t,e,n){let i=r.a,s=r.b,o=r.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function hb(r,t,e,n,i,s,o){let a=e.index,l=e.attributes.position;for(let u=r,c=t+r;u<c;u++)if(Ai(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var _u=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function So(r,t){return t[r+15]===65535}function xl(r,t){return t[r+6]}function Mu(r,t){return t[r+14]}function Eu(r){return r+8}function Tu(r,t){return t[r+6]}function ZT(r,t){return t[r+7]}var Cu=new _t,Mg=new A,l5=["x","y","z"];function Eg(r,t,e,n,i){let s=r*2,o=Pu,a=ha,l=fa;if(So(s,a)){let c=xl(r,l),d=Mu(s,a);QT(t,e,n,c,d,i)}else{let c=Eu(r);Cg(c,o,n,Mg)&&Eg(c,t,e,n,i);let d=Tu(r,l);Cg(d,o,n,Mg)&&Eg(d,t,e,n,i)}}function Tg(r,t,e,n){let i=r*2,s=Pu,o=ha,a=fa;if(So(i,o)){let u=xl(r,a),c=Mu(i,o);return KT(t,e,n,u,c)}else{let u=ZT(r,a),c=l5[u],h=n.direction[c]>=0,f,m;h?(f=Eu(r),m=Tu(r,a)):(f=Tu(r,a),m=Eu(r));let g=Cg(f,s,n,Mg)?Tg(f,t,e,n):null;if(g){let x=g.point[c];if(h?x<=s[m+u]:x>=s[m+u+3])return g}let v=Cg(m,s,n,Mg)?Tg(m,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var JT=function(){let r,t,e=[],n=new _u(()=>new _t);return function(...o){r=n.getPrimitive(),t=n.getPrimitive(),e.push(r,t);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],r=e[l-2]),a};function i(s,o,a,l,u=null,c=0,d=0){function h(x){let w=x*2,S=ha,_=fa;for(;!So(w,S);)x=Eu(x),w=x*2;return xl(x,_)}function f(x){let w=x*2,S=ha,_=fa;for(;!So(w,S);)x=Tu(x,_),w=x*2;return xl(x,_)+Mu(w,S)}let m=s*2,p=Pu,g=ha,y=fa;if(So(m,g)){let x=xl(s,y),w=Mu(m,g);return Si(s,p,r),l(x,w,!1,d,c+s,r)}else{let x=Eu(s),w=Tu(s,y),S=x,_=w,M,b,E,T;if(u&&(E=r,T=t,Si(S,p,E),Si(_,p,T),M=u(E),b=u(T),b<M)){S=w,_=x;let Y=M;M=b,b=Y,E=T}E||(E=r,Si(S,p,E));let P=So(S*2,g),D=a(E,P,M,d+1,c+S),C;if(D===2){let Y=h(S),q=f(S)-Y;C=l(Y,q,!0,d+1,c+S,E)}else C=D&&i(S,o,a,l,u,c,d+1);if(C)return!0;T=t,Si(_,p,T);let O=So(_*2,g),B=a(T,O,b,d+1,c+_),V;if(B===2){let Y=h(_),q=f(_)-Y;V=l(Y,q,!0,d+1,c+_,T)}else V=B&&i(_,o,a,l,u,c,d+1);return!!V}}}(),$T=function(){let r=new jr,t=new jr,e=new ae,n=new qr,i=new qr;return function s(o,a,l,u,c=null){let d=o*2,h=Pu,f=ha,m=fa;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),So(d,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,w=l.attributes.position,S=xl(o,m),_=Mu(d,f);if(e.copy(u).invert(),l.boundsTree)return Si(o,h,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>i.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let E=S*3,T=(_+S)*3;E<T;E+=3)if(Ai(t,E,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let M=S*3,b=_+S*3;M<b;M+=3){Ai(r,M,y,v),r.a.applyMatrix4(e),r.b.applyMatrix4(e),r.c.applyMatrix4(e),r.needsUpdate=!0;for(let E=0,T=x.count;E<T;E+=3)if(Ai(t,E,x,w),t.needsUpdate=!0,r.intersectsTriangle(t))return!0}}else{let g=o+8,y=m[o+6];return Si(g,h,Cu),!!(c.intersectsBox(Cu)&&s(g,a,l,u,c)||(Si(y,h,Cu),c.intersectsBox(Cu)&&s(y,a,l,u,c)))}}}();function Cg(r,t,e,n){return Si(r,t,Cu),e.intersectBox(Cu,n)}var fb=[],_g,Pu,ha,fa;function Du(r){_g&&fb.push(_g),_g=r,Pu=new Float32Array(r),ha=new Uint16Array(r),fa=new Uint32Array(r)}function Jh(){_g=null,Pu=null,ha=null,fa=null,fb.length&&Du(fb.pop())}var pb=Symbol("skip tree generation"),mb=new _t,gb=new _t,Iu=new ae,bl=new qr,$h=new qr,ef=new A,Pg=new A,c5=new A,u5=new A,d5=new A,eC=new _t,Ts=new _u(()=>new jr),un=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),un.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),un.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=t,o=new un(e,{...n,[pb]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Be(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[pb]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[pb]||(this._roots=HT(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new _t))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,i=e.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,d,h=0,f=this._roots;for(let p=0,g=f.length;p<g;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),d=new Float32Array(l),m(0,h),h+=l.byteLength;function m(p,g,y=!1){let v=p*2;if(c[v+15]===65535){let w=u[p+6],S=c[v+14],_=1/0,M=1/0,b=1/0,E=-1/0,T=-1/0,P=-1/0;for(let D=3*w,C=3*(w+S);D<C;D++){let O=n[D]*a+o,B=s[O+0],V=s[O+1],Y=s[O+2];B<_&&(_=B),B>E&&(E=B),V<M&&(M=V),V>T&&(T=V),Y<b&&(b=Y),Y>P&&(P=Y)}return d[p+0]!==_||d[p+1]!==M||d[p+2]!==b||d[p+3]!==E||d[p+4]!==T||d[p+5]!==P?(d[p+0]=_,d[p+1]=M,d[p+2]=b,d[p+3]=E,d[p+4]=T,d[p+5]=P,!0):!1}else{let w=p+8,S=u[p+6],_=w+g,M=S+g,b=y,E=!1,T=!1;t?b||(E=t.has(_),T=t.has(M),b=!E&&!T):(E=!0,T=!0);let P=b||E,D=b||T,C=!1;P&&(C=m(w,g,b));let O=!1;D&&(O=m(S,g,b));let B=C||O;if(B)for(let V=0;V<3;V++){let Y=w+V,W=S+V,q=d[Y],j=d[Y+3],X=d[W],L=d[W+3];d[p+V]=q<X?q:X,d[p+V+3]=j>L?j:L}return B}}}traverse(t,e=0){let n=this._roots[e],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=i[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=i[a+6],f=i[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=si){let n=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(Du(n[c]),Eg(0,i,h,t,s),Jh(),a){let m=l[c].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(t,e=si){let n=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;Du(n[c]);let f=Tg(0,i,h,t);Jh(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,i=!1;for(let s of this._roots)if(Du(s),i=$T(0,n,t,e),Jh(),i)break;return i}shapecast(t,e,n){let i=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,m,p,g)=>{let y=m*3;return h(f,y,y+1,y+2,p,g)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Ts.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,m,p,g,y)=>h(f,m,p,g,y)?!0:hb(f,m,i,u,p,g,s)}else l||(u?l=(h,f,m,p)=>hb(h,f,i,u,m,p,s):l=(h,f,m)=>m);let c=!1,d=0;for(let h of this._roots){if(Du(h),c=JT(0,i,a,l,o,d),Jh(),c)break;d+=h.byteLength}return Ts.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;Iu.copy(e).invert();let c=Ts.getPrimitive(),d=Ts.getPrimitive();if(s){let f=function(m,p,g,y,v,x,w,S){for(let _=g,M=g+y;_<M;_++){Ai(d,_*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let b=m,E=m+p;b<E;b++)if(Ai(c,b*3,o,a),c.needsUpdate=!0,s(c,d,b,_,v,x,w,S))return!0}return!1};if(i){let m=i;i=function(p,g,y,v,x,w,S,_){return m(p,g,y,v,x,w,S,_)?!0:f(p,g,y,v,x,w,S,_)}}else i=f}t.getBoundingBox(gb),gb.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>gb.intersectsBox(f),intersectsRange:(f,m,p,g,y,v)=>(mb.copy(v),mb.applyMatrix4(Iu),t.shapecast({intersectsBounds:x=>mb.intersectsBox(x),intersectsRange:(x,w,S,_,M)=>i(f,m,x,w,g,y,_,M)}))});return Ts.releasePrimitive(c),Ts.releasePrimitive(d),h}intersectsBox(t,e){return bl.set(t.min,t.max,e),bl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>bl.intersectsBox(n),intersectsTriangle:n=>bl.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),bl.set(t.boundingBox.min,t.boundingBox.max,e),bl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=Ts.getPrimitive(),f=Ts.getPrimitive(),m=Pg,p=c5,g=null,y=null;i&&(g=u5,y=d5);let v=1/0,x=null,w=null;return Iu.copy(e).invert(),$h.matrix.copy(Iu),this.shapecast({boundsTraverseOrder:S=>bl.distanceToBox(S),intersectsBounds:(S,_,M)=>M<v&&M<o?(_&&($h.min.copy(S.min),$h.max.copy(S.max),$h.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>$h.distanceToBox(M),intersectsBounds:(M,b,E)=>E<v&&E<o,intersectsRange:(M,b)=>{for(let E=M*3,T=(M+b)*3;E<T;E+=3){Ai(f,E,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let P=S*3,D=(S+_)*3;P<D;P+=3){Ai(h,P,u,l),h.needsUpdate=!0;let C=h.distanceToTriangle(f,m,g);if(C<v&&(p.copy(m),y&&y.copy(g),v=C,x=P/3,w=E/3),C<s)return!0}}}});{let M=d?d.count:c.count;for(let b=0,E=M;b<E;b+=3){Ai(f,b,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let T=S*3,P=(S+_)*3;T<P;T+=3){Ai(h,T,u,l),h.needsUpdate=!0;let D=h.distanceToTriangle(f,m,g);if(D<v&&(p.copy(m),y&&y.copy(g),v=D,x=T/3,w=b/3),D<s)return!0}}}}}),Ts.releasePrimitive(h),Ts.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(Iu),p.applyMatrix4(Iu),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(t,e={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(ef.copy(t).clamp(c.min,c.max),ef.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,ef);let h=t.distanceToSquared(ef);return h<a&&(Pg.copy(ef),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(Pg):e.point=Pg.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Si(0,new Float32Array(n),eC),t.union(eC)}),t}},tC=un.prototype.raycast;un.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,e,n,i]=r;return tC.call(this,n,t.material).forEach(o=>{o=db(o,t,e),o&&i.push(o)}),i}else return tC.apply(this,r)};var nC=un.prototype.raycastFirst;un.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,e,n]=r;return db(nC.call(this,n,t.material),t,e)}else return nC.apply(this,r)};var rC=un.prototype.closestPointToPoint;un.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let t=r[1],e={};return r[1]=e,rC.apply(this,r),t&&t.copy(e.point),e.distance}else return rC.apply(this,r)};var iC=un.prototype.closestPointToGeometry;un.prototype.closestPointToGeometry=function(...r){let t=r[2],e=r[3];if(t&&t.isVector3||e&&e.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,iC.apply(this,r),t&&t.copy(n.point),e&&e.copy(i.point).applyMatrix4(s),n.distance}else return iC.apply(this,r)};var sC=un.prototype.refit;un.prototype.refit=function(...r){let t=r[0],e=r[1];if(e&&(e instanceof Set||Array.isArray(e))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;e.forEach(i=>n.add(i)),t&&t.forEach(i=>n.add(i)),sC.call(this,n)}else sC.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let t=un.prototype[r];un.prototype[r]=function(...e){return(e[0]===null||e[0].isMesh)&&(e.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,e)}});var wd=fs(aC());var h5=.5*(Math.sqrt(3)-1),tf=(3-Math.sqrt(3))/6,f5=1/3,Cs=1/6,Use=(Math.sqrt(5)-1)/4,kse=(5-Math.sqrt(5))/20,nf=r=>Math.floor(r)|0,lC=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]),vb=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 Dg(r=Math.random){let t=uC(r),e=new Float64Array(t).map(i=>lC[i%12*2]),n=new Float64Array(t).map(i=>lC[i%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*h5,d=nf(s+c),h=nf(o+c),f=(d+h)*tf,m=d-f,p=h-f,g=s-m,y=o-p,v,x;g>y?(v=1,x=0):(v=0,x=1);let w=g-v+tf,S=y-x+tf,_=g-1+2*tf,M=y-1+2*tf,b=d&255,E=h&255,T=.5-g*g-y*y;if(T>=0){let C=b+t[E],O=e[C],B=n[C];T*=T,a=T*T*(O*g+B*y)}let P=.5-w*w-S*S;if(P>=0){let C=b+v+t[E+x],O=e[C],B=n[C];P*=P,l=P*P*(O*w+B*S)}let D=.5-_*_-M*M;if(D>=0){let C=b+1+t[E+1],O=e[C],B=n[C];D*=D,u=D*D*(O*_+B*M)}return 70*(a+l+u)}}function cC(r=Math.random){let t=uC(r),e=new Float64Array(t).map(s=>vb[s%12*3]),n=new Float64Array(t).map(s=>vb[s%12*3+1]),i=new Float64Array(t).map(s=>vb[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*f5,m=nf(o+f),p=nf(a+f),g=nf(l+f),y=(m+p+g)*Cs,v=m-y,x=p-y,w=g-y,S=o-v,_=a-x,M=l-w,b,E,T,P,D,C;S>=_?_>=M?(b=1,E=0,T=0,P=1,D=1,C=0):S>=M?(b=1,E=0,T=0,P=1,D=0,C=1):(b=0,E=0,T=1,P=1,D=0,C=1):_<M?(b=0,E=0,T=1,P=0,D=1,C=1):S<M?(b=0,E=1,T=0,P=0,D=1,C=1):(b=0,E=1,T=0,P=1,D=1,C=0);let O=S-b+Cs,B=_-E+Cs,V=M-T+Cs,Y=S-P+2*Cs,W=_-D+2*Cs,q=M-C+2*Cs,j=S-1+3*Cs,X=_-1+3*Cs,L=M-1+3*Cs,U=m&255,G=p&255,H=g&255,z=.6-S*S-_*_-M*M;if(z<0)u=0;else{let k=U+t[G+t[H]];z*=z,u=z*z*(e[k]*S+n[k]*_+i[k]*M)}let re=.6-O*O-B*B-V*V;if(re<0)c=0;else{let k=U+b+t[G+E+t[H+T]];re*=re,c=re*re*(e[k]*O+n[k]*B+i[k]*V)}let K=.6-Y*Y-W*W-q*q;if(K<0)d=0;else{let k=U+P+t[G+D+t[H+C]];K*=K,d=K*K*(e[k]*Y+n[k]*W+i[k]*q)}let Z=.6-j*j-X*X-L*L;if(Z<0)h=0;else{let k=U+1+t[G+1+t[H+1]];Z*=Z,h=Z*Z*(e[k]*j+n[k]*X+i[k]*L)}return 32*(u+c+d+h)}}function uC(r){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let i=n+~~(r()*(256-n)),s=e[n];e[n]=e[i],e[i]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var Yi=new an,Ig=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let s=1;Yi.a.fromBufferAttribute(t,i),Yi.b.fromBufferAttribute(t,i+1),Yi.c.fromBufferAttribute(t,i+2),s*=Yi.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let i=0;i<e.length;i++)n+=e[i],this.distribution[i]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*n);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,i=e.length-1,s=-1;for(;n<=i;){let o=Math.ceil((n+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:n=o+1}return s}sampleFace(t,e,n){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),Yi.a.fromBufferAttribute(this.positionAttribute,t*3),Yi.b.fromBufferAttribute(this.positionAttribute,t*3+1),Yi.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Yi.a,i).addScaledVector(Yi.b,s).addScaledVector(Yi.c,1-(i+s)),Yi.getNormal(n),this}};var hC=fs(xb()),p5=new ae,m5=new ae,g5=new ae,rf;(t=>{function r(e){return e&&e.__isSPEObject}t.is=r})(rf||(rf={}));var Ou=r=>class extends r{constructor(){super(...arguments);this.previousModelViewMatrix=new ae;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ae;this.matrixWorldRigid=new ae;this.shearScale=new ae;this.shearScaleInv=new ae}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof pt&&(n=n.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===n)return!0;i=i.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseObject(n,i=0){if(n(this,i)!==!0)for(let o of this.children)rf.is(o)&&o.traverseObject(n,i+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,i=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,hC.SVD)(i),l=p5.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=m5.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=g5.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,i){this.updateWorldMatrix(!0,!1);let s=new ae().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof ae?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),i!==void 0&&(this.children.pop(),this.children.splice(i,0,n)),this}copy(n,i=!1){return super.copy(n,i),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,i,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var bb=class extends Ou(pt){},y5=r=>r.type==="Mesh",dn=class extends bb{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let i=this.children[e];i?.object!==n&&(i&&this.remove(i),i=new dn(n),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=n.matrix,i.hiddenMatrix=n.hiddenMatrix),i.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return y5(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var wl=new A,Sl=new A,Ru=new ae,pC=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],v5=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],x5=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],fC=(r,t,e)=>{r.updateEntityBoxSize(wl,Sl),Ru.copy(t).multiply(r.matrixWorld),Sl.x===0&&Sl.y===0&&Sl.z===0?e.push(new A(wl.x,wl.y,wl.z).applyMatrix4(Ru)):pC.forEach(n=>{e.push(n.clone().multiply(Sl).add(wl).applyMatrix4(Ru))})},sf=class extends _t{constructor(){super(...arguments);this.matrix=new ae;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ae().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,n)}expandByObjectSize(e,n,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}fC(o,n,s)}}):fC(e,n,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Ru.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Sl).multiplyScalar(.5),this.getCenter(wl),Ru.copy(this.matrix).setPosition(wl),this.vertices=pC.map(e=>e.clone().multiply(Sl).applyMatrix4(Ru))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=v5.map(([e,n])=>new Hn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=x5.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Qi={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Sb=class extends bh{constructor(){super()}getPoints(t=12){let e=[],n,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?i[a]:i[a]-i[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let m=h[f];n&&n.equals(m)||(e.push(m),n=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Ab=.001;function _b(r,t,e){return t.clone().sub(r).cross(t.clone().sub(e)).length()<=Ab}function wb(r,t){let e=new A(...r.position),n=new A(...r.controlNext.position),i=new A(...t.controlPrevious.position),s=new A(...t.position);return _b(e,n,s)&&_b(e,i,s)}function Rg(r){let t=r.points.map(c=>new A(...c.data.position)),e=[r.points[0]],n=new A(...e[0].data.position);for(let c=0;c<r.points.length-1;c++)_b(n,t[c],t[c+1])||(e.push(r.points[c]),n=t[c]);e.push(r.points[r.points.length-1]);let i=r.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new A(...d.position),f=new A(...d.controlPrevious.position),m=new A(...d.controlNext.position),p={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!r.isClosed&&(c===0||c===o-1)){a[c]={...p,removedLength:0};continue}let g=i&&c==0?o-1:c-1,y=i&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,w=new A(...v.position),S=new A(...x.position),_=w.clone().sub(h).normalize(),M=S.clone().sub(h).normalize();Object.assign(p,{prevDir:_,nextDir:M});let b=wb(v,d),E=wb(d,x);if(!b||!E)a[c]={...p,removedLength:0};else{let T=_.clone().add(M).normalize(),P=T.clone().cross(_).length()/_.dot(T);a[c]={...p,tan:P,removedLength:d.roundness/P}}}for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],m=a[h];if(f.removedLength!==0||m.removedLength!==0){let p=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,p/2),m.removedLength=Math.min(m.removedLength,p/2)}}let l=[];for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],m=a[h],p=null;if(!wb(e[d].data,e[h].data))f.position.distanceTo(m.position)>Ab&&(p=new Ka(f.position,f.controlNext,m.controlPrevious,m.position));else{let g=f.position.clone(),y=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&y.add(m.prevDir.clone().setLength(m.removedLength))),g.distanceTo(y)>Ab&&(p=new Ka(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=p}for(let c=0;c<o;c++){let d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),m=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),p=d.tan*d.removedLength,g=d.prevDir.clone().add(d.nextDir).normalize(),y=f.clone().lerp(m,.5),v=f.distanceTo(m)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(v,2))).add(y),w=g.clone().multiplyScalar(-p).add(x),S=h.distanceTo(w)/h.distanceTo(y),_=d.prevDir.clone().multiplyScalar(S*h.distanceTo(f)).add(h),M=_.clone().lerp(w,2),b=f.clone().lerp(_,4/3),E=m.clone().lerp(M,4/3);l[2*c]=new Ka(f,b,E,m)}let u=new Sb;return l.forEach(c=>{c&&u.add(c)}),u}var St;(t=>{function r(e){return e&&e.__isEntity}t.is=r})(St||(St={}));var Ao=r=>St.is(r),b5={type:"completeState",isfromEntity:!0},Lg=r=>class extends Ou(r){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new sf;this._recursiveBBox=new sf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let i=this.children[n];if(St.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let n=this;for(;n.data.type!=="Instance";){let i=n.parent;if(St.is(i))n=i;else return}return n}forInstancesRec(n){this.instances.forEach(i=>{i.disposed||n(i),i.forInstancesRec(n)})}super_Entity(n,i){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)xo.toOps(this.data,o.data).forEach(l=>{let u=Hm.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,i)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=xo.patch(this.data,o),xo.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched),this.stateSelection=n,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(n,i){n.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Ao(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let i;return this.traverseEntity(s=>{s.uuid===n&&(i=s)}),i}traverseSortNextHelper(){let n=this.parent;if(n){let i=n.children,s=i.indexOf(this)+1;if(St.is(i[s]))return i[s];if(St.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&St.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let i=this;for(;n>0&&i!==null;)i=i.parent,n-=1;return i}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let i=this.parent;for(;i;){if(n===i)return!0;i=i.parent}return!1}countToAccestor(n){let i=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(n){for(let i of this.children)Ao(i)&&n(i)}traverseEntityAncestors(n){this.traverseAncestors(i=>{St.is(i)&&n(i)})}traverseEntity(n,i=0){if(n(this,i)!==!0)for(let o of this.children)Ao(o)&&o.traverseEntity(n,i+1)}traverseVisibleEntity(n){n(this);for(let i of this.children)Ao(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,i=!1){return super.copy(n,i),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Ao(n))}isAncestorOf(n){if(this.uuid===n)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===n&&(i=!0)}),i}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return eu(i,n)}updateTransformState(n){let i=!1;return n.position&&(this.position.fromArray(n.position),i=!0),n.rotation&&(this.rotation.fromArray(n.rotation),i=!0),n.scale&&(i=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??la.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)St.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{St.is(n)&&n.disposeRecursively()})}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return eu(i,n)}updateByOp(n,i,s,o){let a=this.data;this.data=i;let l=n,u=Wi(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=Lr.zoom(h,n.path.slice(2));if(f)for(let m in n.props)n.props[m]===void 0&&m in f&&(d[m]=f[m])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=Lr.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,xo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Wi(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(mo.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=Lr.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let m=n.props;if(f)for(let[p,g]of Object.entries(n.props))g===void 0&&(m===n.props&&(m={...n.props}),m[p]=f[p]);n={...n,props:m}}h.overrideData=mu.resolve(i.overrides,c),h.updateByOp(n,gr.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of ua.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of ua.rootOverrideProps)if(Wi(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=mo.filterOp(d.overrideData,c);h&&d.updateByOp(h,gr.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=mo.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=i:f=gr.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,i,s){if(this.dataPatched=i,n.path.length===0&&n.type===0)n.props.type!==void 0&&!ji.is(n.props.type)&&Qi.changeEntityProptotype(this,i,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){Qi.changeEntityProptotype(this,i,s);for(let o of this.children)St.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,i,s)}updateByPatchedOp(n,i,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Wi(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Wi(n.path,["cloner"])!==null){let o=gr.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=n.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data,c=Rg(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new ae;l.updateMatrixWorld();let m=new ae().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(m);let p={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ae().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(g).add(h),v=new ae().lookAt(h,y,new A(0,1,0)),x=new Wt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(b5)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,i){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,i),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof Qi.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,i){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Qi.Cloner(this,n),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,i.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var Ng=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},r.parameters),n=e.width/2,i=e.radiusTop??n,s=e.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=r.parameters,m;return d||f?m=new of(u,c,n,i,s,o,a,l*Math.PI/180,d,d,h,f):m=new Ja(u,c,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,e/t),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function pa(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function mC(r){return new F(r.y,-r.x)}var of=class extends Me{constructor(t,e,n,i,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],y=[],v=0,x=n/2,w=new A,S=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let _=new F(t,x),M=new F(e,-x),b=null,E=null,T=null,P=null,D=_.clone().sub(M),C=0,O=0,B=0;h>0&&(C=Math.min(t,e)*(1-h),O=t-C,B=e-C);let V=_.clone();V.x-=C;let Y=Math.PI-D.angle(),W=D.angle(),q=Math.tan(W/2),j=Math.tan(Y/2),X=q+j,L=h?X:j,U=h?X:q;if(u=Math.min(u,(t-O)/L,D.length()/X),c=Math.min(c,(e-B)/U,D.length()/X),u>0){let Z=u/q;b=_.clone().sub(new F(Z,u)),h&&(T=b.clone(),T.x-=C-X*u),_.sub(D.clone().setLength(Z))}if(c>0){let Z=c/j;E=M.clone().sub(new F(Z,-c)),M.add(D.clone().setLength(Z)),h&&(P=E.clone(),P.x-=C-X*c,V.sub(D.clone().setLength(Z)))}D=_.clone().sub(M);let G=D.length()<.5,H=[];for(let Z=0;Z<=i;Z++){let k=[],he=Z/i,fe=he*l+a,ce=new F(Math.sin(fe),Math.cos(fe));P&&E?(z(k,he,ce,Y,c,P,-1,!0),z(k,he,ce,W,c,E,-1,!1)):E?(re(k,ce,E.x,0,-1),z(k,he,ce,W,c,E,-1,!1)):o||re(k,ce,e,B,-1);let ye=mC(D).normalize();if(pa(ye,ce,w),!G)for(let Se=0;Se<=s;Se++){let ve=Se/s,Ee=D.clone().multiplyScalar(ve).add(M);pa(Ee,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}if(T&&b?(z(k,he,ce,Y,u,b,1,!1),z(k,he,ce,W,u,T,1,!0)):b?(z(k,he,ce,Y,u,b,1,!1),re(k,ce,b.x,0,1)):o||re(k,ce,t,O,1),h&&!G){let Se=mC(D).multiplyScalar(-1).normalize();pa(Se,ce,w);for(let ve=0;ve<=s;ve++){let Ee=ve/s,Te=D.clone().multiplyScalar(-Ee).add(V);pa(Te,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}}h&&!o&&k.push(k[0]),H.push(k)}for(let Z=0;Z<H.length-1;Z++)for(let k=0;k<H[0].length-1;k++){if(o&&h&&k==s)continue;let he=H[Z][k],fe=H[Z+1][k],ce=H[Z+1][k+1],ye=H[Z][k+1],Se=p[ce*3+0],ve=p[ce*3+2];m.push(he,fe,ye),(Se!=0||ve!=0)&&m.push(fe,ce,ye)}l<Math.PI*2&&(K(-1,H[0],a),K(1,H[H.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(y,2));function z(Z,k,he,fe,ce,ye,Se,ve){for(let Ee=0;Ee<d+1;Ee++){let Te=Ee/d,we=Se<0?Te:1-Te;ve&&(we-=1),we*=fe;let Ge=new F(Math.sin(we),Math.cos(we)*Se),gt=Ge.clone().multiplyScalar(ce).add(ye);pa(gt,he,S),p.push(S.x,S.y,S.z),pa(Ge,he,w),g.push(w.x,w.y,w.z),y.push(k,.5+S.y/n),Z.push(v++)}}function re(Z,k,he,fe,ce){let ye=new A,Se=new F,ve=[he,fe];ce<0&&ve.reverse();for(let Ee of ve)Se.set(Ee,x*ce),pa(Se,k,ye),p.push(ye.x,ye.y,ye.z),g.push(0,ce,0),y.push(.5,.5),Z.push(v++)}function K(Z,k,he){let fe=new F(Math.sin(he),Math.cos(he)),ce=new F(-Math.cos(he),Math.sin(he)),ye=new A,Se=Z<0?(Te,we,Ge)=>m.push(Te,we,Ge):(Te,we,Ge)=>m.push(Te,Ge,we),ve=new F((t+e+O+B)/4,0);pa(ve,fe,ye),p.push(ye.x,ye.y,ye.z),g.push(ce.x,0,ce.y),y.push(.5,.5);let Ee=v++;for(let Te of k){let we=p.slice(Te*3,Te*3+3);p.push(...we),g.push(ce.x,0,ce.y);let Ge=y.slice(Te*2,Te*2+2);y.push(...Ge),v++}for(let Te=Ee+1;Te<v-1;Te++)Se(Ee,Te,Te+1);Se(Ee,v-1,Ee+1)}}};var gC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=r.parameters,h;return u>0||c>0||l<360?h=new of(0,t/2,n,i,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new fc(t/2,n,i,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...r,type:"ConeGeometry"}})}};var yC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new er(t,e,n,i,s,o):u=new Eb(t,e,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},Mb=Math.PI/2,Eb=class extends Me{constructor(t=1,e=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,i,o,2),g("x","z","y",1,-1,t,n,-e,i,o,3),g("x","y","z",1,-1,t,e,n,i,s,4),g("x","y","z",-1,-1,t,e,-n,i,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,i,0),y("x","y","z",1,-1,1,t,e,n,i,1),y("x","y","z",-1,1,1,t,e,n,i,0),y("x","y","z",1,1,-1,t,e,n,i,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function g(x,w,S,_,M,b,E,T,P,D,C){let O=(b-2*a)/P,B=(E-2*a)/D,V=b/2-a,Y=E/2-a,W=T/2,q=P+1,j=D+1,X=0,L=0,U=new A;for(let G=0;G<j;G++){let H=G*B-Y;for(let z=0;z<q;z++){let re=z*O-V;U[x]=re*_,U[w]=H*M,U[S]=W,d.push(U.x,U.y,U.z),U[x]=0,U[w]=0,U[S]=T>0?1:-1,h.push(U.x,U.y,U.z),f.push(z/P),f.push(1-G/D),X+=1}}for(let G=0;G<D;G++)for(let H=0;H<P;H++){let z=m+H+q*G,re=m+H+q*(G+1),K=m+(H+1)+q*(G+1),Z=m+(H+1)+q*G;c.push(z,re,Z),c.push(re,K,Z),L+=6}u.addGroup(p,L,C),p+=L,m+=X}function y(x,w,S,_,M,b,E,T,P,D,C){let O=(E-2*a)/D,B=E/2-a,V=T/2-a,Y=P/2,W=D+1,q=0,j=0,X=new A,L=new A;for(let U=0;U<l+1;U++){let G=U/l*Mb,H=Math.sin(G)*a,z=(1-Math.cos(G))*a,re=Math.sin(G),K=Math.cos(G);X[w]=(V+H)*M,X[S]=(Y-z)*b,L[x]=0,L[w]=re*Math.sign(X[w]),L[S]=K*Math.sign(X[S]);for(let Z=0;Z<W;Z++){let k=Z*O-B;X[x]=k*_,d.push(X.x,X.y,X.z),h.push(L.x,L.y,L.z),f.push(Z/D),f.push(0),q+=1}}for(let U=0;U<l;U++)for(let G=0;G<D;G++){let H=m+G+W*U,z=m+G+W*(U+1),re=m+(G+1)+W*(U+1),K=m+(G+1)+W*U;c.push(H,z,K),c.push(z,re,K),j+=6}u.addGroup(p,j,C),p+=j,m+=q}function v(x,w,S){let _=new A,M=new A(t/2,e/2,n/2);M.subScalar(a);let b=[],E=x*w*S>0?(P,D,C)=>c.push(P,D,C):(P,D,C)=>c.push(P,C,D);for(let P=0;P<=l;P++){let D=[],C=Mb*(1-P/l),O=Math.cos(C),B=Math.sin(C),V=0;for(let Y=0;Y<=P;Y++){let W=Math.cos(V),q=Math.sin(V);_.x=O*W,_.y=B,_.z=O*q;let j=M.clone().addScaledVector(_,a);d.push(x*j.x,w*j.y,S*j.z),h.push(x*_.x,w*_.y,S*_.z),f.push(0,0),D.push(m++),V+=Mb/P}b.push(D)}let T=b.length-1;for(let P=0;P<T;P++){let D=b[P],C=b[P+1],O=D.length-1;E(D[0],C[1],C[0]);for(let B=1;B<=O;B++)E(D[B-1],D[B],C[B]),E(D[B],C[B+1],C[B])}}}};var ma=class extends Me{constructor(t=[],e=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new an,y=s*i,v=i-y,x=o+1,w=new A,S=(q,j)=>w.subVectors(q,j).normalize(),_=(q,j)=>Array(q).fill(void 0).map(j),M=_(t.length/3,(q,j)=>new A().fromArray(t,j*3).setLength(i)),b=[],E=1e6;for(let q=0;q<M.length;q++){let j=M[q],X=[],L,U,G,H=1e10,z=-1;for(;(z=e.indexOf(q,z+1))!=-1;){let k=z-z%3;L=e[k+(z+1)%3],U=e[k+(z+2)%3],G=j.distanceToSquared(M[L]),H=Math.min(H,G),X.push([L,U,G])}H+=1e-6;let re=[],K=0,Z=X.length;for(let k=0;k<Z;k++){[L,U,G]=X[K];let he=b[L]?.includes(q)==!0;G<=H&&re.push(L+ +he*E),K=X.findIndex(fe=>fe[0]==U)}b.push(re)}let T=[];{let q=0,j=0,X,L,U=f==3;for(let G=0;G<=o;G++){X=G*(G+1)/2,L=(G+1)*(G+2)/2;for(let H=0;H<o-G;H++)[q,j]=[X+H+G+2,L+H+G+3],T.push(X,L,...U?[j,X]:[q,L],j,q),[X,L]=[q,j];T.push(X,L,X+o+2)}}let P=m.clone(),D=m.clone(),C=m.clone(),O=m.clone(),B=m.clone(),V=[],Y=_(M.length,()=>_(f,()=>m.clone()));for(let q=0;q<M.length;q++){m.copy(M[q]).normalize(),P.copy(m).multiplyScalar(v);let j=b[q];for(let re=0;re<j.length;re++){let K=j[re],Z=j[(re+1)%f];g.setFromPointsAndIndices(M,q,K%E,Z%E),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(P,Y[q][re])}let X=[],L=[],U=[],G=new A;o==0&&[...Y[q]].reduce((re,K)=>re.add(K),G).multiplyScalar(1/f);for(let re=0;re<f;re++){let K=[],Z=(re-1+f)%f,k=Y[q][Z],he=Y[q][re];m.copy(k).sub(P),p.copy(he).sub(P);let fe=P.angleTo(m),ce=m.angleTo(p),ye=Math.cos(fe)*y;o==0?D.copy(G):D.copy(P).setLength(v+ye),L.push(ye);let Se=[D,k,he];for(let ve=0;ve<2;ve++){let Ee=Se[ve],Te=Se[ve+1];O.subVectors(Ee,P),B.subVectors(Te,P),C.crossVectors(O,B).normalize();for(let we=0;we<x;we++){let Ge=[fe,ce][ve]*we/x;m.copy(O).applyAxisAngle(C,Ge).add(P),X.push(m.clone()),ve&&(S(m,P),K.push([we==0?Ee:m.clone(),w.clone()]))}ve&&(S(Te,P),K.push([Te,w.clone()]))}U.push(K)}V.push(U);let H=2*x,z=2;for(let re=0;re<f;re++){let K=H*re,Z=H*((re+1)%f),k=[X[K]];for(let fe=1;fe<x;fe++){O=X[K+fe],B=X[Z+fe],k.push(O);for(let ce=1,ye=fe-z+1;ce<=ye;ce++)m.lerpVectors(O,B,ce/(ye+1)),m.sub(P).setLength(L[re]).add(P),k.push(m.clone());k.push(B)}for(let fe=0;fe<x;fe++)k.push(X[fe+x+K]);k.push(X[Z+x]);let he=T.map(fe=>k[fe]);a.push(...he.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...he.map(fe=>(S(fe,P),[w.x,w.y,w.z])).flat())}}let W=[];for(let q=0;q<b.length;q++)for(let j=0;j<f;j++){let X=b[q][j];if(X<E){let L=b[X].findIndex(H=>H%E==q),U=V[q][j],G=V[X][L];for(let H=0;H<x;H++){let z=U[H],re=G[x-H],K=U[H+1],Z=G[x-(H+1)];[z,re,K,K,re,Z].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),u.push(k[1].x,k[1].y,k[1].z)})}W.push(U[0][0],G[x][0],U[x][0],G[0][0])}}for(;W.length;){let q,j,X,L;[q,j]=W.splice(0,2);let U=[q];for(;q!=j;)U.push(j),X=W.indexOf(j),L=X%2,j=W.splice(X-L,2)[1-L];w.subVectors(U[0],U[1]).cross(m.subVectors(U[0],U[2])).normalize();let G=w.dot(U[0])<0;G&&w.negate();for(let H=1;H<=U.length-2;H++)[U[H+ +G],U[H+1-+G],U[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(w.x,w.y,w.z)})}}function d(){let h=new A;for(let M=0;M<a.length;M+=3){h.x=a[M+0],h.y=a[M+1],h.z=a[M+2];let b=S(h)/2/Math.PI+.5,E=_(h)/Math.PI+.5;l.push(b,1-E)}let f=new A,m=new A,p=new A,g=new A,y=new F,v=new F,x=new F,w=(M,b,E,T)=>{T<0&&M.x===1&&(l[b]=M.x-1),E.x===0&&E.z===0&&(l[b]=T/2/Math.PI+.5)};for(let M=0,b=0;M<a.length;M+=9,b+=6){f.set(a[M+0],a[M+1],a[M+2]),m.set(a[M+3],a[M+4],a[M+5]),p.set(a[M+6],a[M+7],a[M+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(m).add(p).divideScalar(3);let E=S(g);w(y,b+0,f,E),w(v,b+2,m,E),w(x,b+4,p,E)}for(let M=0;M<l.length;M+=6){let b=l[M+0],E=l[M+2],T=l[M+4],P=Math.max(b,E,T),D=Math.min(b,E,T);P>.9&&D<.1&&(b<.2&&(l[M+0]+=1),E<.2&&(l[M+2]+=1),T<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new ma(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var vC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new af(t*.5,s,o):new mc(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},af=class extends ma{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new af(t.radius,t.corner,t.cornerSides)}};var lf=1e-12,Lu=class{constructor(t){this.position=new F;this.startPosition=new F;this.uuid=He.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Lu(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Nu=class extends Lu{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Nu(this.parent).copy(this)}},Ki=class extends Lu{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Nu(this),new Nu(this))}static create(e,n){let i=new Ki(e,new F(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Ki(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new F,n=new F){let[i,s]=this.computeTangents();return i&&s&&(xC(i,e),xC(s,n)),[e,n]}computeTangent(e=new F){let[n,i]=this.computeTangents();return n&&i&&e.copy(n).add(i).normalize(),e}computeNormal(e=new F){let[n,i]=this.computeNormals();return e.copy(n).add(i).normalize(),e}};function xC(r,t=new F){let e=r.length();return t.set(-r.y/e,r.x/e)}var Cb=r=>r,Bu=new F,Bg=new F,w5=new F,S5=new F,A5=new F,_5=new F,wC=new A,SC=new A;function AC(r){let t=new F;t.addVectors(r.v0,Bu.subVectors(r.v1,r.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(r.v2,Bg.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new Sr(r.v0,t,e,r.v2)}function cf(r,t,e=Number.EPSILON){return Math.abs(r-t)<e}function M5(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function E5(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function Pb(r,t,e){let n=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function _C(r,t,e){return bC(r,t)&&bC(t,e)&&Tb(r.position,t.position,e.position)}function Tb(r,t,e){return Bu.copy(t).sub(r).cross(Bg.copy(e).sub(r))===0}function MC(r,t,e,n,i){let s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),o=(r.y+t.y)/2,a=(r.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(r.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function EC(r,t,e){let n=r.distanceTo(e),i=t.distanceTo(e);return n<i?t:r}function TC(r,t,e,n,i,s){let o=t.x-r.x,a=t.y-r.y,l=e.x-r.x,u=e.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return Pb(t,r,e)>Math.PI&&(c*=-1),cf(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),i.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[i,s]}function Db(r,t){return r.position.equals(r.controls[1].position)&&t.position.equals(t.controls[0].position)}function bC(r,t){return Tb(r.position,r.controls[1].position,t.position)&&Tb(r.position,t.controls[0].position,t.position)}function CC(r,t,e,n,i=.5){let s=Bu.subVectors(t,r).multiplyScalar(i).add(r),o=Bg.subVectors(e,t).multiplyScalar(i).add(t),a=w5.subVectors(n,e).multiplyScalar(i).add(e),l=s,u=S5.subVectors(o,s).multiplyScalar(i).add(s),c=A5.subVectors(a,o).multiplyScalar(i).add(o),d=a,h=_5.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function PC(r,t,e=12,n=!0){let i=SC.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=Cb(t[l]),c=Bu,d=ga(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof Sr||u instanceof ai||u instanceof Ar){if(u.getPoint(h/d,c),i.set(c.x,c.y,0),s!==void 0&&E5(s,i))continue;s===void 0&&(s=wC),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function DC(r,t,e,n=12,i=!0){let s=SC.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Cb(t[l]),d=Bu,h=ga(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof Sr||c instanceof ai||c instanceof Ar){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=wC:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function Ib(r,t=12,e=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=ga(o.roundedCurveCorner,t)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=ga(o.curveAfter,t)),n.push(a)}return r.length>0&&e&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=ga(r[0].roundedCurveCorner,t)*.5),n}function ga(r,t=12){return r&&r instanceof Qa?t*2:r&&(r instanceof Ar||r instanceof xh)?1:r&&r instanceof dc?t*r.points.length:t}function IC(r,t,e=12,n=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=Cb(t[o]),l=ga(a,e),u=Bu;for(let c=0;c<=l;c++)if(a instanceof Sr||a instanceof ai||a instanceof Ar){if(a.getPoint(c/l,u),i!==void 0&&M5(i,u,lf))continue;i===void 0&&(i=Bg),i.copy(u),r.push(u.x,u.y),s++}}return cf(r[0],r[r.length-2],lf)&&cf(r[1],r[r.length-1],lf)&&(r.pop(),r.pop()),n&&s>1&&!(cf(r[s-1],r[1],lf)&&cf(r[s-2],r[0],lf))&&(r.push(r[0],r[1]),s++),r}var Ob=new F,T5=new F,C5=new F,P5=new F,D5=new F,I5=new F,Mt=class extends ao{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new yn(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=He.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,i){let s=new Mt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Ki.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Mt.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let i=Ob.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,i=He.generateUUID()){let s;e instanceof F?s=e:s=new F(e,n);let o=new Ki(i,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(i=>i.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return PC(e,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Ib(this.points,e,!1),this.roundedCurveDivisions=Ib(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,i=12){return DC(e,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),IC(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=ga(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(e,n,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(Db(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(Ob.set(i.x,i.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){Db(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,n.curveAfter=i;let s=i.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(n,i)}if(this.points.length>2){let n=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],u=o.roundness,c=a&&l&&_C(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,m=o.roundedCurveAfter,p=d.getLength(),g=h.getLength(),y=Math.min(u,p*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/p,S=x/g,_=d.getPointAt(w,Ob),M=h.getPointAt(S,T5);this._subSplitCurve(d,f,w,_,void 0),this._subSplitCurve(h,m,S,void 0,M);let b;if(this.useCubicForRoundedCorners){let E=Pb(_,o.position,M)/2,T=Math.tan(E)*_.distanceTo(o.position),[P,D]=MC(_,M,T,C5,P5),C=EC(P,D,o.position),[O,B]=TC(C,_,M,T,D5,I5);b=new Sr(_.clone(),O.clone(),B.clone(),M.clone())}else b=new ai(_.clone(),o.position.clone(),M.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+n,0,b),n++}}}}_subSplitCurve(e,n,i,s,o){if(e instanceof Ar)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(i,0),c=CC(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let e=new Mt(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],d=e.points[s+5],h=e.points[s+6],f=new Ki(He.generateUUID(),new F(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new Mt;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof Sr&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof ai&&(s[a]=AC(s[a]));for(a=0,l=s.length;a<l;a++){let d=s[a],h=a>0?s[a-1]:null,f;d instanceof Sr?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Ar&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&n(f,h),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof Sr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof Ar&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(e.curves),e instanceof ao&&(this.shapeHoles=e.holes.map(s=>{let o=new Mt;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let i=this.getPointByUuid(e);i&&(n.position!==void 0&&i.position.fromArray(n.position),n.roundness!==void 0&&(i.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var Lb=Math.PI*2;function Rb({x:r,y:t},e,n,i,s){return{x:r*e+i,y:t*n+s}}function O5(r,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-i*e,y:i+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function OC(r,t,e,n){let i=r*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,r*e+t*n));return i*Math.acos(s)}function R5(r,t,e,n,i,s,o,a,l,u){let c=Math.pow(i,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),m=c*d-c*f-d*h;m<0&&(m=0),m/=c*f+d*h,m=Math.sqrt(m)*(l===u?-1:1);let p=m*i/s*a,g=m*-s/i*o,y=p+(r+e)/2,v=g+(t+n)/2,x=(o-p)/i,w=(a-g)/s,S=(-o-p)/i,_=(-a-g)/s,M=OC(1,0,x,w),b=OC(x,w,S,_);return!u&&b>0&&(b-=Lb),u&&b<0&&(b+=Lb),{centerx:y,centery:v,ang1:M,ang2:b}}function RC({px:r,py:t,cx:e,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(i*=Math.sqrt(d),s*=Math.sqrt(d));let h=R5(r,t,e,n,i,s,u,c,o,a),{ang1:f,ang2:m}=h,{centerx:p,centery:g}=h,y=Math.abs(m)/(Lb/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);m/=v;for(let x=0;x<v;x++)l.push(O5(f,m)),f+=m;return l.map(x=>{let{x:w,y:S}=Rb(x[0],i,s,p,g),{x:_,y:M}=Rb(x[1],i,s,p,g),{x:b,y:E}=Rb(x[2],i,s,p,g);return{x1:w,y1:S,x2:_,y2:M,x:b,y:E}})}var mt;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(mt||(mt={}));var sn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(sn||(sn={}));function $e(r,t){if(!r)throw t||"Assertion Failed!"}var je=function(){function r(){}return r.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},r.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},r.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},r.edgeGoesLeft=function(t){return r.vertLeq(t.Dst,t.Org)},r.edgeGoesRight=function(t){return r.vertLeq(t.Org,t.Dst)},r.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},r.edgeEval=function(t,e,n){$e(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-n.t)*(i/(i+s)):e.t-n.t+(n.t-t.t)*(s/(i+s)):0},r.edgeSign=function(t,e,n){$e(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?(e.t-n.t)*i+(e.t-t.t)*s:0},r.transEval=function(t,e,n){$e(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-n.s)*(i/(i+s)):e.s-n.s+(n.s-t.s)*(s/(i+s)):0},r.transSign=function(t,e,n){$e(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?(e.s-n.s)*i+(e.s-t.s)*s:0},r.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},r.interpolate=function(t,e,n,i){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+i)/2:e+(i-e)*(t/(t+n)):i+(e-i)*(n/(t+n))},r.intersect=function(t,e,n,i,s){var o,a,l;r.vertLeq(t,e)||(l=t,t=e,e=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.vertLeq(n,e)?r.vertLeq(e,i)?(o=r.edgeEval(t,n,e),a=r.edgeEval(n,e,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,e.s)):(o=r.edgeSign(t,n,e),a=-r.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+e.s)/2,r.transLeq(t,e)||(l=t,t=e,e=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.transLeq(n,e)?r.transLeq(e,i)?(o=r.transEval(t,n,e),a=r.transEval(n,e,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,e.t)):(o=r.transSign(t,n,e),a=-r.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+e.t)/2},r}(),uf=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Fg=function(){function r(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),r}(),Fu=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),LC=function(){function r(){var t=new Fu,e=new uf,n=new Fg(0),i=new Fg(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(t){var e=new Fg(0),n=new Fg(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return n.next=i,i.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},r.prototype.splice_=function(t,e){var n=t.Onext,i=e.Onext;n.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=n},r.prototype.makeVertex_=function(t,e,n){var i=t;$e(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},r.prototype.makeFace_=function(t,e,n){var i=t;$e(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=n.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},r.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},r.prototype.killVertex_=function(t,e){var n=t.anEdge,i=n;do i.Org=e,i=i.Onext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.killFace_=function(t,e){var n=t.anEdge,i=n;do i.Lface=e,i=i.Lnext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var t=new Fu,e=new Fu,n=new uf,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(t,e){var n=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new Fu;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new uf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},r.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!n){var i=new uf;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},r.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Fu;return this.makeVertex_(i,n,e.Org),e.Lface=n.Lface=t.Lface,e},r.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},r.prototype.connect=function(t,e){var n=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new uf;this.makeFace_(o,i,t.Lface)}return i},r.prototype.zapFace=function(t){var e=t.anEdge,n,i,s,o,a;i=e.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},r.prototype.mergeConvexFaces=function(t){var e,n,i,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&je.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&je.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=t,s=t;(i=s.next)!==t;s=i){$e(i.prev===s),l=i.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for($e(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){$e(o.prev===a),l=o.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for($e(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)$e(l.Sym.next===u.Sym),$e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Org!==null),$e(l.Dst!==null),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l);$e(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),NC=function(){function r(){this.handle=null}return r}(),BC=function(){function r(){this.key=null,this.node=0}return r}(),L5=function(){function r(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var n=0;n<t+1;n++)this.nodes[n]=new NC,this.handles[n]=new BC;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,$e(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[i].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new NC;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new BC}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},r.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,i=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(t){var e=this.nodes,n=this.handles,i;$e(t>=1&&t<=this.max&&n[t].key!==null),i=n[t].node,e[i].handle=e[this.size].handle,n[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[e[i>>1].handle].key,n[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},r}(),Nb=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),FC=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),N5=function(){function r(t,e){this.frame=t,this.leq=e,this.head=new FC,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(t){return this.insertBefore(this.head,t)},r.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},r.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new FC;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},r.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},r}(),B5=function(){function r(){}return r.regionBelow=function(t){return t.nodeUp.prev.key},r.regionAbove=function(t){return t.nodeUp.next.key},r.debugEvent=function(t){},r.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.edgeLeq=function(t,e,n){var i=t.event,s=e.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?je.vertLeq(s.Org,o.Org)?je.edgeSign(o.Dst,s.Org,o.Org)<=0:je.edgeSign(s.Dst,o.Org,s.Org)>=0:je.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return je.edgeSign(s.Dst,i,s.Org)>=0;var a=je.edgeEval(s.Dst,i,s.Org),l=je.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(t,e){e.fixUpperEdge&&$e(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},r.fixUpperEdge=function(t,e,n){$e(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},r.topLeftRegion=function(t,e){var n=e.eUp.Org,i;do e=r.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(i=t.mesh.connect(r.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;r.fixUpperEdge(t,e,i),e=r.regionAbove(e)}return e},r.topRightRegion=function(t){var e=t.eUp.Dst;do t=r.regionAbove(t);while(t.eUp.Dst===e);return t},r.addRegionBelow=function(t,e,n){var i=new Nb;return i.eUp=n,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(t,e){switch(t.windingRule){case mt.ODD:return(e&1)!==0;case mt.NONZERO:return e!==0;case mt.POSITIVE:return e>0;case mt.NEGATIVE:return e<0;case mt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(t,e){e.windingNumber=r.regionAbove(e).windingNumber+e.eUp.winding,e.inside=r.isWindingInside(t,e.windingNumber)},r.finishRegion=function(t,e){var n=e.eUp,i=n.Lface;i.inside=e.inside,i.anEdge=n,r.deleteRegion(t,e)},r.finishLeftRegions=function(t,e,n){for(var i,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),r.finishRegion(t,o),a=s.eUp,o=s}return a},r.addRightEdges=function(t,e,n,i,s,o){var a,l,u,c,d=!0;u=n;do $e(je.vertLeq(u.Org,u.Dst)),r.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(e).eUp.Rprev),l=e,c=s;a=r.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=r.isWindingInside(t,a.windingNumber),l.dirty=!0,!d&&r.checkForRightSplice(t,l)&&(r.addWinding(u,c),r.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,$e(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(t,l)},r.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},r.vertexWeights=function(t,e,n){var i=je.vertL1dist(e,t),s=je.vertL1dist(n,t),o=.5*s/(i+s),a=.5*i/(i+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},r.getIntersectData=function(t,e,n,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,r.vertexWeights(e,n,i),r.vertexWeights(e,s,o)},r.checkForRightSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp;if(je.vertLeq(i.Org,s.Org)){if(je.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;je.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=n.dirty=!0)}else{if(je.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o;if($e(!je.vertEq(i.Dst,s.Dst)),je.vertLeq(i.Dst,s.Dst)){if(je.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(je.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},r.checkForIntersect=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,d,h=new Fu,f,m;if($e(!je.vertEq(u,l)),$e(je.edgeSign(l,t.event,o)<=0),$e(je.edgeSign(u,t.event,a)>=0),$e(o!==t.event&&a!==t.event),$e(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(je.vertLeq(o,a)){if(je.edgeSign(u,o,a)>0)return!1}else if(je.edgeSign(l,a,o)<0)return!1;return r.debugEvent(t),je.intersect(l,o,u,a,h),$e(Math.min(o.t,l.t)<=h.t),$e(h.t<=Math.max(a.t,u.t)),$e(Math.min(u.s,l.s)<=h.s),$e(h.s<=Math.max(a.s,o.s)),je.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=je.vertLeq(o,a)?o:a,je.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),je.vertEq(h,o)||je.vertEq(h,a)?(r.checkForRightSplice(t,e),!1):!je.vertEq(l,t.event)&&je.edgeSign(l,t.event,h)>=0||!je.vertEq(u,t.event)&&je.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=r.topLeftRegion(t,e),i=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),n),r.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),n=e,e=r.topRightRegion(e),m=r.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(t,n,null),r.addRightEdges(t,e,s.Onext,i.Rprev,m,!0),!0):(je.edgeSign(l,t.event,h)>=0&&(r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),je.edgeSign(u,t.event,h)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=h.s,i.Org.t=h.t,i.Org.pqHandle=t.pq.insert(i.Org),r.getIntersectData(t,i.Org,o,l,a,u),r.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(t,e){for(var n=r.regionBelow(e),i,s;;){for(;n.dirty;)e=n,n=r.regionBelow(n);if(!e.dirty&&(n=e,e=r.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(r.deleteRegion(t,n),t.mesh.delete(s),n=r.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(r.checkForIntersect(t,e))return}else r.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n))}},r.connectRightVertex=function(t,e,n){var i,s=n.Onext,o=r.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(t,e),je.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=r.topLeftRegion(t,e),s=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),o),u=!0),je.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(t,o,null),u=!0),u){r.addRightEdges(t,e,n.Onext,s,s,!0);return}je.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(n.Lprev,i),r.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(t,e)},r.connectLeftDegenerate=function(t,e,n){var i,s,o,a,l;if(i=e.eUp,je.vertEq(i.Org,n)){$e(!1),r.spliceMergeVertices(t,i,n.anEdge);return}if(!je.vertEq(i.Dst,n)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,i),r.sweepEvent(t,n);return}$e(!1),e=r.topRightRegion(e),l=r.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&($e(s!==o),r.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),je.edgeGoesLeft(s)||(s=null),r.addRightEdges(t,e,o.Onext,a,s,!0)},r.connectLeftVertex=function(t,e){var n,i,s,o,a,l,u=new Nb;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,je.edgeSign(o.Dst,e,o.Org)===0){r.connectLeftDegenerate(t,n,e);return}if(s=je.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?r.fixUpperEdge(t,s,l):r.computeWinding(t,r.addRegionBelow(t,n,l)),r.sweepEvent(t,e)}else r.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},r.sweepEvent=function(t,e){t.event=e,r.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){r.connectLeftVertex(t,e);return}var i=r.topLeftRegion(t,n.activeRegion);$e(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(t,s,null);a.Onext===o?r.connectRightVertex(t,i,a):r.addRightEdges(t,i,a.Onext,o,o,!0)},r.addSentinel=function(t,e,n,i){var s=new Nb,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},r.initEdgeDict=function(t){t.dict=new N5(t,r.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;r.addSentinel(t,i,s,o),r.addSentinel(t,i,s,a)},r.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||($e(e.fixUpperEdge),$e(++n===1)),$e(e.windingNumber===0),r.deleteRegion(t,e)},r.removeDegenerateEdges=function(t){var e,n,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,i=e.Lnext,je.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(r.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===n||i===n.Sym)&&(n=n.next),t.mesh.delete(i)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},r.initPriorityQ=function(t){var e,n,i,s=0;for(i=t.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,e=t.pq=new L5(s,je.vertLeq),i=t.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=e.insert(n);return n!==i?!1:(e.init(),!0)},r.donePriorityQ=function(t){t.pq=null},r.removeDegenerateFaces=function(t,e){var n,i,s;for(n=e.fHead.next;n!==e.fHead;n=i)i=n.next,s=n.anEdge,$e(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),t.mesh.delete(s));return!0},r.computeInterior=function(t,e){e===void 0&&(e=!0);var n,i;if(r.removeDegenerateEdges(t),!r.initPriorityQ(t))return!1;for(r.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!je.vertEq(i,n));)i=t.pq.extractMin(),r.spliceMergeVertices(t,n.anEdge,i.anEdge);r.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,r.debugEvent(t),r.doneEdgeDict(t),r.donePriorityQ(t),r.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},r}(),F5=function(){function r(){this.mesh=new LC,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=mt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},r.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},r.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},r.prototype.computeNormal_=function(t){var e,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;e=p.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,m[g]=e,l[g]=s,f[g]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,m[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,n=m[v],i=f[v],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],e=p.next;e!==p;e=e.next)d[0]=e.coords[0]-i.coords[0],d[1]=e.coords[1]-i.coords[1],d[2]=e.coords[2]-i.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(e=n.next;e!==n;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,i,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},r.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.prototype.tessellateMonoRegion_=function(t,e){var n,i;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;je.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;je.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(je.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(je.edgeGoesLeft(i.Lnext)||je.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(je.edgeGoesRight(n.Lprev)||je.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},r.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},r.prototype.setWindingNumber_=function(t,e,n){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},r.prototype.outputPolymesh_=function(t,e,n,i){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===sn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*i;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],i>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===sn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var m=l;m<n;++m)this.elements[h++]=-1}}},r.prototype.outputContours_=function(t,e){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new LC),t<2&&(t=2),t>3&&(t=3);for(var n=null,i=0;i<e.length;i+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[i+0],n.Org.coords[1]=e[i+1],t>2?n.Org.coords[2]=e[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(t,e,n,i,s,o){if(t===void 0&&(t=mt.ODD),e===void 0&&(e=sn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),B5.computeInterior(this,o);var a=this.mesh;return e===sn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===sn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,n,i),!0},r}();function Zi(r){var t=r.windingRule,e=t===void 0?mt.ODD:t,n=r.elementType,i=n===void 0?sn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,d=r.contours,h=d===void 0?[]:d,f=r.strict,m=f===void 0?!0:f,p=r.debug,g=p===void 0?!1:p;if(!h&&m)throw new Error("Contours can't be empty");if(!!h){var y=new F5;r.edgeCreateCallback&&(y.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(y.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,i,o,l,c,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var hae=mt.ODD,fae=mt.NONZERO,pae=mt.POSITIVE,mae=mt.NEGATIVE,gae=mt.ABS_GEQ_TWO,yae=sn.POLYGONS,vae=sn.CONNECTED_POLYGONS,xae=sn.BOUNDARY_CONTOURS;var Ug=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*Ug.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let n=t*Ug.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let u=new Float32Array(i,o*s,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=e,n}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},df=Ug;df.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var hf={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Fb={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Ub={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},Bb=(r,t)=>([e,n])=>(n<e&&(n+=t),(r>=e?r:r+t)<=n),Uu=class extends Me{constructor(e,n,i=0,s=12,o=3,a=mt.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(M=>{let b=M.extractShapePointsToFlatArray([],s),E=[];for(let T=b.length-1;T>=1;T-=2){let P=b[T-1],D=b[T-0];E.push(P,D)}return E}),c;try{c=Zi({windingRule:a,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=hf}let d;try{d=Zi({windingRule:mt.ODD,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=Fb}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let M=0;M<d.elements.length;M++){let b=d.elements[M],E=M%2===0?c.vertexCount:0;c.elements.push(b+E)}for(let M=0;M<d.vertexIndices.length;M++){let b=d.vertexIndices[M],E=c.vertexCount;c.vertexIndices.push(b+E)}for(let M=0;M<d.vertices.length;M++){let b=d.vertices[M];c.vertices.push(b)}}let f=1/0,m=-1/0,p=1/0,g=-1/0;for(let M=0,b=c.vertexCount;M<b;M++){let E=M*2,T=c.vertices[E+0],P=c.vertices[E+1];T<f&&(f=T),T>m&&(m=T),P<p&&(p=P),P>g&&(g=P)}this._minX=f,this._minY=p,this._width=m-f,this._height=g-p,this._buffer=new df(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let M=c.elementCount-1;M>=0;M--){let b=M>=h,E=M*2,T=c.elements[E+0],P=c.elements[E+1],D=T+P,C={start:T,count:P,normals:[],continuous:[],concave:[]},O=T,B=D-1,V=T+1,Y=this._shape.roundedCurves.length;do{let X=O-T,L=c.vertices[B*2+0],U=c.vertices[B*2+1],G=c.vertices[O*2+0],H=c.vertices[O*2+1],z=c.vertices[V*2+0],re=c.vertices[V*2+1],K=G-L,Z=H-U,k=Math.sqrt(K*K+Z*Z);K/=k,Z/=k;let he=G-z,fe=H-re,ce=Math.sqrt(he*he+fe*fe);he/=ce,fe/=ce,C.normals[X*2+0]=-fe,C.normals[X*2+1]=he,C.concave[X]=K*fe-Z*he>0;let ye=c.vertexIndices[O];if(Array.isArray(ye))C.continuous[X]=!1;else{let[Se,ve]=this._shape.getCurveIndexFromVertexId(ye-1,!0);if(ve>0&&ve<1)C.continuous[X]=!0;else{let Ee=ve===1?Se+1:Se-1;Ee=(Ee+Y)%Y;let Te=ve===1?0:1,we=this._shape.roundedCurves[Se].getTangent(ve),Ge=this._shape.roundedCurves[Ee].getTangent(Te);C.continuous[X]=we.dot(Ge)>.95}}b&&(C.normals[X*2+0]*=-1,C.normals[X*2+1]*=-1),[B,O,V]=[O,V,V+1],V>=D&&(V-=P)}while(V!==T+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(T*2,D*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((X,L)=>[L,L]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(T*2,D*2)});for(let X=1;X<=this._bevelSegments;X++){let L=X/this._bevelSegments*Math.PI/2,U=(1-Math.cos(L))*this._bevelSize,G=[],H=[],z=[],re=[],K=0;for(let k=0;k<P;k++){let he=k*2,fe=(k-1+P)%P*2,ce=c.vertices[C.start*2+he+0],ye=c.vertices[C.start*2+he+1],Se=-C.normals[fe+0]*U,ve=-C.normals[fe+1]*U,Ee=-C.normals[he+0]*U,Te=-C.normals[he+1]*U;if(C.concave[k]||!C.concave[k]&&b){let we=Math.atan2(ve,Se),Ge=Math.atan2(Te,Ee);Ge>we&&(Ge-=Math.PI*2);let gt=Ge-we;if(C.continuous[k]||b){let R=we+gt/2,I=Math.cos(R)*U,ee=Math.sin(R)*U;G[2*K+0]=ce+I*(b?-1:1),G[2*K+1]=ye+ee*(b?-1:1),re[K]=k,K++}else{let R=Math.max(1,Math.floor(s/4*Math.abs(gt)/Math.PI));for(let I=0;I<=R;I++){let ee=we+gt*(I/R),me=Math.cos(ee)*U,xe=Math.sin(ee)*U;G[2*K+0]=ce+me,G[2*K+1]=ye+xe,re[K]=k,K++}}}else G[2*K+0]=ce+Se,G[2*K+1]=ye+ve,re[K]=k,H[k]=K,K++,G[2*K+0]=ce,G[2*K+1]=ye,re[K]=k,K++,G[2*K+0]=ce+Ee,G[2*K+1]=ye+Te,re[K]=k,z[k]=K,K++}let Z=Zi({windingRule:mt.POSITIVE,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[G],edgeCreateCallback:k=>{let fe=k.Org.idx,ce=re[fe],ye=re[(fe+1)%re.length];k.idx=[ce,ye],k.Sym.idx=[ye,ce]},vertexIdCallback:k=>{let he=k.Lprev.idx;return[he?he[1]:0,k.idx?k.idx[0]:0]}});if(!Z)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!Z.vertexCount)break;for(let k=0;k<Z.vertexIndices.length;k++){let[he,fe]=Z.vertexIndices[k];if(he===fe)continue;let ce=fe;fe<he&&(ce+=P);for(let ye=he;ye<ce;ye++){let Se=ye%P,ve=(ye+1)%P;if(!C.continuous[Se]||!C.continuous[ve]){Z.vertexIndices[k]=[he,Se],Z.vertexIndices.splice(k+1,0,[ve,fe]),Z.vertices.splice((k+1)*2,0,Z.vertices[k*2],Z.vertices[k*2+1]);break}}}W.push({bevelI:X,angle:L,size:U,boundary:Z,reverseMap:re,insetPoints:G})}let q=(X,L,U)=>{let G=0,H=X.boundary.vertexIndices.length;for(;G<H&&U(X.boundary.vertexIndices[L]);)L=(L+1)%H,G++;return G},j=y.length;for(let X=1;X<W.length;X++){let L=W[X-1],U=W[X],G=L.boundary.vertexIndices.length,H=U.boundary.vertexIndices.length;if(!G||!H)break;let z=C.concave.length,re=0,K=Bb(re,P);for(;!L.boundary.vertexIndices.filter(K).length||!U.boundary.vertexIndices.filter(K).length;)re++,K=Bb(re,P);let Z=L.boundary.vertexIndices.findIndex(K),k=U.boundary.vertexIndices.findIndex(K);do Z=(Z+1)%G;while(K(L.boundary.vertexIndices[Z]));do k=(k+1)%H;while(K(U.boundary.vertexIndices[k]));re=(re+1)%P;let he=re,fe=this._buildBevelVert(C,L,(Z-1+G)%G),ce=this._buildBevelVert(C,U,(k-1+H)%H),ye=fe,Se=ce,ve,Ee,Te=!1;do{K=Bb(re,P);let we=q(L,Z,K),Ge=q(U,k,K),gt=Te;if(Te=!1,we&&!Ge){for(let R=0;R<we;R++)ve=this._buildBevelVert(C,L,(Z+R)%G,R/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve;Te=!0}else if(!we&&Ge)for(let R=0;R<Ge;R++)Ee=this._buildBevelVert(C,U,(k+R)%H,R/(Ge-1)),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,Se.bottomN,Ee.bottomP),Se=Ee;else if(we&&Ge)if(ve=this._buildBevelVert(C,L,Z,0),Ee=this._buildBevelVert(C,U,k,0),gt?(y.push(ye.topN,Ee.topP,Se.topN),y.push(ye.topN,ve.topP,Ee.topP),y.push(Ee.bottomP,ye.bottomN,Se.bottomN),y.push(Ee.bottomP,ve.bottomP,ye.bottomN)):(y.push(Se.topN,ye.topN,ve.topP),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP)),ye=ve,Se=Ee,we===Ge)for(let R=1;R<we;R++)ve=this._buildBevelVert(C,L,(Z+R)%G,R/(we-1)),Ee=this._buildBevelVert(C,U,(k+R)%H,R/(Ge-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),ye=ve,Se=Ee;else if(we>Ge){let R=we/Ge,I=0;for(let ee=1;ee<we;ee++)ve=this._buildBevelVert(C,L,(Z+ee)%G,ee/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve,ee>(I+1)*R&&(I++,Ee=this._buildBevelVert(C,U,(k+I)%H,I/(Ge-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee)}else{let R=Ge/we,I=0;for(let ee=1;ee<Ge;ee++)Ee=this._buildBevelVert(C,U,(k+ee)%H,ee/(Ge-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee,ee>(I+1)*R&&(I++,ve=this._buildBevelVert(C,L,(Z+I)%G,I/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve)}Z=(Z+we)%G,k=(k+Ge)%H,re=(re+1)%z}while(re!==he)}if(this._depth>this._bevel*2&&this._buildWall(W,C,y),b){let X=[];for(let L=y.length-1;L>=j+2;L-=3){let U=y[L-2],G=y[L-1],H=y[L-0];X.push(H,G,U)}y.splice(j,y.length-j,...X)}if(b){let X=[];for(let L=W[W.length-1].boundary.vertices.length-1;L>=1;L-=2){let U=W[W.length-1].boundary.vertices[L-1],G=W[W.length-1].boundary.vertices[L-0];X.push(U,G)}v.push(X)}if(!b){let X=W[W.length-1],L;try{L=Zi({windingRule:W.length>1?mt.POSITIVE:mt.ODD,elementType:sn.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,...v]})}catch{L=Ub}if(!L)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let U=0;U<L.elementCount*3;U+=3){let G=this._buildSurfaceVert(L,L.elements[U+0]),H=this._buildSurfaceVert(L,L.elements[U+1]),z=this._buildSurfaceVert(L,L.elements[U+2]);y.push(G.top,H.top,z.top),y.push(z.bottom,H.bottom,G.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Be(Uint32Array.from(y),1),w=new Be(this._buffer.positions,3),S=new Be(this._buffer.normals,3),_=new Be(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,_.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",_),this.setIndex(x)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=e.vertices[n*2+0],o=e.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=l,this.vertexCache[i]=h,h}_buildBevelVert(e,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=e.continuous[c]&&e.continuous[u]):(u=a,c=(u-1+e.count)%e.count,h=e.concave[u]&&n.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=u*2,y=c*2,v=n.boundary.vertices[p+0],x=n.boundary.vertices[p+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,_=(x-this._minY)/this._height,M=e.normals[g+0],b=e.normals[g+1],E=e.normals[y+0],T=e.normals[y+1];if(h){let B=E-M,V=T-b;M=M+B*(1-s),b=b+V*(1-s);let Y=Math.sqrt(M*M+b*b);M/=Y,b/=Y}let P=this._buffer.get(d?2:4),D=P*3,C=P*2,O={i,fi:u,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1};return this._buffer.positions[D+0]=v,this._buffer.positions[D+1]=x,this._buffer.positions[D+2]=this._depth-w,this._buffer.normals[D+0]=M*f,this._buffer.normals[D+1]=b*f,this._buffer.normals[D+2]=m,this._buffer.uvs[C+0]=S,this._buffer.uvs[C+1]=_,this._buffer.positions[D+3]=v,this._buffer.positions[D+4]=x,this._buffer.positions[D+5]=w,this._buffer.normals[D+3]=M*f,this._buffer.normals[D+4]=b*f,this._buffer.normals[D+5]=-m,this._buffer.uvs[C+2]=_,this._buffer.uvs[C+3]=S,d||(P+=2,D+=6,C+=4,O.topP=P+0,O.bottomP=P+1,this._buffer.positions[D+0]=v,this._buffer.positions[D+1]=x,this._buffer.positions[D+2]=this._depth-w,this._buffer.normals[D+0]=E*f,this._buffer.normals[D+1]=T*f,this._buffer.normals[D+2]=m,this._buffer.uvs[C+0]=S,this._buffer.uvs[C+1]=_,this._buffer.positions[D+3]=v,this._buffer.positions[D+4]=x,this._buffer.positions[D+5]=w,this._buffer.normals[D+3]=E*f,this._buffer.normals[D+4]=T*f,this._buffer.normals[D+5]=-m,this._buffer.uvs[C+2]=_,this._buffer.uvs[C+3]=S),this.vertexCache[o]=O,O}clone(){let e=new Uu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=po(this.userData),e}};var ku=class extends Me{constructor(e,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=mt.ODD;this.elementType=sn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:mt.ODD,elementType:sn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=Zi({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=hf}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Be(new Float32Array(h*3),3),this._normalAttribute=new Be(new Float32Array(h*3),3),this._uvAttribute=new Be(new Float32Array(h*2),2),this._indexAttribute=new Be(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,y=-1/0;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1];M<m&&(m=M),M>p&&(p=M),b<g&&(g=b),b>y&&(y=b)}let v=p-m,x=y-g;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1],E=(M-m)/v,T=(b-g)/x;this._positionAttribute.setXYZ(w,M,b,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,E,T)}for(let w=0,S=f;w<S;w++){let _=w*3,M=a.elements[_+0],b=a.elements[_+1],E=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,b),this._indexAttribute.setX(_+2,E)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new ku(this._shape,this._curveSegments);return e.userData=po(this.userData),e}};var zu=class extends Uu{constructor(e,n,i=0,s=12,o=3,a=mt.ODD){super(e,n,i,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new zu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=po(this.userData),e}};var Xr=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:mt.ODD},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=r.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Mt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new Mt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update());let l=o??new Mt(n,i);return{parameters:Object.assign(e,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return t<=0?a=new ku(r.shape,i,{windingRule:o}):a=new zu(r.shape,t,e,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var kC=Math.PI*2,Vu=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=t*.5,d=e*.5,h=U5(u,c,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Xr.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function U5(r,t,e,n,i,s){if(n>=kC)return i>30||i%4===0?(z5(r,t,e,s),Math.round(i/4)):UC(r,n,i,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=RC({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?k5(r,o.x,o.y,u,i,t,e,s):UC(r,n,i,t,e,s)}function k5(r,t,e,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(Gu(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=r.points[u],f=Gu(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),r.addPoint(f)}return a>0?zC(r,s,o,a):r.addPoint(Gu(0,0)),l}function UC(r,t,e,n,i,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*i;r.addPoint(Gu(u,c))}return t<kC?s>0?zC(r,n,i,s):r.addPoint(Gu(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&GC(r,n,i,s)),1}function z5(r,t,e,n=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;r.addPoint(kg(i-t,s,i-t,s-l,i-t,s+l)),r.addPoint(kg(i,s+e,i-a,s+e,i+a,s+e)),r.addPoint(kg(i+t,s,i+t,s+l,i+t,s-l)),r.addPoint(kg(i,s-e,i+a,s-e,i-a,s-e)),n>0&&GC(r,t,e,n)}function Gu(r,t){return new Ki(He.generateUUID(),new F(r,t))}function kg(r,t,e,n,i,s){let o=Gu(r,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(i,s),o}function zC(r,t,e,n){VC(r,t,e,n).forEach(s=>r.addPoint(s))}function GC(r,t,e,n){let i=VC(r,t,e,n),s=new Mt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function VC(r,t,e,n){let i=n*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new F(i/t,s/e),a=r.points.map(l=>{let u=l.clone();return u.uuid=He.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var HC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(r){let{width:t,height:e,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=r.parameters,h=new ff(!1,t,e,n,i,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...r,type:"HelixGeometry"}})}},kb=new vs([0,0,0],1),ff=class extends Me{constructor(t=!0,e=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let m=()=>new A,p=new A,g=m(),y=m(),v=m(),x,w,S,_,M,b,E,T,P=m(),D=m(),C=m(),O=m(),B=m(),V=m(),Y=m(),W=m(),q=n-2*l+.001,j=q/o,X=Math.ceil(a*o),L=X+1,U=q/X,G=-q/2,H=c+1,z=2*Math.PI/c,re=Math.PI/2/h,K=.01,Z=Math.min((1-d/100)*l,l-K),k=l-Z,he=0,fe=2,ce=h*fe+fe,ye=H*ce/fe,Se=ye+H*L,ve=H*(L+ce),[Ee,Te,we]=[3,3,2].map(Re=>Array(ve*Re).fill(0)),Ge=[],gt=s-l;function R(Re,De){let Ue=Math.PI/2;b=De*U,T=2*Math.PI*(b%j)/j+Ue,b+=G,E=Math.sin(T)*gt,M=Math.cos(T)*gt,t?Re.set(M,E,b):Re.set(M,b,E)}R(p,-1e-10),R(g,0),P.copy(p),R(p,1);let I=p.distanceTo(g),ee=f?0:k+Z,me=I*X+2*ee,xe=Z,Ce=me-ee;for(let Re=0;Re<=X;Re++){R(y,Re),W.subVectors(y,P).normalize(),P.copy(y),V.copy(y).setComponent(+t+1,0).normalize(),Y.crossVectors(W,V).normalize();let De=Re===0,Ue=Re===X,Ye=De?3*Math.PI/2:re,yt=De?xe:Ce,zt=De?H:Se,En=De?0:ve-H,Q=W.clone().multiplyScalar(De?-k:k).add(y),se=W.clone().multiplyScalar(De?-1:1).normalize();for(let ge=0;ge<H;ge++){let Le=ge*z;if(D.addVectors(p.copy(V).multiplyScalar(l*Math.cos(Le)),g.copy(Y).multiplyScalar(l*Math.sin(Le))),C.copy(D).normalize(),De||Ue){f||(he=En+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=Q.getComponent(Oe),Te[he*3+Oe]=se.getComponent(Oe)}),we[he*2]=+Ue,we[he*2+1]=ge/c),g.copy(C).multiplyScalar(Z),v.addVectors(y,g);for(let Oe=0;Oe<h;Oe++){let vt=Oe*re+Ye;O.addVectors(p.copy(W).multiplyScalar(k*Math.sin(vt)),g.copy(C).multiplyScalar(k*Math.cos(vt))),B.copy(O).normalize(),g.addVectors(v,O),O.normalize(),he=zt+Oe*H+ge,[0,1,2].forEach(pn=>{Ee[he*3+pn]=g.getComponent(pn),Te[he*3+pn]=B.getComponent(pn)});let Tn=+De+Math.sin(vt);we[he*2]=(yt+k*Tn)/me,we[he*2+1]=ge/c}}g.addVectors(y,D),he=ye+Re*H+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=g.getComponent(Oe),Te[he*3+Oe]=C.getComponent(Oe)}),we[he*2]=(ee+Re*I)/me,we[he*2+1]=ge/c}}let Ve=L+2*h+fe,Pe=1,[de,Xe]=[+f,Ve-1];for(let Re=de;Re<=Xe-1;Re++){let De=f&&Re===Xe-1;for(let Ue=0;Ue<H-1;Ue++)x=Re*H+Ue,w=x+1,S=(De?Ue:x)+H,_=(De?Ue+1:w)+H,Re===0?Ge.push(w,_,S):Re===Ve-2?Ge.push(x,w,S):Ge.push(x,w,S,w,_,S)}this.setIndex(Ge),this.setAttribute("position",new Ae(Ee,3)),this.setAttribute("normal",new Ae(Te,3)),this.setAttribute("uv",new Ae(we,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,i=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let h=0;h<t.radialSegments;h++)s=c*n+h,o=s+1,a=(d?h:s)+n,l=(d?h+1:o)+n,i[u++]=s,i[u++]=o,i[u++]=a,i[u++]=o,i[u++]=l,i[u++]=a;return i.length=u,kb.array=i,kb.count=i.length,kb}};var WC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new pf(t*.5,s,o):new yc(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},pf=class extends ma{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new pf(t.radius,t.corner,t.cornerSides)}};var jC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{points:t,segments:e,verticalSegments:n}=r.parameters,i=new ao;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new hc(i.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var Ps=new ae,zb=new pt,zg=new A,ya=class extends Ht{constructor(){super(),this.uuid=He.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new Kt().getNormalMatrix(t);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(t);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Ps.makeRotationX(t),this.applyMatrix4(Ps),this}rotateY(t){return Ps.makeRotationY(t),this.applyMatrix4(Ps),this}rotateZ(t){return Ps.makeRotationZ(t),this.applyMatrix4(Ps),this}translate(t,e,n){return Ps.makeTranslation(t,e,n),this.applyMatrix4(Ps),this}scale(t,e,n){return Ps.makeScale(t,e,n),this.applyMatrix4(Ps),this}lookAt(t){return zb.lookAt(t),zb.updateMatrix(),this.applyMatrix4(zb.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,i=t.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Ne().fromBufferAttribute(a,h));function c(h,f,m,p){let g=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[m].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],v=new Hu(h,f,m,y,g,p);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new F().fromBufferAttribute(l,h),new F().fromBufferAttribute(l,f),new F().fromBufferAttribute(l,m)]),u!==void 0&&e.faceVertexUvs[1].push([new F().fromBufferAttribute(u,h),new F().fromBufferAttribute(u,f),new F().fromBufferAttribute(u,m)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],m=f.start,p=f.count;for(let g=m,y=m+p;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zg).negate(),this.translate(zg.x,zg.y,zg.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,i=new ae;return i.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)e[n]=new A;if(t){let n=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)e[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let t=new ya;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let i=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _t),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rn),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let i,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(i=new Kt().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let m=u[h],p,g,y=m.vertexNormals,v=m.vertexColors,x=new Hu(m.a+s,m.b+s,m.c+s);x.normal.copy(m.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let w=0,S=y.length;w<S;w++)p=y[w].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),x.vertexNormals.push(p);x.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)g=v[w],x.vertexColors.push(g.clone());x.materialIndex=m.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++)v.push(y[x].clone());this.faceVertexUvs[h].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},n=[],i=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let i=t[e];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(i[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(t[p]=m[p]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];e.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,y=!1,v=this.faceVertexUvs[0][m]!==void 0,x=p.normal.length()>0,w=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,M=0;if(M=c(M,0,0),M=c(M,1,g),M=c(M,2,y),M=c(M,3,v),M=c(M,4,x),M=c(M,5,w),M=c(M,6,S),M=c(M,7,_),n.push(M),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let b=this.faceVertexUvs[0][m];n.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&n.push(d(p.normal)),w){let b=p.vertexNormals;n.push(d(b[0]),d(b[1]),d(b[2]))}if(S&&n.push(h(p.color)),_){let b=p.vertexColors;n.push(h(b[0]),h(b[1]),h(b[2]))}}function c(m,p,g){return g?m|1<<p:m&~(1<<p)}function d(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function h(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(m.x,m.y)),u[p]}return t.data={},t.data.vertices=e,t.data.normals=i,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new ya().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let i=t.faces;for(let h=0,f=i.length;h<f;h++)this.faces.push(i[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++){let S=y[x];v.push(S.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let m={};if(m.name=s[h].name,s[h].vertices!==void 0){m.vertices=[];for(let p=0,g=s[h].vertices.length;p<g;p++)m.vertices.push(s[h].vertices[p].clone())}if(s[h].normals!==void 0){m.normals=[];for(let p=0,g=s[h].normals.length;p<g;p++)m.normals.push(s[h].normals[p].clone())}this.morphTargets.push(m)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let m={};if(o[h].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[h].vertexNormals.length;p<g;p++){let y=o[h].vertexNormals[p],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),m.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[h].faceNormals.length;p<g;p++)m.faceNormals.push(o[h].faceNormals[p].clone())}this.morphNormals.push(m)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Gb().fromGeometry(this),e=new Me,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Gg.call(new Be(n,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",Gg.call(new Be(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",qC.call(new Be(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",XC.call(new Be(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",XC.call(new Be(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new Ae(u.data.length*3,3);c.name=u.name,s.push(Gg.call(c,u.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new Ae(t.skinIndices.length*4,4);e.setAttribute("skinIndex",YC.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Ae(t.skinWeights.length*4,4);e.setAttribute("skinWeight",YC.call(i,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Me,n=t.geometry;if(t.isPoints||t.isLine){let i=new Ae(n.vertices.length*3,3),s=new Ae(n.colors.length*3,3);if(e.setAttribute("position",Gg.call(i,n.vertices)),e.setAttribute("color",qC.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Ae(n.lineDistances.length,1);e.setAttribute("lineDistance",G5.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};ya.prototype.isGeometry=!0;var Gb=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],n,i,s,o=t.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,e.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,i=t.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,m=t.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][y];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new F,new F,new F))}if(o===!0){let S=i[1][y];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new F,new F,new F))}for(let S=0;S<l;S++){let _=a[S].vertices;u[S].data.push(_[v.a],_[v.b],_[v.c])}for(let S=0;S<d;S++){let _=c[S].vertexNormals[y];h[S].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Hu=class{constructor(t,e,n,i,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Ne,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function G5(r){return this.array.set(r),this}function qC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Ne),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function XC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new F),t[e++]=s.x,t[e++]=s.y}return this}function Gg(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function YC(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Ze),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var V5=["a","b","c"];function H5(r,t){switch(t){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function Vb(r,t,e){let n=Math.min(r,t),i=Math.max(r,t),s=n+"_"+i;return e.get(s)}function Hb(r,t,e,n,i,s){let o=Math.min(r,t),a=Math.max(r,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[t].edges.push(u)}function W5(r,t,e,n){let i,s,o;for(i=0,s=r.length;i<s;i++)e[i]={edges:[]};for(i=0,s=t.length;i<s;i++)o=t[i],Hb(o.a,o.b,r,n,o,e),Hb(o.b,o.c,r,n,o,e),Hb(o.c,o.a,r,n,o,e)}function Vg(r,t,e,n,i){r.push(new Hu(t,e,n,void 0,void 0,i))}function Wu(r,t){return Math.abs(t-r)/2+Math.min(r,t)}function Hg(r,t,e,n){r.push([t.clone(),e.clone(),n.clone()])}var Wg=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Me?t=new ya().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,i,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;W5(l,u,h,f);let m=[],p,g,y,v,x,w,S;for(let K of Array.from(f.keys())){for(g=f.get(K),y=new A,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[H5(v,V5[a])],!(p!==g.a&&p!==g.b));a++);p&&e.add(p)}e.multiplyScalar(w),y.add(e),g.newEdge=m.length,m.push(y)}let _,M,b,E,T,P,D,C=[];for(i=0,s=l.length;i<s;i++){for(P=l[i],T=h[i].edges,n=T.length,n==3?_=3/16:n>3&&(_=3/(8*n)),M=1-n*Number(_),b=_,n<=2&&(n==2?(M=3/4,b=1/8):n==1||n==0),D=P.clone().multiplyScalar(M),e.set(0,0,0),o=0;o<n;o++)E=T[o],p=E.a!==P?E.a:E.b,e.add(p);e.multiplyScalar(Number(b)),D.add(e),C.push(D)}let O=C.concat(m),B=C.length,V,Y,W,q=[],j=[],X,L,U,G,H=new F,z=new F,re=new F;for(i=0,s=u.length;i<s;i++)v=u[i],V=Number(Vb(v.a,v.b,f).newEdge)+B,Y=Number(Vb(v.b,v.c,f).newEdge)+B,W=Number(Vb(v.c,v.a,f).newEdge)+B,Vg(q,V,Y,W,v.materialIndex),Vg(q,v.a,V,W,v.materialIndex),Vg(q,v.b,Y,V,v.materialIndex),Vg(q,v.c,W,Y,v.materialIndex),d&&(X=c[i],L=X[0],U=X[1],G=X[2],H.set(Wu(L.x,U.x),Wu(L.y,U.y)),z.set(Wu(U.x,G.x),Wu(U.y,G.y)),re.set(Wu(L.x,G.x),Wu(L.y,G.y)),Hg(j,H,z,re),Hg(j,L,H,re),Hg(j,U,z,H),Hg(j,G,re,z));t.vertices=O,t.faces=q,d&&(t.faceVertexUvs[0]=j)}};var qn=new A,QC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=r.geometry??t?.geometry??new Me().copy(new er(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(qn),n={width:qn.x,height:qn.y,depth:qn.z,subdivisions:0}):n=t.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(r){let{width:t,height:e,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Me().copy(new er(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(qn)):qn.set(o.width,o.height,o.depth),(t!==qn.x||e!==qn.y||n!==qn.z)&&s.scale(qn.x===0?1:t/qn.x,qn.y===0?1:e/qn.y,qn.z===0?1:n/qn.z);let a=s.originalGeometry;try{i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Wg(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,t,e){new Sc(e).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(qn);let o=100/qn.x;Object.assign(s.parameters,{width:100,height:qn.y*o,depth:qn.z*o}),t(this.build(s))})}};var jg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,y=d+Math.sin(g)*u,v=h+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Xr.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var KC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new jb(t*.5,e,i,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function mf(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function Wb(r,t,e,n,i,s){let o=t.clone().sub(r),a=e.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function j5(r,t,e){let n=r.clone().sub(t),i=e.clone().sub(t);return n.projectOnVector(i),n.add(t)}var jb=class extends Me{constructor(t=.5,e=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,m=Math.PI/n,p=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),w=new A(0,f,0),S=new F(t,-f),_=new F(p,-f),M=new F(0,w.y).sub(_),b=new F(0,w.y).sub(S),E=new F(M.y,-M.x).normalize(),T=new F(b.y,-b.x).normalize(),D=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,D);let C;{let j=new A(E.x,E.y,0),X=new A(Math.cos(g)*j.x,j.y,Math.sin(g)*j.x);C=j.angleTo(X)}let O=o/Math.tan((Math.PI-M.angle())/2),B=o/Math.tan((Math.PI-C)/2),V=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let j=h++,X=[],L=S.clone(),U=O/Math.cos(Math.PI/n);L.x-=U;for(let G=0;G<n;G++){let H=G/n*Math.PI*2+m,z=new F(Math.sin(H),Math.cos(H));mf(L,z,V),u.push(V.x,V.y,V.z),c.push(0,-1,0),d.push(0,0),X.push(h++)}for(let G=0;G<X.length;G++)l.push(X[G],j,X[(G+1)%X.length])}let Y=[];{let j=new A,X=new A,L=new A,U=new A,G=new A,H=new A;for(let z=0;z<n;z++){let re=z/n*Math.PI*2+m,K=(z+.5)/n*Math.PI*2+m,Z=(z+1)/n*Math.PI*2+m,k=new F(Math.sin(re),Math.cos(re)),he=new F(Math.sin(K),Math.cos(K)),fe=new F(Math.sin(Z),Math.cos(Z));mf(S,k,X),mf(S,fe,L),mf(E,he,j),Wb(w,X,L,B,B,U),u.push(U.x,U.y,U.z),Wb(X,w,L,B,O,G),u.push(G.x,G.y,G.z),Wb(L,X,w,O,B,H),u.push(H.x,H.y,H.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),d.push(0,0),d.push(0,0),d.push(0,0);let ce=h++,ye=h++,Se=h++;if(l.push(ce,ye,Se),o>0){{let Te=X.clone().add(L).multiplyScalar(.5),we=w.clone().sub(Te).normalize(),gt=x.clone().sub(Te).normalize().add(we).normalize().multiplyScalar(-1),R=H.clone().sub(G);W(Te,R,gt,M.angle())}let ve,Ee;{let Te=new A;mf(T,fe,Te);let we=H.clone().add(U).multiplyScalar(.5);we=j5(we,L,w);let Ge=H.clone().sub(U);[ve,Ee]=W(we,Ge,Te,C,U.y)}{let Te=ve,we=Te.clone().setY(0).normalize(),Ge=new A(0,-1,0),gt=we.clone().cross(Ge);q(Te,we,Ge,gt)}Y.concat(Ee);{let Te=M.angle(),we=Math.PI-Te,Ge=w.clone();Ge.y-=o/Math.sin(Te-Math.PI/2);let gt=new A,R=[];for(let ee=0;ee<a;ee++){let me=[],xe=Math.PI/2-we*ee/a,Ce=Math.cos(xe),Ve=Math.sin(xe),Pe=K;for(let de=0;de<=ee;de++){let Xe=Math.cos(Pe),Re=Math.sin(Pe);j.x=Ce*Re,j.y=Ve,j.z=Ce*Xe,gt.copy(Ge).addScaledVector(j,o),u.push(gt.x,gt.y,gt.z),c.push(j.x,j.y,j.z),d.push(0,0),me.push(h++),Pe+=Math.PI*2/ee/n}R.push(me)}Ee.reverse(),R.push(Ee);let I=R.length-1;for(let ee=0;ee<I;ee++){let me=R[ee],xe=R[ee+1],Ce=me.length-1;l.push(xe[1],me[0],xe[0]);for(let Ve=1;Ve<=Ce;Ve++)l.push(me[Ve],me[Ve-1],xe[Ve]),l.push(xe[Ve+1],me[Ve],xe[Ve])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(d,2));function W(j,X,L,U,G){let H=-U/2,z=(Math.PI-U)/2,re=X.clone().normalize().cross(L);j.addScaledVector(L,-o/Math.sin(z));let K=new A,Z=new A,k=1,he=h,fe=[];for(let ce=0;ce<=a;ce++){let ye=H+ce/a*U;Z.set(0,0,0),Z.addScaledVector(re,Math.sin(ye)),Z.addScaledVector(L,Math.cos(ye));for(let Se=0;Se<=k;Se++){let ve=Se/k-.5;if(K.copy(j),K.addScaledVector(X,ve),K.addScaledVector(Z,o),G!=null){let Ee=Math.max(0,K.y-G);K.addScaledVector(X,-Ee/X.y)}u.push(K.x,K.y,K.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),Se===0&&fe.push(h),h++}}for(let ce=0;ce<a;ce++)for(let ye=0;ye<k;ye++){let Se=he+ye+(k+1)*ce,ve=Se+(k+1),Ee=ve+1,Te=Se+1;l.push(Se,ve,Te),l.push(ve,Ee,Te)}return[j.clone().addScaledVector(X,.5),fe]}function q(j,X,L,U){let G=Math.PI/2,H=b.angle()-G,z=[],re=new A,K=new A;for(let k=0;k<=a;k++){let he=[],fe=k/a;for(let ce=0;ce<=k;ce++){let Se=((k?ce/k:0)-.5)*v,ve=Math.cos(Se),Ee=Math.sin(Se),Te=Math.atan(Math.tan(H)*ve),we=(G+Te)*fe,Ge=Math.cos(we),gt=Math.sin(we);re.set(0,0,0),re.addScaledVector(X,gt*ve),re.addScaledVector(L,Ge),re.addScaledVector(U,gt*Ee),K.copy(j).addScaledVector(re,o),u.push(K.x,K.y,K.z),c.push(re.x,re.y,re.z),d.push(0,0),he.push(h++)}z.push(he)}let Z=z.length-1;for(let k=0;k<Z;k++){let he=z[k],fe=z[k+1],ce=he.length-1;l.push(he[0],fe[1],fe[0]);for(let ye=1;ye<=ce;ye++)l.push(he[ye-1],he[ye],fe[ye]),l.push(he[ye],fe[ye+1],fe[ye])}}}};var qg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(r){let t=r.shape,{width:e,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(w,S,_){return S>e&&_>n?Math.min(w*e/S,w*n/_):S>e?w*e/S:_>n?w*n/_:w}let f=[];f[0]=i[0]===0?0:h(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:h(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:h(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:h(i[3],i[3]+i[0],i[3]+i[2]);let m=c.x,p=d.x,g=d.y,y=c.y;t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let v=!0;for(let w=0,S=t.points.length;w<S;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Xr.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...r,type:"RectangleGeometry"}})}};var ZC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t=100,height:e=t,depth:n=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new el(.5*t,i,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var JC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(r){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new oo(t,e,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var $C=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,height:e,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new qb(t,e,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},qb=class extends Me{constructor(t=1,e=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let d=[],h=Math.PI/2,f=(K=0,Z=0,k=0)=>new A(K,Z,k),m=f(),p=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,w=+y,[S,_,M]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(K,Z=!1)=>Math.sin(K-Math.PI/(1+ +Z)),E=(K,Z=!1)=>Math.cos(K-Math.PI/(1+ +Z));M.y=Math.sin(i)*e-g;let T=Math.cos(i)*e-v,P=S.z-c;i<=h?(M.z=Math.min(T,P),M.z==P&&(M.y-=(T-P)/Math.tan(h-i))):_.z=Math.min(_.z-T-v,S.z-c),m.subVectors(S,_),p.subVectors(M,_);let D=Math.min(m.length(),p.length())*s/100,C=D*Math.tan(i/2),O=D/Math.cos(i/2),B=m.clone().normalize().add(p.normalize()).setLength(O).add(_);m.set(0,b(i,!0),E(i,!0)),d.push([M,m.clone()]);let V=(Math.PI-i)/o;for(let K=0;K<=o;K++){let Z=h+i+K*V;m.set(0,Math.sin(Z)*C,Math.cos(Z)*C),m.add(B),p.set(0,b(Z),E(Z)),d.push([m.clone(),p.clone()])}d.push([S,f(0,1,0)]);let Y=Math.sin(V/2)*C*2,W=d.length-1,q=d[0][0].distanceTo(d[1][0]),j=d[W-1][0].distanceTo(d[W][0]),X=q+Y*o+j;d[0].push(1);for(let K=0;K<=o;K++)d[K+1].push(1-(q+K*Y)/X);d[W].push(0);let[L,U,G]=d[0],H,z,re;for(let K=1;K<d.length;K++)[H,z,re]=d[K],a.push(x,L.y,L.z,x,H.y,H.z,w,L.y,L.z,w,L.y,L.z,x,H.y,H.z,w,H.y,H.z),l.push(0,U.y,U.z,0,z.y,z.z,0,U.y,U.z,0,U.y,U.z,0,z.y,z.z,0,z.y,z.z),u.push(0,G,0,re,1,G,1,G,0,re,1,re),[L,U,G]=[H,z,re];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var Xg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,d=t*.5,h=e*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let w=0;w<i;w++){let S=p*w,_=f+Math.sin(S)*d,M=m+Math.cos(S)*h;c.addPoint(c.createPoint(_,M))}}else for(let w=0;w<i;w++){let S=f+Math.cos(g)*d,_=m+Math.sin(g)*h;c.addPoint(c.createPoint(S,_)),g+=p,S=f+Math.cos(g)*y,_=m+Math.sin(g)*v,w<=i,c.addPoint(c.createPoint(S,_)),g+=p}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let x=Xr.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...r,type:"StarGeometry"}})}};var eP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e}=r.parameters,n=new oo(t,e);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var tP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:i,depth:s})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=q5(t,e,n,t*.5,o,s,0,0,i,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function q5(r,t,e,n,i,s,o,a,l,u,c){return[t,e]=[e,t],o=t/2,i/=2*Math.PI,i==1&&(u=0),new ff(!0,r,t,e,n,i,s,o,a,l,u,c)}var nP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(r){let{width:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=t*.5;a!==e&&(a-=e);let l=new vc(a,e,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var rP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof Mt?r.shape:new Mt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t=100,height:e,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=Xr.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...r,type:"TriangleGeometry"}})}};function iP(r,t){let e=2*Math.PI;return(r%e+e)%e===(t%e+e)%e}function X5(r,t,e){let n=[new A,new A,new A],i=[new A,new A,new A];return r.extractBasis(n[0],n[1],n[2]),t.extractBasis(i[0],i[1],i[2]),n.forEach((s,o)=>{let a=i[o],l=He.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ae().makeBasis(n[0],n[1],n[2])}var sP=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Vu.create({parameters:Jx}).userData.shape;return{path:r.path??hu.defaultData(),parameters:Object.assign(e,{width:n,height:i,depth:s,extrusion:{...pg,...e.extrusion}}),shapeData:o}}static build(r){if(r.path.points.length>=2){let e=new Xb(r);return Object.assign(e,{userData:{...r,type:"PathGeometry"}})}else return Object.assign(new Me,{userData:{...r,type:"PathGeometry"}})}},Xb=class extends Me{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)||!iP(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:i,offset:s}=this.inputs.parameters.extrusion,o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((i+s)*o):Math.ceil(Math.min(1,i+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let D=0;D<u;D++){let C=this.inputs.path.isClosed?(D+a)%e.length:Math.min(D+a,e.length-1);c.push(e[C].clone()),d.push(n[C].clone())}let h=(D,C,O)=>{c[D]=c[D].clone().lerp(c[C],O),d[D]=X5(d[D],d[C],O)},f=0,m=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(m||s===0)&&(f=m,h(0,1,f));let p=0,g=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&g&&(p=g,h(c.length-1,c.length-2,1-p)),i===0){let D=c.length-1;c[D].copy(c[0]),d[D].copy(d[0])}this._applyPathModifiers(d,f,p);let{regions:y,infos:v,vertices:x}=this._computeShapePoints(5),w=0,S=0;v.sort((D,C)=>D.start-C.start),v.forEach(D=>{D.verticesStart=w,D.verticesCount=D.continuous.reduce((C,O,B)=>C+(B===0||!O?2:1),0),S+=D.verticesCount,w=S});let _=S*u,M,b=0;if(this._isOpenEnded()){try{M=Zi({windingRule:mt.ODD,elementType:sn.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{M=Ub}b=M.vertexCount}let E=_+2*b,T={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},P=[];v.forEach(D=>{this._extrudeRegion(D,x,d,c,T,P,this._isGeometryClosed()&&!this._isOpenEnded())}),M&&(this._closeEnd(M,_,P,T,d[0],c[0],!1),this._closeEnd(M,_+b,P,T,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Be(T.positions,3)),this.setAttribute("normal",new Be(T.normals,3)),this.setAttribute("uv",new Be(T.uvs,2)),this.setIndex(P)}_extractPathPoints(){let n=Rg(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let i=[n[0]];return n.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let n=[],i=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let g=0;g<i;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===i-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let w=y.clone().sub(v).normalize(),S=x.clone().sub(y).normalize(),_=w.clone().add(S).normalize();l.copy(_),g===0&&(_.equals(c)||_.clone().negate().equals(c))&&c.set(0,0,1);let M=c.clone().cross(_).normalize(),b=_.clone().cross(M).normalize();c.copy(b),u.copy(M),g===0&&(o.copy(b),a.copy(_));let E=new ae().makeBasis(M,b,_);n.push(E)}let d=s?a:l,h=s?o:new A(0,1,0),f=d.clone().cross(u).normalize(),m=Math.acos(h.dot(f));if(isNaN(m))return n;let p=h.clone().cross(f);d.dot(p)>0&&(m*=-1);for(let g=1;g<n.length;g++){let y=new ae().makeRotationZ(m*g/n.length);n[g].multiply(y)}return n}_applyPathModifiers(e,n,i){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new ae,d=new ae;return e.forEach((h,f)=>{let m=f===0?0:f===s-1?1:(f-n)/(s-(i===0?0:1)-(n+(1-i)));c.makeRotationZ(He.lerp(o,o+a,m));let p=He.lerp(l,u,m);d.makeScale(p,p,p),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=mt.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(p=>{let g=p.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],w=g[v-0];y.push(x,w)}return y}),a;try{a=Zi({windingRule:n,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=hf}let l;try{l=Zi({windingRule:mt.ODD,elementType:sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=Fb}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let g=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let p=0;p<l.vertexIndices.length;p++){let g=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let p=0;p<l.vertices.length;p++){let g=l.vertices[p];a.vertices.push(g)}}let c=1/0,d=-1/0,h=1/0,f=-1/0;for(let p=0,g=a.vertexCount;p<g;p++){let y=p*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>d&&(d=v),x<h&&(h=x),x>f&&(f=x)}let m=[];for(let p=a.elementCount-1;p>=0;p--){let g=p>=u,y=p*2,v=a.elements[y+0],x=a.elements[y+1],w=v+x,S={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let _=v,M=w-1,b=v+1,E=i.roundedCurves.length;do{let T=_-v,P=a.vertices[M*2+0],D=a.vertices[M*2+1],C=a.vertices[_*2+0],O=a.vertices[_*2+1],B=a.vertices[b*2+0],V=a.vertices[b*2+1],Y=C-P,W=O-D,q=Math.sqrt(Y*Y+W*W);Y/=q,W/=q;let j=C-B,X=O-V,L=Math.sqrt(j*j+X*X);j/=L,X/=L,S.normals[T*2+0]=-X,S.normals[T*2+1]=j;let U=a.vertexIndices[_];if(Array.isArray(U))S.continuous[T]=!1;else{let[G,H]=i.getCurveIndexFromVertexId(U-1,!0);if(H>0&&H<1)S.continuous[T]=!0;else{let z=H===1?G+1:G-1;z=(z+E)%E;let re=H===1?0:1,K=i.roundedCurves[G].getTangent(H),Z=i.roundedCurves[z].getTangent(re);S.continuous[T]=K.dot(Z)>.95}}g&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[M,_,b]=[_,b,b+1],b>=w&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:m,vertices:a.vertices}}_insertVertex(e,n,i,s,o){let a=n*2,l=n*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,n,i,s,o,a,l){let u=new A,c=new A,d=new A,h=new A,f=new F;i.forEach((p,g)=>{let y=s[g],v=e.verticesStart*i.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let w=(e.start+x)*2;if(u.set(n[w+0],n[w+1],0),d.copy(u).applyMatrix4(p).add(y),e.continuous[x])h.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let S=x==0?(e.start+e.count-1)*2:w-2;c.set(n[S+0],n[S+1],0),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(p).normalize(),f.set(x===0?1:x/e.count,g/(i.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(i.length-1));else{let S=x===e.count-1?e.start*2:w+2;c.set(n[S+0],n[S+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(p).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let m=i.length-1;for(let p=0;p<m;p++){let g=e.verticesStart*i.length+e.verticesCount*p,y=e.verticesStart*i.length+e.verticesCount*(p+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let w=x===e.count-1?0:v+1,S=g+v,_=g+w,M=y+w,b=y+v;e.isHole?a.push(S,M,_,S,b,M):a.push(S,_,M,S,M,b),v++}}}_closeEnd(e,n,i,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),d=new A,h=new F;for(let m=0;m<u;m++){let p=2*m;d.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+m,d,c,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let p=3*m,g=f[p+0]+n,y=f[p+(l?1:2)]+n,v=f[p+(l?2:1)]+n;i.push(g,y,v)}}};function oP(){let r=new Me;return r.setAttribute("position",new Be(new Float32Array([]),3)),r.setIndex(new Be(new Uint16Array([]),1)),r}var Y5=oP().attributes,Q5=12,K5=1,ju=class extends Me{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,Y5),this.userData={parameters:e,type:"TextGeometry"};let i=n.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let i=n.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=Z5(e,n,d),{shapes:f,charWidths:m,charCoords:p}=n.generateShapes(h,e),g=i*.5,y=s*.5,v=f.map(S=>new Mt().fromShape(S));this.vectorShapes=v;let x=v.map(S=>Xr.create({shape:S,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?mt.NONZERO:mt.ODD,subdivisions:this.isLowResolution&&o>0?K5:Q5}})),w=x.length?Xi(x):oP();w.translate(-g,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,_])=>{this.setAttribute(S,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Hi(new Me,ju.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function Z5(r,t,e){e=e??r.text;let n=[""],i="";for(let s of e)i+=s,s===" "||s===`
3139
3139
  `?(n[n.length-1]+=i,i="",s===`
3140
- `&&n.push("")):t.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var lP,qu=new Promise(r=>{lP=r}),aP=!1;async function cP(){if(aP)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.381/build",[e,n]=await Promise.all([import("./process.js"),fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});lP(s),aP=!0}function Al(r,t,e){let n={parameters:r,type:r.type};if(r.type==="PathGeometry")n.path=r.path;else if(r.type==="VectorGeometry"){let s=Mt.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new Sc().parse(r);else{if(r.type==="SubdivGeometry")return new xn(r,e);if(r.type==="TextGeometry")return new ju(r,t)}let i;try{i=Yb(n)}catch(s){console.error(s)}if(!i){let s=Mt.createFromState(du.defaultData(),100,100);n.shape=s,i=Yb(n)}return i}var J5=new ae;function gf(r,t,e,n){let i=r.position.array,s=r.normal.array,o=J5.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=t,i[c+1]*=e,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var Yg=new _t,Xu=new A,Ke;qu.then(r=>{Ke=r});var uP=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),dP=new Uint32Array([0,1,2,3]),hP=new Uint8Array([4]),xn=class extends Me{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=Ms.div(n,i);this.subdividedGeometry&&gf(this.subdividedGeometry.attributes,...s),this.originalGeometry&&gf(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Xu.fromArray(s));let a=Xu.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,i;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:i}=xn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new er(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Rn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;Yg.setFromBufferAttribute(n),Yg.getCenter(i),e.boundingSphere.radius=i.distanceTo(Yg.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Yg.getSize(Xu);let s={width:Xu.x,height:Xu.y,depth:Xu.z};return this.userData.parameters=s,s}static build(e,n,i,s){let o,a,l,u=e?.phongAngle??35;i===!1&&(u=-1),n&&(Ke.free_bvh(n),Ke.free_subdivision_surface(n));try{o=xn.allocate(e,s)}catch(c){console.error(c,e),o=xn.allocate({positionWASM:uP,indexWASM:dP,verticesPerFaceWASM:hP},s)}if(Ke.set_destination_refinement_level(o,0),a=xn.buildLevel(o,!0,u),e.subdivisions>0)try{Ke.set_destination_refinement_level(o,e.subdivisions),l=xn.buildLevel(o,!1,u)}catch{try{Ke.set_destination_refinement_level(o,e.subdivisions-1),l=xn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0?n.geometry:Al(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=_l(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=Jb(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=uP,s=dP,o=hP);let u=i.length,c=s.length,d=o.length,h=i.length+a.length+l.length,f=s.length+o.length,m=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=Ke._malloc(m),v=new Float32Array(Ke.HEAPF32.buffer,y,h),x=new Uint32Array(Ke.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new ae().makeScale(...e.scaleBaked)),n&&(w?w.premultiply(n):w=n);let S=w?Ke.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Ke.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Ke._free(y),S}static buildLevel(e,n,i,s,o){let a=o?Ke.get_mesh_data2(e,n?Ke.Level.CONTROL:Ke.Level.REFINED,i,o.elements):Ke.get_mesh_data(e,n?Ke.Level.CONTROL:Ke.Level.REFINED,i),l=8,u=Ke.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Ke.HEAPU32[u[d]>>2],f=Ke.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let m=Ke.HEAPU32[u[d]>>2],p=Ke.HEAPF32.subarray(m>>2,(m>>2)+c[d]);d++;let g=Ke.HEAPU32[u[d]>>2],y=Ke.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=Ke.HEAPU32[u[d]>>2],x=Ke.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let w=new Me;if(w.setIndex(new vs(x,1)),w.setAttribute("position",new Ae(f,3)),w.setAttribute("normal",new Ae(p,3)),n){w.setAttribute("faceMap",new vs(y,1));let S=new Float32Array(p.length/3*4).fill(0);w.setAttribute("color",new Be(S,4))}return Ke.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Ke.free_mesh_data(a)}static freeSubdivPointer(e){Ke.free_bvh(e),Ke.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=Ke.get_wireframe_data_for_base_level(e),o=4,a=Ke.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Ke.HEAPU32[a[u]>>2],d=Ke.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Ke.HEAPU32[a[u]>>2],f=Ke.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let m=new Me;m.setAttribute("position",new Ae(d,3));let p=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return m.setAttribute("color",new Be(p,3)),m.setIndex(new vs(f,1)),Ke.free_wireframe_data_for_base_level(s),m}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Ke.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||Ke.set_destination_refinement_level(e,n);let o=i?Ke.get_topological_data2(e,s?Ke.Level.CONTROL:Ke.Level.REFINED,i.elements):Ke.get_topological_data(e,s?Ke.Level.CONTROL:Ke.Level.REFINED),a=6,l=Ke.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Ke.HEAPU32[l[c]>>2],h=new Float32Array(Ke.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Ke.HEAPU32[l[c]>>2],m=new Uint32Array(Ke.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Ke.HEAPU32[l[c]>>2],g=new Uint8Array(Ke.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Ke.free_topological_data(o),{positions:h,indices:m,verticesPerFace:g}}};var fP=["getX","getY","getZ"];function _l(r,t){let e={},n=t?t.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[fP[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[fP[h]](c));e[d]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Qg=new A,Qb=new A,Kb=new A,Zb=new A;function Jb(r,t,e,n){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Qg.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),Qb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),Kb.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),Zb.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),Qb.sub(Qg).normalize(),Kb.sub(Qg).normalize(),Zb.sub(Qg).normalize();let l=Qb.cross(Kb).dot(Zb);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(i.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Ji={};jS(Ji,{calcBoolean:()=>tW,calcBooleanTopological:()=>eW,freeMeshSet:()=>iW,getMeshSet:()=>nW,transformMeshSet:()=>rW});var mP,gP=new Promise(r=>{mP=r}),pP=!1;async function yP(){if(pP)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.381/build",[e,n]=await Promise.all([import("./boolean.js"),fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});mP(s),pP=!0}var ut,Yu;gP.then(r=>ut=r);function $5(r,t,e){let n,i;r.userData.parameters.type==="TorusGeometry"&&r.userData.parameters.arc===Math.PI*2?i=r.getClosedTorusIndicesForBooleanOrSubdiv():i=r.getIndex();let{positions:s,triIndices:o}=_l(r.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:u}=Jb(s,o,r);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function vP(r){let t=r.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?e:n,s=ut._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(ut.HEAPU32.buffer,s,t):new Float32Array(ut.HEAPF32.buffer,s,t)).set(r,0),s}function xP(r){switch(r){case 0:return ut.OP.UNION;case 1:return ut.OP.INTERSECTION;case 2:return ut.OP.A_MINUS_B;case 3:return ut.OP.B_MINUS_A;case 4:return ut.OP.SYMMETRIC_DIFFERENCE;case 5:return ut.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function eW(r,t){Yu===void 0&&(Yu=ut.init_csg());let e=vP(r),n=ut.csg_calc_topological(Yu,e,r.length,xP(t));ut._free(e);let i=6,s=ut.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=ut.HEAPU32[s[a]>>2],u=new Float32Array(ut.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ut.HEAPU32[s[a]>>2],d=new Uint32Array(ut.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=ut.HEAPU32[s[a]>>2],f=new Uint8Array(ut.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return ut.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function tW(r,t,e,n){Yu===void 0&&(Yu=ut.init_csg());let i=vP(r),s=ut.csg_calc(Yu,i,r.length,n,xP(t));ut._free(i);let o=5,a=ut.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ut.HEAPU32[a[u]>>2],d=ut.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=ut.HEAPU32[a[u]>>2],f=ut.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let m=l[u];e.setAttribute("position",new Ae(d,3)),e.setAttribute("normal",new Ae(f,3));let p=ut.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Rn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ut.free_mesh_data(s),m}function nW(r,t,e){if(ut===void 0)return-1;let n,i,s;if(t&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){i[x++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)i[x++]=g.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=$5(r,t,e));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=ut._malloc(c),m=new Float32Array(ut.HEAPF32.buffer,f,l),p=new Uint32Array(ut.HEAPU32.buffer,f+d,u);return m.set(n,0),p.set(i,0),ut.get_csg_mesh(f,o,f+d,a,s)}function rW(r,t){ut.transform_csg_mesh(r,t.elements)}function iW(r){ut.free_csg_mesh(r)}var sW={ConeGeometry:gC,CubeGeometry:yC,CylinderGeometry:Ng,DodecahedronGeometry:vC,EllipseGeometry:Vu,HelixGeometry:HC,IcosahedronGeometry:WC,LatheGeometry:jC,NonParametricGeometry:QC,PolygonGeometry:jg,PyramidGeometry:KC,RectangleGeometry:qg,SphereGeometry:ZC,PlaneGeometry:JC,BackdropGeometry:$C,StarGeometry:Xg,TextFrameGeometry:eP,TorusGeometry:tP,TorusKnotGeometry:nP,TriangleGeometry:rP,PathGeometry:sP,VectorGeometry:Xr},Yb=r=>sW[r.type].create(r);function yf(r){return r!==null&&"booleanOp"in r}var Qu=class extends Lg(In){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ae}updateVisible(){super.updateVisible(),this.visible=!yf(this.parent)&&this.visible,yf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ji.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),yf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Qu&&(e.freeBooleanPointer(),yf(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&yf(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Kg=new _t;function vf(r,t=0,e=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=r.getX(d),f=r.getY(d),m=r.getZ(d);h<s&&(s=h),f<o&&(o=f),m<a&&(a=m),h>l&&(l=h),f>u&&(u=f),m>c&&(c=m)}Kg.min.set(s,o,a),Kg.max.set(l,u,c),Kg.getCenter(n),Kg.getSize(i).multiplyScalar(.5)}var oW=new Me,aW=new Ui,kt=class extends Qu{constructor(t,e){super(oW,aW),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?vf(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var xf=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var ar=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=He.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,n){e=e??this.getType(t,e);let i=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,i,s,o){return""}generate(t,e,n,i,s){return""}parse(t,e,n,i){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let i=t.getTypeLength(n);(i>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=i,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof ar&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var $b=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xn=new $b;var ze=class extends ar{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,i,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=He.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,i)):super.build(e,n,i);if(o)return a.name=a.name||super.build(e,n,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,i);i=this.getUUID(!1);let u=this.getTemp(e,i);if(u)return e.format(u,l,n);{u=super.generate(e,n,i,a.output,s);let c=this.generate(e,l,i);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,i)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let i=e.getVars()[n];return i?i.name:void 0}generate(e,n,i,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var Nt=class extends ze{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var hn=class extends Nt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(e,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,n,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var yr=class extends Nt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var $t=class extends Ne{constructor(e,n,i,s){super(e,n,i);this.isColorA=!0;this.a=s}setRGBA(e,n,i,s){super.setRGB(e,n,i),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Yr=class extends Nt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof $t?e:new $t(e.r,e.g,e.b,e.a)}generateReadonly(e,n,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var lW=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bP=/[a-z_0-9]+/gi,pe=class extends ze{constructor(e,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,i,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=bP.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&Xn.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=Xn.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||Xn.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}p=g.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Xn.contains(p)&&e.include(Xn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,i,s){if(this.src=e||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=lW.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(bP);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var cW=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ew=class extends ze{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ew.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,i,s,o){this.src=e||"";let a,l,u="",c=cW.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),n)}generate(e,n,i,s,o){return e.format(this.name,this.getType(e),n)}},At=ew;At.PI="PI",At.PI2="PI2",At.RECIPROCAL_PI="RECIPROCAL_PI",At.RECIPROCAL_PI2="RECIPROCAL_PI2",At.LOG2="LOG2",At.EPSILON="EPSILON";var uW=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3140
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var lP,qu=new Promise(r=>{lP=r}),aP=!1;async function cP(){if(aP)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.382/build",[e,n]=await Promise.all([import("./process.js"),fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});lP(s),aP=!0}function Al(r,t,e){let n={parameters:r,type:r.type};if(r.type==="PathGeometry")n.path=r.path;else if(r.type==="VectorGeometry"){let s=Mt.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new Sc().parse(r);else{if(r.type==="SubdivGeometry")return new xn(r,e);if(r.type==="TextGeometry")return new ju(r,t)}let i;try{i=Yb(n)}catch(s){console.error(s)}if(!i){let s=Mt.createFromState(du.defaultData(),100,100);n.shape=s,i=Yb(n)}return i}var J5=new ae;function gf(r,t,e,n){let i=r.position.array,s=r.normal.array,o=J5.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=t,i[c+1]*=e,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var Yg=new _t,Xu=new A,Ke;qu.then(r=>{Ke=r});var uP=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),dP=new Uint32Array([0,1,2,3]),hP=new Uint8Array([4]),xn=class extends Me{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=Ms.div(n,i);this.subdividedGeometry&&gf(this.subdividedGeometry.attributes,...s),this.originalGeometry&&gf(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Xu.fromArray(s));let a=Xu.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,i;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:i}=xn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new er(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Rn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;Yg.setFromBufferAttribute(n),Yg.getCenter(i),e.boundingSphere.radius=i.distanceTo(Yg.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Yg.getSize(Xu);let s={width:Xu.x,height:Xu.y,depth:Xu.z};return this.userData.parameters=s,s}static build(e,n,i,s){let o,a,l,u=e?.phongAngle??35;i===!1&&(u=-1),n&&(Ke.free_bvh(n),Ke.free_subdivision_surface(n));try{o=xn.allocate(e,s)}catch(c){console.error(c,e),o=xn.allocate({positionWASM:uP,indexWASM:dP,verticesPerFaceWASM:hP},s)}if(Ke.set_destination_refinement_level(o,0),a=xn.buildLevel(o,!0,u),e.subdivisions>0)try{Ke.set_destination_refinement_level(o,e.subdivisions),l=xn.buildLevel(o,!1,u)}catch{try{Ke.set_destination_refinement_level(o,e.subdivisions-1),l=xn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0?n.geometry:Al(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=_l(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=Jb(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=uP,s=dP,o=hP);let u=i.length,c=s.length,d=o.length,h=i.length+a.length+l.length,f=s.length+o.length,m=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=Ke._malloc(m),v=new Float32Array(Ke.HEAPF32.buffer,y,h),x=new Uint32Array(Ke.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new ae().makeScale(...e.scaleBaked)),n&&(w?w.premultiply(n):w=n);let S=w?Ke.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Ke.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Ke._free(y),S}static buildLevel(e,n,i,s,o){let a=o?Ke.get_mesh_data2(e,n?Ke.Level.CONTROL:Ke.Level.REFINED,i,o.elements):Ke.get_mesh_data(e,n?Ke.Level.CONTROL:Ke.Level.REFINED,i),l=8,u=Ke.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Ke.HEAPU32[u[d]>>2],f=Ke.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let m=Ke.HEAPU32[u[d]>>2],p=Ke.HEAPF32.subarray(m>>2,(m>>2)+c[d]);d++;let g=Ke.HEAPU32[u[d]>>2],y=Ke.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=Ke.HEAPU32[u[d]>>2],x=Ke.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let w=new Me;if(w.setIndex(new vs(x,1)),w.setAttribute("position",new Ae(f,3)),w.setAttribute("normal",new Ae(p,3)),n){w.setAttribute("faceMap",new vs(y,1));let S=new Float32Array(p.length/3*4).fill(0);w.setAttribute("color",new Be(S,4))}return Ke.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Ke.free_mesh_data(a)}static freeSubdivPointer(e){Ke.free_bvh(e),Ke.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=Ke.get_wireframe_data_for_base_level(e),o=4,a=Ke.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Ke.HEAPU32[a[u]>>2],d=Ke.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Ke.HEAPU32[a[u]>>2],f=Ke.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let m=new Me;m.setAttribute("position",new Ae(d,3));let p=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return m.setAttribute("color",new Be(p,3)),m.setIndex(new vs(f,1)),Ke.free_wireframe_data_for_base_level(s),m}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Ke.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||Ke.set_destination_refinement_level(e,n);let o=i?Ke.get_topological_data2(e,s?Ke.Level.CONTROL:Ke.Level.REFINED,i.elements):Ke.get_topological_data(e,s?Ke.Level.CONTROL:Ke.Level.REFINED),a=6,l=Ke.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Ke.HEAPU32[l[c]>>2],h=new Float32Array(Ke.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Ke.HEAPU32[l[c]>>2],m=new Uint32Array(Ke.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Ke.HEAPU32[l[c]>>2],g=new Uint8Array(Ke.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Ke.free_topological_data(o),{positions:h,indices:m,verticesPerFace:g}}};var fP=["getX","getY","getZ"];function _l(r,t){let e={},n=t?t.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[fP[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[fP[h]](c));e[d]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Qg=new A,Qb=new A,Kb=new A,Zb=new A;function Jb(r,t,e,n){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Qg.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),Qb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),Kb.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),Zb.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),Qb.sub(Qg).normalize(),Kb.sub(Qg).normalize(),Zb.sub(Qg).normalize();let l=Qb.cross(Kb).dot(Zb);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(i.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Ji={};jS(Ji,{calcBoolean:()=>tW,calcBooleanTopological:()=>eW,freeMeshSet:()=>iW,getMeshSet:()=>nW,transformMeshSet:()=>rW});var mP,gP=new Promise(r=>{mP=r}),pP=!1;async function yP(){if(pP)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.382/build",[e,n]=await Promise.all([import("./boolean.js"),fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});mP(s),pP=!0}var ut,Yu;gP.then(r=>ut=r);function $5(r,t,e){let n,i;r.userData.parameters.type==="TorusGeometry"&&r.userData.parameters.arc===Math.PI*2?i=r.getClosedTorusIndicesForBooleanOrSubdiv():i=r.getIndex();let{positions:s,triIndices:o}=_l(r.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:u}=Jb(s,o,r);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function vP(r){let t=r.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?e:n,s=ut._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(ut.HEAPU32.buffer,s,t):new Float32Array(ut.HEAPF32.buffer,s,t)).set(r,0),s}function xP(r){switch(r){case 0:return ut.OP.UNION;case 1:return ut.OP.INTERSECTION;case 2:return ut.OP.A_MINUS_B;case 3:return ut.OP.B_MINUS_A;case 4:return ut.OP.SYMMETRIC_DIFFERENCE;case 5:return ut.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function eW(r,t){Yu===void 0&&(Yu=ut.init_csg());let e=vP(r),n=ut.csg_calc_topological(Yu,e,r.length,xP(t));ut._free(e);let i=6,s=ut.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=ut.HEAPU32[s[a]>>2],u=new Float32Array(ut.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ut.HEAPU32[s[a]>>2],d=new Uint32Array(ut.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=ut.HEAPU32[s[a]>>2],f=new Uint8Array(ut.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return ut.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function tW(r,t,e,n){Yu===void 0&&(Yu=ut.init_csg());let i=vP(r),s=ut.csg_calc(Yu,i,r.length,n,xP(t));ut._free(i);let o=5,a=ut.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ut.HEAPU32[a[u]>>2],d=ut.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=ut.HEAPU32[a[u]>>2],f=ut.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let m=l[u];e.setAttribute("position",new Ae(d,3)),e.setAttribute("normal",new Ae(f,3));let p=ut.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Rn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ut.free_mesh_data(s),m}function nW(r,t,e){if(ut===void 0)return-1;let n,i,s;if(t&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){i[x++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)i[x++]=g.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=$5(r,t,e));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=ut._malloc(c),m=new Float32Array(ut.HEAPF32.buffer,f,l),p=new Uint32Array(ut.HEAPU32.buffer,f+d,u);return m.set(n,0),p.set(i,0),ut.get_csg_mesh(f,o,f+d,a,s)}function rW(r,t){ut.transform_csg_mesh(r,t.elements)}function iW(r){ut.free_csg_mesh(r)}var sW={ConeGeometry:gC,CubeGeometry:yC,CylinderGeometry:Ng,DodecahedronGeometry:vC,EllipseGeometry:Vu,HelixGeometry:HC,IcosahedronGeometry:WC,LatheGeometry:jC,NonParametricGeometry:QC,PolygonGeometry:jg,PyramidGeometry:KC,RectangleGeometry:qg,SphereGeometry:ZC,PlaneGeometry:JC,BackdropGeometry:$C,StarGeometry:Xg,TextFrameGeometry:eP,TorusGeometry:tP,TorusKnotGeometry:nP,TriangleGeometry:rP,PathGeometry:sP,VectorGeometry:Xr},Yb=r=>sW[r.type].create(r);function yf(r){return r!==null&&"booleanOp"in r}var Qu=class extends Lg(In){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ae}updateVisible(){super.updateVisible(),this.visible=!yf(this.parent)&&this.visible,yf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ji.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),yf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Qu&&(e.freeBooleanPointer(),yf(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&yf(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Kg=new _t;function vf(r,t=0,e=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=r.getX(d),f=r.getY(d),m=r.getZ(d);h<s&&(s=h),f<o&&(o=f),m<a&&(a=m),h>l&&(l=h),f>u&&(u=f),m>c&&(c=m)}Kg.min.set(s,o,a),Kg.max.set(l,u,c),Kg.getCenter(n),Kg.getSize(i).multiplyScalar(.5)}var oW=new Me,aW=new Ui,kt=class extends Qu{constructor(t,e){super(oW,aW),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?vf(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var xf=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var ar=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=He.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,n){e=e??this.getType(t,e);let i=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,i,s,o){return""}generate(t,e,n,i,s){return""}parse(t,e,n,i){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let i=t.getTypeLength(n);(i>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=i,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof ar&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var $b=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xn=new $b;var ze=class extends ar{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,i,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=He.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,i)):super.build(e,n,i);if(o)return a.name=a.name||super.build(e,n,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,i);i=this.getUUID(!1);let u=this.getTemp(e,i);if(u)return e.format(u,l,n);{u=super.generate(e,n,i,a.output,s);let c=this.generate(e,l,i);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,i)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let i=e.getVars()[n];return i?i.name:void 0}generate(e,n,i,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var Nt=class extends ze{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var hn=class extends Nt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(e,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,n,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var yr=class extends Nt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var $t=class extends Ne{constructor(e,n,i,s){super(e,n,i);this.isColorA=!0;this.a=s}setRGBA(e,n,i,s){super.setRGB(e,n,i),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Yr=class extends Nt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof $t?e:new $t(e.r,e.g,e.b,e.a)}generateReadonly(e,n,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var lW=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bP=/[a-z_0-9]+/gi,pe=class extends ze{constructor(e,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,i,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=bP.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&Xn.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=Xn.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||Xn.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}p=g.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Xn.contains(p)&&e.include(Xn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,i,s){if(this.src=e||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=lW.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(bP);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var cW=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ew=class extends ze{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ew.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,i,s,o){this.src=e||"";let a,l,u="",c=cW.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),n)}generate(e,n,i,s,o){return e.format(this.name,this.getType(e),n)}},At=ew;At.PI="PI",At.PI2="PI2",At.RECIPROCAL_PI="RECIPROCAL_PI",At.RECIPROCAL_PI2="RECIPROCAL_PI2",At.LOG2="LOG2",At.EPSILON="EPSILON";var uW=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
3141
  )*?)}`,"gim"),dW=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ku=class extends ze{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}generate(e,n,i,s,o){return n==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),n)}parse(e=""){this.src=e,this.inputs=[];let n=uW.exec(e);if(n){let i=n[2],s;for(;s=dW.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Zu=class extends ze{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,n){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(s,this.getType(e),n)}};Xn.addKeyword("uv",function(){return new Zu});Xn.addKeyword("uv2",function(){return new Zu(1)});var Ml=class extends ze{constructor(e,n){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=n??Ml.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case oi:return["Linear"];case Qe:return["sRGB"];default:return[]}}generate(e,n){let i=this.input.build(e,"v4"),s=this.getType(e),o=Ml.Nodes[this.method],a=e.include(o);if(a===Ml.LINEAR_TO_LINEAR)return e.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+i+", "+l+" )",s,n)}else return e.format(a+"( "+i+" )",s,n)}fromEncoding(e){let n=Ml.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(e){let n=Ml.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}},Ur=Ml;Ur.Nodes={LinearToLinear:new pe(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3142
3142
  `)),sRGBToLinear:new pe(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
3143
3143
  `)),LinearTosRGB:new pe(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -5595,7 +5595,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
5595
5595
  }
5596
5596
  `,_y=new ot({vertexShader:oj,fragmentShader:aj,uniforms:{depthContrast:{value:1}}});var My=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((n,i)=>{let s=[i,n],o=n;for(;this._constraints.has(o);)o=this._constraints.get(o),e.has(o)||s.push(o);for(let a=s.length-2;a>=0;a--)if(!e.has(s[a])){let l=t.find(s[a]);l?l.applyPathSnapping(t):console.warn(`missing entity ${s[a]}`),e.add(s[a])}})}findDependency(t,e){let n=t;for(;this._constraints.has(n);)if(n=this._constraints.get(n),n===e)return!0;return!1}};var Ey=new Ui;Ey.wireframe=!0;var y2=new A,Bw=class extends Or{constructor(e,n){super();this.data=e;this.backupFog=new uc(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.occlusion=!1;this.aoFullRes=!1;this.radius=128;this.bias=.5;this.aoColor={r:0,g:0,b:0};this.geometryCacheChanged=!1;this.bgColor=new $t(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new My;this.needsRecomputeInstances=!1;this.ambientLight=new Yp(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=p2(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=f2(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let n=e.identity.join("-"),i=this.entityIdentityToEntity[n];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[n]=e,this.entityByUuid[e.uuid]=e}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}getWithSortKey(e){let n=this.find(e);if(n===void 0)return;let i=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);i.splice(0,0,a)}return{entity:n,sortKey:i}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push(s)}return n.sort((i,s)=>bE(i.sortKey,s.sortKey)),n.map(i=>i.entity)}nonExistOrDescendantOf(e,n){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===n)return!0;i=i.parent}return!1}find(e){if(e===""||e===void 0)return;let n=this.entityByUuid[e];return n===void 0?this.getObjectByProperty("uuid",e):n}debugEnsureEntity(e){let n=this.find(e);if(n){if(Array.isArray(n.identity)&&this.findInstance(n.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(n=>{this.toExpandCloner.add(n)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,n){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,i,e.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),Zr(s)&&Gr(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s)}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(i),i.parent.remove(i),Gr(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Zr(i)&&(i.freeBooleanPointer(),s instanceof Pi&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof Aa&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid)}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(i),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Zr(i)&&(i.invalidateUpstreamBooleanData(),Gr(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Pi&&s.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,n,i,s){if(n.type===0){if(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),n.path.includes("overrides")&&"states"in n.props){let{rest:a}=n.props;n={...n,props:a},this.markNeedsRecomputeInstances()}n.path[0]==="pathSnapping"&&n.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,n.props.pathId)}let o=this.find(e);if(o)try{c2(o,n,i,{scene:this,shared:s}),o instanceof tn&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,n){if(this.createChildrenObjects(e.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(dr(e.backgroundColor,n)),this.updateFog(e.fog,n),this.updateAmbientLight(e.environment.ambientLight,n),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Yt&&this.switchActiveCamera(i)}this.expandInstances(n,!0),this.traverseEntity(i=>{Gr(i)&&i.recomputeBoolean(),i instanceof Yt&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(n=>{(n.data.type==="Component"||n.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){St.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(n=>{St.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,n,i,s,o,a,l){e&&e!==s.uuid&&s.find(e)&&o.forInstancesRec(c=>{c.isInstanceRoot||(c.data=lu(c.data,d=>{let h=d.events.data(l.id),f=c.goUp(a);if(f){let m=[...Nm(f.identity),e].join("-"),p=this.entityIdentityToEntity[m];if(p){let g=p.uuid;Lr.zoom(h,n)[i]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ss&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((n,i)=>{n.data.events.forEach(s=>{s.data.type==="GameControl"?n.forInstancesRec(o=>{o.isInstanceRoot||(o.data=lu(o.data,a=>{a.events.delete(s.id)}).data)}):s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,n,i,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,n,i,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,n,i,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,n,i,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,n,i,s)),s.data.inActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["inActions",o.id],"object",e,n,i,s)}),s.data.outActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["outActions",o.id],"object",e,n,i,s)})):"actions"in s.data&&s.data.actions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["actions",o.id],"object",e,n,i,s)})})}),!0})}expandInstances(e,n){let i=new Set;this.traverseEntity(s=>{if(s instanceof ss&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),n||s.resetBBoxNeedsUpdate(),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Sy(s)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof ss&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(e,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(n=>{let i=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[i]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[i]),n.dispose()})}clearScene(){for(let e of this.children)St.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,n){this.init(e,n)}createPersonalCamera(){let e=new Yt(Bw.PERSONAL_CAMERA_ID,{...pu.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let n=[],i=s=>{for(let o of s.children){let a=o.cloner;St.is(o)&&!o.raycastLock&&(o.visible||a?.object.data.visible)&&((Zr(o)||Lw(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),Nw(o,e,n)),i(o))}};return i(this),n}raycastWithClones(e){let n=[],i=s=>{for(let o of s.children){let a=o.cloner;St.is(o)&&(o.visible||a?.object.data.visible)&&((Zr(o)||Lw(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),Nw(o,e,n,!0)),i(o))}};return i(this),n}forEachEntity(e){for(let n of this.children)St.is(n)&&e(n)}traverseEntity(e){for(let n of this.children)St.is(n)&&n.traverseEntity(e)}traverseObject(e){for(let n of this.children)rf.is(n)&&n.traverseObject(e)}traverseVisibleEntity(e){for(let n of this.children)St.is(n)&&n.visible&&n.traverseVisibleEntity(e)}updateFog(e,n){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=dr(e.color,n),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,n){e.color!==void 0&&(this.ambientLight.color=dr(e.color,n)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=dr(e.groundColor,n)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled),e.occlusion!==void 0&&(this.occlusion=e.occlusion),e.aoFullRes!==void 0&&(this.aoFullRes=e.aoFullRes),e.radius!==void 0&&(this.radius=e.radius),e.bias!==void 0&&(this.bias=e.bias),e.aoColor!==void 0&&(this.aoColor=dr(e.aoColor,n))}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,n,i){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,n,s,i),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let n of e.children)this.unregisterObject(n)}createObject(e,n,i,s,o,a){let l={scene:this,shared:a},u=Ay(e,n,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),i.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,u,a)),u.updateState(n,l),u instanceof tn&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),n.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,n.pathSnapping.pathId)),u}getCenter(e){let n=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;n.push(...c.vertices)}let i=new _t;return i.setFromPoints(n),i.getCenter(y2),y2}copyMatrixWorld(e,n){if(e===null){n.identity();return}let i=this.find(e);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(e,n){if(e===null){n.identity();return}let i=this.find(e)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(e){this.traverseEntity(n=>{if(n instanceof kt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)n.material[i]instanceof Kr&&e(n.material[i]);else n.material instanceof Kr&&e(n.material)})}updateCanvasSize(e,n){this.activeCamera.setViewplaneSize(e,n);let i,s;e>=n?(i=n/e,s=1):(i=1,s=e/n),this.traverseMaterial(o=>{o.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},bn=Bw;bn.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera",bn.PERSONAL_CAMERA_EXPORT_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCameraExport";var Bf=(r,t)=>{let e=t.x-r.x,n=t.y-r.y;return Math.sqrt(e*e+n*n)},v2=(r,t)=>{let e=t.x-r.x,n=t.y-r.y;return lj(Math.atan2(n,e))},x2=(r,t,e)=>{let n={x:0,y:0};return e=Ty(e),n.x=r.x-t*Math.cos(e),n.y=r.y-t*Math.sin(e),n},Ty=r=>r*(Math.PI/180),lj=r=>r*(180/Math.PI),b2=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,Fw=new Map,Uw=r=>{Fw.has(r)&&clearTimeout(Fw.get(r)),Fw.set(r,setTimeout(r,100))},Td=(r,t,e)=>{let n=t.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.addEventListener?r.addEventListener(i,e,!1):r.attachEvent&&r.attachEvent(i,e)},kw=(r,t,e)=>{let n=t.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.removeEventListener?r.removeEventListener(i,e):r.detachEvent&&r.detachEvent(i,e)};var Cy=r=>(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),zw=()=>{if(typeof window>"u")return;let r=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:r,y:t}},Py=(r,t)=>{t.top||t.right||t.bottom||t.left?(r.style.top=t.top,r.style.right=t.right,r.style.bottom=t.bottom,r.style.left=t.left):(r.style.left=t.x+"px",r.style.top=t.y+"px")},Dy=(r,t,e)=>{let n=S2(r);for(let i in n)if(n.hasOwnProperty(i))if(typeof t=="string")n[i]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";n[i]=s.slice(0,-2)}return n},w2=(r,t)=>{let e=S2(r);for(let n in e)e.hasOwnProperty(n)&&(e[n]=t);return e},S2=r=>{let t={};return t[r]="",["webkit","Moz","o"].forEach(function(n){t[n+r.charAt(0).toUpperCase()+r.slice(1)]=""}),t},Iy=(r,t)=>{for(let e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r},A2=(r,t)=>{let e={};for(let n in r)r.hasOwnProperty(n)&&t.hasOwnProperty(n)?e[n]=t[n]:r.hasOwnProperty(n)&&(e[n]=r[n]);return e},Ff=(r,t)=>{if(r.length)for(let e=0,n=r.length;e<n;e+=1)t(r[e]);else t(r)},_2=(r,t,e)=>({x:Math.min(Math.max(r.x,t.x-e),t.x+e),y:Math.min(Math.max(r.y,t.y-e),t.y+e)});typeof window<"u"&&(M2="ontouchstart"in window,E2=!!window.PointerEvent,T2=!!window.MSPointerEvent);var M2,E2,T2,Uf={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Cd,kf={};E2?Cd=Uf.pointer:T2?Cd=Uf.MSPointer:M2?(Cd=Uf.touch,kf=Uf.mouse):Cd=Uf.mouse;function Bl(){}Bl.prototype.on=function(r,t){var e=this,n=r.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};Bl.prototype.off=function(r,t){var e=this;return e._handlers_=e._handlers_||{},r===void 0?e._handlers_={}:t===void 0?e._handlers_[r]=null:e._handlers_[r]&&e._handlers_[r].indexOf(t)>=0&&e._handlers_[r].splice(e._handlers_[r].indexOf(t),1),e};Bl.prototype.trigger=function(r,t){var e=this,n=r.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(o){o.call(e,{type:i,target:e},t)})};Bl.prototype.config=function(r){var t=this;t.options=t.defaults||{},r&&(t.options=A2(t.options,r))};Bl.prototype.bindEvt=function(r,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Td(r,Cd[t],e._domHandlers_[t]),kf[t]&&Td(r,kf[t],e._domHandlers_[t]),e};Bl.prototype.unbindEvt=function(r,t){var e=this;return e._domHandlers_=e._domHandlers_||{},kw(r,Cd[t],e._domHandlers_[t]),kf[t]&&kw(r,kf[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Pd=Bl;function Yn(r,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=r,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Yn.id,Yn.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Yn.prototype=new Pd;Yn.constructor=Yn;Yn.id=0;Yn.prototype.buildEl=function(r){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Yn.prototype.stylize=function(){if(this.options.dataOnly)return this;var r=this.options.fadeTime+"ms",t=w2("borderRadius","50%"),e=Dy("transition","opacity",r),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},Iy(n.el,e),this.options.shape==="circle"&&Iy(n.back,t),Iy(n.front,t),this.applyStyles(n),this};Yn.prototype.applyStyles=function(r){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in r[t])this.ui[t].style[e]=r[t][e];return this};Yn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Yn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Yn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Yn.prototype.show=function(r){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof r=="function"&&r.call(this)},t.options.fadeTime)),t};Yn.prototype.hide=function(r){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof r=="function"&&r.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,n={};n.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,n.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(r,n)}return t};Yn.prototype.setPosition=function(r,t){var e=this;e.frontPosition={x:t.x,y:t.y};var n=e.options.fadeTime+"ms",i={};i.front=Dy("transition",["top","left"],n);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof r=="function"&&r.call(e),e.restCallback()},e.options.fadeTime)};Yn.prototype.restCallback=function(){var r=this,t={};t.front=Dy("transition","none",""),r.applyStyles(t),r.trigger("rested",r.instance)};Yn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Yn.prototype.computeDirection=function(r){var t=r.angle.radian,e=Math.PI/4,n=Math.PI/2,i,s,o;if(t>e&&t<e*3&&!r.lockX?i="up":t>-e&&t<=e&&!r.lockY?i="left":t>-e*3&&t<=-e&&!r.lockX?i="down":r.lockY||(i="right"),r.lockY||(t>-n&&t<n?s="left":s="right"),r.lockX||(t>0?o="up":o="down"),r.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:i},r.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return r;(!u.x||!u.y)&&this.trigger("plain",r),u.x||this.trigger("plain:"+s,r),u.y||this.trigger("plain:"+o,r),u.angle||this.trigger("dir dir:"+i,r)}else this.resetDirection();return r};var C2=Yn;function wn(r,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=r,e.id=wn.id,wn.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let n=getComputedStyle(e.options.zone.parentElement);return n&&n.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}wn.prototype=new Pd;wn.constructor=wn;wn.id=0;wn.prototype.prepareNipples=function(){var r=this,t=r.nipples;t.on=r.on.bind(r),t.off=r.off.bind(r),t.options=r.options,t.destroy=r.destroy.bind(r),t.ids=r.ids,t.id=r.id,t.processOnMove=r.processOnMove.bind(r),t.processOnEnd=r.processOnEnd.bind(r),t.get=function(e){if(e===void 0)return t[0];for(var n=0,i=t.length;n<i;n+=1)if(t[n].identifier===e)return t[n];return!1}};wn.prototype.bindings=function(){var r=this;r.bindEvt(r.options.zone,"start"),r.options.zone.style.touchAction="none",r.options.zone.style.msTouchAction="none"};wn.prototype.begin=function(){var r=this,t=r.options;if(t.mode==="static"){var e=r.createNipple(t.position,r.manager.getIdentifier());e.add(),r.idles.push(e)}};wn.prototype.createNipple=function(r,t){var e=this,n=e.manager.scroll,i={},s=e.options,o={x:e.parentIsFlex?n.x:n.x+e.box.left,y:e.parentIsFlex?n.y:n.y+e.box.top};if(r.x&&r.y)i={x:r.x-o.x,y:r.y-o.y};else if(r.top||r.right||r.bottom||r.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=r.top,a.style.right=r.right,a.style.bottom=r.bottom,a.style.left=r.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=r,r={x:l.left+n.x,y:l.top+n.y}}var u=new C2(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:r,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Py(u.ui.el,i),Py(u.ui.front,u.frontPosition)),e.nipples.push(u),e.trigger("added "+u.identifier+":added",u),e.manager.trigger("added "+u.identifier+":added",u),e.bindNipple(u),u};wn.prototype.updateBox=function(){var r=this;r.box=r.options.zone.getBoundingClientRect()};wn.prototype.bindNipple=function(r){var t=this,e,n=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};wn.prototype.pressureFn=function(r,t,e){var n=this,i=0;clearInterval(n.pressureIntervals[e]),n.pressureIntervals[e]=setInterval(function(){var s=r.force||r.pressure||r.webkitForce||0;s!==i&&(t.trigger("pressure",s),n.trigger("pressure "+t.identifier+":pressure",s),i=s)}.bind(n),100)};wn.prototype.onstart=function(r){var t=this,e=t.options,n=r;r=Cy(r),t.updateBox();var i=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(n.touches).findIndex(function(l){return l.identifier===o})<0){var a=[r[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return Ff(r,i),t.manager.bindDocument(),!1};wn.prototype.processOnStart=function(r){var t=this,e=t.options,n,i=t.manager.getIdentifier(r),s=r.force||r.pressure||r.webkitForce||0,o={x:r.pageX,y:r.pageY},a=t.getOrCreate(i,o);a.identifier!==i&&t.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(r,c,c.identifier),t.processOnMove(r)};if((n=t.idles.indexOf(a))>=0&&t.idles.splice(n,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var u=Bf(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(r);return}}return a};wn.prototype.getOrCreate=function(r,t){var e=this,n=e.options,i;return/(semi|static)/.test(n.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):n.mode==="semi"?e.createNipple(t,r):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,r),i)};wn.prototype.processOnMove=function(r){var t=this,e=t.options,n=t.manager.getIdentifier(r),i=t.nipples.get(n),s=t.manager.scroll;if(!b2(r)){this.processOnEnd(r);return}if(!i){console.error("Found zombie joystick with ID "+n),t.manager.removeIdentifier(n);return}if(e.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=n;var a=i.options.size/2,l={x:r.pageX,y:r.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var u=Bf(l,i.position),c=v2(l,i.position),d=Ty(c),h=u/a,f={distance:u,position:l},m,p;if(i.options.shape==="circle"?(m=Math.min(u,a),p=x2(i.position,m,c)):(p=_2(l,i.position,a),m=Bf(p,i.position)),e.follow){if(u>a){let x=l.x-p.x,w=l.y-p.y;i.position.x+=x,i.position.y+=w,i.el.style.top=i.position.y-(t.box.top+s.y)+"px",i.el.style.left=i.position.x-(t.box.left+s.x)+"px",u=Bf(l,i.position)}}else l=p,u=m;var g=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:g,y},e.dataOnly||Py(i.ui.front,i.frontPosition);var v={identifier:i.identifier,position:l,force:h,pressure:r.force||r.pressure||r.webkitForce||0,distance:u,angle:{radian:d,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:i,lockX:e.lockX,lockY:e.lockY};v=i.computeDirection(v),v.angle={radian:Ty(180-c),degree:180-c},i.trigger("move",v),t.trigger("move "+i.id+":move",v)};wn.prototype.processOnEnd=function(r){var t=this,e=t.options,n=t.manager.getIdentifier(r),i=t.nipples.get(n),s=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};wn.prototype.onDestroyed=function(r,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};wn.prototype.destroy=function(){var r=this;r.unbindEvt(r.options.zone,"start"),r.nipples.forEach(function(e){e.destroy()});for(var t in r.pressureIntervals)r.pressureIntervals.hasOwnProperty(t)&&clearInterval(r.pressureIntervals[t]);r.trigger("destroyed",r.nipples),r.manager.unbindDocument(),r.off()};var P2=wn;function fr(r){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=zw(),t.config(r),t.prepareCollections();var e=function(){var i;t.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+i.left,y:t.scroll.y+i.top}})})};if(typeof window>"u")return t.collections;Td(window,"resize",function(){Uw(e)});var n=function(){t.scroll=zw()};return Td(window,"scroll",function(){Uw(n)}),t.collections}fr.prototype=new Pd;fr.constructor=fr;fr.prototype.prepareCollections=function(){var r=this;r.collections.create=r.create.bind(r),r.collections.on=r.on.bind(r),r.collections.off=r.off.bind(r),r.collections.destroy=r.destroy.bind(r),r.collections.get=function(t){var e;return r.collections.every(function(n){return e=n.get(t),!e}),e}};fr.prototype.create=function(r){return this.createCollection(r)};fr.prototype.createCollection=function(r){var t=this,e=new P2(t,r);return t.bindCollection(e),t.collections.push(e),e};fr.prototype.bindCollection=function(r){var t=this,e,n=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};fr.prototype.bindDocument=function(){var r=this;r.binded||(r.bindEvt(document,"move").bindEvt(document,"end"),r.binded=!0)};fr.prototype.unbindDocument=function(r){var t=this;(!Object.keys(t.ids).length||r===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};fr.prototype.getIdentifier=function(r){var t;return r?(t=r.identifier===void 0?r.pointerId:r.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};fr.prototype.removeIdentifier=function(r){var t={};for(var e in this.ids)if(this.ids[e]===r){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};fr.prototype.onmove=function(r){var t=this;return t.onAny("move",r),!1};fr.prototype.onend=function(r){var t=this;return t.onAny("end",r),!1};fr.prototype.oncancel=function(r){var t=this;return t.onAny("end",r),!1};fr.prototype.onAny=function(r,t){var e=this,n,i="processOn"+r.charAt(0).toUpperCase()+r.slice(1);t=Cy(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[i](a),a._found_=!0)},o=function(a){n=e.getIdentifier(a),Ff(e.collections,s.bind(null,a,n)),a._found_||e.removeIdentifier(n)};return Ff(t,o),!1};fr.prototype.destroy=function(){var r=this;r.unbindDocument(!0),r.ids={},r.index=0,r.collections.forEach(function(t){t.destroy()}),r.off()};fr.prototype.onDestroyed=function(r,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var D2=fr;var I2=new D2,O2={create:function(r){return I2.create(r)},factory:I2};var R2=fs(xb());function os(r,t){let e=new Me;if(!r.getAttribute("position"))return e.setAttribute("position",new Ae([],3)),e.setIndex([]),e;let{positions:n,triIndices:i}=_l(r.getAttribute("position"),r.getIndex());return e.setAttribute("position",new Ae(n,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var cj=new ae,uj=new ae,ks=[[0,0,0],[0,0,0],[0,0,0]];function Gw(r){let t=r.elements;ks[0][0]=t[0],ks[0][1]=t[4],ks[0][2]=t[8],ks[1][0]=t[1],ks[1][1]=t[5],ks[1][2]=t[9],ks[2][0]=t[2],ks[2][1]=t[6],ks[2][2]=t[10];let{u:e,v:n}=(0,R2.SVD)(ks),i=cj.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=uj.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return i.multiply(s.transpose())}var Ry=class extends Ac{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,n=[]){return t.forEach(i=>{i.visible&&this.intersectObject(i,e,n)}),n}createRaycastLineHelper(){let t=new vi({color:65280,linewidth:10}),e=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new A().addVectors(e,n.multiplyScalar(i)),o=new Me;return o.setFromPoints([e,s]),new Ya(o,t)}};var L2=r=>r instanceof Eo||r instanceof ss;function dj(r,t){return r.distance-t.distance}function N2(r,t,e){if(!(!Ao(t)||!t.visible)){Zr(t)&&t.raycast(r,e);for(let n of t.children)N2(r,n,e)}}function zf(r,t,e){if(!e.some(i=>Dd(r,i)!==void 0))return[];let n=[];return t.children.forEach(i=>N2(r,i,n)),n.sort(dj),n}function Gf(r){let t=[];if(r.length){let e=r[0].object;Ao(e)&&t.push(e);let n=e.parent;for(;n;)L2(n)&&t.push(n),n=n.parent}return t}function Dd(r,t){if(Zr(t)){if(t.visible){let e=[];return t.raycast(r,e),e.length?e[0]:void 0}}else if(L2(t))return B2(r,t)}function B2(r,t){if(!(!Ao(t)||!t.visible)){if(Zr(t)){let e=[];if(t.raycast(r,e),e.length)return e[0]}for(let e of t.children){let n=B2(r,e);if(n)return n}}}function hj(r,t,e){return{x:(r-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var Ly=class{constructor(t,e,n,i,s,o,a){this.scene=e;this.getCamera=n;this.sharedAssets=i;this.stopRaycast=s;this.requestRender=o;this.isExport=a;this.raycaster=new Ry;this.raycasterNeedsUpdate=!0;this._useWindowEvents=!1;this.renderer=t,this._useWindowEvents=e.data.publish.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:n}=t.touches?.length>0?t.touches[0]:t,i=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(hj(e,n,i),this.getCamera())}};var Vw=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))(Vw||{}),Bn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var F2=new Map,Vf=new Map,To=class{constructor(t,e,n,i){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let u=typeof s=="string"?i.getAudio(s).src:s.data;this.audioPlayer=new _o({src:u,volume:o,delay:a,loop:l}),Vf.has(n.uuid)?Vf.get(n.uuid).push(this):Vf.set(n.uuid,[this]),F2.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Id=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=F2.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Vf.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...Vf.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Co=class{constructor(t,e,n,i){this.data=e;if(e.interaction==="play")this.interaction=new To(t,e,n,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Id(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof To?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof To?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){this.interaction instanceof To&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function U2(r,t){let e;if("material"in r){let n=r.material;Array.isArray(n)?e=r.material[0].layers.find(i=>i.uuid===t):e=r.material.layers.find(i=>i.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var k2=new Map,Hf=new Map,_a=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:i,loop:s,volume:o,delay:a}=e;if(this.object=n,i===void 0)throw new Error("Missing property");let l=U2(n,i);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),Hf.has(n.uuid)?Hf.get(n.uuid).push(this):Hf.set(n.uuid,[this]),k2.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let n=this.videoElement.play();n!==void 0&&n.then(i=>{}).catch(i=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Od=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=k2.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=Hf.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let t=[...Hf.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Fl=class{constructor(t,e,n){this.data=e;if(e.interaction==="play")this.interaction=new _a(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Od(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof _a?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof _a?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var fj="text/plain",pj="us-ascii",z2=(r,t)=>t.some(e=>e instanceof RegExp?e.test(r):e===r),mj=(r,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(r);if(!e)throw new Error(`Invalid URL: ${r}`);let{type:n,data:i,hash:s}=e.groups,o=n.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(d=>{let[h,f=""]=d.split("=").map(m=>m.trim());return h==="charset"&&(f=f.toLowerCase(),f===pj)?"":`${h}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==fj)&&c.unshift(l),`data:${c.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function Hw(r,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},r=r.trim(),/^data:/i.test(r))return mj(r,t);if(/^view-source:/i.test(r))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=r.startsWith("//");!e&&/^\.*\//.test(r)||(r=r.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let i=new URL(r);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),t.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),t.stripAuthentication&&(i.username="",i.password=""),t.stripHash?i.hash="":t.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(i.pathname);if(!c)break;let d=c[0],h=c.index,f=i.pathname.slice(a,h);l+=f.replace(/\/{2,}/g,"/"),l+=d,a=h+d.length}let u=i.pathname.slice(a,i.pathname.length);l+=u.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];z2(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...i.searchParams.keys()])z2(o,t.removeQueryParameters)&&i.searchParams.delete(o);if(t.removeQueryParameters===!0&&(i.search=""),t.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}t.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=r;return r=i.toString(),!t.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(r=r.replace(/\/$/,"")),(t.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&t.removeSingleSlash&&(r=r.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(r=r.replace(/^http:\/\//,"//")),t.stripProtocol&&(r=r.replace(/^(?:https?:)?\/\//,"")),r}var Ny=class{constructor({url:t,context:e},n){this.managers=n;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:Hw(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){Lm?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.managers.controlsManager.orbitControls?.onPointerUp(ke[0]),SE())}};var Wf=class{constructor(t,e,n){this.data=t;this.managers=n;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.scene.find(t);if(e===void 0)return;let n=this.controlsManager.sharedGameControlGlobals.rapierWorld,i=n?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)i?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.boundsTree&&(s.boundsTree=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(n.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(i||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.boundsTree&&(e.boundsTree=void 0))}else e.rigidBody&&(n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.boundsTree&&(e.boundsTree=void 0),e.visible=!1;n===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.boundsTree!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),this.managers.eventManager.requestRender()};this.objects=[...t.objects],this.scene=e,this.controlsManager=n.controlsManager}dispatch(t){this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var G2=(()=>{let r,t,e,n;function i(a){!r&&!V2()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(r=requestAnimationFrame(s)),a&&(t=a,n=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,d=u.length,h=0;for(;h<d;){let f=u[h];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),n()),h++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(h,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody):(f.boundsTree=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(m=>m.boundsTree!==void 0)),d--,n())}r=h>0?requestAnimationFrame(s):void 0,e=h>0?a:void 0}function o(){V2()?r&&(cancelAnimationFrame(r),e=void 0):i()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),i})();function V2(){return!!document&&document.hidden}var H2=new Je,gj=new A,yj=new A,Po=class{constructor(t,e,n){this.data=t;this.scene=e;this.controlsManager=n;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=He.generateUUID();this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=wx(this.dispatch,1e3/this.data.creationSpeed);this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))};this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)};this.dispatchInner=()=>{if(this.timeoutIdQueue.shift(),this.object===void 0)return;let t=new dn(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem;n===bn.PERSONAL_CAMERA_ID&&this.scene.find(bn.PERSONAL_CAMERA_EXPORT_ID)&&(n=bn.PERSONAL_CAMERA_EXPORT_ID);let i=this.scene.find(n);i&&(i.updateMatrixWorldSVD(),t.hiddenMatrix.setPosition(0,0,0),t.hiddenMatrix.premultiply(i.matrixWorldRigid),t.updateMatrixWorld())}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.scene.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),G2(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof hr)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof dn)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof hr)return;t instanceof dn?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId),t.matrixWorld.decompose(gj,H2,yj);let n=new A().fromArray(this.data.velocity).applyQuaternion(H2),i=e.dataPatched;if(!(i.collision==="visibility"?!i.visible:!i.collision)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(n.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=n)),e.dataPatched.physics?.fusedBody===!0))return!0};this.scene=e,this.object=this.scene.find(this.data.object),G2(n)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.scene.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var By=class{constructor(t,e,n,i){this.scene=e,this.sharedAssets=n,this.sceneData=t,this.managers=i}dispatch(){Fy(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager?.gameControls.forEach(e=>e.reset(!0));let t;this.sceneData.publish.playCamera?t=this.scene.find(this.sceneData.publish.playCamera):(t=this.scene.find(bn.PERSONAL_CAMERA_ID),t||(t=this.scene.find(bn.PERSONAL_CAMERA_EXPORT_ID))),this.scene.switchActiveCamera(t),this.managers.controlsManager.requestRender()}};var Q2={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Xw={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},vj=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],ky={CSS:{},springs:{}};function as(r,t,e){return Math.min(Math.max(r,t),e)}function jf(r,t){return r.indexOf(t)>-1}function Ww(r,t){return r.apply(null,t)}var et={arr:function(r){return Array.isArray(r)},obj:function(r){return jf(Object.prototype.toString.call(r),"Object")},pth:function(r){return et.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||et.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return et.hex(r)||et.rgb(r)||et.hsl(r)},key:function(r){return!Q2.hasOwnProperty(r)&&!Xw.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function K2(r){var t=/\(([^)]+)\)/.exec(r);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function Z2(r,t){var e=K2(r),n=as(et.und(e[0])?1:e[0],.1,100),i=as(et.und(e[1])?100:e[1],.1,100),s=as(et.und(e[2])?10:e[2],.1,100),o=as(et.und(e[3])?0:e[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*a+-o)/u:-o+a;function h(m){var p=t?t*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(c*Math.cos(u*p)+d*Math.sin(u*p)):p=(c+d*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=ky.springs[r];if(m)return m;for(var p=1/6,g=0,y=0;;)if(g+=p,h(g)===1){if(y++,y>=16)break}else y=0;var v=g*p*1e3;return ky.springs[r]=v,v}return t?h:f}function xj(r){return r===void 0&&(r=10),function(t){return Math.ceil(as(t,1e-6,1)*r)*(1/r)}}var bj=function(){var r=11,t=1/(r-1);function e(c,d){return 1-3*d+3*c}function n(c,d){return 3*d-6*c}function i(c){return 3*c}function s(c,d,h){return((e(d,h)*c+n(d,h))*c+i(d))*c}function o(c,d,h){return 3*e(d,h)*c*c+2*n(d,h)*c+i(d)}function a(c,d,h,f,m){var p,g,y=0;do g=d+(h-d)/2,p=s(g,f,m)-c,p>0?h=g:d=g;while(Math.abs(p)>1e-7&&++y<10);return g}function l(c,d,h,f){for(var m=0;m<4;++m){var p=o(d,h,f);if(p===0)return d;var g=s(d,h,f)-c;d-=g/p}return d}function u(c,d,h,f){if(!(0<=c&&c<=1&&0<=h&&h<=1))return;var m=new Float32Array(r);if(c!==d||h!==f)for(var p=0;p<r;++p)m[p]=s(p*t,c,h);function g(y){for(var v=0,x=1,w=r-1;x!==w&&m[x]<=y;++x)v+=t;--x;var S=(y-m[x])/(m[x+1]-m[x]),_=v+S*t,M=o(_,c,h);return M>=.001?l(y,_,c,h):M===0?_:a(y,v,v+t,c,h)}return function(y){return c===d&&h===f||y===0||y===1?y:s(g(y),d,f)}}return u}(),J2=function(){var r={linear:function(){return function(n){return n}}},t={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=as(n,1,10),o=as(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(n,i){t[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(t).forEach(function(n){var i=t[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function Yw(r,t){if(et.fnc(r))return r;var e=r.split("(")[0],n=J2[e],i=K2(r);switch(e){case"spring":return Z2(r,t);case"cubicBezier":return Ww(bj,i);case"steps":return Ww(xj,i);default:return Ww(n,i)}}function $2(r){try{var t=document.querySelectorAll(r);return t}catch{return}}function zy(r,t){for(var e=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<e;s++)if(s in r){var o=r[s];t.call(n,o,s,r)&&i.push(o)}return i}function Gy(r){return r.reduce(function(t,e){return t.concat(et.arr(e)?Gy(e):e)},[])}function W2(r){return et.arr(r)?r:(et.str(r)&&(r=$2(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function Qw(r,t){return r.some(function(e){return e===t})}function Kw(r){var t={};for(var e in r)t[e]=r[e];return t}function jw(r,t){var e=Kw(r);for(var n in r)e[n]=t.hasOwnProperty(n)?t[n]:r[n];return e}function Vy(r,t){var e=Kw(r);for(var n in t)e[n]=et.und(r[n])?t[n]:r[n];return e}function wj(r){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return t?"rgba("+t[1]+",1)":r}function Sj(r){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=r.replace(t,function(a,l,u,c){return l+l+u+u+c+c}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function Aj(r){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),e=parseInt(t[1],10)/360,n=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,s=t[4]||1;function o(h,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?h+(f-h)*6*m:m<1/2?f:m<2/3?h+(f-h)*(2/3-m)*6:h}var a,l,u;if(n==0)a=l=u=i;else{var c=i<.5?i*(1+n):i+n-i*n,d=2*i-c;a=o(d,c,e+1/3),l=o(d,c,e),u=o(d,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function _j(r){if(et.rgb(r))return wj(r);if(et.hex(r))return Sj(r);if(et.hsl(r))return Aj(r)}function Do(r){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(r);if(t)return t[1]}function Mj(r){if(jf(r,"translate")||r==="perspective")return"px";if(jf(r,"rotate")||jf(r,"skew"))return"deg"}function qw(r,t){return et.fnc(r)?r(t.target,t.id,t.total):r}function zs(r,t){return r.getAttribute(t)}function Zw(r,t,e){var n=Do(t);if(Qw([e,"deg","rad","turn"],n))return t;var i=ky.CSS[t+e];if(!et.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return ky.CSS[t+e]=u,u}function eD(r,t,e){if(t in r.style){var n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[t]||getComputedStyle(r).getPropertyValue(n)||"0";return e?Zw(r,i,e):i}}function Jw(r,t){if(et.dom(r)&&!et.inp(r)&&(zs(r,t)||et.svg(r)&&r[t]))return"attribute";if(et.dom(r)&&Qw(vj,t))return"transform";if(et.dom(r)&&t!=="transform"&&eD(r,t))return"css";if(r[t]!=null)return"object"}function tD(r){if(!!et.dom(r)){for(var t=r.style.transform||"",e=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=e.exec(t);)n.set(i[1],i[2]);return n}}function Ej(r,t,e,n){var i=jf(t,"scale")?1:0+Mj(t),s=tD(r).get(t)||i;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),n?Zw(r,s,n):s}function $w(r,t,e,n){switch(Jw(r,t)){case"transform":return Ej(r,t,n,e);case"css":return eD(r,t,e);case"attribute":return zs(r,t);default:return r[t]||0}}function eS(r,t){var e=/^(\*=|\+=|-=)/.exec(r);if(!e)return r;var n=Do(r)||0,i=parseFloat(t),s=parseFloat(r.replace(e[0],""));switch(e[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function nD(r,t){if(et.col(r))return _j(r);if(/\s/g.test(r))return r;var e=Do(r),n=e?r.substr(0,r.length-e.length):r;return t?n+t:n}function tS(r,t){return Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2))}function Tj(r){return Math.PI*2*zs(r,"r")}function Cj(r){return zs(r,"width")*2+zs(r,"height")*2}function Pj(r){return tS({x:zs(r,"x1"),y:zs(r,"y1")},{x:zs(r,"x2"),y:zs(r,"y2")})}function rD(r){for(var t=r.points,e=0,n,i=0;i<t.numberOfItems;i++){var s=t.getItem(i);i>0&&(e+=tS(n,s)),n=s}return e}function Dj(r){var t=r.points;return rD(r)+tS(t.getItem(t.numberOfItems-1),t.getItem(0))}function iD(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return Tj(r);case"rect":return Cj(r);case"line":return Pj(r);case"polyline":return rD(r);case"polygon":return Dj(r)}}function Ij(r){var t=iD(r);return r.setAttribute("stroke-dasharray",t),t}function Oj(r){for(var t=r.parentNode;et.svg(t)&&et.svg(t.parentNode);)t=t.parentNode;return t}function sD(r,t){var e=t||{},n=e.el||Oj(r),i=n.getBoundingClientRect(),s=zs(n,"viewBox"),o=i.width,a=i.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function Rj(r,t){var e=et.str(r)?$2(r)[0]:r,n=t||100;return function(i){return{property:i,el:e,svg:sD(e),totalLength:iD(e)*(n/100)}}}function Lj(r,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return r.el.getPointAtLength(l)}var n=sD(r.el,r.svg),i=e(),s=e(-1),o=e(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function j2(r,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=nD(et.pth(r)?r.totalLength:r,t)+"";return{original:n,numbers:n.match(e)?n.match(e).map(Number):[0],strings:et.str(r)||t?n.split(e):[]}}function oD(r){var t=r?Gy(et.arr(r)?r.map(W2):W2(r)):[];return zy(t,function(e,n,i){return i.indexOf(e)===n})}function aD(r){var t=oD(r);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:tD(e)}}})}function Nj(r,t){var e=Kw(t);if(/^spring/.test(e.easing)&&(e.duration=Z2(e.easing)),et.arr(r)){var n=r.length,i=n===2&&!et.obj(r[0]);i?r={value:r}:et.fnc(t.duration)||(e.duration=t.duration/n)}var s=et.arr(r)?r:[r];return s.map(function(o,a){var l=et.obj(o)&&!et.pth(o)?o:{value:o};return et.und(l.delay)&&(l.delay=a?0:t.delay),et.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return Vy(o,e)})}function Bj(r){for(var t=zy(Gy(r.map(function(s){return Object.keys(s)})),function(s){return et.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},n=function(s){var o=t[s];e[o]=r.map(function(a){var l={};for(var u in a)et.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},i=0;i<t.length;i++)n(i);return e}function Fj(r,t){var e=[],n=t.keyframes;n&&(t=Vy(Bj(n),t));for(var i in t)et.key(i)&&e.push({name:i,tweens:Nj(t[i],r)});return e}function Uj(r,t){var e={};for(var n in r){var i=qw(r[n],t);et.arr(i)&&(i=i.map(function(s){return qw(s,t)}),i.length===1&&(i=i[0])),e[n]=i}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function kj(r,t){var e;return r.tweens.map(function(n){var i=Uj(n,t),s=i.value,o=et.arr(s)?s[1]:s,a=Do(o),l=$w(t.target,r.name,a,t),u=e?e.to.original:l,c=et.arr(s)?s[0]:u,d=Do(c)||Do(l),h=a||d;return et.und(o)&&(o=u),i.from=j2(c,h),i.to=j2(eS(o,c),h),i.start=e?e.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=Yw(i.easing,i.duration),i.isPath=et.pth(s),i.isColor=et.col(i.from.original),i.isColor&&(i.round=1),e=i,i})}var lD={css:function(r,t,e){return r.style[t]=e},attribute:function(r,t,e){return r.setAttribute(t,e)},object:function(r,t,e){return r[t]=e},transform:function(r,t,e,n,i){if(n.list.set(t,e),t===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function cD(r,t){var e=aD(r);e.forEach(function(n){for(var i in t){var s=qw(t[i],n),o=n.target,a=Do(s),l=$w(o,i,a,n),u=a||Do(l),c=eS(nD(s,u),l),d=Jw(o,i);lD[d](o,i,c,n.transforms,!0)}})}function zj(r,t){var e=Jw(r.target,t.name);if(e){var n=kj(t,r),i=n[n.length-1];return{type:e,property:t.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function Gj(r,t){return zy(Gy(r.map(function(e){return t.map(function(n){return zj(e,n)})})),function(e){return!et.und(e)})}function uD(r,t){var e=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=e?Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,i.delay=e?Math.min.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):t.delay,i.endDelay=e?i.duration-Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,i}var q2=0;function Vj(r){var t=jw(Q2,r),e=jw(Xw,r),n=Fj(e,r),i=aD(r.targets),s=Gj(i,n),o=uD(s,e),a=q2;return q2++,Vy(t,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Di=[],X2=[],Uy,Hj=function(){function r(){Uy=requestAnimationFrame(t)}function t(e){var n=Di.length;if(n){for(var i=0;i<n;){var s=Di[i];s.paused?(Di.splice(i,1),n-=1):(s.tick(e),i++)}r()}else Uy=cancelAnimationFrame(Uy)}return r}();function Wj(r){document.hidden?(Di.forEach(function(t){return t.pause(r.timeStamp)}),X2=Di.slice(0),Sn.running=Di=[]):X2.forEach(function(t){return t.play(r.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Wj);function Sn(r){r===void 0&&(r={});var t=0,e=0,n=0,i,s,o=0,a=null;function l(M){var b=window.Promise&&new Promise(function(E){return a=E});return M.finished=b,b}var u=Vj(r),c=l(u);function d(){var M=u.direction;M!=="alternate"&&(u.direction=M!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=u.reversed)})}function h(){u.direction="normal",u.reversed=!1,s.forEach(function(M){return M.reversed=!1})}function f(M){return u.reversed?u.duration-M:M}function m(){t=0,e=f(u.currentTime)*(1/Sn.speed)}function p(M,b){b&&(u.reversed?b.seek(b.duration*b.loop-(M-b.timelineOffset-b.pingPongDelayCorrection)):b.seek(M-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection))}function g(M){if(u.reversed)for(var E=o;E--;)p(M,s[E]);else for(var b=0;b<o;b++)p(M,s[b])}function y(M){var b=0,E=u.animations,T=E.length;for(u.direction!=="alternate"&&u.parent?.direction==="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1&&(u.parent?.reversed&&u.direction==="alternate"?M=u.duration-u.delay+u.endDelay-M:M=u.duration+u.delay-u.endDelay-M):S(!1,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)&&(u.parent?.reversed&&u.direction==="alternate"?M=u.duration-u.delay+u.endDelay-M:M=u.duration+u.delay-u.endDelay-M);b<T;){var P=E[b],D=P.animatable,C=P.tweens,O=C.length-1,B=C[O];O&&(B=zy(C,function(k){return M<k.end})[0]||B);let Z;u.parent?.reversed&&u.direction==="alternate"?Z=as(M-B.start-B.endDelay,0,B.duration)/B.duration:Z=as(M-B.start-B.delay,0,B.duration)/B.duration;for(var V=isNaN(Z)?1:B.easing(Z),Y=B.to.strings,W=B.round,q=[],j=B.to.numbers.length,X=void 0,L=0;L<j;L++){var U=void 0;let k,he;u.direction!=="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1?(k=B.to.numbers[L],he=B.from.numbers[L]||0):(he=B.to.numbers[L],k=B.from.numbers[L]||0):S(!0,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)?(k=B.to.numbers[L],he=B.from.numbers[L]||0):(he=B.to.numbers[L],k=B.from.numbers[L]||0),B.isPath?U=Lj(B.value,V*he):U=k+V*(he-k),W&&(B.isColor&&L>2||(U=Math.round(U*W)/W)),q.push(U)}var G=Y.length;if(!G)X=q[0];else{X=Y[0];for(var H=0;H<G;H++){var z=Y[H],re=Y[H+1],K=q[H];isNaN(K)||(re?X+=K+re:X+=K+" ")}}lD[P.type](D.target,P.property,X,D.transforms),P.currentValue=X,b++}}function v(M){u[M]&&!u.passThrough&&u[M](u)}function x(){u.remaining&&u.remaining!==!0&&u.remaining--}let w={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function S(M,b,E,T,P){return w[M<<4|b<<3|E<<2|T<<1|P]}function _(M){var b=u.duration;let E=u.delay,T=b-u.endDelay;u.parent?.reversed&&u.direction==="alternate"&&(E=u.endDelay,T=b-u.delay);var P=f(M);if(u.progress=as(P/b*100,0,100),u.reversePlayback=P<u.currentTime,o&&g(P),!u.began&&u.currentTime>=0&&(u.began=!0,v("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,v("loopBegin")),(u.reversed||P>=0)&&P<=E&&u.currentTime!==0&&(y(0),v("change")),(P>=T&&u.currentTime!==b+u.pingPongDelayCorrection||!b)&&(y(b),v("change")),P>E&&P<T?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,v("changeBegin")),y(P),v("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):u.began&&P>T&&v("changeComplete"),u.currentTime=as(P,0,b+u.pingPongDelayCorrection),u.began&&v("update"),M>=b)if(x(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,v("loopComplete"),v("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/Sn.speed:t+=u.duration;for(let D of s)D.setStartTime(0),D.remaining=D.loop;v("loopComplete"),u.loopBegan=!1,u.direction==="alternate"?d():o&&h()}}return u.reset=function(){var M=u.direction;u.passThrough=!1,u.currentTime=0,u.progress=0,u.paused=!0,u.began=!1,u.loopBegan=!1,u.changeBegan=!1,u.completed=!1,u.changeCompleted=!1,u.reversePlayback=!1,u.reversed=M==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var b=o;b--;)u.children[b].reset();(u.reversed&&u.loop!==!0||M==="alternate"&&u.loop===1)&&u.remaining++,y(u.reversed?u.duration:0)},u.setStartTime=function(M){t=M},u.set=function(M,b){return cD(M,b),u},u.tick=function(M){n=M,t||(t=n),_((n+(e-t))*Sn.speed)},u.seek=function(M){_(M-t)},u.pause=function(M){u.paused=!0,o&&(i=M??performance.now())},u.play=function(M){!u.paused||(u.completed&&u.reset(),u.paused=!1,Di.push(u),o&&i!==void 0&&(t+=(M??performance.now())-i),Uy||Hj())},u.reverse=function(){d(),u.completed=!u.reversed,m()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function Y2(r,t){for(var e=t.length;e--;)Qw(r,t[e].animatable.target)&&t.splice(e,1)}function jj(r){for(var t=oD(r),e=Di.length;e--;){var n=Di[e],i=n.animations,s=n.children;Y2(t,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;Y2(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function qj(r,t){t===void 0&&(t={});var e=t.direction||"normal",n=t.easing?Yw(t.easing):null,i=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=et.arr(r),d=parseFloat(c?r[0]:r),h=c?parseFloat(r[1]):0,f=Do(c?r[1]:r)||0,m=t.start||0+(c?d:0),p=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!p.length){for(var w=0;w<x;w++){if(!i)p.push(Math.abs(o-w));else{var S=l?(i[0]-1)/2:o%i[0],_=l?(i[1]-1)/2:Math.floor(o/i[0]),M=w%i[0],b=Math.floor(w/i[0]),E=S-M,T=_-b,P=Math.sqrt(E*E+T*T);s==="x"&&(P=-E),s==="y"&&(P=-T),p.push(P)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(C){return n(C/g)*g})),e==="reverse"&&(p=p.map(function(C){return s?C<0?C*-1:-C:Math.abs(g-C)}))}var D=c?(h-d)/g:d;return m+D*(Math.round(p[v]*100)/100)+f}}function Xj(r){r===void 0&&(r={});var t=Sn(r);return t.duration=0,t.add=function(e,n){var i=Di.indexOf(t),s=t.children;i>-1&&Di.splice(i,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Vy(e,jw(Xw,r));l.targets=l.targets||r.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=et.und(n)?u:eS(n,u),o(t);var c=Sn(l);o(c),s.push(c),c.parent=t;var d=uD(s,r);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}Sn.version="3.2.0";Sn.speed=1;Sn.running=Di;Sn.remove=jj;Sn.get=$w;Sn.set=cD;Sn.convertPx=Zw;Sn.path=Rj;Sn.setDashoffset=Ij;Sn.stagger=qj;Sn.timeline=Xj;Sn.easing=Yw;Sn.penner=J2;Sn.random=function(r,t){return Math.floor(Math.random()*(t-r+1))+r};var Hy=Sn;var dD=new A,hD=new A,fD=new Je;function pD(r,t,e,n){if(n===0)return e.copy(r);if(n===1)return e.copy(t);let i=r.w*t.w+r.x*t.x+r.y*t.y+r.z*t.z;if(i>=1)return e.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let c=1-n;return e.w=c*r.w+n*t.w,e.x=c*r.x+n*t.x,e.y=c*r.y+n*t.y,e.z=c*r.z+n*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return e.w=r.w*l+t.w*u,e.x=r.x*l+t.x*u,e.y=r.y*l+t.y*u,e.z=r.z*l+t.z*u,e}function ls(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(o==null)return;let a=s??t[r],l=o;if(a!==l)return{update:u=>{let c=He.lerp(a,l,u);i?t[r]=Math.trunc(c):t[r]=c},start:()=>{t[r]=a},end:()=>{t[r]=l}}}function nS(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(!o)return;let a=t[r],l=[...s??a],u=[...o];if(!(l.length!==u.length||ll(l,u)))return{update:c=>{l.forEach((d,h)=>{let f=He.lerp(d,u[h],c);t[r][h]=i?Math.trunc(f):f})},start:()=>{Object.assign(t[r],l)},end:()=>{Object.assign(t[r],u)}}}function rS(r,t,e,n){let i=e[r]?e[r]:void 0,s=n[r];if(!s)return;let o=t[r],a=i?new A().fromArray(i):o.clone(),l=new A().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function mD(r,t,e,n){let i=e[r]?e[r]:void 0,s=n[r];if(!s)return;let o=t[r],a=i?new ae().fromArray(i):o.clone(),l=new A,u=new Je,c=new A;a.decompose(l,u,c);let d=new ae().fromArray(s),h=new A,f=new Je,m=new A;if(d.decompose(h,f,m),!a.equals(d))return{update:p=>{fD.slerpQuaternions(u,f,p),dD.lerpVectors(l,h,p),hD.lerpVectors(c,m,p),o.compose(dD,fD,hD)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(h,f,m)}}}function gD(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(!o)return;let a=t[r],l=s?typeof s=="string"?i.getColor(s).clone():new Ne().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Ne().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[r]=c,{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Gs(r,t,e,n){if(typeof t[r]=="number")return ls(r,t,e??{},n);if(Array.isArray(t[r]))return nS(r,t,e??{},n)}function yD(r,t,e){let n=[],i=r.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,s=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(s!==void 0){let o=i??r.zoom,a=s;o!==a&&n.push({update:l=>{r.zoom=He.lerp(o,a,l),r.updateProjectionMatrix()},start:()=>{r.zoom=o,r.updateProjectionMatrix()},end:()=>{r.zoom=a,r.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let o=ls("targetOffset",r,t,e);o&&n.push(o)}return n}function Yj(r,t,e,n){if(e.scaleBaked===void 0)return;let i=t.scaleBaked??r.data.geometry.scaleBaked,s=e.scaleBaked;if(Ms.isEqual(i,s))return;let o=[];return o.push({update:a=>{r.updateGeometryInteractions({scaleBaked:[He.lerp(i[0],s[0],a),He.lerp(i[1],s[1],a),He.lerp(i[2],s[2],a)]},n),r.invalidateDownstreamBooleanData()},start:()=>{r.updateGeometryInteractions({scaleBaked:i},n),r.invalidateDownstreamBooleanData()},end:()=>{r.updateGeometryInteractions({scaleBaked:s},n),r.invalidateDownstreamBooleanData()}}),o}function Qj(r,t,e){if(!e.extrusion)return;let n=r.extrusion,i=t.extrusion??{},s=e.extrusion,o=[];return $x.forEach(a=>{let l=Gs(a,n,i,s);l&&o.push(l)}),o}function vD(r,t,e,n){let i=[];if(!("geometry"in e))return i;let s=r.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(r instanceof rs){let l=Yj(r,o,a,n);l&&i.push(...l)}else{let l={};if(Object.assign(l,ia(s,eb)),eb.forEach(u=>{let c=Gs(u,l,o,a);c&&i.push(c)}),r instanceof Aa){Object.assign(l,{extrusion:{...s.extrusion}});let u=Qj(l,o,a);u&&i.push(...u)}i.length&&i.push({update:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()},start:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()},end:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()}})}return i}function xD(r,t,e,n){let i=[];if(e.intensity!==void 0){let s=ls("intensity",r,t,e);s&&i.push(s)}if(e.color!==void 0){let s=gD("color",r,t,e,n);s&&i.push(s)}return i}function wD(r,t,e,n){let i=[];if(Array.isArray(r.material)){if(!("materials"in e&&e.materials))return i;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;r.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||i.push(...bD(a,u,c,n))})}else{if(!("material"in e&&e.material))return i;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return i;i.push(...bD(r.material,s,o,n))}return i}function bD(r,t,e,n){let i=[],s=Cf(e,n)||!!t.layers&&Cf(t,n);i.push(i6(r,s));for(let o of r.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||!(o.visible??!0)||!(l.visible??!0))continue;let u=o.getNames().filter(c=>!hg.some(d=>c.includes(d)));for(let c of u)try{let d=o.getValue(c),h;if(c==="colors")h=n6(o,a,l,c);else if(Array.isArray(d))c==="steps"&&(h=t6(o,a,l,c));else if(typeof d=="number")h=Kj(o,a,l,c);else{if(typeof d=="boolean")continue;d instanceof F?h=Zj(o,a,l,c):d instanceof A?h=Jj(o,a,l,c):d instanceof $t?h=e6(o,a,l,c,n):d instanceof Ne?h=$j(o,a,l,c,n):"isTexture"in d&&(h=r6(o,a,l,c))}h&&(Array.isArray(h)?i.push(...h):i.push(h))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${c}`,d)}}return i}function Kj(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=t?t[n]:r.getValue(n),s=e[n];if(i!==s)return{update:o=>{r.setValue(n,He.lerp(i,s,o))},start:()=>{r.setValue(n,i)},end:()=>{r.setValue(n,s)}}}function Zj(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=r.getValue(n),s=t?new F().fromArray(t[n]):i.clone(),o=new F().fromArray(e[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function Jj(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=r.getValue(n),s=t?new A().fromArray(t[n]):i.clone(),o=new A().fromArray(e[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function $j(r,t,e,n,i){if(!r.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Ne().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Ne().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return{update:d=>{r.getValue(n)!==c&&r.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function e6(r,t,e,n,i){if(!r.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Ne().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new $t(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return{update:d=>{r.getValue(n)!==c&&r.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function t6(r,t,e,n="steps"){if(!r.hasValue(n)||!(n in e))return;let i=[],s=r.getValue(n),o=t?t[n]:s,a=e[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&i.push({update:d=>{s[l]=He.lerp(u,c,d)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return i.length?i:void 0}function n6(r,t,e,n="colors"){if(!r.hasValue(n)||!(n in e))return;let i=[],s=r.getValue(n),o=t?t[n]:s.map(l=>l.toArray()),a=e[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];qh.isEqual(u,c)||i.push({update:d=>{s[l].fromArray(qh.lerp(u,c,d))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return i.length?i:void 0}function r6(r,t,e,n="texture"){if(!r.hasValue(n)||!(n in e))return;let i=r.getNode("mat");if(!i)return;let s=t?t[n]:i,o=e[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!fl.isEqual(a,u)||!fl.isEqual(l,c))return{update:d=>{i.repeat=fl.lerp(a,u,d),i.offset=fl.lerp(l,c,d),i.updateMatrix()},start:()=>{i.repeat=[...a],i.offset=[...l],i.updateMatrix()},end:()=>{i.repeat=[...u],i.offset=[...c],i.updateMatrix()}}}function i6(r,t){return{update:()=>{r.transparent=t}}}var iS=new A,SD=new Wt;function AD(r,t,e,n){let i=[],s,o,a,l,u,c,d={slide:(t.pathSnapping??r.updatedPathSnapping??r.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??r.updatedPathSnapping??r.dataPatched.pathSnapping).offset};if(u=ls("slide",d,t.pathSnapping??r.updatedPathSnapping??r.dataPatched.pathSnapping,e.pathSnapping??r.dataPatched.pathSnapping),u&&i.push(u),c=ls("offset",d,t.pathSnapping??r.updatedPathSnapping??r.dataPatched.pathSnapping,e.pathSnapping??r.dataPatched.pathSnapping),c&&i.push(c),!u&&!c&&(s=rS("position",r,t,e),s&&i.push(s),o=rS("scale",r,t,e),o&&i.push(o),a=s6(r,t,e,n),a&&i.push(a),l=mD("hiddenMatrix",r,t,e),l&&i.push(l)),s||o||a||l||u||c){let h=()=>{r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r.parent?.matrixWorldFusedFalse&&(r.matrixWorld.multiplyMatrices(r.parent.matrixWorldFusedFalse,r.matrix),r.matrixWorldNeedsUpdate=!1),Zr(r)&&Gr(r.parent)&&r.invalidateDownstreamBooleanData(!0),r.updatePathSnapping(Object.assign({},t.pathSnapping,d))};i.push({update:h,start:h,end:h})}return i}function s6(r,t,e,n){let i=t?.rotation?t.rotation:void 0,s=e.rotation;if(!s)return;let o=i?new A().fromArray(i):new A().setFromEuler(r.rotation),a=new A().fromArray(s);if(o.equals(a))return;let l=iS.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new Je().setFromEuler(SD.setFromVector3(o)),c=new Je().setFromEuler(SD.setFromVector3(a));return{update:d=>{pD(u,c,r.quaternion,d)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}else return{update:u=>{iS.lerpVectors(o,a,u),r.rotation.setFromVector3(iS)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}function _D(r,t,e){let n=[];if(!("cloner"in e)||!r.cloner)return n;let i=r.cloner,s="cloner"in t?t.cloner:{},o=e.cloner;Wx.forEach(h=>{let f;h==="count"?f=ls("count",i.parameters,s,o,!0):f=Gs(h,i.parameters,s??{},o),f&&n.push(f)});let a=o6(i,s,o);a?.length&&n.push(...a);let l=a6(i,s,o);l?.length&&n.push(...l);let u=l6(i,s,o);u?.length&&n.push(...u);let c=c6(i,s,o);c?.length&&n.push(...c);let d=u6(i,s,o);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{i.update()}}),n}function o6(r,t,e){if(r.parameters.type!=="radial")return;let n=t.radial,i=e.radial;if(!i)return;let s=r.parameters.radial,o=[];return jx.forEach(a=>{let l=Gs(a,s,n??{},i);l&&o.push(l)}),o}function a6(r,t,e){if(r.parameters.type!=="linear")return;let n=t.linear,i=e.linear;if(!i)return;let s=[],o=r.parameters.linear;return qx.forEach(a=>{let l=Gs(a,o,n??{},i);l&&s.push(l)}),s}function l6(r,t,e){if(r.parameters.type!=="grid")return;let n=t.grid,i=e.grid;if(!i)return;let s=[],o=r.parameters.grid;return Xx.forEach(a=>{let l;a==="count"?l=nS(a,o,n??{},i,!0):l=Gs(a,o,n??{},i),l&&s.push(l)}),s}function c6(r,t,e){if(r.parameters.type!=="toObject")return;let n=t.toObject,i=e.toObject;if(!i)return;let s=[],o=r.parameters.toObject;return Yx.forEach(a=>{let l;a==="count"?l=ls(a,o,n??{},i,!0):l=Gs(a,o,n??{},i),l&&s.push(l)}),s}function u6(r,t,e){if(!r.parameters.randomness)return;let n=t.randomnessObject,i=e.randomnessObject;if(!i)return;let s=[],o=r.parameters.randomnessObject;return Qx.forEach(a=>{let l=Gs(a,o,n??{},i);l&&s.push(l)}),s}function sS(r,t,e,n,i){let s=[];return r.data.visible&&s.push(...AD(r,t,e,i)),r.data.visible&&s.push(..._D(r,t,e)),Zr(r)?(r instanceof tn&&r.data.visible&&s.push(...vD(r,t,e,n)),r.data.visible&&s.push(...wD(r,t,e,n))):r2(r)?r.data.visible&&s.push(...xD(r,t,e,n)):n2(r)&&s.push(...yD(r,t,e)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var MD=new A;function Fy(r,t,e,n=!1){let i=[];t.traverseObject(s=>{if(n&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(MD,!0),s.rigidBody?.setAngvel(MD,!0)),!St.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,!a.states)return;let l=!1;i.some(u=>r.objects.isDescendantOf(o,u))?l=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&i.push(o),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let u of a.states){let c={...u.data};r.environment.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||l)&&(u.data.position!==void 0&&delete c.position,u.data.rotation!==void 0&&delete c.rotation,u.data.hiddenMatrix!==void 0&&delete c.hiddenMatrix),s.states||(s.states={}),s.states[u.id]=xo.patch(a,c)}h6(t,s,null,e,a.events.find(u=>u.data.type==="Follow"||u.data.type==="LookAt")!==void 0),d6(t)})}function d6(r){r.traverseEntity(t=>{for(let e of t.data.events){let n=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":n.push(...e.data.actions);break;case"GameControl":for(let i of Object.values(e.data.gameActions))n.push(...i);break;case"DragDrop":n.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":n.push(...e.data.inActions,...e.data.outActions);break}for(let i of n)i.data.type==="Create"&&i.data.hideBase==="Yes"&&(r.find(i.data.object).visible=!1)}})}function h6(r,t,e,n,i=!1){if(t instanceof tn&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:r,shared:n},i),t instanceof tn&&t.updateGeometryGroupsIfNeeded(),t instanceof Yt&&t.updateCameraState(t.dataPatched,{scene:r,shared:n}),t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}function oS(r){let t;if(r.easing===5){let{control1:e,control2:n}=r;t=`cubicBezier(
5597
5597
  ${e[0]}, ${e[1]}, ${n[0]}, ${n[1]}
5598
- )`}else if(r.easing===6){let{mass:e,stiffness:n,damping:i,velocity:s}=r;t=`spring( ${e}, ${n}, ${i}, ${s} )`}else{let e;switch(r.easing){case 0:e=vo.linear;break;case 1:e=vo.ease;break;case 2:e=vo.easeIn;break;case 3:e=vo.easeOut;break;case 4:e=vo.easeInOut;break;default:e=vo.linear}let[n,i,s,o]=e;t=`cubicBezier( ${n}, ${i}, ${s}, ${o} )`}return{duration:r.duration,easing:t}}function ED(r){let t={delay:0,loop:r.repeat===-1?!0:r.repeat+1};if(r.repeat===0)t.direction="normal",t.rewind=!1;else switch(r.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,r.delayDirection){case"start-once":t.startOnceDelay=r.delay;break;case"start":t.delay=r.delay;break;case"end":t.endDelay=r.delay;break;case"start-end":case void 0:t.delay=r.delay,t.endDelay=r.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,r.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):r.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):r.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var f6={type:"beginState"},p6={type:"completeState",isfromEntity:!1},jy=class{constructor(t,e,n,i,s,o){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Yt&&e.dispatchEvent(f6)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Yt&&e.dispatchEvent(p6)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=sS(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=Wy(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=Wy(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=Wy(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...ED(i),...oS(i),change:this.onChange},this.callback=sS(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Io=class extends Ht{constructor(e,n,i){super();this.data=e;this.scene=n;this.sharedAssets=i;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let s=n.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=Wy(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:n=!1}={}){try{let i=ED(this.data.tweens[0].data),s=i.loop;n&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=Hy.timeline({autoplay:!1,...i,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),i.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Yt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new jy(this.object,d,c.data.state===void 0?this.currentState:c.data.state,c.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?i.delay:0)+(l===a&&!n?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Yt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new jy(this.object,d,c.data.state===void 0?this.currentState:c.data.state,u.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l-1]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?i.endDelay:0))}this.timeline.duration+=i.delay+(n?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Wy(r,t){let e,n;if(typeof t=="string"?(e=t,n=r.states?.[e]):t===null&&(e=null,n=r.data),!(e===void 0||n===void 0))return{id:e,data:n}}var m6={type:"beginState"},TD={type:"completeState",isfromEntity:!1},CD={type:"requestRender"},qf=class extends Ht{constructor(e,n){super();this.data=e;this.scene=n;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new Je;this.qEnd=new Je;this.zoomStart=1;this.zoomEnd=1;this.toCamera=n.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let n={t:0};this.posStart.copy(this.scene.activeCamera.position),this.qStart.copy(this.scene.activeCamera.quaternion),this.zoomStart=this.scene.activeCamera.zoom,this.animation=Hy({targets:n,t:1,...oS(this.data),update:()=>{n.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.scene.activeCamera,this.switchCamera(this.toCamera)),this.scene.activeCamera.dispatchEvent(m6));let i=this.scene.activeCamera;i.position.lerpVectors(this.posStart,this.posEnd,n.t),i.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),i.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,i.wasMovedBySwitchCameraAction=!0,i.updateMatrix(),i.updateMatrixWorld(),i.updateProjectionMatrix(),i.dispatchEvent(CD),n.t===1&&i.dispatchEvent(TD)}})}switchCamera(e){this.scene.switchActiveCamera(e),this.scene.activeCamera.dispatchEvent({type:"cameraChange",camera:e})}play(){this.playing||this.scene.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.scene.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.scene.activeCamera.dispatchEvent(TD),this.scene.activeCamera.dispatchEvent(CD))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function Qn(r,t,e,n,i,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[]};return t.forEach(({id:a,data:l})=>{try{l.type==="Audio"?yo[r.type].includes("Audio")&&o.Audio.push(new Co(a,l,s,n)):l.type==="Video"?yo[r.type].includes("Video")&&o.Video.push(new Fl(a,l,s)):l.type==="Link"?yo[r.type].includes("Link")&&o.Link.push(new Ny(l,i)):l.type==="Create"?yo[r.type].includes("Create")&&o.Create.push(new Po(l,e,i.controlsManager)):l.type==="Destroy"?yo[r.type].includes("Destroy")&&o.Destroy.push(new Wf(l,e,i)):l.type==="Reset"?yo[r.type].includes("Reset")&&o.Reset.push(new By(e.data,e,n,i)):l.type==="Transition"?yo[r.type].includes("Transition")&&o.Transition.push(new Io(l,e,n)):l.type==="SwitchCamera"&&yo[r.type].includes("SwitchCamera")&&o.SwitchCamera.push(new qf(l,e))}catch(u){!1&&console.log(u)}}),o}function An(r){Object.values(r).forEach(t=>{t.forEach(e=>{(e instanceof Co||e instanceof Fl||e instanceof Io||e instanceof Po||e instanceof Wf||e instanceof qf)&&e.dispose()})})}var aS=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],PD=r=>aS.find(([t,e])=>e===r)?.[0],Vs=r=>aS.find(([t])=>t===r)?.[1],g6=(r,t)=>{let e=PD(r);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},qy=class extends Bn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[PD(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(n)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{if(!!i.data?.events.length){for(let[s,o]of aS)if(i.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(i):this.objectsPerEvents.set(s,[i]);let a={id:i.uuid,name:i.name},l=g6(o,a),u=this.splineEvents[s];u?u[i.uuid]=l:this.splineEvents[s]={[i.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var lS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;if(this.useToggle=e.toggle,(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=Qn(e,e.actions,i,s,o,n)}disconnect(){An(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){let e=new Set;this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this?(n.object.currentTransitionEvent=this,n.init()):this.useToggle===!1&&e.add(n)}),this.useToggle?(this.actions.Transition.forEach(n=>{n.toggle()}),this.actions.SwitchCamera.forEach(n=>{n.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(n=>n.playFromCurrent()),this.actions.SwitchCamera.forEach(n=>n.playFromCurrent()),this.actions.Create.forEach(n=>n.dispatchStart())):(this.actions.Transition.some(s=>s.playing)||this.actions.Transition.forEach(s=>{e.has(s)===!1&&s.play()}),this.actions.SwitchCamera.some(s=>s.playing)||this.actions.SwitchCamera.forEach(s=>{s.play()})),this.actions.Link.forEach(n=>{n.dispatch()}),t===!1&&this.actions.Create.forEach(n=>{n.dispatch()}),this.actions.Destroy.forEach(n=>{n.dispatch()}),this.actions.Reset.forEach(n=>{n.dispatch()}),this.actions.Audio.forEach(n=>{n.dispatchBasic()}),this.actions.Video.forEach(n=>{n.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}},Xy=class extends Bn{constructor(e,n){super(e);this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.windowMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.onWindowMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})};this.onWindowMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!o.data?.events.length)return;let a=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let l of a){let u=this.eventsPerObjects[l];o.data.events.filter(({data:c})=>c.type===l&&c.disabled!==!0).forEach(({id:c,data:d})=>{try{let h=new lS(c,d,o,i,s,n);h.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?d.mode==="Canvas"&&this.canvasMouseEvents.push(h):u[o.uuid]?u[o.uuid].push(h):u[o.uuid]=[h]}catch(h){!1&&console.log(h)}}),u[o.uuid]?.length&&this.objectsPerTypes[l].push(o)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(n=>{Object.values(n).forEach(i=>{i.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:i,scene:s}=this.eventContext,o=this.objectsPerTypes[e];if(!!o.length)if(n){let a=zf(i,s,o);Gf(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}else o.forEach(a=>{Dd(i,a)&&this.handleObjectMouseEventDispatch(a,e)})}handleMousePressEvent(e=!1){let n="MousePress",i=this.objectsPerTypes[n],s=[];if(!!i.length){if(!e){let{stopRaycast:o,raycaster:a,scene:l}=this.eventContext;if(o){let u=zf(a,l,i);s=Gf(u)}else i.forEach(u=>{Dd(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,n,i=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,i=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}};var y6=new A,v6=new A;var Yy=class{constructor(t,e,n,i,s){this.actionsIn=Qn(t,t.inActions,n,i,s,e),this.actionsOut=Qn(t,t.outActions,n,i,s,e)}disconnect(){An(this.actionsIn),An(this.actionsOut)}};var cS=class extends Yy{constructor(e,n,i,s,o,a){super(n,i,s,o,a);this.id=e;this.data=n;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{let e=y6.setFromMatrixPosition(this.objects[0].matrixWorld),n=v6.setFromMatrixPosition(this.objects[1].matrixWorld),i=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==i){let s=i==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),this.stage=i}};let{distance:l,fromObject:u,toObject:c}=n.condition;this.distance=l;for(let d of[u,c]){if(!d)throw new Error("Missing property");let h=s.find(d);if(!h)throw new Error("Missing property");this.objects.push(h)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},uS=class extends Yy{constructor(e,n,i,s,o,a){super(n,i,s,o,a);this.id=e;this.data=n;this.object=i;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Create.forEach(i=>i.dispatch()),this.actionsOut.Destroy.forEach(i=>i.dispatch()),this.actionsOut.Reset.forEach(i=>i.dispatch()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(i=>i.play()),this.actionsIn.SwitchCamera.forEach(i=>i.pause()),this.actionsOut.SwitchCamera.forEach(i=>i.play()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Create.forEach(i=>i.dispatch()),this.actionsIn.Destroy.forEach(i=>i.dispatch()),this.actionsIn.Reset.forEach(i=>i.dispatch()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(i=>i.play()),this.actionsOut.SwitchCamera.forEach(i=>i.pause()),this.actionsIn.SwitchCamera.forEach(i=>i.play()))};let{condition:l}=n;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.SwitchCamera.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.SwitchCamera.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.SwitchCamera.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.SwitchCamera.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Qy=class extends Bn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new cS(a,l,o,i,s,n):l.condition.type==="State"&&(u=new uS(a,l,o,i,s,n))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var Xf=new A,Ma=new A,Ul=new A,DD=new yn,x6=.01,Ot=new A,Kn=new A,ID=new A,kl=new Je,dS=new Wt,b6=new ae,hS=new Kt,Rd=new A,Hs=new A,Ld=.2;function fS(r,t){!t||(t[0]<t[1]&&(r.x=Math.min(Math.max(r.x,t[0]),t[1])),t[2]<t[3]&&(r.y=Math.min(Math.max(r.y,t[2]),t[3])),t[4]<t[5]&&(r.z=Math.min(Math.max(r.z,t[4]),t[5])))}var w6=function(){let r=new ae;return(t,e,n)=>{let i=t.obj;r.copy(i.hiddenMatrix),i.parent!==null&&r.premultiply(i.parent.matrixWorld),r.invert(),i.position.copy(e),t.reference==="global"&&fS(i.position,t.limits),i.position.applyMatrix4(r),t.reference==="parent"?fS(i.position,t.limits):t.reference==="local"&&(kl.copy(t.quat0).invert(),i.position.sub(t.position0),i.position.applyQuaternion(kl),fS(i.position,t.limits),kl.invert(),i.position.applyQuaternion(kl),i.position.add(t.position0)),r.multiply(n??i.matrixWorld).decompose(Ot,i.quaternion,Kn),i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i instanceof kt&&Gr(i.parent)&&i.invalidateDownstreamBooleanData(!0)}}(),pS=class{constructor(t,e,n,i,s,o){this.object=t;this.data=e;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Qn(e,e.dragDropActions.drag,n,i,s,this.object),this.actionsDrop=Qn(e,e.dragDropActions.drop,n,i,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.dataPatched.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.dataPatched.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.dataPatched.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.dataPatched.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new Je().copy(l.quaternion),snapped:!1,orientationMatrix:new ae,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){An(this.actionsDrag),An(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Ky=class extends Bn{constructor(e,n){super(e);this.managers=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,scene:i}=this.eventContext,s=i.raycastWithClones(n);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||St.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.managers.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Ot,kl,Kn),dS.setFromQuaternion(kl),d.prevR===void 0?(d.prevR=dS.clone(),d.prevT=Ot.clone()):(d.prevR.copy(dS),d.prevT.copy(Ot)),this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.managers.controlsManager.usePhysics&&l.dataPatched.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,scene:i}=this.eventContext,s=i.raycastWithClones(n);if(ke.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||St.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof Eo)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||i.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=ID.copy(a.face.normal).applyMatrix3(hS.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ot.copy(l).applyMatrix3(hS.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Ot.x>Ld?Kn.x=-u.recursiveBBox.min.x:Ot.x<-Ld&&(Kn.x=-u.recursiveBBox.max.x),Ot.y>Ld?Kn.y=-u.recursiveBBox.min.y:Ot.y<-Ld&&(Kn.y=-u.recursiveBBox.max.y),Ot.z>Ld?Kn.z=-u.recursiveBBox.min.z:Ot.z<-Ld&&(Kn.z=-u.recursiveBBox.max.z),Kn.applyMatrix3(hS.invert())}else Kn.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Kn)}this.activeEvent.data.autoOrient&&(Ot.set(0,1,0).cross(l),Ot.length()<1e-4&&Ot.set(-1,0,0).cross(l),Kn.crossVectors(ID,Ot),o.orientationMatrix.makeBasis(Ot,Kn,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=this.activeEvent.activeDragItem.obj.dataPatched.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.managers.controlsManager.usePhysics===!1||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.managers.controlsManager.usePhysics&&n&&(this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(i=>{i.stop(),i.object.currentState!==null&&i.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Audio.forEach(i=>{i.dispatchGameControl("stop")})),this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!0)}};let i={};e.scene.traverseEntity(s=>{s.component&&(i[s.component.uuid]?i[s.component.uuid].push(s.uuid):i[s.component.uuid]=[s.uuid])}),e.scene.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new pS(s,o.data,e.scene,e.sharedAssets,n,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,i,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(Ma),Ma.negate();let l=kl.identity();switch(s==="parent"?b6.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ot,l,Kn):s==="local"&&e.matrixWorld.decompose(Ot,l,Kn),i){case"x":Ot.set(1,0,0).applyQuaternion(l),Rd.copy(Ma).cross(Ot),Hs.copy(Ot).cross(Rd);break;case"y":Ot.set(0,1,0).applyQuaternion(l),Rd.copy(Ma).cross(Ot),Hs.copy(Ot).cross(Rd);break;case"z":Ot.set(0,0,1).applyQuaternion(l),Rd.copy(Ma).cross(Ot),Hs.copy(Ot).cross(Rd);break;case"xy":Hs.set(0,0,1).applyQuaternion(l);break;case"yz":Hs.set(1,0,0).applyQuaternion(l);break;case"xz":Hs.set(0,1,0).applyQuaternion(l);break;case"adaptive":Ma.angleTo(Kn.set(0,1,0))>Math.PI/6?(Ot.crossVectors(Kn.set(0,1,0),Ma),Hs.crossVectors(Ot,Kn)):Hs.set(0,1,0);break;default:Hs.copy(Ma);break}Ul.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:Ul;if(DD.setFromNormalAndCoplanarPoint(Hs,u),!!a.ray.intersectPlane(DD,n)&&(i==="x"||i==="y"||i==="z")){let c=Kn.subVectors(n,u).dot(Ot);n.copy(u).addScaledVector(Ot,c)}}updateDragItem(e,n=!1){Ul.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Xf.subVectors(e.fromPosition,Ul).divideScalar(e.currentDampingFactor):e.reset==="original"?(Xf.subVectors(e.obj.userData.worldPosition0,Ul).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Xf.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Ul).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Xf.length()<x6:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&w6(e,Xf.add(Ul),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.managers.eventManager.requestRender()}};var Nd=new A,mS=new A,Oo=new A,Ro=new A,OD=new yn,S6=.01,A6={type:"requestRender"},_6=function(){let r=new A,t=new A;return(e,n,i)=>i>0?(r.subVectors(e,n),r.length()<=i?e:t.copy(n).add(r.normalize().multiplyScalar(i))):n}(),RD=function(){let r=new ae;return(t,e)=>{t.position.copy(e),t.parent!==null&&(r.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(r)),r.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(r),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof kt&&Gr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),gS=class{constructor(t,e,n,i,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...sg.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(t.target==="personal camera"?this.target=n.find(bn.PERSONAL_CAMERA_ID):this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Qn(t,t.actions,n,i,s,e)}},Zy=class extends Bn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{scene:i}=this.eventContext;i.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!i.data.environment.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new gS(o.data,s,i,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let s=i.target,o=this.onTargetChange(i);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let i of this.events)i.paused=!0,i.isReset=!1,An(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:i,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Oo),e.isReset)Ro.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Ro);else{let{getCamera:l,raycaster:u}=this.eventContext;if(i==="custom"?(l().getWorldDirection(mS),mS.negate(),Nd.copy(mS)):i==="xy"?Nd.set(0,0,1):i==="xz"?Nd.set(0,1,0):i==="yz"&&Nd.set(1,0,0),OD.setFromNormalAndCoplanarPoint(Nd,Oo),!u.ray.intersectPlane(OD,Ro))return}if(!e.isReset){if(Ro.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Ro.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(Ro.x=Oo.x),e.data.enabledTranslation[1]===!1&&(Ro.y=Oo.y),e.data.enabledTranslation[2]===!1&&(Ro.z=Oo.z);let a=_6(Oo,Ro,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Nd.subVectors(a,Oo).divideScalar(e.currentDampingFactor);Oo.add(l),n&&RD(e.object,Oo),e.paused=l.length()<S6}else RD(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(A6)}};var Yf=new A,Jy=new A,Qf=new ae,Bd=new Je,Ea=new Je,Kf=new A,Zf=new A,zl=new A,Lo=new A,yS=new yn,M6=1e-6,E6={type:"requestRender"},T6={type:"changeRotation"},ND=function(){let r=new ae;return function(e,n){e.parent!==null?r.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):r.copy(e.hiddenMatrix),n.premultiply(Gw(r).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof kt&&Gr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),vS=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Je;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...og.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(t.target==="personal camera"?this.target=n.find(bn.PERSONAL_CAMERA_ID):this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},$y=class extends Bn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:i})=>{if(!n||!i)return;let s=Vs(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new vS(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let a=this.onTargetChange(i),l=i.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(i),o=i.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let[i,s]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",s);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:i,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:d}=this.eventContext,{object:h,target:f}=e;if(h.getWorldPosition(Kf),!e.isReset)if(e.target)e.target.getWorldPosition(Zf);else{if(o==="custom"?(c().getWorldDirection(Jy),Jy.negate(),yS.setFromNormalAndCoplanarPoint(Jy,Kf)):(o==="xy"?Yf.set(0,0,1):o==="xz"?Yf.set(0,1,0):o==="yz"&&Yf.set(1,0,0),yS.setFromNormalAndCoplanarPoint(Yf,Kf)),!d.ray.intersectPlane(yS,Zf))return;s>0&&(o==="custom"||o===void 0)&&Zf.addScaledVector(Jy,s)}if(e.isReset||(f?n==="target"?zl.copy(f.up).applyMatrix4(Qf.extractRotation(f.matrixWorld)).normalize():l.some(m=>m===!1)?(i==="x"?(Lo.set(0,0,1),l[2]===!1&&Lo.set(0,1,0)):i==="y"?(Lo.set(1,0,0),l[0]===!1&&Lo.set(0,0,1)):(Lo.set(0,1,0),l[1]===!1&&Lo.set(1,0,0)),zl.copy(Lo).applyQuaternion(e.worldQuaternion0).normalize()):zl.set(0,1,0):o==="custom"?zl.set(0,1,0):zl.copy(Yf)),e.isReset)Ea.copy(e.worldQuaternion0);else if(Kf.distanceTo(Zf)>a&&u&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Ea.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;C6(Qf,Zf,Kf,zl,i,Lo),Ea.setFromRotationMatrix(Qf),Bd.setFromUnitVectors(Lo.applyQuaternion(Ea),zl),l.some(m=>m===!1)&&n!=="target"&&Ea.premultiply(Bd).normalize()}e.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),Bd.setFromRotationMatrix(Gw(h.matrixWorld)),Bd.slerp(Ea,1/e.currentDampingFactor),ND(h,Qf.makeRotationFromQuaternion(Bd)),e.paused=8*(1-Bd.dot(Ea))<M6):(ND(h,Qf.makeRotationFromQuaternion(Ea)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(E6),h.dispatchEvent(T6)}},Ii=new A,Zn=new A,_n=new A;function C6(r,t,e,n,i,s){let o=r.elements;_n.subVectors(t,e),_n.lengthSq()===0&&(_n.z=1),_n.normalize(),Zn.crossVectors(n,_n),Zn.lengthSq()===0&&(Math.abs(n.z)===1?_n.x+=1e-4:_n.z+=1e-4,_n.normalize(),Zn.crossVectors(n,_n)),Zn.normalize(),Ii.crossVectors(_n,Zn),i==="x"?s.z===1?[Zn,Ii,_n]=[_n,Zn,Ii]:(Zn.negate(),[Zn,_n]=[_n,Zn]):i==="y"?s.x===1?[Zn,Ii,_n]=[Ii,_n,Zn]:(Zn.negate(),[Ii,_n]=[_n,Ii]):s.x===1&&(Zn.negate(),[Zn,Ii]=[Ii,Zn]),o[0]=Zn.x,o[4]=Ii.x,o[8]=_n.x,o[1]=Zn.y,o[5]=Ii.y,o[9]=_n.y,o[2]=Zn.z,o[6]=Ii.z,o[10]=_n.z}var xS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=Qn(e,e.actions,i,s,o,n)}disconnect(){An(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()))}},ev=class extends Bn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{ke.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(i)))};let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new xS(a,l,o,i,s,n);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),jn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),jn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(i=>{i.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:i,raycaster:s,scene:o}=this.eventContext;if(i){let a=zf(s,o,this.objects);n=Gf(a)}else this.objects.forEach(a=>{Dd(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{n.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var bS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=Qn(e,e.actions,i,s,o,n)}connect(){this.scrollCounter=0}disconnect(){An(this.actions)}dispatch(t){this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(n)),this.actions.Create.forEach(i=>i.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?this.actions.Transition.forEach(e=>e.reverseFromCurrent()):this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Create.forEach(e=>e.dispatchThrottled())}},wS=class{constructor(t,e,n,i,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.managers=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Qn(e,e.actions,i,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,i=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+i-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){An(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let n=this.scrollEnd-this.scrollStart,i=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(i)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?this.actions.Transition.forEach(e=>e.reverseFromCurrent()):this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Create.forEach(e=>e.dispatchThrottled())}},tv=class extends Bn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([i,s])=>{i.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,i])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),i.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:i,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;i.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let d=new bS(u,c,l,i,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(d):this.wheelEventsPerObject.set(l,[d])}else{let d=new wS(u,c,l,i,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(d):this.scrollEventsPerObject.set(l,[d])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var SS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qn(e,e.actions,i,s,o,n)}disconnect(){An(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof To?e.interaction.audioPlayer.play():e.interaction instanceof Id&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof _a?e.interaction.play(n==="autoplay"):e.interaction instanceof Od&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof To?e.interaction.audioPlayer.play():e.interaction instanceof Id&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof _a?e.interaction.play():e.interaction instanceof Od&&e.interaction.dispatch()})}},nv=class extends Bn{constructor(e,n){super(e);this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!!o.data?.events.length)for(let{id:a,data:l}of o.data.events){if(l.disabled||l.type!=="Start")continue;let u=new SS(a,l,o,i,s,n);(u.actions.Transition.length||u.actions.SwitchCamera.length||u.actions.Create.length||u.actions.Destroy.length)&&(this.eventsPerObject.has(o)?this.eventsPerObject.get(o)?.push(u):this.eventsPerObject.set(o,[u])),u.actions.Audio.length&&(this.eventsAfterPerObject.has(o)?this.eventsAfterPerObject.get(o)?.push(u):this.eventsAfterPerObject.set(o,[u])),u.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(o)?this.eventsAfterPerObject.get(o)?.push(u):this.eventsAfterPerObject.set(o,[u]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,i=n?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>i.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,i=n?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(i=>i.disconnect())})}};var rv=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!0;this.actions=Qn(e,e.actions,i,s,o,n),this.target=e.target,this.useToggle=e.toggle}disconnect(){An(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var FD=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.381/build/",P6=!1?FD:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.381/build/",D6=`
5598
+ )`}else if(r.easing===6){let{mass:e,stiffness:n,damping:i,velocity:s}=r;t=`spring( ${e}, ${n}, ${i}, ${s} )`}else{let e;switch(r.easing){case 0:e=vo.linear;break;case 1:e=vo.ease;break;case 2:e=vo.easeIn;break;case 3:e=vo.easeOut;break;case 4:e=vo.easeInOut;break;default:e=vo.linear}let[n,i,s,o]=e;t=`cubicBezier( ${n}, ${i}, ${s}, ${o} )`}return{duration:r.duration,easing:t}}function ED(r){let t={delay:0,loop:r.repeat===-1?!0:r.repeat+1};if(r.repeat===0)t.direction="normal",t.rewind=!1;else switch(r.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,r.delayDirection){case"start-once":t.startOnceDelay=r.delay;break;case"start":t.delay=r.delay;break;case"end":t.endDelay=r.delay;break;case"start-end":case void 0:t.delay=r.delay,t.endDelay=r.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,r.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):r.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):r.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var f6={type:"beginState"},p6={type:"completeState",isfromEntity:!1},jy=class{constructor(t,e,n,i,s,o){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Yt&&e.dispatchEvent(f6)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Yt&&e.dispatchEvent(p6)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=sS(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=Wy(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=Wy(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=Wy(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...ED(i),...oS(i),change:this.onChange},this.callback=sS(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Io=class extends Ht{constructor(e,n,i){super();this.data=e;this.scene=n;this.sharedAssets=i;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let s=n.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=Wy(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:n=!1}={}){try{let i=ED(this.data.tweens[0].data),s=i.loop;n&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=Hy.timeline({autoplay:!1,...i,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),i.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Yt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new jy(this.object,d,c.data.state===void 0?this.currentState:c.data.state,c.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?i.delay:0)+(l===a&&!n?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Yt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new jy(this.object,d,c.data.state===void 0?this.currentState:c.data.state,u.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l-1]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?i.endDelay:0))}this.timeline.duration+=i.delay+(n?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Wy(r,t){let e,n;if(typeof t=="string"?(e=t,n=r.states?.[e]):t===null&&(e=null,n=r.data),!(e===void 0||n===void 0))return{id:e,data:n}}var m6={type:"beginState"},TD={type:"completeState",isfromEntity:!1},CD={type:"requestRender"},qf=class extends Ht{constructor(e,n){super();this.data=e;this.scene=n;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new Je;this.qEnd=new Je;this.zoomStart=1;this.zoomEnd=1;this.toCamera=n.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let n={t:0};this.posStart.copy(this.scene.activeCamera.position),this.qStart.copy(this.scene.activeCamera.quaternion),this.zoomStart=this.scene.activeCamera.zoom,this.animation=Hy({targets:n,t:1,...oS(this.data),update:()=>{n.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.scene.activeCamera,this.switchCamera(this.toCamera)),this.scene.activeCamera.dispatchEvent(m6));let i=this.scene.activeCamera;i.position.lerpVectors(this.posStart,this.posEnd,n.t),i.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),i.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,i.wasMovedBySwitchCameraAction=!0,i.updateMatrix(),i.updateMatrixWorld(),i.updateProjectionMatrix(),i.dispatchEvent(CD),n.t===1&&i.dispatchEvent(TD)}})}switchCamera(e){this.scene.switchActiveCamera(e),this.scene.activeCamera.dispatchEvent({type:"cameraChange",camera:e})}play(){this.playing||this.scene.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.scene.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.scene.activeCamera.dispatchEvent(TD),this.scene.activeCamera.dispatchEvent(CD))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function Qn(r,t,e,n,i,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[]};return t.forEach(({id:a,data:l})=>{try{l.type==="Audio"?yo[r.type].includes("Audio")&&o.Audio.push(new Co(a,l,s,n)):l.type==="Video"?yo[r.type].includes("Video")&&o.Video.push(new Fl(a,l,s)):l.type==="Link"?yo[r.type].includes("Link")&&o.Link.push(new Ny(l,i)):l.type==="Create"?yo[r.type].includes("Create")&&o.Create.push(new Po(l,e,i.controlsManager)):l.type==="Destroy"?yo[r.type].includes("Destroy")&&o.Destroy.push(new Wf(l,e,i)):l.type==="Reset"?yo[r.type].includes("Reset")&&o.Reset.push(new By(e.data,e,n,i)):l.type==="Transition"?yo[r.type].includes("Transition")&&o.Transition.push(new Io(l,e,n)):l.type==="SwitchCamera"&&yo[r.type].includes("SwitchCamera")&&o.SwitchCamera.push(new qf(l,e))}catch(u){!1&&console.log(u)}}),o}function An(r){Object.values(r).forEach(t=>{t.forEach(e=>{(e instanceof Co||e instanceof Fl||e instanceof Io||e instanceof Po||e instanceof Wf||e instanceof qf)&&e.dispose()})})}var aS=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],PD=r=>aS.find(([t,e])=>e===r)?.[0],Vs=r=>aS.find(([t])=>t===r)?.[1],g6=(r,t)=>{let e=PD(r);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},qy=class extends Bn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[PD(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(n)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{if(!!i.data?.events.length){for(let[s,o]of aS)if(i.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(i):this.objectsPerEvents.set(s,[i]);let a={id:i.uuid,name:i.name},l=g6(o,a),u=this.splineEvents[s];u?u[i.uuid]=l:this.splineEvents[s]={[i.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var lS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;if(this.useToggle=e.toggle,(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=Qn(e,e.actions,i,s,o,n)}disconnect(){An(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){let e=new Set;this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this?(n.object.currentTransitionEvent=this,n.init()):this.useToggle===!1&&e.add(n)}),this.useToggle?(this.actions.Transition.forEach(n=>{n.toggle()}),this.actions.SwitchCamera.forEach(n=>{n.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(n=>n.playFromCurrent()),this.actions.SwitchCamera.forEach(n=>n.playFromCurrent()),this.actions.Create.forEach(n=>n.dispatchStart())):(this.actions.Transition.some(s=>s.playing)||this.actions.Transition.forEach(s=>{e.has(s)===!1&&s.play()}),this.actions.SwitchCamera.some(s=>s.playing)||this.actions.SwitchCamera.forEach(s=>{s.play()})),this.actions.Link.forEach(n=>{n.dispatch()}),t===!1&&this.actions.Create.forEach(n=>{n.dispatch()}),this.actions.Destroy.forEach(n=>{n.dispatch()}),this.actions.Reset.forEach(n=>{n.dispatch()}),this.actions.Audio.forEach(n=>{n.dispatchBasic()}),this.actions.Video.forEach(n=>{n.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}},Xy=class extends Bn{constructor(e,n){super(e);this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.windowMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.onWindowMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})};this.onWindowMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!o.data?.events.length)return;let a=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let l of a){let u=this.eventsPerObjects[l];o.data.events.filter(({data:c})=>c.type===l&&c.disabled!==!0).forEach(({id:c,data:d})=>{try{let h=new lS(c,d,o,i,s,n);h.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?d.mode==="Canvas"&&this.canvasMouseEvents.push(h):u[o.uuid]?u[o.uuid].push(h):u[o.uuid]=[h]}catch(h){!1&&console.log(h)}}),u[o.uuid]?.length&&this.objectsPerTypes[l].push(o)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(n=>{Object.values(n).forEach(i=>{i.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:i,scene:s}=this.eventContext,o=this.objectsPerTypes[e];if(!!o.length)if(n){let a=zf(i,s,o);Gf(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}else o.forEach(a=>{Dd(i,a)&&this.handleObjectMouseEventDispatch(a,e)})}handleMousePressEvent(e=!1){let n="MousePress",i=this.objectsPerTypes[n],s=[];if(!!i.length){if(!e){let{stopRaycast:o,raycaster:a,scene:l}=this.eventContext;if(o){let u=zf(a,l,i);s=Gf(u)}else i.forEach(u=>{Dd(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,n,i=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,i=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}};var y6=new A,v6=new A;var Yy=class{constructor(t,e,n,i,s){this.actionsIn=Qn(t,t.inActions,n,i,s,e),this.actionsOut=Qn(t,t.outActions,n,i,s,e)}disconnect(){An(this.actionsIn),An(this.actionsOut)}};var cS=class extends Yy{constructor(e,n,i,s,o,a){super(n,i,s,o,a);this.id=e;this.data=n;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{let e=y6.setFromMatrixPosition(this.objects[0].matrixWorld),n=v6.setFromMatrixPosition(this.objects[1].matrixWorld),i=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==i){let s=i==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),this.stage=i}};let{distance:l,fromObject:u,toObject:c}=n.condition;this.distance=l;for(let d of[u,c]){if(!d)throw new Error("Missing property");let h=s.find(d);if(!h)throw new Error("Missing property");this.objects.push(h)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},uS=class extends Yy{constructor(e,n,i,s,o,a){super(n,i,s,o,a);this.id=e;this.data=n;this.object=i;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Create.forEach(i=>i.dispatch()),this.actionsOut.Destroy.forEach(i=>i.dispatch()),this.actionsOut.Reset.forEach(i=>i.dispatch()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(i=>i.play()),this.actionsIn.SwitchCamera.forEach(i=>i.pause()),this.actionsOut.SwitchCamera.forEach(i=>i.play()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Create.forEach(i=>i.dispatch()),this.actionsIn.Destroy.forEach(i=>i.dispatch()),this.actionsIn.Reset.forEach(i=>i.dispatch()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(i=>i.play()),this.actionsOut.SwitchCamera.forEach(i=>i.pause()),this.actionsIn.SwitchCamera.forEach(i=>i.play()))};let{condition:l}=n;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.SwitchCamera.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.SwitchCamera.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.SwitchCamera.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.SwitchCamera.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Qy=class extends Bn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new cS(a,l,o,i,s,n):l.condition.type==="State"&&(u=new uS(a,l,o,i,s,n))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var Xf=new A,Ma=new A,Ul=new A,DD=new yn,x6=.01,Ot=new A,Kn=new A,ID=new A,kl=new Je,dS=new Wt,b6=new ae,hS=new Kt,Rd=new A,Hs=new A,Ld=.2;function fS(r,t){!t||(t[0]<t[1]&&(r.x=Math.min(Math.max(r.x,t[0]),t[1])),t[2]<t[3]&&(r.y=Math.min(Math.max(r.y,t[2]),t[3])),t[4]<t[5]&&(r.z=Math.min(Math.max(r.z,t[4]),t[5])))}var w6=function(){let r=new ae;return(t,e,n)=>{let i=t.obj;r.copy(i.hiddenMatrix),i.parent!==null&&r.premultiply(i.parent.matrixWorld),r.invert(),i.position.copy(e),t.reference==="global"&&fS(i.position,t.limits),i.position.applyMatrix4(r),t.reference==="parent"?fS(i.position,t.limits):t.reference==="local"&&(kl.copy(t.quat0).invert(),i.position.sub(t.position0),i.position.applyQuaternion(kl),fS(i.position,t.limits),kl.invert(),i.position.applyQuaternion(kl),i.position.add(t.position0)),r.multiply(n??i.matrixWorld).decompose(Ot,i.quaternion,Kn),i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i instanceof kt&&Gr(i.parent)&&i.invalidateDownstreamBooleanData(!0)}}(),pS=class{constructor(t,e,n,i,s,o){this.object=t;this.data=e;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Qn(e,e.dragDropActions.drag,n,i,s,this.object),this.actionsDrop=Qn(e,e.dragDropActions.drop,n,i,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.dataPatched.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.dataPatched.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.dataPatched.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.dataPatched.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new Je().copy(l.quaternion),snapped:!1,orientationMatrix:new ae,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){An(this.actionsDrag),An(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Ky=class extends Bn{constructor(e,n){super(e);this.managers=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,scene:i}=this.eventContext,s=i.raycastWithClones(n);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||St.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.managers.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Ot,kl,Kn),dS.setFromQuaternion(kl),d.prevR===void 0?(d.prevR=dS.clone(),d.prevT=Ot.clone()):(d.prevR.copy(dS),d.prevT.copy(Ot)),this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.managers.controlsManager.usePhysics&&l.dataPatched.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,scene:i}=this.eventContext,s=i.raycastWithClones(n);if(ke.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||St.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof Eo)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||i.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=ID.copy(a.face.normal).applyMatrix3(hS.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ot.copy(l).applyMatrix3(hS.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Ot.x>Ld?Kn.x=-u.recursiveBBox.min.x:Ot.x<-Ld&&(Kn.x=-u.recursiveBBox.max.x),Ot.y>Ld?Kn.y=-u.recursiveBBox.min.y:Ot.y<-Ld&&(Kn.y=-u.recursiveBBox.max.y),Ot.z>Ld?Kn.z=-u.recursiveBBox.min.z:Ot.z<-Ld&&(Kn.z=-u.recursiveBBox.max.z),Kn.applyMatrix3(hS.invert())}else Kn.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Kn)}this.activeEvent.data.autoOrient&&(Ot.set(0,1,0).cross(l),Ot.length()<1e-4&&Ot.set(-1,0,0).cross(l),Kn.crossVectors(ID,Ot),o.orientationMatrix.makeBasis(Ot,Kn,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=this.activeEvent.activeDragItem.obj.dataPatched.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.managers.controlsManager.usePhysics===!1||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.managers.controlsManager.usePhysics&&n&&(this.managers.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(i=>{i.stop(),i.object.currentState!==null&&i.object.changeSelectedState(null,{scene:this.eventContext.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Audio.forEach(i=>{i.dispatchGameControl("stop")})),this.managers.controlsManager.orbitControls&&(this.managers.controlsManager.orbitControls.enabled=!0)}};let i={};e.scene.traverseEntity(s=>{s.component&&(i[s.component.uuid]?i[s.component.uuid].push(s.uuid):i[s.component.uuid]=[s.uuid])}),e.scene.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new pS(s,o.data,e.scene,e.sharedAssets,n,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,i,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(Ma),Ma.negate();let l=kl.identity();switch(s==="parent"?b6.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ot,l,Kn):s==="local"&&e.matrixWorld.decompose(Ot,l,Kn),i){case"x":Ot.set(1,0,0).applyQuaternion(l),Rd.copy(Ma).cross(Ot),Hs.copy(Ot).cross(Rd);break;case"y":Ot.set(0,1,0).applyQuaternion(l),Rd.copy(Ma).cross(Ot),Hs.copy(Ot).cross(Rd);break;case"z":Ot.set(0,0,1).applyQuaternion(l),Rd.copy(Ma).cross(Ot),Hs.copy(Ot).cross(Rd);break;case"xy":Hs.set(0,0,1).applyQuaternion(l);break;case"yz":Hs.set(1,0,0).applyQuaternion(l);break;case"xz":Hs.set(0,1,0).applyQuaternion(l);break;case"adaptive":Ma.angleTo(Kn.set(0,1,0))>Math.PI/6?(Ot.crossVectors(Kn.set(0,1,0),Ma),Hs.crossVectors(Ot,Kn)):Hs.set(0,1,0);break;default:Hs.copy(Ma);break}Ul.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:Ul;if(DD.setFromNormalAndCoplanarPoint(Hs,u),!!a.ray.intersectPlane(DD,n)&&(i==="x"||i==="y"||i==="z")){let c=Kn.subVectors(n,u).dot(Ot);n.copy(u).addScaledVector(Ot,c)}}updateDragItem(e,n=!1){Ul.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Xf.subVectors(e.fromPosition,Ul).divideScalar(e.currentDampingFactor):e.reset==="original"?(Xf.subVectors(e.obj.userData.worldPosition0,Ul).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Xf.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Ul).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Xf.length()<x6:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&w6(e,Xf.add(Ul),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.managers.eventManager.requestRender()}};var Nd=new A,mS=new A,Oo=new A,Ro=new A,OD=new yn,S6=.01,A6={type:"requestRender"},_6=function(){let r=new A,t=new A;return(e,n,i)=>i>0?(r.subVectors(e,n),r.length()<=i?e:t.copy(n).add(r.normalize().multiplyScalar(i))):n}(),RD=function(){let r=new ae;return(t,e)=>{t.position.copy(e),t.parent!==null&&(r.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(r)),r.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(r),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof kt&&Gr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),gS=class{constructor(t,e,n,i,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...sg.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(t.target==="personal camera"?this.target=n.find(bn.PERSONAL_CAMERA_ID):this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Qn(t,t.actions,n,i,s,e)}},Zy=class extends Bn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{scene:i}=this.eventContext;i.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!i.data.environment.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new gS(o.data,s,i,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let s=i.target,o=this.onTargetChange(i);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let i of this.events)i.paused=!0,i.isReset=!1,An(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:i,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Oo),e.isReset)Ro.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Ro);else{let{getCamera:l,raycaster:u}=this.eventContext;if(i==="custom"?(l().getWorldDirection(mS),mS.negate(),Nd.copy(mS)):i==="xy"?Nd.set(0,0,1):i==="xz"?Nd.set(0,1,0):i==="yz"&&Nd.set(1,0,0),OD.setFromNormalAndCoplanarPoint(Nd,Oo),!u.ray.intersectPlane(OD,Ro))return}if(!e.isReset){if(Ro.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Ro.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(Ro.x=Oo.x),e.data.enabledTranslation[1]===!1&&(Ro.y=Oo.y),e.data.enabledTranslation[2]===!1&&(Ro.z=Oo.z);let a=_6(Oo,Ro,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Nd.subVectors(a,Oo).divideScalar(e.currentDampingFactor);Oo.add(l),n&&RD(e.object,Oo),e.paused=l.length()<S6}else RD(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(A6)}};var Yf=new A,Jy=new A,Qf=new ae,Bd=new Je,Ea=new Je,Kf=new A,Zf=new A,zl=new A,Lo=new A,yS=new yn,M6=1e-6,E6={type:"requestRender"},T6={type:"changeRotation"},ND=function(){let r=new ae;return function(e,n){e.parent!==null?r.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):r.copy(e.hiddenMatrix),n.premultiply(Gw(r).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof kt&&Gr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),vS=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Je;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...og.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(t.target==="personal camera"?this.target=n.find(bn.PERSONAL_CAMERA_ID):this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},$y=class extends Bn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:i})=>{if(!n||!i)return;let s=Vs(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new vS(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let a=this.onTargetChange(i),l=i.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(i),o=i.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),jn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let[i,s]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",s);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:i,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:d}=this.eventContext,{object:h,target:f}=e;if(h.getWorldPosition(Kf),!e.isReset)if(e.target)e.target.getWorldPosition(Zf);else{if(o==="custom"?(c().getWorldDirection(Jy),Jy.negate(),yS.setFromNormalAndCoplanarPoint(Jy,Kf)):(o==="xy"?Yf.set(0,0,1):o==="xz"?Yf.set(0,1,0):o==="yz"&&Yf.set(1,0,0),yS.setFromNormalAndCoplanarPoint(Yf,Kf)),!d.ray.intersectPlane(yS,Zf))return;s>0&&(o==="custom"||o===void 0)&&Zf.addScaledVector(Jy,s)}if(e.isReset||(f?n==="target"?zl.copy(f.up).applyMatrix4(Qf.extractRotation(f.matrixWorld)).normalize():l.some(m=>m===!1)?(i==="x"?(Lo.set(0,0,1),l[2]===!1&&Lo.set(0,1,0)):i==="y"?(Lo.set(1,0,0),l[0]===!1&&Lo.set(0,0,1)):(Lo.set(0,1,0),l[1]===!1&&Lo.set(1,0,0)),zl.copy(Lo).applyQuaternion(e.worldQuaternion0).normalize()):zl.set(0,1,0):o==="custom"?zl.set(0,1,0):zl.copy(Yf)),e.isReset)Ea.copy(e.worldQuaternion0);else if(Kf.distanceTo(Zf)>a&&u&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Ea.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;C6(Qf,Zf,Kf,zl,i,Lo),Ea.setFromRotationMatrix(Qf),Bd.setFromUnitVectors(Lo.applyQuaternion(Ea),zl),l.some(m=>m===!1)&&n!=="target"&&Ea.premultiply(Bd).normalize()}e.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),Bd.setFromRotationMatrix(Gw(h.matrixWorld)),Bd.slerp(Ea,1/e.currentDampingFactor),ND(h,Qf.makeRotationFromQuaternion(Bd)),e.paused=8*(1-Bd.dot(Ea))<M6):(ND(h,Qf.makeRotationFromQuaternion(Ea)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(E6),h.dispatchEvent(T6)}},Ii=new A,Zn=new A,_n=new A;function C6(r,t,e,n,i,s){let o=r.elements;_n.subVectors(t,e),_n.lengthSq()===0&&(_n.z=1),_n.normalize(),Zn.crossVectors(n,_n),Zn.lengthSq()===0&&(Math.abs(n.z)===1?_n.x+=1e-4:_n.z+=1e-4,_n.normalize(),Zn.crossVectors(n,_n)),Zn.normalize(),Ii.crossVectors(_n,Zn),i==="x"?s.z===1?[Zn,Ii,_n]=[_n,Zn,Ii]:(Zn.negate(),[Zn,_n]=[_n,Zn]):i==="y"?s.x===1?[Zn,Ii,_n]=[Ii,_n,Zn]:(Zn.negate(),[Ii,_n]=[_n,Ii]):s.x===1&&(Zn.negate(),[Zn,Ii]=[Ii,Zn]),o[0]=Zn.x,o[4]=Ii.x,o[8]=_n.x,o[1]=Zn.y,o[5]=Ii.y,o[9]=_n.y,o[2]=Zn.z,o[6]=Ii.z,o[10]=_n.z}var xS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=Qn(e,e.actions,i,s,o,n)}disconnect(){An(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()))}},ev=class extends Bn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{ke.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(i)))};let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new xS(a,l,o,i,s,n);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),jn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),jn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(i=>{i.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:i,raycaster:s,scene:o}=this.eventContext;if(i){let a=zf(s,o,this.objects);n=Gf(a)}else this.objects.forEach(a=>{Dd(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{n.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var bS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=Qn(e,e.actions,i,s,o,n)}connect(){this.scrollCounter=0}disconnect(){An(this.actions)}dispatch(t){this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(n)),this.actions.Create.forEach(i=>i.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?this.actions.Transition.forEach(e=>e.reverseFromCurrent()):this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Create.forEach(e=>e.dispatchThrottled())}},wS=class{constructor(t,e,n,i,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.managers=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Qn(e,e.actions,i,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,i=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+i-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){An(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let n=this.scrollEnd-this.scrollStart,i=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(i)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?this.actions.Transition.forEach(e=>e.reverseFromCurrent()):this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Create.forEach(e=>e.dispatchThrottled())}},tv=class extends Bn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([i,s])=>{i.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,i])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),i.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:i,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;i.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let d=new bS(u,c,l,i,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(d):this.wheelEventsPerObject.set(l,[d])}else{let d=new wS(u,c,l,i,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(d):this.scrollEventsPerObject.set(l,[d])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var SS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qn(e,e.actions,i,s,o,n)}disconnect(){An(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof To?e.interaction.audioPlayer.play():e.interaction instanceof Id&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof _a?e.interaction.play(n==="autoplay"):e.interaction instanceof Od&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof To?e.interaction.audioPlayer.play():e.interaction instanceof Id&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof _a?e.interaction.play():e.interaction instanceof Od&&e.interaction.dispatch()})}},nv=class extends Bn{constructor(e,n){super(e);this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=Vs(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:i,sharedAssets:s}=this.eventContext;i.traverseEntity(o=>{if(!!o.data?.events.length)for(let{id:a,data:l}of o.data.events){if(l.disabled||l.type!=="Start")continue;let u=new SS(a,l,o,i,s,n);(u.actions.Transition.length||u.actions.SwitchCamera.length||u.actions.Create.length||u.actions.Destroy.length)&&(this.eventsPerObject.has(o)?this.eventsPerObject.get(o)?.push(u):this.eventsPerObject.set(o,[u])),u.actions.Audio.length&&(this.eventsAfterPerObject.has(o)?this.eventsAfterPerObject.get(o)?.push(u):this.eventsAfterPerObject.set(o,[u])),u.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(o)?this.eventsAfterPerObject.get(o)?.push(u):this.eventsAfterPerObject.set(o,[u]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,i=n?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>i.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,i=n?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(i=>i.disconnect())})}};var rv=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!0;this.actions=Qn(e,e.actions,i,s,o,n),this.target=e.target,this.useToggle=e.toggle}disconnect(){An(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var FD=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.382/build/",P6=!1?FD:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.382/build/",D6=`
5599
5599
  (async function() {
5600
5600
  const [wasmImport, wasmBinary] = await Promise.all([
5601
5601
  import('${FD}' + 'navmesh.js'),
@@ -6099,4 +6099,4 @@ void main() {
6099
6099
  vec4 image = texture2D(tMap, insideUv);
6100
6100
  gl_FragColor = mix(image, background, isOutside);
6101
6101
  }
6102
- `,wv=class extends qs{constructor(){super(new ot({vertexShader:Sq,fragmentShader:Aq,uniforms:{tInput:new ie(null),tMap:new ie(null),uResolution:new ie(new F),uSize:new ie(new F),uCoords:new ie(new F),uScale:new ie(1),uSceneColor:new ie(new Ne(16711680)),uDPR:new ie(1),uCurrent:new ie(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(t){this.uniforms.tMap.value=t}};function DI(r,t){return t&&t.enabled&&r.push(t.effect),r}var _q=r=>Object.values(lt).includes(r)?r:lt.NORMAL,np=class extends Ht{constructor(e){super();this.postprocessingState=ml.defaultData;this._scene=new Or;this._camera=new Yt;this.effects=new Map;this.blueNoiseTexture=new qo;this._renderToScreen=!0;this.clock=new Jp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new Gd),this.effects.set("chromaticAberration",new Hd),this.effects.set("vignette",new Xd),this.effects.set("noise",new qd),this.effects.set("colorAverage",new Wd),this.effects.set("hueSaturation",new jd),this.effects.set("brightnessContrast",new Vd),this.effects.set("depthOfField",new Yd),this.effects.set("pixelation",new Qd),this.effectComposer=new yv(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Vl(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new gv(this.scene,this.camera,this.renderer),this.aoPass=new bv(this.scene,this.camera),this.taaPass=new mv,this.taaPass.renderToScreen=!1,this.helperPass=new vv(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new wv,this.overlayPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let n=this.effectComposer.passes.length-1;n>=0;n--){let i=this.effectComposer.passes[n];if(i.enabled===!0&&!e&&this._renderToScreen){i.renderToScreen=!0,e=!0;continue}i.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new qo(e,128,128),this.blueNoiseTexture.wrapS=Bi,this.blueNoiseTexture.wrapT=Bi,this.blueNoiseTexture.minFilter=Pt,this.blueNoiseTexture.magFilter=Pt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,n,i,s,o,a,l,u){this.aoPass.enabled=e,this.aoPass.radius=n,this.aoPass.bias=i,this.aoPass.aoColor=s,this.aoPass.fogEnabled=o,this.aoPass.fogNear=a,this.aoPass.fogFar=l,this.aoPass.runHalfRes!==!u&&(this.aoPass.runHalfRes=!u)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(DI,[]);e.length>0&&(this.uvEffectPass=new Gl(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(DI,[]);n.length>0&&(this.effectPass=new Gl(this.camera,...n),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new st(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Bi,wrapT:Bi}),this._rt.samples=0,this._savePass=new tp(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new tp(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?n.removePass(this._savePass):n.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...i}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(i)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=_q(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof Ze?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,i,s),this.effectComposer.outputBuffer.scissor.set(e,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,i,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,i,s){e instanceof Ze?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,i,s),this.effectComposer.outputBuffer.viewport.set(e,n,i,s))}resize(e,n,i){if(this.effectComposer.setSize(e,n,i),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var II=new Vt,Sv=class extends tx{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new np(this);this.isXRCopyPassSet=!1;this.clear=(e=!0,n=!0,i=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),n&&(o|=s.DEPTH_BUFFER_BIT),i&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let n=this.setPixelRatio.bind(this),i=this.setSize.bind(this),s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio=o,n(o)},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,i(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new st(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:qe,magFilter:qe,wrapS:Gt,wrapT:Gt,depthBuffer:!1}))}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,n*this._pixelRatio/1)}get hdTransmission(){return Fe.transmissionLod.value===1}set hdTransmission(e){Fe.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new st(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Ha,magFilter:qe,wrapS:Gt,wrapT:Gt,depthBuffer:!1}),this.transmissionDepthTarget=new st(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Pt,magFilter:Pt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new st(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Pt,magFilter:Pt,type:wr,depthTexture:new yi(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof Yt?_y.uniforms.depthContrast.value=(n.far-n.near)/1e4:_y.uniforms.depthContrast.value=1,e.overrideMaterial=_y,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Ey:null,n.layers.enable(0),n.layers.enable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!0)}))}renderSplineScene(e,n,i,s,o){this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(n)),this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((l,u)=>{Fe.penumbraSize.value[u]=l}),Fe.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Fe.resolution.value.set(this.resolution.x,this.resolution.y):Fe.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Fe.normalRenderTarget.value=this.overrideNormal,Fe.normalRenderTargetDepth.value=II):e.needsNormal()&&(this.createNormalRenderTarget(),Fe.normalRenderTarget.value=this.normalRenderTarget.texture,Fe.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n)),e.occlusion&&(this.createAORenderTarget(),Fe.aoRenderTarget.value=this.aoRenderTarget.texture),Fe.aoEnabled.value=e.occlusion,this.pipeline.setAmbientOcclusionParams(e.occlusion,e.radius,e.bias,e.aoColor,e.enableFog,e.backupFog.near,e.backupFog.far,e.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let a=!1;if(this.overrideTransmission!==void 0)Fe.transmissionRenderTarget.value=this.overrideTransmission,Fe.transmissionRenderTargetDepth.value=II,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),Fe.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Fe.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(l)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=s,this.pipeline.sceneHelpersOnTop=o,this.pipeline.scene=e,this.pipeline.camera=n,a&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&(this.pipeline.updatePostprocessing(e.postprocessing),!s&&!o&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Ey:null,this.pipeline.render(),Fe.frameIndex.value=(Fe.frameIndex.value+1)%16,n instanceof Yt&&n.copyHistory()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var Av=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Ol(t.shared,e),this.scene=new bn(t.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof tn&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var _v=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Mq(r){let t;if(!!r.index)for(let e=0;e<r.index.array.length;e+=3)t=r.index.array[e],r.index.array[e]=r.index.array[e+2],r.index.array[e+2]=t}function rp(r){return r instanceof rs?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Eq(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof kt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof kt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!or.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!or.isMergable(u.material))return;s=or.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][rp(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][rp(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][rp(n)].push(u)}),e}function Tq(r){let t=0;return Object.values(r).forEach(e=>{Object.values(e).forEach(n=>{let i=n.length;i>t&&(t=i)})}),t}function OI(r,t){let e=Eq(t,r),n=Tq(e),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let m of Object.values(f)){if(a=0,u=0,m.forEach(g=>{g instanceof kt&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&Mq(o[g]);let p=Xi(o.slice(0,a),!1);if(p){let g;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new In(p,l[0].material);break}default:{g=new In(p,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof kt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][rp(x)]&&e[x.material.uuid][rp(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let h=0;h<s;h++)i[h].removeFromParent()}var NI=fs(LI(),1);var Cq=new F;function Pq(r){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(t)}var GS=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this._lastTime=performance.now();this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping()),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Cq.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderAutoMode())};this._debouncedResize=al(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new _v({x:10,y:10})),ME(t)}async load(t,e){Pq(t),this.disposed=!1;let i=await(await fetch(t,e)).arrayBuffer();await this.start(i)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await KD(t);this._data=n,n.version&&(0,NI.default)(n.version,"0.9.381")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Rw(n)&&yP(),kP(n)&&cP(),n.scene.environment.usePhysics&&LE(),_w(n)&&FP(),_S(n)&&DE()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let i=new Av(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();OI(n,i.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}Rw(n)&&this._scene.traverse(o=>{Gr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof hr&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{i.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),_w(n)&&kD(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),Fy(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new Sv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=n.scene.environment.ambientLight.softShadows?im:K0,g2(n.scene.environment.ambientLight.softShadowQuality)),n.scene.environment.ambientLight.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.environment.ambientLight.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new dv(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}if(e){let o=new Ly(this._renderer,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,n.scene.publish.stopRaycast,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new sv(n,o),this._eventManager=new uv(n.scene.publish,this._controls,o),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==bn.PERSONAL_CAMERA_ID){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Fd&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:i,a:s}={r:0,g:0,b:0,a:1},o=new $t(e,n,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{px.unsubscribe(t)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),EE(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,emitEvent(i){t.dispatchEvent({type:"userEvent",eventName:i})},emitEventReverse(i){t.dispatchEvent({type:"userEvent",eventName:i,reverse:!0})}},n=px(e,(i,s)=>{typeof t[i]!="object"&&Object.getOwnPropertyDescriptor(t,i)?.writable&&(t[i]=s),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};
6102
+ `,wv=class extends qs{constructor(){super(new ot({vertexShader:Sq,fragmentShader:Aq,uniforms:{tInput:new ie(null),tMap:new ie(null),uResolution:new ie(new F),uSize:new ie(new F),uCoords:new ie(new F),uScale:new ie(1),uSceneColor:new ie(new Ne(16711680)),uDPR:new ie(1),uCurrent:new ie(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(t){this.uniforms.tMap.value=t}};function DI(r,t){return t&&t.enabled&&r.push(t.effect),r}var _q=r=>Object.values(lt).includes(r)?r:lt.NORMAL,np=class extends Ht{constructor(e){super();this.postprocessingState=ml.defaultData;this._scene=new Or;this._camera=new Yt;this.effects=new Map;this.blueNoiseTexture=new qo;this._renderToScreen=!0;this.clock=new Jp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new Gd),this.effects.set("chromaticAberration",new Hd),this.effects.set("vignette",new Xd),this.effects.set("noise",new qd),this.effects.set("colorAverage",new Wd),this.effects.set("hueSaturation",new jd),this.effects.set("brightnessContrast",new Vd),this.effects.set("depthOfField",new Yd),this.effects.set("pixelation",new Qd),this.effectComposer=new yv(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Vl(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new gv(this.scene,this.camera,this.renderer),this.aoPass=new bv(this.scene,this.camera),this.taaPass=new mv,this.taaPass.renderToScreen=!1,this.helperPass=new vv(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new wv,this.overlayPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let n=this.effectComposer.passes.length-1;n>=0;n--){let i=this.effectComposer.passes[n];if(i.enabled===!0&&!e&&this._renderToScreen){i.renderToScreen=!0,e=!0;continue}i.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new qo(e,128,128),this.blueNoiseTexture.wrapS=Bi,this.blueNoiseTexture.wrapT=Bi,this.blueNoiseTexture.minFilter=Pt,this.blueNoiseTexture.magFilter=Pt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,n,i,s,o,a,l,u){this.aoPass.enabled=e,this.aoPass.radius=n,this.aoPass.bias=i,this.aoPass.aoColor=s,this.aoPass.fogEnabled=o,this.aoPass.fogNear=a,this.aoPass.fogFar=l,this.aoPass.runHalfRes!==!u&&(this.aoPass.runHalfRes=!u)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(DI,[]);e.length>0&&(this.uvEffectPass=new Gl(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(DI,[]);n.length>0&&(this.effectPass=new Gl(this.camera,...n),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new st(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Bi,wrapT:Bi}),this._rt.samples=0,this._savePass=new tp(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new tp(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?n.removePass(this._savePass):n.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...i}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(i)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=_q(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof Ze?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,i,s),this.effectComposer.outputBuffer.scissor.set(e,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,i,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,i,s){e instanceof Ze?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,i,s),this.effectComposer.outputBuffer.viewport.set(e,n,i,s))}resize(e,n,i){if(this.effectComposer.setSize(e,n,i),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var II=new Vt,Sv=class extends tx{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new np(this);this.isXRCopyPassSet=!1;this.clear=(e=!0,n=!0,i=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),n&&(o|=s.DEPTH_BUFFER_BIT),i&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let n=this.setPixelRatio.bind(this),i=this.setSize.bind(this),s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio=o,n(o)},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,i(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new st(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:qe,magFilter:qe,wrapS:Gt,wrapT:Gt,depthBuffer:!1}))}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,n*this._pixelRatio/1)}get hdTransmission(){return Fe.transmissionLod.value===1}set hdTransmission(e){Fe.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new st(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Ha,magFilter:qe,wrapS:Gt,wrapT:Gt,depthBuffer:!1}),this.transmissionDepthTarget=new st(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Pt,magFilter:Pt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new st(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Pt,magFilter:Pt,type:wr,depthTexture:new yi(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof Yt?_y.uniforms.depthContrast.value=(n.far-n.near)/1e4:_y.uniforms.depthContrast.value=1,e.overrideMaterial=_y,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Ey:null,n.layers.enable(0),n.layers.enable(3),e.traverseEntity(i=>{i.layers.isEnabled(8)&&(i.copyPreviousMatrix=!0)}))}renderSplineScene(e,n,i,s,o){this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(n)),this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((l,u)=>{Fe.penumbraSize.value[u]=l}),Fe.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Fe.resolution.value.set(this.resolution.x,this.resolution.y):Fe.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Fe.normalRenderTarget.value=this.overrideNormal,Fe.normalRenderTargetDepth.value=II):e.needsNormal()&&(this.createNormalRenderTarget(),Fe.normalRenderTarget.value=this.normalRenderTarget.texture,Fe.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n)),e.occlusion&&(this.createAORenderTarget(),Fe.aoRenderTarget.value=this.aoRenderTarget.texture),Fe.aoEnabled.value=e.occlusion,this.pipeline.setAmbientOcclusionParams(e.occlusion,e.radius,e.bias,e.aoColor,e.enableFog,e.backupFog.near,e.backupFog.far,e.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let a=!1;if(this.overrideTransmission!==void 0)Fe.transmissionRenderTarget.value=this.overrideTransmission,Fe.transmissionRenderTargetDepth.value=II,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),Fe.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Fe.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(l)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=s,this.pipeline.sceneHelpersOnTop=o,this.pipeline.scene=e,this.pipeline.camera=n,a&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&(this.pipeline.updatePostprocessing(e.postprocessing),!s&&!o&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Ey:null,this.pipeline.render(),Fe.frameIndex.value=(Fe.frameIndex.value+1)%16,n instanceof Yt&&n.copyHistory()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var Av=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Ol(t.shared,e),this.scene=new bn(t.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof tn&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var _v=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Mq(r){let t;if(!!r.index)for(let e=0;e<r.index.array.length;e+=3)t=r.index.array[e],r.index.array[e]=r.index.array[e+2],r.index.array[e+2]=t}function rp(r){return r instanceof rs?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Eq(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof kt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof kt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!or.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!or.isMergable(u.material))return;s=or.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][rp(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][rp(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][rp(n)].push(u)}),e}function Tq(r){let t=0;return Object.values(r).forEach(e=>{Object.values(e).forEach(n=>{let i=n.length;i>t&&(t=i)})}),t}function OI(r,t){let e=Eq(t,r),n=Tq(e),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let m of Object.values(f)){if(a=0,u=0,m.forEach(g=>{g instanceof kt&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&Mq(o[g]);let p=Xi(o.slice(0,a),!1);if(p){let g;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new In(p,l[0].material);break}default:{g=new In(p,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof kt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][rp(x)]&&e[x.material.uuid][rp(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let h=0;h<s;h++)i[h].removeFromParent()}var NI=fs(LI(),1);var Cq=new F;function Pq(r){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(t)}var GS=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this._lastTime=performance.now();this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping()),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Cq.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderAutoMode())};this._debouncedResize=al(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new _v({x:10,y:10})),ME(t)}async load(t,e){Pq(t),this.disposed=!1;let i=await(await fetch(t,e)).arrayBuffer();await this.start(i)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await KD(t);this._data=n,n.version&&(0,NI.default)(n.version,"0.9.382")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Rw(n)&&yP(),kP(n)&&cP(),n.scene.environment.usePhysics&&LE(),_w(n)&&FP(),_S(n)&&DE()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let i=new Av(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();OI(n,i.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}Rw(n)&&this._scene.traverse(o=>{Gr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof hr&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{i.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),_w(n)&&kD(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),Fy(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new Sv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=n.scene.environment.ambientLight.softShadows?im:K0,g2(n.scene.environment.ambientLight.softShadowQuality)),n.scene.environment.ambientLight.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.environment.ambientLight.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new dv(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}if(e){let o=new Ly(this._renderer,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,n.scene.publish.stopRaycast,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new sv(n,o),this._eventManager=new uv(n.scene.publish,this._controls,o),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==bn.PERSONAL_CAMERA_ID){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Fd&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:i,a:s}={r:0,g:0,b:0,a:1},o=new $t(e,n,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{px.unsubscribe(t)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),EE(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,emitEvent(i){t.dispatchEvent({type:"userEvent",eventName:i})},emitEventReverse(i){t.dispatchEvent({type:"userEvent",eventName:i,reverse:!0})}},n=px(e,(i,s)=>{typeof t[i]!="object"&&Object.getOwnPropertyDescriptor(t,i)?.writable&&(t[i]=s),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};